Fix accessibility services tests to work with atest
- Remove @BeforeClass `Looper.prepare()` that do not work with atest - Fix TouchExplorerTest: mock AccessibilityGestureDetector to not create internal handler. - Fix broken tests in MagnificationControllerTest - Remove @FlakyTest annotation from MagnificationControllerTest & FingerprintGestureControllerTest When using atest, timeout is applied to command `am instrument`. Then @BeforeClass & @Before are both running on instrument thread, but test cases are running on a seperate thread. It dispatch messages immediately if the looper is associated to the same thread. When runniung tests with atest, dispatching the message is not always done in the same thread. So verifying the expectation on test thread would be flaky. The solution to use a looper associated with test thread would be ugly. Because the looper related stuff should set up without @Before or @BeforeClass including preparing a looper on demand in a utility function for every test case needed. Here changing the handler behavior to enqueue but to dispatch messages explictly from test could serialize the execution. This would use main looper (no need to prepare) to create handler, but dispatch and clear messages ourself. Not good enough but less ugly to run `am instrument` with or without timeout. Bug: 74748946 Test: atest -d FrameworksServicesTests:com.android.server.accessibility Test: adb shell am instrument -w -e package com.android.server.accessibility \ com.android.frameworks.servicestests/androidx.test.runner.AndroidJUnitRunner Change-Id: Ib67d8b7305511d218b23f4b5ab0b0a12bea9ae10
Loading
Please register or sign in to comment