summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-11-01 04:18:41 +0100
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-11-01 04:18:41 +0100
commit287d5dc618f2067fdadc82502cb1b6b72f4b3f8b (patch)
treeb85763984bf5181303d40af60c21dc1dae80a812 /tests
parentMerge "recovery: Fix mounting /system with dynamic partitions." (diff)
parentminui: Add a protected GRSurface ctor. (diff)
downloadandroid_bootable_recovery-287d5dc618f2067fdadc82502cb1b6b72f4b3f8b.tar
android_bootable_recovery-287d5dc618f2067fdadc82502cb1b6b72f4b3f8b.tar.gz
android_bootable_recovery-287d5dc618f2067fdadc82502cb1b6b72f4b3f8b.tar.bz2
android_bootable_recovery-287d5dc618f2067fdadc82502cb1b6b72f4b3f8b.tar.lz
android_bootable_recovery-287d5dc618f2067fdadc82502cb1b6b72f4b3f8b.tar.xz
android_bootable_recovery-287d5dc618f2067fdadc82502cb1b6b72f4b3f8b.tar.zst
android_bootable_recovery-287d5dc618f2067fdadc82502cb1b6b72f4b3f8b.zip
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/minui_test.cpp2
-rw-r--r--tests/unit/screen_ui_test.cpp41
2 files changed, 21 insertions, 22 deletions
diff --git a/tests/unit/minui_test.cpp b/tests/unit/minui_test.cpp
index cad6a3d79..b188b5992 100644
--- a/tests/unit/minui_test.cpp
+++ b/tests/unit/minui_test.cpp
@@ -25,7 +25,7 @@
TEST(GRSurfaceTest, Create_aligned) {
static constexpr size_t kSurfaceDataAlignment = 8;
for (size_t data_size = 100; data_size < 128; data_size++) {
- std::unique_ptr<GRSurface> surface(GRSurface::Create(data_size));
+ auto surface = GRSurface::Create(10, 1, 10, 1, data_size);
ASSERT_TRUE(surface);
ASSERT_EQ(0, reinterpret_cast<uintptr_t>(surface->data()) % kSurfaceDataAlignment);
}
diff --git a/tests/unit/screen_ui_test.cpp b/tests/unit/screen_ui_test.cpp
index 0014e45f1..2b76944b1 100644
--- a/tests/unit/screen_ui_test.cpp
+++ b/tests/unit/screen_ui_test.cpp
@@ -69,17 +69,6 @@ class ScreenUITest : public testing::Test {
MockDrawFunctions draw_funcs_;
};
-// TODO(xunchang) Create a constructor.
-static GRSurface CreateFakeGRSurface(int width, int height, int row_bytes, int pixel_bytes) {
- GRSurface fake_surface;
- fake_surface.width = width;
- fake_surface.height = height;
- fake_surface.row_bytes = row_bytes;
- fake_surface.pixel_bytes = pixel_bytes;
-
- return fake_surface;
-}
-
TEST_F(ScreenUITest, StartPhoneMenuSmoke) {
TextMenu menu(false, 10, 20, HEADERS, ITEMS, 0, 20, draw_funcs_);
ASSERT_FALSE(menu.scrollable());
@@ -241,9 +230,14 @@ TEST_F(ScreenUITest, WearMenuSelectItemsOverflow) {
}
TEST_F(ScreenUITest, GraphicMenuSelection) {
- auto fake_surface = CreateFakeGRSurface(50, 50, 50, 1);
- std::vector<GRSurface*> items = { &fake_surface, &fake_surface, &fake_surface };
- GraphicMenu menu(&fake_surface, items, 0, draw_funcs_);
+ auto header = GRSurface::Create(50, 50, 50, 1, 50 * 50);
+ auto item = GRSurface::Create(50, 50, 50, 1, 50 * 50);
+ std::vector<GRSurface*> items = {
+ item.get(),
+ item.get(),
+ item.get(),
+ };
+ GraphicMenu menu(header.get(), items, 0, draw_funcs_);
ASSERT_EQ(0, menu.selection());
@@ -263,18 +257,23 @@ TEST_F(ScreenUITest, GraphicMenuSelection) {
}
TEST_F(ScreenUITest, GraphicMenuValidate) {
- auto fake_surface = CreateFakeGRSurface(50, 50, 50, 1);
- std::vector<GRSurface*> items = { &fake_surface, &fake_surface, &fake_surface };
+ auto header = GRSurface::Create(50, 50, 50, 1, 50 * 50);
+ auto item = GRSurface::Create(50, 50, 50, 1, 50 * 50);
+ std::vector<GRSurface*> items = {
+ item.get(),
+ item.get(),
+ item.get(),
+ };
- ASSERT_TRUE(GraphicMenu::Validate(200, 200, &fake_surface, items));
+ ASSERT_TRUE(GraphicMenu::Validate(200, 200, header.get(), items));
// Menu exceeds the horizontal boundary.
- auto wide_surface = CreateFakeGRSurface(300, 50, 300, 1);
- ASSERT_FALSE(GraphicMenu::Validate(299, 200, &wide_surface, items));
+ auto wide_surface = GRSurface::Create(300, 50, 300, 1, 300 * 50);
+ ASSERT_FALSE(GraphicMenu::Validate(299, 200, wide_surface.get(), items));
// Menu exceeds the vertical boundary.
- items.push_back(&fake_surface);
- ASSERT_FALSE(GraphicMenu::Validate(200, 249, &fake_surface, items));
+ items.push_back(item.get());
+ ASSERT_FALSE(GraphicMenu::Validate(200, 249, header.get(), items));
}
static constexpr int kMagicAction = 101;