summaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorJerry Zhang <zhangjerry@google.com>2018-05-22 21:08:35 +0200
committerHridya Valsaraju <hridya@google.com>2018-07-30 22:17:27 +0200
commitb76af93ab56bc3296e01e65a6fe64a0622ab5b91 (patch)
tree72a598a84fa4bb141873c59ec979e9660e1c2428 /tests/unit
parentMerge "minadbd: avoid overrriding services_to_fd." (diff)
downloadandroid_bootable_recovery-b76af93ab56bc3296e01e65a6fe64a0622ab5b91.tar
android_bootable_recovery-b76af93ab56bc3296e01e65a6fe64a0622ab5b91.tar.gz
android_bootable_recovery-b76af93ab56bc3296e01e65a6fe64a0622ab5b91.tar.bz2
android_bootable_recovery-b76af93ab56bc3296e01e65a6fe64a0622ab5b91.tar.lz
android_bootable_recovery-b76af93ab56bc3296e01e65a6fe64a0622ab5b91.tar.xz
android_bootable_recovery-b76af93ab56bc3296e01e65a6fe64a0622ab5b91.tar.zst
android_bootable_recovery-b76af93ab56bc3296e01e65a6fe64a0622ab5b91.zip
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/screen_ui_test.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/unit/screen_ui_test.cpp b/tests/unit/screen_ui_test.cpp
index 4c0a868f0..7d97a006b 100644
--- a/tests/unit/screen_ui_test.cpp
+++ b/tests/unit/screen_ui_test.cpp
@@ -264,6 +264,10 @@ int TestableScreenRecoveryUI::KeyHandler(int key, bool) const {
}
int TestableScreenRecoveryUI::WaitKey() {
+ if (IsKeyInterrupted()) {
+ return static_cast<int>(RecoveryUI::KeyError::INTERRUPTED);
+ }
+
CHECK_LT(key_buffer_index_, key_buffer_.size());
return static_cast<int>(key_buffer_[key_buffer_index_++]);
}
@@ -391,7 +395,8 @@ TEST_F(ScreenRecoveryUITest, ShowMenu_TimedOut) {
ui_->SetKeyBuffer({
KeyCode::TIMEOUT,
});
- ASSERT_EQ(static_cast<size_t>(-1), ui_->ShowMenu(HEADERS, ITEMS, 3, true, nullptr));
+ ASSERT_EQ(static_cast<size_t>(RecoveryUI::KeyError::TIMED_OUT),
+ ui_->ShowMenu(HEADERS, ITEMS, 3, true, nullptr));
}
TEST_F(ScreenRecoveryUITest, ShowMenu_TimedOut_TextWasEverVisible) {
@@ -412,6 +417,38 @@ TEST_F(ScreenRecoveryUITest, ShowMenu_TimedOut_TextWasEverVisible) {
std::placeholders::_1, std::placeholders::_2)));
}
+TEST_F(ScreenRecoveryUITest, ShowMenuWithInterrupt) {
+ RETURN_IF_NO_GRAPHICS;
+
+ ASSERT_TRUE(ui_->Init(kTestLocale));
+ ui_->SetKeyBuffer({
+ KeyCode::UP,
+ KeyCode::DOWN,
+ KeyCode::UP,
+ KeyCode::DOWN,
+ KeyCode::ENTER,
+ });
+
+ ui_->InterruptKey();
+ ASSERT_EQ(static_cast<size_t>(RecoveryUI::KeyError::INTERRUPTED),
+ ui_->ShowMenu(HEADERS, ITEMS, 3, true,
+ std::bind(&TestableScreenRecoveryUI::KeyHandler, ui_.get(),
+ std::placeholders::_1, std::placeholders::_2)));
+
+ ui_->SetKeyBuffer({
+ KeyCode::UP,
+ KeyCode::UP,
+ KeyCode::NO_OP,
+ KeyCode::NO_OP,
+ KeyCode::UP,
+ KeyCode::ENTER,
+ });
+ ASSERT_EQ(static_cast<size_t>(RecoveryUI::KeyError::INTERRUPTED),
+ ui_->ShowMenu(HEADERS, ITEMS, 0, true,
+ std::bind(&TestableScreenRecoveryUI::KeyHandler, ui_.get(),
+ std::placeholders::_1, std::placeholders::_2)));
+}
+
TEST_F(ScreenRecoveryUITest, LoadAnimation) {
RETURN_IF_NO_GRAPHICS;