Skip to content

Commit 0cd3180

Browse files
author
Arthur Hung
committed
Add test to verify the repeated key when window focus changed
In previous version, when an user long press a key and it's not consumed by the policy, a synthesized repeat key will be delivered to the focused window even it changed to another one. This will add a new test to verify it won't synthesize the new repeat key when the focused window is changed. Flag: EXEMPT bugfix Bug: 400516905 Test: atest inputflinger_tests Change-Id: Iafc85800bfc292bc1daab6d70c67b8597757bac1
1 parent 9dfcfef commit 0cd3180

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)