diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 03bf4af3de..c3839977cb 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -431,6 +431,22 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); } + @Test + public void testDisableRotationCheck() throws Exception { + try { + mLauncher.setExpectedRotationCheckEnabled(false); + mLauncher.setEnableRotation(false); + final AllApps allApps = mLauncher.getWorkspace().switchToAllApps(); + final AppIcon app = allApps.getAppIcon("TestActivity7"); + mLauncher.getDevice().setOrientationLeft(); + mLauncher.goHome(); + } finally { + mLauncher.setExpectedRotationCheckEnabled(true); + mLauncher.setEnableRotation(true); + mLauncher.getDevice().setOrientationNatural(); + } + } + @Test @PortraitLandscape public void testDeleteFromWorkspace() throws Exception { diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 5f920972ca..0d0905a2eb 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -178,6 +178,7 @@ public final class LauncherInstrumentation { private final UiDevice mDevice; private final Instrumentation mInstrumentation; private int mExpectedRotation = Surface.ROTATION_0; + private boolean mExpectedRotationCheckEnabled = true; private final Uri mTestProviderUri; private final Deque mDiagnosticContext = new LinkedList<>(); private Function mSystemHealthSupplier; @@ -667,6 +668,10 @@ public final class LauncherInstrumentation { mExpectedRotation = expectedRotation; } + public void setExpectedRotationCheckEnabled(boolean expectedRotationCheckEnabled) { + mExpectedRotationCheckEnabled = expectedRotationCheckEnabled; + } + public String getNavigationModeMismatchError(boolean waitForCorrectState) { final int waitTime = waitForCorrectState ? WAIT_TIME_MS : 0; final NavigationModel navigationModel = getNavigationModel(); @@ -700,8 +705,10 @@ public final class LauncherInstrumentation { private UiObject2 verifyContainerType(ContainerType containerType) { waitForLauncherInitialized(); - assertEquals("Unexpected display rotation", - mExpectedRotation, mDevice.getDisplayRotation()); + if (mExpectedRotationCheckEnabled) { + assertEquals("Unexpected display rotation", + mExpectedRotation, mDevice.getDisplayRotation()); + } final String error = getNavigationModeMismatchError(true); assertTrue(error, error == null);