diff options
author | Tianjie Xu <xunchang@google.com> | 2018-10-23 20:16:23 +0200 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-10-23 20:16:23 +0200 |
commit | 06ccd00ef5bfa36f8f0d508df77f747aa099eabf (patch) | |
tree | e68e20918057d4c1f88189edb49bcabad066535c /tests | |
parent | Merge "minui: Move GRSurface into a class." (diff) | |
parent | Add function to show localized rescue party menu (diff) | |
download | android_bootable_recovery-06ccd00ef5bfa36f8f0d508df77f747aa099eabf.tar android_bootable_recovery-06ccd00ef5bfa36f8f0d508df77f747aa099eabf.tar.gz android_bootable_recovery-06ccd00ef5bfa36f8f0d508df77f747aa099eabf.tar.bz2 android_bootable_recovery-06ccd00ef5bfa36f8f0d508df77f747aa099eabf.tar.lz android_bootable_recovery-06ccd00ef5bfa36f8f0d508df77f747aa099eabf.tar.xz android_bootable_recovery-06ccd00ef5bfa36f8f0d508df77f747aa099eabf.tar.zst android_bootable_recovery-06ccd00ef5bfa36f8f0d508df77f747aa099eabf.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 { |