diff options
Diffstat (limited to 'quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java')
-rw-r--r-- | quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java | 183 |
1 files changed, 93 insertions, 90 deletions
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 25f90caa3e..6cbe1712e0 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -16,11 +16,9 @@ package com.android.quickstep; -import static com.android.launcher3.testing.shared.TestProtocol.FLAKY_QUICK_SWITCH_TO_PREVIOUS_APP; -import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName; import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL; import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT; -import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT; +import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -29,8 +27,8 @@ import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; import android.content.Intent; +import android.content.res.Configuration; import android.platform.test.annotations.PlatinumTest; -import android.util.Log; import androidx.test.filters.LargeTest; import androidx.test.platform.app.InstrumentationRegistry; @@ -46,10 +44,8 @@ import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel; import com.android.launcher3.tapl.Overview; import com.android.launcher3.tapl.OverviewActions; import com.android.launcher3.tapl.OverviewTask; -import com.android.launcher3.tapl.OverviewTaskMenu; +import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape; -import com.android.launcher3.ui.TaplTestsLauncher3; -import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.Wait; import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord; import com.android.launcher3.util.rule.TestStabilityRule; @@ -67,7 +63,6 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class TaplTestsQuickstep extends AbstractQuickStepTest { - private static final String APP_NAME = "LauncherTestApp"; private static final String CALCULATOR_APP_PACKAGE = resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR); private static final String READ_DEVICE_CONFIG_PERMISSION = @@ -76,7 +71,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Before public void setUp() throws Exception { super.setUp(); - TaplTestsLauncher3.initialize(this); + AbstractLauncherUiTest.initialize(this); executeOnLauncher(launcher -> { RecentsView recentsView = launcher.getOverviewPanel(); recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(true); @@ -85,7 +80,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @After public void tearDown() { - executeOnLauncher(launcher -> { + executeOnLauncherInTearDown(launcher -> { RecentsView recentsView = launcher.getOverviewPanel(); recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(false); }); @@ -108,7 +103,6 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @NavigationModeSwitch @PortraitLandscape - @PlatinumTest(focusArea = "launcher") public void testWorkspaceSwitchToAllApps() { assertNotNull("switchToAllApps() returned null", mLauncher.getWorkspace().switchToAllApps()); @@ -185,8 +179,9 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @NavigationModeSwitch @PortraitLandscape - @PlatinumTest(focusArea = "launcher") public void testOverviewActions() throws Exception { + assumeFalse("Skipping Overview Actions tests for grid only overview", + mLauncher.isTablet() && mLauncher.isGridOnlyOverviewEnabled()); // Experimenting for b/165029151: final Overview overview = mLauncher.goHome().switchToOverview(); if (overview.hasTasks()) overview.dismissAllTasks(); @@ -199,19 +194,6 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { actionsView.clickAndDismissScreenshot(); } - - @Test - public void testOverviewActionsMenu() throws Exception { - startTestAppsWithCheck(); - - OverviewTaskMenu menu = mLauncher.goHome().switchToOverview().getCurrentTask().tapMenu(); - - assertNotNull("Tapping App info menu item returned null", menu.tapAppInfoMenuItem()); - executeOnLauncher(launcher -> assertTrue( - "Launcher activity is the top activity; expecting another activity to be the top", - isInLaunchedApp(launcher))); - } - private int getCurrentOverviewPage(Launcher launcher) { return launcher.<RecentsView>getOverviewPanel().getCurrentPage(); } @@ -233,7 +215,6 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @NavigationModeSwitch @PortraitLandscape @ScreenRecord // b/238461765 - @PlatinumTest(focusArea = "launcher") public void testSwitchToOverview() throws Exception { startTestAppsWithCheck(); assertNotNull("Workspace.switchToOverview() returned null", @@ -242,11 +223,23 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { isInState(() -> LauncherState.OVERVIEW)); } + @Test + @TaskbarModeSwitch(mode = TRANSIENT) + public void testSwitchToOverviewWithStashedTaskbar() throws Exception { + try { + startTestAppsWithCheck(); + // Set ignoreTaskbarVisibility, as transient taskbar will be stashed after app launch. + mLauncher.setIgnoreTaskbarVisibility(true); + mLauncher.getLaunchedAppState().switchToOverview(); + } finally { + mLauncher.setIgnoreTaskbarVisibility(false); + } + } + @Ignore @Test @NavigationModeSwitch @PortraitLandscape - @PlatinumTest(focusArea = "launcher") public void testBackground() throws Exception { startAppFast(CALCULATOR_APP_PACKAGE); final LaunchedAppState launchedAppState = getAndAssertLaunchedApp(); @@ -271,27 +264,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { } @Test - @PortraitLandscape - public void testAllAppsFromHome() throws Exception { - // Test opening all apps - assertNotNull("switchToAllApps() returned null", - mLauncher.getWorkspace().switchToAllApps()); - - TaplTestsLauncher3.runAllAppsTest(this, mLauncher.getAllApps()); - - // Testing pressHome. - assertTrue("Launcher internal state is not All Apps", - isInState(() -> LauncherState.ALL_APPS)); - assertNotNull("pressHome returned null", mLauncher.goHome()); - assertTrue("Launcher internal state is not Home", - isInState(() -> LauncherState.NORMAL)); - assertNotNull("getHome returned null", mLauncher.getWorkspace()); - } - - @Test @NavigationModeSwitch @PortraitLandscape - @PlatinumTest(focusArea = "launcher") public void testQuickSwitchFromApp() throws Exception { startTestActivity(2); startTestActivity(3); @@ -320,9 +294,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { } @Test - @ScreenRecord // b/242163205 - @PlatinumTest(focusArea = "launcher") - @TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/286084688 + @TaskbarModeSwitch + @Ignore // b/314873201 public void testQuickSwitchToPreviousAppForTablet() throws Exception { assumeTrue(mLauncher.isTablet()); startTestActivity(2); @@ -331,33 +304,43 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { // Set ignoreTaskbarVisibility to true to verify the task bar visibility explicitly. mLauncher.setIgnoreTaskbarVisibility(true); - // Expect task bar invisible when the launched app was the IME activity. - LaunchedAppState launchedAppState = getAndAssertLaunchedApp(); - launchedAppState.assertTaskbarHidden(); - // Quick-switch to the test app with swiping to right. - quickSwitchToPreviousAppAndAssert(true /* toRight */); + try { + boolean isTransientTaskbar = mLauncher.isTransientTaskbar(); + // Expect task bar invisible when the launched app was the IME activity. + LaunchedAppState launchedAppState = getAndAssertLaunchedApp(); + if (!isTransientTaskbar && isHardwareKeyboard()) { + launchedAppState.assertTaskbarVisible(); + } else { + launchedAppState.assertTaskbarHidden(); + } + + // Quick-switch to the test app with swiping to right. + quickSwitchToPreviousAppAndAssert(true /* toRight */); - assertTestActivityIsRunning(2, - "The first app we should have quick switched to is not running"); - // Expect task bar visible when the launched app was the test activity. - launchedAppState = getAndAssertLaunchedApp(); - - Log.e(FLAKY_QUICK_SWITCH_TO_PREVIOUS_APP, - "is Taskbar Transient : " + DisplayController.isTransientTaskbar(mTargetContext)); - // TODO(b/286084688): Remove this branching check after test corruption is resolved. - // Branching this check because of test corruption. - if (DisplayController.isTransientTaskbar(mTargetContext)) { - launchedAppState.assertTaskbarHidden(); - } else { - launchedAppState.assertTaskbarVisible(); + assertTestActivityIsRunning(2, + "The first app we should have quick switched to is not running"); + launchedAppState = getAndAssertLaunchedApp(); + if (isTransientTaskbar) { + launchedAppState.assertTaskbarHidden(); + } else { + // Expect taskbar visible when the launched app was the test activity. + launchedAppState.assertTaskbarVisible(); + } + } finally { + // Reset ignoreTaskbarVisibility to ensure other tests still verify it. + mLauncher.setIgnoreTaskbarVisibility(false); } } + private boolean isHardwareKeyboard() { + return Configuration.KEYBOARD_QWERTY + == mTargetContext.getResources().getConfiguration().keyboard; + } + @Test @NavigationModeSwitch @PortraitLandscape - @PlatinumTest(focusArea = "launcher") public void testQuickSwitchFromHome() throws Exception { startTestActivity(2); mLauncher.goHome().quickSwitchToPreviousApp(); @@ -369,10 +352,11 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @PortraitLandscape @NavigationModeSwitch - @PlatinumTest(focusArea = "launcher") public void testPressBack() throws Exception { InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity( READ_DEVICE_CONFIG_PERMISSION); + // Debug if we need to goHome to prevent wrong previous state b/315525621 + mLauncher.goHome(); assumeFalse(FeatureFlags.ENABLE_BACK_SWIPE_LAUNCHER_ANIMATION.get()); mLauncher.getWorkspace().switchToAllApps(); mLauncher.pressBack(); @@ -387,8 +371,10 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @PortraitLandscape - @TaskbarModeSwitch(mode = PERSISTENT) + @TaskbarModeSwitch() @PlatinumTest(focusArea = "launcher") + @TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/309820115 + @ScreenRecord // b/309820115 public void testOverviewForTablet() throws Exception { assumeTrue(mLauncher.isTablet()); @@ -411,7 +397,9 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { // Test opening the task. overview.getCurrentTask().open(); assertTrue("Test activity didn't open from Overview", - mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity10")), + mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text( + mLauncher.isGridOnlyOverviewEnabled() ? "TestActivity12" + : "TestActivity13")), DEFAULT_UI_TIMEOUT)); // Scroll the task offscreen as it is now first @@ -432,16 +420,17 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet( launcher)) <= 1))); - // Test dismissing more tasks. - assertTrue("Launcher internal state didn't remain in Overview", - isInState(() -> LauncherState.OVERVIEW)); - overview.getCurrentTask().dismiss(); - assertTrue("Launcher internal state didn't remain in Overview", - isInState(() -> LauncherState.OVERVIEW)); - overview.getCurrentTask().dismiss(); - executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after multiple dismissals", - (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet( - launcher)) <= 1))); + // TODO(b/308841019): Re-enable after fixing Overview jank when dismiss +// // Test dismissing more tasks. +// assertTrue("Launcher internal state didn't remain in Overview", +// isInState(() -> LauncherState.OVERVIEW)); +// overview.getCurrentTask().dismiss(); +// assertTrue("Launcher internal state didn't remain in Overview", +// isInState(() -> LauncherState.OVERVIEW)); +// overview.getCurrentTask().dismiss(); +// executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after multiple dismissals", +// (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet( +// launcher)) <= 1))); // Test dismissing all tasks. mLauncher.goHome().switchToOverview().dismissAllTasks(); @@ -478,6 +467,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @PortraitLandscape + @TaskbarModeSwitch public void testTaskbarDeadzonesForTablet() throws Exception { assumeTrue(mLauncher.isTablet()); @@ -490,19 +480,32 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { launcher -> assertTrue("Should have at least 3 tasks", getTaskCount(launcher) >= 3)); - // On persistent taskbar, it should not dismiss when tapping the taskbar - overview.touchTaskbarBottomCorner(/* tapRight= */ false); - assertTrue("Launcher internal state should be Overview", - isInState(() -> LauncherState.OVERVIEW)); + if (mLauncher.isTransientTaskbar()) { + // On transient taskbar, it should dismiss when tapping outside taskbar bounds. + overview.touchTaskbarBottomCorner(/* tapRight= */ false); + assertTrue("Launcher internal state should be Normal", + isInState(() -> LauncherState.NORMAL)); - // On persistent taskbar, it should not dismiss when tapping the taskbar - overview.touchTaskbarBottomCorner(/* tapRight= */ true); - assertTrue("Launcher internal state should be Overview", - isInState(() -> LauncherState.OVERVIEW)); + overview = mLauncher.getWorkspace().switchToOverview(); + + // On transient taskbar, it should dismiss when tapping outside taskbar bounds. + overview.touchTaskbarBottomCorner(/* tapRight= */ true); + assertTrue("Launcher internal state should be Normal", + isInState(() -> LauncherState.NORMAL)); + } else { + // On persistent taskbar, it should not dismiss when tapping the taskbar + overview.touchTaskbarBottomCorner(/* tapRight= */ false); + assertTrue("Launcher internal state should be Overview", + isInState(() -> LauncherState.OVERVIEW)); + + // On persistent taskbar, it should not dismiss when tapping the taskbar + overview.touchTaskbarBottomCorner(/* tapRight= */ true); + assertTrue("Launcher internal state should be Overview", + isInState(() -> LauncherState.OVERVIEW)); + } } @Test - @ScreenRecord // b/242163205 public void testDisableRotationCheckForPhone() throws Exception { assumeFalse(mLauncher.isTablet()); try { |