Allow disabling orientation changes check on TAPL
This is necessary when a command intentionally changes the device orientation. For example, when triggering `goHome` from an app that is in landscape mode, without enabling launcher rotation Bug: 238757607 Test: testDisableRotationCheck Change-Id: Ia00d85d3263b6524b4806f54f729a0749684b92a
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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<String> mDiagnosticContext = new LinkedList<>();
|
||||
private Function<Long, String> 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);
|
||||
|
||||
Reference in New Issue
Block a user