Increase ANR test timeouts
Currently, when running the ANR tests on the cloud device, we
occasionally observe failures.
There are several failures, and one of them is explained as follows:
when we call setInputWindows, a FOCUS(hasFocus=true) event is generated
for the focused window. The focused window needs to respond to the FOCUS
event.
But currently, we are setting a 10 ms dispatching timeout for the focused
window. That means the focused window needs to respond to the FOCUS
event within 10 ms.
This happens most of the time, but on cuttlefish, this amount of time
isn't always sufficient. Even changing this to 20 ms, I found cases
where the test flakes.
The timeouts were originally set to 10 ms to speed up the tests, and
were tested on physical devices, but not stress tested on cf.
To fix the immediate issue, increase the timeouts.
We could also have fixed it by doing the following:
Set a long timeout, process FOCUS event, then set a short timeout and
call setInputWindows again. I decided against that approach because it's
more complicated.
Bug: 159489444
Test: adb shell /data/nativetest/inputflinger_tests/inputflinger_tests --gtest_repeat=100000 --gtest_break_on_failure --gtest_filter='*WindowAnr*'
Change-Id: I61b27550f812c60738310b6cf1c0c2ed7bb86dc8
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 1a133dc..ea4d885 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -2368,7 +2368,7 @@
mWindow =
new FakeWindowHandle(mApplication, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
mWindow->setFrame(Rect(0, 0, 30, 30));
- mWindow->setDispatchingTimeout(10ms);
+ mWindow->setDispatchingTimeout(30ms);
mWindow->setFocus(true);
// Adding FLAG_NOT_TOUCH_MODAL to ensure taps outside this window are not sent to this
// window.
@@ -2760,7 +2760,7 @@
mFocusedWindow =
new FakeWindowHandle(mApplication, mDispatcher, "Focused", ADISPLAY_ID_DEFAULT);
- mFocusedWindow->setDispatchingTimeout(10ms);
+ mFocusedWindow->setDispatchingTimeout(30ms);
mFocusedWindow->setFrame(Rect(50, 50, 100, 100));
mFocusedWindow->setLayoutParamFlags(InputWindowInfo::FLAG_NOT_TOUCH_MODAL |
InputWindowInfo::FLAG_SPLIT_TOUCH);