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

Commit feb22118 authored by Ice Chang's avatar Ice Chang Committed by Android (Google) Code Review
Browse files

Merge "Add swipes left method in Background.java"

parents 04099cda 212cff1d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -310,6 +310,10 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
            assertTrue("The second app we should have quick switched to is not running",
                    isTestActivityRunning(2));
        }
        background = getAndAssertBackground();
        background.quickSwitchToPreviousAppSwipeLeft();
        assertTrue("The 2nd app we should have quick switched to is not running",
                isTestActivityRunning(3));
        getAndAssertBackground();
    }

+45 −17
Original line number Diff line number Diff line
@@ -144,11 +144,22 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
    private void expectSwitchToOverviewEvents() {
    }

    /**
     * Swipes right or double presses the square button to switch to the previous app.
     */
    @NonNull
    public Background quickSwitchToPreviousApp() {
        boolean toRight = true;
        quickSwitch(toRight);
        return new Background(mLauncher);
    }

    @NonNull
    public Background quickSwitchToPreviousAppSwipeLeft() {
        boolean toRight = false;
        quickSwitch(toRight);
        return new Background(mLauncher);
    }

    @NonNull
    private void quickSwitch(boolean toRight) {
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
            LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                    "want to quick switch to the previous app")) {
@@ -164,6 +175,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                    final int startY;
                    final int endX;
                    final int endY;
                    if (toRight) {
                        if (mLauncher.getDevice().isNaturalOrientation() || !transposeInLandscape) {
                            // Swipe from the bottom left to the bottom right of the screen.
                            startX = 0;
@@ -177,6 +189,22 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                            endX = startX;
                            endY = 0;
                        }
                    } else {
                        if (mLauncher.getDevice().isNaturalOrientation() || !transposeInLandscape) {
                            // Swipe from the bottom right to the bottom left of the screen.
                            startX = mLauncher.getDevice().getDisplayWidth();
                            startY = getSwipeStartY();
                            endX = 0;
                            endY = startY;
                        } else {
                            // Swipe from the bottom left to the top left of the screen.
                            startX = getSwipeStartX();
                            startY = 0;
                            endX = startX;
                            endY = mLauncher.getRealDisplaySize().y - 1;
                        }
                    }

                    final boolean isZeroButton = mLauncher.getNavigationModel()
                            == LauncherInstrumentation.NavigationModel.ZERO_BUTTON;
                    LauncherInstrumentation.GestureScope gestureScope =
@@ -205,7 +233,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                    break;
            }
            mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT);
            return new Background(mLauncher);
            return;
        }
    }