Ensure dispatcher is idle before checking policy state
Some of the dispatcher tests are flaky, including the newly added
'InjectedTouchesPokeUserActivity'.
The test can fail if the dispatcher hasn't yet notified policy about the
user activity.
To ensure that the dispatcher is done processing events, including
calling the policy, add a 'waitForIdle' call.
Bug: 281559590
Change-Id: I39a7b29638e2051d11a61560b0ef623a1ff91ea0
Test: m inputflinger_tests && $ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests --gtest_filter="*InjectedTouchesPokeUserActivity*" --gtest_repeat=100000 --gtest_break_on_failure
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index e6b73af..d506285 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -4592,6 +4592,7 @@
window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
// Should have poked user activity
+ mDispatcher->waitForIdle();
mFakePolicy->assertUserActivityPoked();
}
@@ -4613,6 +4614,7 @@
window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
// Should have poked user activity
+ mDispatcher->waitForIdle();
mFakePolicy->assertUserActivityNotPoked();
}
@@ -4696,6 +4698,7 @@
AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ADISPLAY_ID_DEFAULT)));
// Should have poked user activity
+ mDispatcher->waitForIdle();
mFakePolicy->assertUserActivityPoked();
}