diff options
author | Tony Wickham <twickham@google.com> | 2019-10-07 17:08:20 -0700 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2019-10-14 11:51:19 -0700 |
commit | 1e73e320b78adaac5dd74835ad6a51a3c5589fd3 (patch) | |
tree | 68d0232b98271520da3d1014be6d08869179fdff /tests/tapl/com | |
parent | 3d97fdcfdf5ae39cf98b0bd7d1a5e260eecc1d9c (diff) | |
download | android_packages_apps_Trebuchet-1e73e320b78adaac5dd74835ad6a51a3c5589fd3.tar.gz android_packages_apps_Trebuchet-1e73e320b78adaac5dd74835ad6a51a3c5589fd3.tar.bz2 android_packages_apps_Trebuchet-1e73e320b78adaac5dd74835ad6a51a3c5589fd3.zip |
Add tests for quick switch from an app and home
Bug: 140252765
Change-Id: I5621b614ae2d8cd3db03cae818cf8b8c1c6cb20f
Diffstat (limited to 'tests/tapl/com')
-rw-r--r-- | tests/tapl/com/android/launcher3/tapl/Background.java | 41 | ||||
-rw-r--r-- | tests/tapl/com/android/launcher3/tapl/Home.java | 6 |
2 files changed, 47 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..0dd3e775c 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,46 @@ 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) { + switch (mLauncher.getNavigationModel()) { + case ZERO_BUTTON: + // Fall through, zero button and two button modes behave the same. + case TWO_BUTTON: { + // Swipe from the bottom left to the bottom right of the screen. + final int startX = 0; + final int startY = getSwipeStartY(); + final int endX = mLauncher.getDevice().getDisplayWidth(); + final int endY = startY; + 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; } diff --git a/tests/tapl/com/android/launcher3/tapl/Home.java b/tests/tapl/com/android/launcher3/tapl/Home.java index cfc43749d..e0fe933ee 100644 --- a/tests/tapl/com/android/launcher3/tapl/Home.java +++ b/tests/tapl/com/android/launcher3/tapl/Home.java @@ -17,6 +17,7 @@ package com.android.launcher3.tapl; import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL; +import static com.android.launcher3.testing.TestProtocol.QUICK_SWITCH_STATE_ORDINAL; import androidx.annotation.NonNull; @@ -58,4 +59,9 @@ public abstract class Home extends Background { } } } + + @Override + protected int getExpectedStateForQuickSwitch() { + return QUICK_SWITCH_STATE_ORDINAL; + } }
\ No newline at end of file |