diff options
Diffstat (limited to 'quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java')
-rw-r--r-- | quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 885fdbf42..41f4a8217 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -17,6 +17,7 @@ package com.android.quickstep; import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -34,6 +35,7 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.tapl.AllApps; import com.android.launcher3.tapl.AllAppsFromOverview; import com.android.launcher3.tapl.Background; +import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel; import com.android.launcher3.tapl.Overview; import com.android.launcher3.tapl.OverviewTask; import com.android.launcher3.tapl.TestHelpers; @@ -210,16 +212,21 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @PortraitLandscape public void testBackground() throws Exception { startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); + final Background background = getAndAssertBackground(); + + assertNotNull("Background.switchToOverview() returned null", background.switchToOverview()); + assertTrue("Launcher internal state didn't switch to Overview", + isInState(LauncherState.OVERVIEW)); + } + + private Background getAndAssertBackground() { final Background background = mLauncher.getBackground(); assertNotNull("Launcher.getBackground() returned null", background); executeOnLauncher(launcher -> assertTrue( "Launcher activity is the top activity; expecting another activity to be the top " + "one", isInBackground(launcher))); - - assertNotNull("Background.switchToOverview() returned null", background.switchToOverview()); - assertTrue("Launcher internal state didn't switch to Overview", - isInState(LauncherState.OVERVIEW)); + return background; } @Test @@ -237,4 +244,47 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { assertTrue("Launcher internal state is not Home", isInState(LauncherState.NORMAL)); assertNotNull("getHome returned null", mLauncher.getWorkspace()); } + + @Test + @NavigationModeSwitch + @PortraitLandscape + public void testQuickSwitchFromApp() throws Exception { + startAppFast(getAppPackageName()); + startTestActivity(2); + String calculatorPackage = resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR); + startAppFast(calculatorPackage); + + Background background = getAndAssertBackground(); + background.quickSwitchToPreviousApp(); + assertTrue("The first app we should have quick switched to is not running", + isTestActivityRunning("TestActivity2")); + + background = getAndAssertBackground(); + background.quickSwitchToPreviousApp(); + if (mLauncher.getNavigationModel() == NavigationModel.THREE_BUTTON) { + // 3-button mode toggles between 2 apps, rather than going back further. + assertTrue("Second quick switch should have returned to the first app.", + mDevice.wait(Until.hasObject(By.pkg(calculatorPackage)), DEFAULT_UI_TIMEOUT)); + } else { + assertTrue("The second app we should have quick switched to is not running", + isTestActivityRunning("Test Pin Item")); + } + getAndAssertBackground(); + } + + private boolean isTestActivityRunning(String activityLabel) { + return mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text(activityLabel)), + DEFAULT_UI_TIMEOUT); + } + + @Test + @NavigationModeSwitch + @PortraitLandscape + public void testQuickSwitchFromHome() throws Exception { + startTestActivity(2); + mLauncher.pressHome().quickSwitchToPreviousApp(); + assertTrue("The most recent task is not running after quick switching from home", + isTestActivityRunning("TestActivity2")); + getAndAssertBackground(); + } } |