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

Commit 9fb02b91 authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Protect mock with lock to fix flakiness, add two tests to presubmit

AppWindowTokenAnimationTests and DisplayContentTests are no longer
flaky. Removed the annotation respectively.

The fix of WrongTypeOfReturnValue flakiness works, as in
787b244d. Apply the fix to two more
cases.

Bug: 117117823
Bug: 124357362
Bug: 74078662
Bug: 123654474
Test: presubmit
Test: atest WindowStateTests
Test: atest TaskStackTests
Change-Id: I2f6a870cf921dd6a874839e080ae5fb324f36e6f
parent 05ad6df9
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import static org.mockito.ArgumentMatchers.eq;
import android.platform.test.annotations.Presubmit;
import android.view.SurfaceControl;

import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;

import com.android.server.wm.WindowTestUtils.TestAppWindowToken;
@@ -49,7 +48,6 @@ import org.mockito.MockitoAnnotations;
 */
@SmallTest
@Presubmit
@FlakyTest(bugId = 124357362)
public class AppWindowTokenAnimationTests extends WindowTestsBase {

    private TestAppWindowToken mToken;
+0 −2
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ import android.view.Surface;
import android.view.ViewRootImpl;
import android.view.test.InsetsModeSession;

import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;

import com.android.dx.mockito.inline.extended.ExtendedMockito;
@@ -97,7 +96,6 @@ import java.util.List;
public class DisplayContentTests extends WindowTestsBase {

    @Test
    @FlakyTest(detail = "Promote to presubmit when shown to be stable.")
    public void testForAllWindows() {
        final WindowState exitingAppWindow = createWindow(null, TYPE_BASE_APPLICATION,
                mDisplayContent, "exiting app");
+7 −3
Original line number Diff line number Diff line
@@ -175,10 +175,14 @@ public class TaskStackTests extends WindowTestsBase {
    @Test
    public void testStackOutset() {
        final TaskStack stack = createTaskStackOnDisplay(mDisplayContent);
        final int stackOutset = 10;
        // Clear the handler and hold the lock for mock, to prevent multi-thread issue.
        waitUntilHandlersIdle();
        synchronized (mWm.mGlobalLock) {
            spyOn(stack);

        final int stackOutset = 10;
            doReturn(stackOutset).when(stack).getStackOutset();
        }

        final Rect stackBounds = new Rect(200, 200, 800, 1000);
        // Update surface position and size by the given bounds.
+5 −2
Original line number Diff line number Diff line
@@ -110,9 +110,12 @@ public class WindowStateTests extends WindowTestsBase {
        // TODO: Let the insets source with new mode keep the visibility control, and remove this
        // setup code. Now mTopFullscreenOpaqueWindowState will take back the control of insets
        // visibility.
        // Hold the lock to protect the mock from accesssing by other threads.
        synchronized (mWm.mGlobalLock) {
            spyOn(mDisplayContent);
            doNothing().when(mDisplayContent).layoutAndAssignWindowLayersIfNeeded();
        }
    }

    @Test
    public void testIsParentWindowHidden() {