Add TAPL test for dismiss DesktopTaskView
This CL adds 2 new E2E Tapl tests for checking dismiss DesktopTaskView.
- dismissFocusedTask_thenDesktopIsCentered validates the following scenarios:
- Scenario: When Focused Task is in the center of the screen, with 1 other task in the grid and 1 desktop task.
- When focused task is dismissed, the next task in the grid takes its place to be the next focused task at the center of the screen.
- When the last focused task is dismissed, the desktop task takes its place at the center of the screen.
- dismissDesktopTask_thenFocusedTaskIsCentred validates the following scenarios:
- Scenario: When Desktop Task is in the center of the screen, with 1 focused task and 1 task in the grid.
- When focused task is dismissed, the next task in the grid takes its place, adjacent to desktop task.
- When desktop task is dismissed, the focused task takes its place at the center of the screen.
Fix: 353948500
Flag: com.android.launcher3.enable_large_desktop_windowing_tile
Test: TaplTestsOverviewDesktop
Change-Id: Ie2aa28cd2b30a2bf10e877721416399bcf47acf6
diff --git a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
index 9bc1c59..2c275f4 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
@@ -22,7 +22,7 @@
import android.platform.test.annotations.PlatinumTest;
import com.android.launcher3.tapl.Overview;
-import com.android.launcher3.tapl.OverviewTask.OverviewSplitTask;
+import com.android.launcher3.tapl.OverviewTask.OverviewTaskContainer;
import com.android.launcher3.tapl.OverviewTaskMenu;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.uioverrides.QuickstepLauncher;
@@ -76,7 +76,7 @@
taskMenu.touchOutsideTaskMenuToDismiss();
OverviewTaskMenu splitMenu = overview.getCurrentTask().tapMenu(
- OverviewSplitTask.SPLIT_BOTTOM_OR_RIGHT);
+ OverviewTaskContainer.SPLIT_BOTTOM_OR_RIGHT);
assertTrue("App info item not appearing in expanded split task's menu.",
splitMenu.hasMenuItem("App info"));
splitMenu.touchOutsideTaskMenuToDismiss();
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt b/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt
index 694a382..2a8afbf 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt
@@ -21,6 +21,8 @@
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import com.android.launcher3.BuildConfig
+import com.android.launcher3.tapl.LaunchedAppState
+import com.android.launcher3.tapl.OverviewTask
import com.android.launcher3.ui.AbstractLauncherUiTest
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape
import com.android.launcher3.uioverrides.QuickstepLauncher
@@ -45,22 +47,16 @@
@Test
@PortraitLandscape
fun enterDesktopViaOverviewMenu() {
- // Move last launched TEST_ACTIVITY_2 into Desktop
- mLauncher.workspace
- .switchToOverview()
- .getTestActivityTask(TEST_ACTIVITY_2)
- .tapMenu()
- .tapDesktopMenuItem()
- assertTestAppLaunched(TEST_ACTIVITY_2)
+ mLauncher.workspace.switchToOverview()
+ moveTaskToDesktop(TEST_ACTIVITY_2) // Move last launched TEST_ACTIVITY_2 into Desktop
// Scroll back to TEST_ACTIVITY_1, then move it into Desktop
mLauncher
.goHome()
.switchToOverview()
.apply { flingForward() }
- .getTestActivityTask(TEST_ACTIVITY_1)
- .tapMenu()
- .tapDesktopMenuItem()
+ .also { moveTaskToDesktop(TEST_ACTIVITY_1) }
+
TEST_ACTIVITIES.forEach { assertTestAppLaunched(it) }
// Launch static DesktopTaskView
@@ -73,6 +69,83 @@
TEST_ACTIVITIES.forEach { assertTestAppLaunched(it) }
}
+ @Test
+ @PortraitLandscape
+ fun dismissFocusedTasks_thenDesktopIsCentered() {
+ // Create DesktopTaskView
+ mLauncher.goHome().switchToOverview()
+ moveTaskToDesktop(TEST_ACTIVITY_2)
+
+ // Create a new task activity to be the focused task
+ mLauncher.goHome()
+ startTestActivity(TEST_ACTIVITY_EXTRA)
+
+ val overview = mLauncher.goHome().switchToOverview()
+
+ // Dismiss focused task
+ val focusedTask1 = overview.currentTask
+ assertTaskContentDescription(focusedTask1, TEST_ACTIVITY_EXTRA)
+ focusedTask1.dismiss()
+
+ // Dismiss new focused task
+ val focusedTask2 = overview.currentTask
+ assertTaskContentDescription(focusedTask2, TEST_ACTIVITY_1)
+ focusedTask2.dismiss()
+
+ // Dismiss DesktopTaskView
+ val desktopTask = overview.currentTask
+ assertWithMessage("The current task is not a Desktop.").that(desktopTask.isDesktop).isTrue()
+ desktopTask.dismiss()
+
+ assertWithMessage("Still have tasks after dismissing all the tasks")
+ .that(mLauncher.workspace.switchToOverview().hasTasks())
+ .isFalse()
+ }
+
+ @Test
+ @PortraitLandscape
+ fun dismissFocusedTask_thenDesktopTask_thenFocusedTaskIsCentered() {
+ // Create extra activity to be DesktopTaskView
+ startTestActivity(TEST_ACTIVITY_EXTRA)
+ mLauncher.goHome().switchToOverview()
+ val desktop = moveTaskToDesktop(TEST_ACTIVITY_EXTRA)
+
+ val overview = desktop.switchToOverview()
+
+ // Dismiss focused task
+ val focusedTask1 = overview.getTestActivityTask(TEST_ACTIVITY_2)
+ assertTaskContentDescription(focusedTask1, TEST_ACTIVITY_2)
+ focusedTask1.dismiss()
+
+ // Dismiss DesktopTaskView
+ val desktopTask = overview.currentTask
+ assertWithMessage("The current task is not a Desktop.").that(desktopTask.isDesktop).isTrue()
+ desktopTask.dismiss()
+
+ // Dismiss focused task
+ val focusedTask2 = overview.currentTask
+ assertTaskContentDescription(focusedTask2, TEST_ACTIVITY_1)
+ focusedTask2.dismiss()
+
+ assertWithMessage("Still have tasks after dismissing all the tasks")
+ .that(mLauncher.workspace.switchToOverview().hasTasks())
+ .isFalse()
+ }
+
+ private fun assertTaskContentDescription(task: OverviewTask, activityIndex: Int) {
+ assertWithMessage("The current task content description is not TestActivity$activityIndex.")
+ .that(task.containsContentDescription("TestActivity$activityIndex"))
+ .isTrue()
+ }
+
+ private fun moveTaskToDesktop(activityIndex: Int): LaunchedAppState {
+ return mLauncher.overview
+ .getTestActivityTask(activityIndex)
+ .tapMenu()
+ .tapDesktopMenuItem()
+ .also { assertTestAppLaunched(activityIndex) }
+ }
+
private fun startTestAppsWithCheck() {
TEST_ACTIVITIES.forEach {
startTestActivity(it)
@@ -91,7 +164,7 @@
.that(
mDevice.wait(
Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity$index")),
- DEFAULT_UI_TIMEOUT
+ DEFAULT_UI_TIMEOUT,
)
)
.isTrue()
@@ -100,6 +173,7 @@
companion object {
const val TEST_ACTIVITY_1 = 2
const val TEST_ACTIVITY_2 = 3
+ const val TEST_ACTIVITY_EXTRA = 4
val TEST_ACTIVITIES = listOf(TEST_ACTIVITY_1, TEST_ACTIVITY_2)
}
}
diff --git a/quickstep/tests/src/com/android/quickstep/util/SplitScreenTestUtils.kt b/quickstep/tests/src/com/android/quickstep/util/SplitScreenTestUtils.kt
index 82361aa..99c74be 100644
--- a/quickstep/tests/src/com/android/quickstep/util/SplitScreenTestUtils.kt
+++ b/quickstep/tests/src/com/android/quickstep/util/SplitScreenTestUtils.kt
@@ -43,11 +43,11 @@
val currentTask = overviewWithSplitPair.currentTask
currentTask.containsContentDescription(
By.pkg(AbstractLauncherUiTest.getAppPackageName()).text("TestActivity3").toString(),
- OverviewTask.OverviewSplitTask.SPLIT_TOP_OR_LEFT
+ OverviewTask.OverviewTaskContainer.SPLIT_TOP_OR_LEFT,
)
currentTask.containsContentDescription(
By.pkg(AbstractLauncherUiTest.getAppPackageName()).text("TestActivity2").toString(),
- OverviewTask.OverviewSplitTask.SPLIT_BOTTOM_OR_RIGHT
+ OverviewTask.OverviewTaskContainer.SPLIT_BOTTOM_OR_RIGHT,
)
return overviewWithSplitPair
}
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index 0edcfea..1002ca4 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -369,7 +369,6 @@
}
}
-
int getTaskCount() {
return getTasks().size();
}
@@ -441,7 +440,7 @@
"Not expecting an actions bar: device is tablet and task is not centered");
return false;
}
- if (task.isTaskSplit() && (!mLauncher.isAppPairsEnabled() || !isTablet)) {
+ if (task.isGrouped() && (!mLauncher.isAppPairsEnabled() || !isTablet)) {
testLogD(TAG, "Not expecting an actions bar: device is phone and task is split");
// Overview actions aren't visible for split screen tasks, except for save app pair
// button on tablets.
@@ -504,11 +503,11 @@
"want to assert overview actions view visibility="
+ isActionsViewVisible()
+ ", focused task is "
- + (task == null ? "null" : (task.isTaskSplit() ? "split" : "not split"))
+ + (task == null ? "null" : (task.isGrouped() ? "split" : "not split"))
)) {
if (isActionsViewVisible()) {
- if (task.isTaskSplit()) {
+ if (task.isGrouped()) {
mLauncher.waitForOverviewObject("action_save_app_pair");
} else {
mLauncher.waitForOverviewObject("action_buttons");
diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
index 9a8d952..4da0122 100644
--- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
+++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
@@ -16,9 +16,10 @@
package com.android.launcher3.tapl;
-import static com.android.launcher3.tapl.OverviewTask.OverviewSplitTask.DEFAULT;
-import static com.android.launcher3.tapl.OverviewTask.OverviewSplitTask.SPLIT_BOTTOM_OR_RIGHT;
-import static com.android.launcher3.tapl.OverviewTask.OverviewSplitTask.SPLIT_TOP_OR_LEFT;
+import static com.android.launcher3.tapl.OverviewTask.OverviewTaskContainer.DEFAULT;
+import static com.android.launcher3.tapl.OverviewTask.OverviewTaskContainer.DESKTOP;
+import static com.android.launcher3.tapl.OverviewTask.OverviewTaskContainer.SPLIT_BOTTOM_OR_RIGHT;
+import static com.android.launcher3.tapl.OverviewTask.OverviewTaskContainer.SPLIT_TOP_OR_LEFT;
import android.graphics.Rect;
@@ -69,7 +70,7 @@
* divider between.
*/
int getVisibleHeight() {
- if (isTaskSplit()) {
+ if (isGrouped()) {
return getCombinedSplitTaskHeight();
}
@@ -102,7 +103,7 @@
* divider between.
*/
int getVisibleWidth() {
- if (isTaskSplit()) {
+ if (isGrouped()) {
return getCombinedSplitTaskWidth();
}
@@ -164,8 +165,11 @@
dismissBySwipingUp();
+ long numNonDesktopTasks = mOverview.getCurrentTasksForTablet()
+ .stream().filter(t -> !t.isDesktop()).count();
+
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("dismissed")) {
- if (taskWasFocused) {
+ if (taskWasFocused && numNonDesktopTasks > 0) {
mLauncher.assertNotNull("No task became focused",
mOverview.getFocusedTaskForTablet());
}
@@ -256,7 +260,7 @@
/** Taps the task menu of the split task. Returns the split task's menu object. */
@NonNull
- public OverviewTaskMenu tapMenu(OverviewSplitTask task) {
+ public OverviewTaskMenu tapMenu(OverviewTaskContainer task) {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to tap the task menu")) {
@@ -270,10 +274,6 @@
}
}
- boolean isTaskSplit() {
- return findObjectInTask(SPLIT_BOTTOM_OR_RIGHT.snapshotRes) != null;
- }
-
private UiObject2 findObjectInTask(String resName) {
return mTask.findObject(mLauncher.getOverviewObjectSelector(resName));
}
@@ -285,8 +285,8 @@
* TODO(b/342627272): remove Nullable support once the bug causing it to be null is fixed.
*/
public boolean containsContentDescription(@Nullable String expected,
- OverviewSplitTask overviewSplitTask) {
- String actual = findObjectInTask(overviewSplitTask.snapshotRes).getContentDescription();
+ OverviewTaskContainer overviewTaskContainer) {
+ String actual = findObjectInTask(overviewTaskContainer.snapshotRes).getContentDescription();
if (actual == null && expected == null) {
return true;
}
@@ -315,21 +315,31 @@
}
}
+ boolean isGrouped() {
+ return mType == TaskViewType.GROUPED;
+ }
+
+ public boolean isDesktop() {
+ return mType == TaskViewType.DESKTOP;
+ }
+
/**
- * Enum used to specify which task is retrieved when it is a split task.
+ * Enum used to specify which resource name should be used depending on the type of the task.
*/
- public enum OverviewSplitTask {
+ public enum OverviewTaskContainer {
// The main task when the task is not split.
DEFAULT("snapshot", "icon"),
// The first task in split task.
SPLIT_TOP_OR_LEFT("snapshot", "icon"),
// The second task in split task.
- SPLIT_BOTTOM_OR_RIGHT("bottomright_snapshot", "bottomRight_icon");
+ SPLIT_BOTTOM_OR_RIGHT("bottomright_snapshot", "bottomRight_icon"),
+ // The desktop task.
+ DESKTOP("background", "icon");
public final String snapshotRes;
public final String iconAppRes;
- OverviewSplitTask(String snapshotRes, String iconAppRes) {
+ OverviewTaskContainer(String snapshotRes, String iconAppRes) {
this.snapshotRes = snapshotRes;
this.iconAppRes = iconAppRes;
}