Merge "Update Tapl tests for enable_grid_only_overview" into main
diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml
index 823a86e..9d599c9 100644
--- a/quickstep/res/layout/task.xml
+++ b/quickstep/res/layout/task.xml
@@ -19,6 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/task"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
diff --git a/quickstep/res/layout/task_desktop.xml b/quickstep/res/layout/task_desktop.xml
index fe12bd3..5a39d1c 100644
--- a/quickstep/res/layout/task_desktop.xml
+++ b/quickstep/res/layout/task_desktop.xml
@@ -19,6 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/task"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="true"
diff --git a/quickstep/res/layout/task_grouped.xml b/quickstep/res/layout/task_grouped.xml
index d20afd3..e91e773 100644
--- a/quickstep/res/layout/task_grouped.xml
+++ b/quickstep/res/layout/task_grouped.xml
@@ -24,6 +24,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/task"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
diff --git a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
index f6368b0..f51f286 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
@@ -92,7 +92,7 @@
startTestActivity(2);
startTestActivity(3);
- if (mLauncher.isTablet()) {
+ if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
mLauncher.goHome().switchToOverview().getOverviewActions()
.clickSplit()
.getTestActivityTask(2)
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index d45c225..1899472 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -179,6 +179,8 @@
@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();
@@ -377,7 +379,9 @@
// 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
@@ -398,16 +402,17 @@
(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();
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java b/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java
index acbb58f..ee0fbb8 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java
@@ -143,7 +143,7 @@
startTestActivity(2);
startTestActivity(3);
- if (mLauncher.isTablet()) {
+ if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
mLauncher.goHome().switchToOverview().getOverviewActions()
.clickSplit()
.getTestActivityTask(2)
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 8713b68..7c76f3c 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -18,6 +18,7 @@
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
+import static com.android.launcher3.tapl.BaseOverview.TASK_RES_ID;
import static com.android.launcher3.tapl.OverviewTask.TASK_START_EVENT;
import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_STATE_ORDINAL;
@@ -118,10 +119,10 @@
// non-tablet overview, snapshots can be on either side of the swiped
// task, but we still check that they become visible after swiping and
// pausing.
- mLauncher.waitForOverviewObject("snapshot");
+ mLauncher.waitForOverviewObject(TASK_RES_ID);
if (mLauncher.isTablet()) {
List<UiObject2> tasks = mLauncher.getDevice().findObjects(
- mLauncher.getOverviewObjectSelector("snapshot"));
+ mLauncher.getOverviewObjectSelector(TASK_RES_ID));
final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
mLauncher.assertTrue(
"All tasks not to the left of the swiped task",
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index a85b6bd..f874cc5 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -33,6 +33,7 @@
*/
public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
private static final int FLINGS_FOR_DISMISS_LIMIT = 40;
+ protected static final String TASK_RES_ID = "task";
BaseOverview(LauncherInstrumentation launcher) {
super(launcher);
@@ -201,7 +202,8 @@
OverviewTask task = getCurrentTask();
mLauncher.assertNotNull("current task is null", task);
mLauncher.scrollLeftByDistance(verifyActiveContainer(),
- task.getVisibleWidth() + mLauncher.getOverviewPageSpacing());
+ mLauncher.getRealDisplaySize().x - task.getUiObject().getVisibleBounds().left
+ + mLauncher.getOverviewPageSpacing());
try (LauncherInstrumentation.Closable c2 =
mLauncher.addContextLayer("scrolled task off screen")) {
@@ -231,14 +233,24 @@
final List<UiObject2> taskViews = getTasks();
mLauncher.assertNotEquals("Unable to find a task", 0, taskViews.size());
- // taskViews contains up to 3 task views: the 'main' (having the widest visible part) one
- // in the center, and parts of its right and left siblings. Find the main task view by
- // its width.
- final UiObject2 widestTask = Collections.max(taskViews,
- (t1, t2) -> Integer.compare(mLauncher.getVisibleBounds(t1).width(),
- mLauncher.getVisibleBounds(t2).width()));
+ // The widest, and most top-right task should be the current task
+ final UiObject2 currentTask = Collections.max(taskViews, (t1, t2) -> {
+ Rect t1Bounds = mLauncher.getVisibleBounds(t1);
+ Rect t2Bounds = mLauncher.getVisibleBounds(t2);
- return new OverviewTask(mLauncher, widestTask, this);
+ int result = Integer.compare(t1Bounds.width(), t2Bounds.width());
+ if (result != 0) {
+ return result;
+ }
+
+ result = Integer.compare(t1Bounds.left, t2Bounds.left);
+ if (result != 0) {
+ return result;
+ }
+
+ return Integer.compare(t2Bounds.top, t1Bounds.top);
+ });
+ return new OverviewTask(mLauncher, currentTask, this);
}
/** Returns an overview task matching TestActivity {@param activityNumber}. */
@@ -251,7 +263,7 @@
UiObject2 task = null;
for (UiObject2 taskView : taskViews) {
// TODO(b/239452415): Use equals instead of descEndsWith
- if (taskView.getParent().hasObject(By.descEndsWith(activityName))) {
+ if (taskView.hasObject(By.descEndsWith(activityName))) {
task = taskView;
break;
}
@@ -282,7 +294,7 @@
"want to get overview tasks")) {
verifyActiveContainer();
return mLauncher.getDevice().findObjects(
- mLauncher.getOverviewObjectSelector("snapshot"));
+ mLauncher.getOverviewObjectSelector(TASK_RES_ID));
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 307f192..9998f52 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -1608,8 +1608,11 @@
scroll(
container,
Direction.LEFT,
- new Rect(leftGestureMargin, 0,
- containerRect.width() - distance - rightGestureMarginInContainer, 0),
+ new Rect(leftGestureMargin,
+ 0,
+ Math.max(containerRect.width() - distance - leftGestureMargin,
+ rightGestureMarginInContainer),
+ 0),
10,
true);
}
@@ -1782,7 +1785,7 @@
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
- boolean isGridOnlyOverviewEnabled() {
+ public boolean isGridOnlyOverviewEnabled() {
return getTestInfo(TestProtocol.REQUEST_FLAG_ENABLE_GRID_ONLY_OVERVIEW).getBoolean(
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
index 06fac48..9d128a0 100644
--- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
+++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java
@@ -66,17 +66,16 @@
return getCombinedSplitTaskHeight();
}
- return mTask.getVisibleBounds().height();
+ UiObject2 taskSnapshot1 = findObjectInTask(TASK_SNAPSHOT_1);
+ return taskSnapshot1.getVisibleBounds().height();
}
/**
* Calculates the visible height for split tasks, containing 2 snapshot tiles and a divider.
*/
private int getCombinedSplitTaskHeight() {
- UiObject2 taskSnapshot1 =
- mLauncher.findObjectInContainer(mTask.getParent(), TASK_SNAPSHOT_1);
- UiObject2 taskSnapshot2 =
- mLauncher.findObjectInContainer(mTask.getParent(), TASK_SNAPSHOT_2);
+ UiObject2 taskSnapshot1 = findObjectInTask(TASK_SNAPSHOT_1);
+ UiObject2 taskSnapshot2 = findObjectInTask(TASK_SNAPSHOT_2);
int top = Math.min(
taskSnapshot1.getVisibleBounds().top, taskSnapshot2.getVisibleBounds().top);
@@ -102,10 +101,8 @@
* Calculates the visible width for split tasks, containing 2 snapshot tiles and a divider.
*/
private int getCombinedSplitTaskWidth() {
- UiObject2 taskSnapshot1 =
- mLauncher.findObjectInContainer(mTask.getParent(), TASK_SNAPSHOT_1);
- UiObject2 taskSnapshot2 =
- mLauncher.findObjectInContainer(mTask.getParent(), TASK_SNAPSHOT_2);
+ UiObject2 taskSnapshot1 = findObjectInTask(TASK_SNAPSHOT_1);
+ UiObject2 taskSnapshot2 = findObjectInTask(TASK_SNAPSHOT_2);
int left = Math.min(
taskSnapshot1.getVisibleBounds().left, taskSnapshot2.getVisibleBounds().left);
@@ -144,7 +141,8 @@
boolean taskWasFocused = mLauncher.isTablet() && getVisibleHeight() == mLauncher
.getFocusedTaskHeightForTablet();
- List<Integer> originalTasksCenterX = getCurrentTasksCenterXList();
+ List<Integer> originalTasksCenterX =
+ getCurrentTasksCenterXList().stream().sorted().toList();
boolean isClearAllVisibleBeforeDismiss = mOverview.isClearAllVisible();
dismissBySwipingUp();
@@ -155,7 +153,8 @@
mOverview.getFocusedTaskForTablet());
}
if (!isClearAllVisibleBeforeDismiss) {
- List<Integer> currentTasksCenterX = getCurrentTasksCenterXList();
+ List<Integer> currentTasksCenterX =
+ getCurrentTasksCenterXList().stream().sorted().toList();
if (originalTasksCenterX.size() == currentTasksCenterX.size()) {
// Check for the same number of visible tasks before and after to
// avoid asserting on cases of shifting all tasks to close the distance
@@ -173,7 +172,7 @@
// Dismiss the task via flinging it up.
final Rect taskBounds = mLauncher.getVisibleBounds(mTask);
final int centerX = taskBounds.centerX();
- final int centerY = taskBounds.centerY();
+ final int centerY = taskBounds.bottom - 1;
mLauncher.executeAndWaitForLauncherEvent(
() -> mLauncher.linearGesture(centerX, centerY, centerX, 0, 10, false,
LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER),
@@ -200,7 +199,7 @@
() -> mLauncher.clickLauncherObject(mTask),
event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
() -> "Launching task didn't open a new window: "
- + mTask.getParent().getContentDescription(),
+ + mTask.getContentDescription(),
"clicking an overview task");
if (mOverview.getContainerType()
== LauncherInstrumentation.ContainerType.SPLIT_SCREEN_SELECT) {
@@ -227,7 +226,7 @@
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to tap the task menu")) {
mLauncher.clickLauncherObject(
- mLauncher.waitForObjectInContainer(mTask.getParent(), "icon"));
+ mLauncher.waitForObjectInContainer(mTask, "icon"));
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"tapped the task menu")) {
@@ -243,7 +242,7 @@
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to tap the split task's menu")) {
mLauncher.clickLauncherObject(
- mLauncher.waitForObjectInContainer(mTask.getParent(), "bottomRight_icon"));
+ mLauncher.waitForObjectInContainer(mTask, "bottomRight_icon"));
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"tapped the split task's menu")) {
@@ -253,6 +252,10 @@
}
boolean isTaskSplit() {
- return mLauncher.findObjectInContainer(mTask.getParent(), "bottomright_snapshot") != null;
+ return findObjectInTask(TASK_SNAPSHOT_2) != null;
+ }
+
+ private UiObject2 findObjectInTask(String resName) {
+ return mTask.findObject(mLauncher.getOverviewObjectSelector(resName));
}
}