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

Commit f77d53d7 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Fix AppWindowTokenAnimationTests and add them to presubmit

Tests were failing because the SurfaceControl in TestAppWindowToken was null. Changed the
test class to not skip onParentChanged callback.

Test: atest AppWindowTokenAnimationTests
Bug: 124357362
Change-Id: I7b12b615c9ae5b57997a9a53aa50bff5962ab723
parent 1ca52f00
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -27,10 +27,9 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;

import android.platform.test.annotations.Presubmit;
import android.view.SurfaceControl;

import androidx.test.filters.SmallTest;

import com.android.server.wm.WindowTestUtils.TestAppWindowToken;

import org.junit.Before;
@@ -39,13 +38,18 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

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

/**
 * Animation related tests for the {@link AppWindowToken} class.
 *
 * Build/Install/Run:
 *  atest FrameworksServicesTests:AppWindowTokenAnimationTests
 *  atest AppWindowTokenAnimationTests
 */
@SmallTest
@Presubmit
@FlakyTest(bugId = 124357362)
public class AppWindowTokenAnimationTests extends WindowTestsBase {

    private TestAppWindowToken mToken;
@@ -60,7 +64,7 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase {
        MockitoAnnotations.initMocks(this);

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

+10 −2
Original line number Diff line number Diff line
@@ -144,7 +144,14 @@ public 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);
        }
    }

@@ -155,7 +162,7 @@ public class WindowTestUtils {
        private Transaction mPendingTransactionOverride;
        boolean mSkipOnParentChanged = true;

        private TestAppWindowToken(DisplayContent dc) {
        private TestAppWindowToken(DisplayContent dc, boolean skipOnParentChanged) {
            super(dc.mWmService, new IApplicationToken.Stub() {
                @Override
                public String getName() {
@@ -163,6 +170,7 @@ public class WindowTestUtils {
                }
            }, new ComponentName("", ""), false, dc, true /* fillsParent */);
            mTargetSdk = Build.VERSION_CODES.CUR_DEVELOPMENT;
            mSkipOnParentChanged = skipOnParentChanged;
        }

        TestAppWindowToken(WindowManagerService service, IApplicationToken token,
+7 −1
Original line number Diff line number Diff line
@@ -257,10 +257,16 @@ class WindowTestsBase {

    WindowTestUtils.TestAppWindowToken createTestAppWindowToken(DisplayContent dc, int
            windowingMode, int activityType) {
        return createTestAppWindowToken(dc, windowingMode, activityType,
                true /*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;
    }