From 6dd9a627c166c97555a6c7c23d0db743f5e73b26 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Mon, 18 Feb 2019 15:12:33 +0900 Subject: [PATCH] Fix flaky testForAllWinddow It was flaky because the exiting window may be removed before the assertion. Prevent it from removal can fix it. During the setup, while window get created, there are WindowSurfacePlacer traversal being posted to mAnimationHandler. This could happen while we run the test. During the traversal, all exiting window will be removed if possible, and the test window will get removed. Wait until the traversal finished can fix the issue. Bug: 77772044 Bug: 74078662 Bug: 124088319 Test: atest DisplayContentTests#testForAllWindows Change-Id: I7f14605d3bd4a548755b7e88b0294168ab46ec7b --- .../src/com/android/server/wm/DisplayContentTests.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index a62bc713db40a..2452ef0425e1d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -61,7 +61,6 @@ import android.os.SystemClock; import android.platform.test.annotations.Presubmit; import android.util.DisplayMetrics; import android.view.DisplayCutout; -import android.view.DisplayInfo; import android.view.Gravity; import android.view.MotionEvent; import android.view.Surface; @@ -87,18 +86,22 @@ import java.util.List; * Tests for the {@link DisplayContent} class. * * Build/Install/Run: - * atest FrameworksServicesTests:DisplayContentTests + * atest WmTests:DisplayContentTests */ @SmallTest @Presubmit public class DisplayContentTests extends WindowTestsBase { @Test - @FlakyTest(bugId = 77772044) + @FlakyTest(detail = "Promote to presubmit when shown to be stable.") public void testForAllWindows() { final WindowState exitingAppWindow = createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "exiting app"); final AppWindowToken exitingAppToken = exitingAppWindow.mAppToken; + // Wait until everything in animation handler get executed to prevent the exiting window + // from being removed during WindowSurfacePlacer Traversal. + waitUntilHandlersIdle(); + exitingAppToken.mIsExiting = true; exitingAppToken.getTask().mStack.mExitingAppTokens.add(exitingAppToken);