diff options
author | 2024-10-29 09:10:12 +0000 | |
---|---|---|
committer | 2025-03-05 19:22:58 +0000 | |
commit | 0cd3180b8484e72c352f8dc5abbb93023e114510 (patch) | |
tree | 3c380094cc5753bea20634ded3628e707a375d94 | |
parent | 9dfcfef009d3950f8a1898e77795603f59ea1385 (diff) |
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
-rw-r--r-- | services/inputflinger/tests/InputDispatcher_test.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp index 2b9b470a21..b2a3e0956c 100644 --- a/services/inputflinger/tests/InputDispatcher_test.cpp +++ b/services/inputflinger/tests/InputDispatcher_test.cpp @@ -9307,6 +9307,24 @@ TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterUp) { mWindow->assertNoEvents(); } +TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterFocusedWindowChanged) { + sp<FakeWindowHandle> anotherWindow = + sp<FakeWindowHandle>::make(mApp, mDispatcher, "AnotherWindow", + ui::LogicalDisplayId::DEFAULT); + anotherWindow->setFocusable(true); + mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *anotherWindow->getInfo()}, {}, 0, 0}); + + sendAndConsumeKeyDown(/*deviceId=*/1); + expectKeyRepeatOnce(/*repeatCount=*/1); + expectKeyRepeatOnce(/*repeatCount=*/2); + setFocusedWindow(anotherWindow); + anotherWindow->consumeFocusEvent(true); + + // Window should receive key up event with cancel. + mWindow->consumeKeyUp(ui::LogicalDisplayId::DEFAULT, AKEY_EVENT_FLAG_CANCELED); + anotherWindow->assertNoEvents(); +} + TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_KeyRepeatAfterStaleDeviceKeyUp) { sendAndConsumeKeyDown(/*deviceId=*/1); expectKeyRepeatOnce(/*repeatCount=*/1); |