From a56aa0d539fa2aef08e441186fc52efa26e96e8e Mon Sep 17 00:00:00 2001 From: Schneider Victor-Tulias Date: Thu, 1 May 2025 16:04:32 -0400 Subject: [PATCH] Update TAPL tests to dismiss all tasks safely Flag: EXEMPT test refactor Bug: 377678992 Test: pre/post-submit tests Change-Id: I6a2225bea4f004bdc598e2c67ce26da9fd42f7a6 --- .../com/android/quickstep/TaplTestsKeyboardQuickSwitch.java | 2 +- .../src/com/android/quickstep/TaplTestsOverviewDesktop.kt | 5 +---- .../tests/src/com/android/quickstep/TaplTestsQuickstep.java | 4 ++-- tests/tapl/com/android/launcher3/tapl/BaseOverview.java | 4 ++++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java b/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java index 3c4f1d9c6c..6f8600d637 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java @@ -152,7 +152,7 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest { @Test public void testLaunchSingleRecentTask() { - mLauncher.getLaunchedAppState().switchToOverview().dismissAllTasks(); + clearAllRecentTasks(); startAppFast(CALCULATOR_APP_PACKAGE); mLauncher.goHome().showQuickSwitchView().launchFocusedAppTask(CALCULATOR_APP_PACKAGE); } diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt b/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt index 88d0969239..8c02340ce0 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt @@ -35,10 +35,7 @@ import org.junit.Test class TaplTestsOverviewDesktop : AbstractQuickStepTest() { @Before fun setup() { - val overview = mLauncher.goHome().switchToOverview() - if (overview.hasTasks()) { - overview.dismissAllTasks() - } + clearAllRecentTasks() startTestAppsWithCheck() mLauncher.goHome() } diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index ede2aa24b4..560a28c1f2 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -548,7 +548,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @EnableFlags(value = Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW) public void testDismissBottomRow() throws Exception { assumeTrue(mLauncher.isTablet()); - mLauncher.goHome().switchToOverview().dismissAllTasks(); + clearAllRecentTasks(); startTestAppsWithCheck(); Overview overview = mLauncher.goHome().switchToOverview(); @@ -570,7 +570,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @EnableFlags(value = Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW) public void testDismissLastGridRow() throws Exception { assumeTrue(mLauncher.isTablet()); - mLauncher.goHome().switchToOverview().dismissAllTasks(); + clearAllRecentTasks(); startTestAppsWithCheck(); startTestActivity(3); startTestActivity(4); diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java index f27c25a159..176f81c418 100644 --- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java @@ -151,6 +151,10 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { /** * Dismissed all tasks by scrolling to Clear-all button and pressing it. + *

+ * NOTE: Fails if there are already no recent tasks. If a test needs to start with an empty task + * list, check {@link #hasTasks} before calling this since the previous test may have already + * cleared the task list. */ public void dismissAllTasks() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();