Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9dfbc5f authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

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
parent 84c262cf
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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 */);
    }
+4 −0
Original line number Diff line number Diff line
@@ -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());
    }

+1 −1
Original line number Diff line number Diff line
@@ -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;