diff options
author | Tianjie Xu <xunchang@google.com> | 2018-10-17 00:13:09 +0200 |
---|---|---|
committer | Tianjie Xu <xunchang@google.com> | 2018-10-23 00:27:33 +0200 |
commit | b99e6069c1b0749a4811c4d222c5009cbad1edc8 (patch) | |
tree | 2f292bb636b67baf932f9e6b08972fc14ad4c66c /tests | |
parent | Merge "Fix instrumentation_for to refer to name of module" (diff) | |
download | android_bootable_recovery-b99e6069c1b0749a4811c4d222c5009cbad1edc8.tar android_bootable_recovery-b99e6069c1b0749a4811c4d222c5009cbad1edc8.tar.gz android_bootable_recovery-b99e6069c1b0749a4811c4d222c5009cbad1edc8.tar.bz2 android_bootable_recovery-b99e6069c1b0749a4811c4d222c5009cbad1edc8.tar.lz android_bootable_recovery-b99e6069c1b0749a4811c4d222c5009cbad1edc8.tar.xz android_bootable_recovery-b99e6069c1b0749a4811c4d222c5009cbad1edc8.tar.zst android_bootable_recovery-b99e6069c1b0749a4811c4d222c5009cbad1edc8.zip |
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/screen_ui_test.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/screen_ui_test.cpp b/tests/unit/screen_ui_test.cpp index ec269503e..dc6e6a896 100644 --- a/tests/unit/screen_ui_test.cpp +++ b/tests/unit/screen_ui_test.cpp @@ -229,6 +229,43 @@ TEST_F(ScreenUITest, WearMenuSelectItemsOverflow) { ASSERT_EQ(3u, menu.MenuEnd()); } +TEST_F(ScreenUITest, GraphicMenuSelection) { + GRSurface fake_surface = GRSurface{ 50, 50, 50, 1, nullptr }; + std::vector<GRSurface*> items = { &fake_surface, &fake_surface, &fake_surface }; + GraphicMenu menu(&fake_surface, items, 0, draw_funcs_); + + ASSERT_EQ(0, menu.selection()); + + int sel = 0; + for (int i = 0; i < 3; i++) { + sel = menu.Select(++sel); + ASSERT_EQ((i + 1) % 3, sel); + ASSERT_EQ(sel, menu.selection()); + } + + sel = 0; + for (int i = 0; i < 3; i++) { + sel = menu.Select(--sel); + ASSERT_EQ(2 - i, sel); + ASSERT_EQ(sel, menu.selection()); + } +} + +TEST_F(ScreenUITest, GraphicMenuValidate) { + auto fake_surface = GRSurface{ 50, 50, 50, 1, nullptr }; + std::vector<GRSurface*> items = { &fake_surface, &fake_surface, &fake_surface }; + + ASSERT_TRUE(GraphicMenu::Validate(200, 200, &fake_surface, items)); + + // Menu exceeds the horizontal boundary. + auto wide_surface = GRSurface{ 300, 50, 300, 1, nullptr }; + ASSERT_FALSE(GraphicMenu::Validate(299, 200, &wide_surface, items)); + + // Menu exceeds the vertical boundary. + items.push_back(&fake_surface); + ASSERT_FALSE(GraphicMenu::Validate(200, 249, &fake_surface, items)); +} + static constexpr int kMagicAction = 101; enum class KeyCode : int { |