Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15bb18ab authored by Arthur Hung's avatar Arthur Hung Committed by Android (Google) Code Review
Browse files

Merge "Add test to verify the repeated key when window focus changed" into main

parents 0b651c16 0cd3180b
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -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);