Skip to content

Commit 15bb18a

Browse files
Arthur HungAndroid (Google) Code Review
authored andcommitted
Merge "Add test to verify the repeated key when window focus changed" into main
2 parents 0b651c1 + 0cd3180 commit 15bb18a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

services/inputflinger/tests/InputDispatcher_test.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9307,6 +9307,24 @@ TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterUp) {
93079307
mWindow->assertNoEvents();
93089308
}
93099309

9310+
TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterFocusedWindowChanged) {
9311+
sp<FakeWindowHandle> anotherWindow =
9312+
sp<FakeWindowHandle>::make(mApp, mDispatcher, "AnotherWindow",
9313+
ui::LogicalDisplayId::DEFAULT);
9314+
anotherWindow->setFocusable(true);
9315+
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *anotherWindow->getInfo()}, {}, 0, 0});
9316+
9317+
sendAndConsumeKeyDown(/*deviceId=*/1);
9318+
expectKeyRepeatOnce(/*repeatCount=*/1);
9319+
expectKeyRepeatOnce(/*repeatCount=*/2);
9320+
setFocusedWindow(anotherWindow);
9321+
anotherWindow->consumeFocusEvent(true);
9322+
9323+
// Window should receive key up event with cancel.
9324+
mWindow->consumeKeyUp(ui::LogicalDisplayId::DEFAULT, AKEY_EVENT_FLAG_CANCELED);
9325+
anotherWindow->assertNoEvents();
9326+
}
9327+
93109328
TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_KeyRepeatAfterStaleDeviceKeyUp) {
93119329
sendAndConsumeKeyDown(/*deviceId=*/1);
93129330
expectKeyRepeatOnce(/*repeatCount=*/1);

0 commit comments

Comments
 (0)