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

Commit 9853497f authored by vadimt's avatar vadimt Committed by Vadim Tryshev
Browse files

Making Launcher TAPL check orientation only when the expected orientation is set by the test

This makes life simpler for tests that don't care about orientation

Bug: 245576832
Test: presubmit
Change-Id: I3c247826c6cac0e20c93a2fad9b81775fd2ebaa8
Merged-In: I3c247826c6cac0e20c93a2fad9b81775fd2ebaa8
parent 24dd3f57
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
@@ -180,7 +179,7 @@ public final class LauncherInstrumentation {

    private final UiDevice mDevice;
    private final Instrumentation mInstrumentation;
    private int mExpectedRotation = Surface.ROTATION_0;
    private Integer mExpectedRotation = null;
    private final Uri mTestProviderUri;
    private final Deque<String> mDiagnosticContext = new LinkedList<>();
    private Function<Long, String> mSystemHealthSupplier;
@@ -193,6 +192,7 @@ public final class LauncherInstrumentation {

    private boolean mCheckEventsForSuccessfulGestures = false;
    private Runnable mOnLauncherCrashed;

    private static Pattern getTouchEventPattern(String prefix, String action) {
        // The pattern includes checks that we don't get a multi-touch events or other surprises.
        return Pattern.compile(
@@ -693,7 +693,12 @@ public final class LauncherInstrumentation {
        mIgnoreTaskbarVisibility = ignoreTaskbarVisibility;
    }

    public void setExpectedRotation(int expectedRotation) {
    /**
     * Sets expected rotation.
     * TAPL periodically checks that Launcher didn't suddenly change the rotation to unexpected one.
     * Null parameter disables checks. The initial state is "no checks".
     */
    public void setExpectedRotation(Integer expectedRotation) {
        mExpectedRotation = expectedRotation;
    }

@@ -730,8 +735,10 @@ public final class LauncherInstrumentation {
    private UiObject2 verifyContainerType(ContainerType containerType) {
        waitForLauncherInitialized();

        if (mExpectedRotation != null) {
            assertEquals("Unexpected display rotation",
                    mExpectedRotation, mDevice.getDisplayRotation());
        }

        final String error = getNavigationModeMismatchError(true);
        assertTrue(error, error == null);