Add OverviewDesktop test to verify carousel behavior on swipe up
This CL updates a test to verify the behaviour while swiping up from a fullscreen app to Overview and checking if that TaskView is between DesktopTasks (right side) and Grid Tasks (left side).
The test adds the following validations:
- Launches adjacent task while DesktopTask is at the center of the screen
- Swipe up from a fullscreen app to Overview to validate whether the task is between other tasks and desktop tasks.
- Fling back to DesktopTask to dismiss the adjacent focused task
Fix: 353948167
Flag: com.android.launcher3.enable_large_desktop_windowing_tile
Test: TaplTestsOverviewDesktop
Change-Id: Iaa15d4061c3b6ba8fc0d03416b4721cdf3f047c3
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt b/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt
index 2a8afbf..120a89b 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsOverviewDesktop.kt
@@ -104,28 +104,36 @@
@Test
@PortraitLandscape
- fun dismissFocusedTask_thenDesktopTask_thenFocusedTaskIsCentered() {
+ fun dismissTasks_whenDesktopTask_IsInTheCenter() {
// Create extra activity to be DesktopTaskView
startTestActivity(TEST_ACTIVITY_EXTRA)
mLauncher.goHome().switchToOverview()
+
val desktop = moveTaskToDesktop(TEST_ACTIVITY_EXTRA)
+ var overview = desktop.switchToOverview()
- val overview = desktop.switchToOverview()
+ // Open focused task and go back to Overview to validate whether it has adjacent tasks in
+ // its both sides (grid task on left and desktop tasks at its right side)
+ val focusedTaskOpened = overview.getTestActivityTask(TEST_ACTIVITY_2).open()
- // Dismiss focused task
- val focusedTask1 = overview.getTestActivityTask(TEST_ACTIVITY_2)
- assertTaskContentDescription(focusedTask1, TEST_ACTIVITY_2)
- focusedTask1.dismiss()
-
- // Dismiss DesktopTaskView
+ // Fling to desktop task and dismiss the focused task to check repositioning of
+ // grid tasks.
+ overview = focusedTaskOpened.switchToOverview().apply { flingBackward() }
val desktopTask = overview.currentTask
assertWithMessage("The current task is not a Desktop.").that(desktopTask.isDesktop).isTrue()
+
+ // Get focused task (previously opened task) then dismiss this task
+ val focusedTaskInOverview = overview.getTestActivityTask(TEST_ACTIVITY_2)
+ assertTaskContentDescription(focusedTaskInOverview, TEST_ACTIVITY_2)
+ focusedTaskInOverview.dismiss()
+
+ // Dismiss DesktopTask to validate whether the new focused task will take its position
desktopTask.dismiss()
- // Dismiss focused task
- val focusedTask2 = overview.currentTask
- assertTaskContentDescription(focusedTask2, TEST_ACTIVITY_1)
- focusedTask2.dismiss()
+ // Dismiss last focused task
+ val lastFocusedTask = overview.currentTask
+ assertTaskContentDescription(lastFocusedTask, TEST_ACTIVITY_1)
+ lastFocusedTask.dismiss()
assertWithMessage("Still have tasks after dismissing all the tasks")
.that(mLauncher.workspace.switchToOverview().hasTasks())
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index e1bd686..512db39 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -29,6 +29,7 @@
import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel;
import com.android.launcher3.tapl.LauncherInstrumentation.TrackpadGestureType;
+import com.android.launcher3.tapl.OverviewTask.TaskViewType;
import com.android.launcher3.testing.shared.TestProtocol;
import java.util.List;
@@ -121,12 +122,31 @@
if (mLauncher.isTablet()) {
List<UiObject2> tasks = mLauncher.getDevice().findObjects(
TASK_SELECTOR);
+
final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
- mLauncher.assertTrue(
- "Task(s) found to the right of the swiped task",
- tasks.stream().allMatch(t ->
- t.getVisibleBounds().right < centerX
- || t.getVisibleBounds().centerX() == centerX));
+ UiObject2 centerTask = tasks.stream()
+ .filter(t -> t.getVisibleCenter().x == centerX)
+ .findFirst()
+ .orElse(null);
+
+ if (centerTask != null) {
+ mLauncher.assertTrue(
+ "Task(s) found to the right of the swiped task",
+ tasks.stream()
+ .filter(t -> t != centerTask
+ && OverviewTask.getType(t)
+ != TaskViewType.DESKTOP)
+ .allMatch(t -> t.getVisibleBounds().right
+ < centerTask.getVisibleBounds().left));
+ mLauncher.assertTrue(
+ "DesktopTask(s) found to the left of the swiped task",
+ tasks.stream()
+ .filter(t -> t != centerTask
+ && OverviewTask.getType(t)
+ == TaskViewType.DESKTOP)
+ .allMatch(t -> t.getVisibleBounds().left
+ > centerTask.getVisibleBounds().right));
+ }
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
index 5fd4dac..8512d73 100644
--- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
+++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
@@ -57,7 +57,7 @@
mLauncher.assertNotNull("task must not be null", task);
mTask = task;
mOverview = overview;
- mType = getType();
+ mType = getType(task);
verifyActiveContainer();
}
@@ -304,8 +304,12 @@
return containsContentDescription(expected, DEFAULT);
}
- private TaskViewType getType() {
- String resourceName = mTask.getResourceName();
+ /**
+ * Returns the TaskView type of the task. It will return whether the task is a single TaskView,
+ * a GroupedTaskView or a DesktopTaskView.
+ */
+ static TaskViewType getType(UiObject2 task) {
+ String resourceName = task.getResourceName();
if (resourceName.endsWith("task_view_grouped")) {
return TaskViewType.GROUPED;
} else if (resourceName.endsWith("task_view_desktop")) {
@@ -345,7 +349,7 @@
}
}
- private enum TaskViewType {
+ enum TaskViewType {
SINGLE,
GROUPED,
DESKTOP