Disable key repeat for PendingKey_IsDroppedWhileMotionIsProcessedAndNewTouchComesIn test
This test occasionally fails because the dispatcher generates a key
repeat. This key repeat races with the other timeouts that are used in
this test, so it is only occasionally generated.
Since this test isn't related to key repeats, attempt to deflake it by
disabling key repeats.
Bug: 294547658
Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST --gtest_filter="*PendingKey_IsDroppedWhileMotionIsProcessedAndNewTouchComesIn"
Test: m checkinput
Change-Id: I75cae28b07011ddaeb9165494e27fc17a2ef36f5
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 4d7a170..71362e3 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -6748,8 +6748,8 @@
class InputDispatcherKeyRepeatTest : public InputDispatcherTest {
protected:
- static constexpr nsecs_t KEY_REPEAT_TIMEOUT = 40 * 1000000; // 40 ms
- static constexpr nsecs_t KEY_REPEAT_DELAY = 40 * 1000000; // 40 ms
+ static constexpr std::chrono::nanoseconds KEY_REPEAT_TIMEOUT = 40ms;
+ static constexpr std::chrono::nanoseconds KEY_REPEAT_DELAY = 40ms;
std::shared_ptr<FakeApplicationHandle> mApp;
sp<FakeWindowHandle> mWindow;
@@ -8131,7 +8131,8 @@
// Injection is async, so it will succeed
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
- ADISPLAY_ID_DEFAULT, InputEventInjectionSync::NONE));
+ ADISPLAY_ID_DEFAULT, InputEventInjectionSync::NONE, INJECT_EVENT_TIMEOUT,
+ /*allowKeyRepeat=*/false));
// At this point, key is still pending, and should not be sent to the application yet.
// Make sure the `assertNoEvents` check doesn't take too long. It uses
// CONSUME_TIMEOUT_NO_EVENT_EXPECTED under the hood.