From 63b59dceadcce2c31b617e884941bf26b2730eb0 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 31 Oct 2018 15:23:04 -0700 Subject: minui: Add GRSurface::Clone(). Clone() allows duplicating the image that's stored in the GRSurface. Test: Run recovery_unit_test. Change-Id: Ia50d507c6200f2de5f17143775de805247a60e1f --- tests/unit/minui_test.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/unit/minui_test.cpp') diff --git a/tests/unit/minui_test.cpp b/tests/unit/minui_test.cpp index b188b5992..d68e5e3a1 100644 --- a/tests/unit/minui_test.cpp +++ b/tests/unit/minui_test.cpp @@ -15,8 +15,9 @@ */ #include +#include -#include +#include #include @@ -30,3 +31,14 @@ TEST(GRSurfaceTest, Create_aligned) { ASSERT_EQ(0, reinterpret_cast(surface->data()) % kSurfaceDataAlignment); } } + +TEST(GRSurfaceTest, Clone) { + static constexpr size_t kImageSize = 10 * 50; + auto image = GRSurface::Create(50, 10, 50, 1, kImageSize); + for (auto i = 0; i < kImageSize; i++) { + image->data()[i] = rand() % 128; + } + auto image_copy = image->Clone(); + ASSERT_EQ(std::vector(image->data(), image->data() + kImageSize), + std::vector(image_copy->data(), image_copy->data() + kImageSize)); +} -- cgit v1.2.3