summaryrefslogtreecommitdiffstats
path: root/tests/tapl/com/android/launcher3/tapl/Background.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tapl/com/android/launcher3/tapl/Background.java')
-rw-r--r--tests/tapl/com/android/launcher3/tapl/Background.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index bcce8ef57..db3d846a0 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -23,6 +23,7 @@ import android.os.SystemClock;
import android.view.MotionEvent;
import androidx.annotation.NonNull;
+import androidx.test.uiautomator.UiObject2;
import com.android.launcher3.testing.TestProtocol;
@@ -114,6 +115,60 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
}
}
+ /**
+ * Swipes right or double presses the square button to switch to the previous app.
+ */
+ public Background quickSwitchToPreviousApp() {
+ try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "want to quick switch to the previous app")) {
+ verifyActiveContainer();
+ quickSwitchToPreviousApp(getExpectedStateForQuickSwitch());
+ return new Background(mLauncher);
+ }
+ }
+
+ protected int getExpectedStateForQuickSwitch() {
+ return BACKGROUND_APP_STATE_ORDINAL;
+ }
+
+ protected void quickSwitchToPreviousApp(int expectedState) {
+ boolean transposeInLandscape = false;
+ switch (mLauncher.getNavigationModel()) {
+ case TWO_BUTTON:
+ transposeInLandscape = true;
+ // Fall through, zero button and two button modes behave the same.
+ case ZERO_BUTTON: {
+ final int startX;
+ final int startY;
+ final int endX;
+ final int endY;
+ if (mLauncher.getDevice().isNaturalOrientation() || !transposeInLandscape) {
+ // Swipe from the bottom left to the bottom right of the screen.
+ startX = 0;
+ startY = getSwipeStartY();
+ endX = mLauncher.getDevice().getDisplayWidth();
+ endY = startY;
+ } else {
+ // Swipe from the bottom right to the top right of the screen.
+ startX = getSwipeStartX();
+ startY = mLauncher.getRealDisplaySize().y - 1;
+ endX = startX;
+ endY = 0;
+ }
+ mLauncher.swipeToState(startX, startY, endX, endY, 20, expectedState);
+ break;
+ }
+
+ case THREE_BUTTON:
+ // Double press the recents button.
+ UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps");
+ recentsButton.click();
+ mLauncher.getOverview();
+ recentsButton.click();
+ break;
+ }
+ }
+
protected String getSwipeHeightRequestName() {
return TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT;
}