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

Commit 5658951c authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Revert "WM: Cleanup TestAppWindowToken code and promote ZOrderingTests to non-flaky"

This reverts commit 469dcbf7.

Reason for revert: ZOrderingTests are still flaky in postsubmit (go/wm-tests)

Change-Id: I30c8ed06986da7327324e1db749f79c7a7eb4da8
parent 469dcbf7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public class AppChangeTransitionTests extends WindowTestsBase {
    public void setUpOnDisplay(DisplayContent dc) {
        mStack = createTaskStackOnDisplay(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_STANDARD, dc);
        mTask = createTaskInStack(mStack, 0 /* userId */);
        mToken = WindowTestUtils.createTestAppWindowToken(dc);
        mToken = WindowTestUtils.createTestAppWindowToken(dc, false /* skipOnParentChanged */);

        mTask.addChild(mToken, 0);

+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase {
        MockitoAnnotations.initMocks(this);

        mToken = createTestAppWindowToken(mDisplayContent, WINDOWING_MODE_FULLSCREEN,
                ACTIVITY_TYPE_STANDARD);
                ACTIVITY_TYPE_STANDARD, false /* skipOnParentChanged */);
    }

    @Test
+5 −1
Original line number Diff line number Diff line
@@ -81,7 +81,8 @@ public class AppWindowTokenTests extends WindowTestsBase {
    public void setUp() throws Exception {
        mStack = createTaskStackOnDisplay(mDisplayContent);
        mTask = createTaskInStack(mStack, 0 /* userId */);
        mToken = WindowTestUtils.createTestAppWindowToken(mDisplayContent);
        mToken = WindowTestUtils.createTestAppWindowToken(mDisplayContent,
                false /* skipOnParentChanged */);

        mTask.addChild(mToken, 0);
    }
@@ -218,6 +219,9 @@ public class AppWindowTokenTests extends WindowTestsBase {

    @Test
    public void testSizeCompatBounds() {
        // The real surface transaction is unnecessary.
        mToken.setSkipPrepareSurfaces(true);

        final Rect fixedBounds = mToken.getRequestedOverrideConfiguration().windowConfiguration
                .getBounds();
        fixedBounds.set(0, 0, 1200, 1600);
+51 −2
Original line number Diff line number Diff line
@@ -56,15 +56,24 @@ class WindowTestUtils {

    static TestAppWindowToken createTestAppWindowToken(DisplayContent dc) {
        synchronized (dc.mWmService.mGlobalLock) {
            return new TestAppWindowToken(dc);
            return new TestAppWindowToken(dc, true /* skipOnParentChanged */);
        }
    }

    static TestAppWindowToken createTestAppWindowToken(DisplayContent dc,
            boolean skipOnParentChanged) {
        synchronized (dc.mWmService.mGlobalLock) {
            return new TestAppWindowToken(dc, skipOnParentChanged);
        }
    }

    /** Used so we can gain access to some protected members of the {@link AppWindowToken} class. */
    static class TestAppWindowToken extends AppWindowToken {
        boolean mOnTop = false;
        private boolean mSkipPrepareSurfaces;
        boolean mSkipOnParentChanged = true;

        private TestAppWindowToken(DisplayContent dc) {
        private TestAppWindowToken(DisplayContent dc, boolean skipOnParentChanged) {
            super(dc.mWmService, new IApplicationToken.Stub() {
                @Override
                public String getName() {
@@ -72,6 +81,7 @@ class WindowTestUtils {
                }
            }, new ComponentName("", ""), false, dc, true /* fillsParent */);
            mTargetSdk = Build.VERSION_CODES.CUR_DEVELOPMENT;
            mSkipOnParentChanged = skipOnParentChanged;
            mActivityRecord = mock(ActivityRecord.class);
            mActivityRecord.app = mock(WindowProcessController.class);
        }
@@ -92,11 +102,45 @@ class WindowTestUtils {
            return mChildren.peekLast();
        }

        @Override
        void onParentChanged() {
            if (!mSkipOnParentChanged) {
                super.onParentChanged();
            } else {
                updateConfigurationFromParent(this);
            }
        }

        @Override
        boolean isOnTop() {
            return mOnTop;
        }

        @Override
        void prepareSurfaces() {
            if (!mSkipPrepareSurfaces) {
                super.prepareSurfaces();
            }
        }

        void setSkipPrepareSurfaces(boolean ignore) {
            mSkipPrepareSurfaces = ignore;
        }
    }

    /**
     * Used when we don't want to perform surface related operation in
     * {@link WindowContainer#onParentChanged} or the overridden method, but the configuration
     * still needs to propagate from parent.
     *
     * @see ConfigurationContainer#onParentChanged
     */
    static void updateConfigurationFromParent(WindowContainer container) {
        final WindowContainer parent = container.getParent();
        if (parent != null) {
            container.onConfigurationChanged(parent.getConfiguration());
            container.onMergedOverrideConfigurationChanged();
        }
    }

    static TestWindowToken createTestWindowToken(int type, DisplayContent dc) {
@@ -202,5 +246,10 @@ class WindowTestUtils {

            mHasSurface = hadSurface;
        }

        @Override
        void onParentChanged() {
            updateConfigurationFromParent(this);
        }
    }
}
+7 −1
Original line number Diff line number Diff line
@@ -269,10 +269,16 @@ class WindowTestsBase {

    WindowTestUtils.TestAppWindowToken createTestAppWindowToken(DisplayContent dc, int
            windowingMode, int activityType) {
        return createTestAppWindowToken(dc, windowingMode, activityType,
                false /*skipOnParentChanged */);
    }

    WindowTestUtils.TestAppWindowToken createTestAppWindowToken(DisplayContent dc, int
            windowingMode, int activityType, boolean skipOnParentChanged) {
        final TaskStack stack = createTaskStackOnDisplay(windowingMode, activityType, dc);
        final Task task = createTaskInStack(stack, 0 /* userId */);
        final WindowTestUtils.TestAppWindowToken appWindowToken =
                WindowTestUtils.createTestAppWindowToken(dc);
                WindowTestUtils.createTestAppWindowToken(dc, skipOnParentChanged);
        task.addChild(appWindowToken, 0);
        return appWindowToken;
    }
Loading