Clean up AnimationThread default handler
To avoid flakiness during unit tests. Note that this is a different object than WindowManagerService.mAnimationHandler. Bug: N/A Test: Let them pass! Change-Id: I71a775b0599facb4172c86b28d7a9f7e36c65673
This commit is contained in:
@@ -40,6 +40,10 @@ class SystemServiceTestsBase {
|
||||
mLockRule.waitForLocked(mSystemServicesTestRule::waitUntilWindowManagerHandlersIdle);
|
||||
}
|
||||
|
||||
void cleanupWindowManagerHandlers() {
|
||||
mLockRule.waitForLocked(mSystemServicesTestRule::cleanupWindowManagerHandlers);
|
||||
}
|
||||
|
||||
boolean waitHandlerIdle(Handler handler) {
|
||||
return waitHandlerIdle(handler, 0 /* timeout */);
|
||||
}
|
||||
|
||||
@@ -355,6 +355,8 @@ public class SystemServicesTestRule implements TestRule {
|
||||
}
|
||||
wm.mH.removeCallbacksAndMessages(null);
|
||||
wm.mAnimationHandler.removeCallbacksAndMessages(null);
|
||||
// This is a different handler object than the wm.mAnimationHandler above.
|
||||
AnimationThread.getHandler().removeCallbacksAndMessages(null);
|
||||
SurfaceAnimationThread.getHandler().removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@@ -367,6 +369,8 @@ public class SystemServicesTestRule implements TestRule {
|
||||
wm.mH.removeMessages(WindowManagerService.H.FORCE_GC);
|
||||
waitHandlerIdle(wm.mH);
|
||||
waitHandlerIdle(wm.mAnimationHandler);
|
||||
// This is a different handler object than the wm.mAnimationHandler above.
|
||||
waitHandlerIdle(AnimationThread.getHandler());
|
||||
waitHandlerIdle(SurfaceAnimationThread.getHandler());
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
}
|
||||
|
||||
// Cleaned up everything in Handler.
|
||||
mSystemServicesTestRule.cleanupWindowManagerHandlers();
|
||||
cleanupWindowManagerHandlers();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to tear down test", e);
|
||||
throw e;
|
||||
|
||||
Reference in New Issue
Block a user