Merge "Revert "Update Tapl tests for enable_grid_only_overview"" into main

This commit is contained in:
Alex Chau
2023-11-02 13:36:34 +00:00
committed by Android (Google) Code Review
10 changed files with 44 additions and 71 deletions
-1
View File
@@ -19,7 +19,6 @@
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"
-1
View File
@@ -19,7 +19,6 @@
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"
-1
View File
@@ -24,7 +24,6 @@
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"
@@ -92,7 +92,7 @@ public class TaplOverviewIconTest extends AbstractLauncherUiTest {
startTestActivity(2);
startTestActivity(3);
if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
if (mLauncher.isTablet()) {
mLauncher.goHome().switchToOverview().getOverviewActions()
.clickSplit()
.getTestActivityTask(2)
@@ -179,8 +179,6 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
@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();
@@ -379,9 +377,7 @@ 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(
mLauncher.isGridOnlyOverviewEnabled() ? "TestActivity12"
: "TestActivity13")),
mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity10")),
DEFAULT_UI_TIMEOUT));
// Scroll the task offscreen as it is now first
@@ -402,17 +398,16 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
(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 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();
@@ -143,7 +143,7 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
startTestActivity(2);
startTestActivity(3);
if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
if (mLauncher.isTablet()) {
mLauncher.goHome().switchToOverview().getOverviewActions()
.clickSplit()
.getTestActivityTask(2)
@@ -18,7 +18,6 @@ package com.android.launcher3.tapl;
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;
@@ -119,10 +118,10 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
// 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(TASK_RES_ID);
mLauncher.waitForOverviewObject("snapshot");
if (mLauncher.isTablet()) {
List<UiObject2> tasks = mLauncher.getDevice().findObjects(
mLauncher.getOverviewObjectSelector(TASK_RES_ID));
mLauncher.getOverviewObjectSelector("snapshot"));
final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
mLauncher.assertTrue(
"All tasks not to the left of the swiped task",
@@ -33,7 +33,6 @@ import java.util.stream.Collectors;
*/
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);
@@ -202,8 +201,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
OverviewTask task = getCurrentTask();
mLauncher.assertNotNull("current task is null", task);
mLauncher.scrollLeftByDistance(verifyActiveContainer(),
mLauncher.getRealDisplaySize().x - task.getUiObject().getVisibleBounds().left
+ mLauncher.getOverviewPageSpacing());
task.getVisibleWidth() + mLauncher.getOverviewPageSpacing());
try (LauncherInstrumentation.Closable c2 =
mLauncher.addContextLayer("scrolled task off screen")) {
@@ -233,24 +231,14 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
final List<UiObject2> taskViews = getTasks();
mLauncher.assertNotEquals("Unable to find a task", 0, taskViews.size());
// 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);
// 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()));
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);
return new OverviewTask(mLauncher, widestTask, this);
}
/** Returns an overview task matching TestActivity {@param activityNumber}. */
@@ -263,7 +251,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
UiObject2 task = null;
for (UiObject2 taskView : taskViews) {
// TODO(b/239452415): Use equals instead of descEndsWith
if (taskView.hasObject(By.descEndsWith(activityName))) {
if (taskView.getParent().hasObject(By.descEndsWith(activityName))) {
task = taskView;
break;
}
@@ -294,7 +282,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
"want to get overview tasks")) {
verifyActiveContainer();
return mLauncher.getDevice().findObjects(
mLauncher.getOverviewObjectSelector(TASK_RES_ID));
mLauncher.getOverviewObjectSelector("snapshot"));
}
}
@@ -1608,11 +1608,8 @@ public final class LauncherInstrumentation {
scroll(
container,
Direction.LEFT,
new Rect(leftGestureMargin,
0,
Math.max(containerRect.width() - distance - leftGestureMargin,
rightGestureMarginInContainer),
0),
new Rect(leftGestureMargin, 0,
containerRect.width() - distance - rightGestureMarginInContainer, 0),
10,
true);
}
@@ -1785,7 +1782,7 @@ public final class LauncherInstrumentation {
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
public boolean isGridOnlyOverviewEnabled() {
boolean isGridOnlyOverviewEnabled() {
return getTestInfo(TestProtocol.REQUEST_FLAG_ENABLE_GRID_ONLY_OVERVIEW).getBoolean(
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
@@ -66,16 +66,17 @@ public final class OverviewTask {
return getCombinedSplitTaskHeight();
}
UiObject2 taskSnapshot1 = findObjectInTask(TASK_SNAPSHOT_1);
return taskSnapshot1.getVisibleBounds().height();
return mTask.getVisibleBounds().height();
}
/**
* Calculates the visible height for split tasks, containing 2 snapshot tiles and a divider.
*/
private int getCombinedSplitTaskHeight() {
UiObject2 taskSnapshot1 = findObjectInTask(TASK_SNAPSHOT_1);
UiObject2 taskSnapshot2 = findObjectInTask(TASK_SNAPSHOT_2);
UiObject2 taskSnapshot1 =
mLauncher.findObjectInContainer(mTask.getParent(), TASK_SNAPSHOT_1);
UiObject2 taskSnapshot2 =
mLauncher.findObjectInContainer(mTask.getParent(), TASK_SNAPSHOT_2);
int top = Math.min(
taskSnapshot1.getVisibleBounds().top, taskSnapshot2.getVisibleBounds().top);
@@ -101,8 +102,10 @@ public final class OverviewTask {
* Calculates the visible width for split tasks, containing 2 snapshot tiles and a divider.
*/
private int getCombinedSplitTaskWidth() {
UiObject2 taskSnapshot1 = findObjectInTask(TASK_SNAPSHOT_1);
UiObject2 taskSnapshot2 = findObjectInTask(TASK_SNAPSHOT_2);
UiObject2 taskSnapshot1 =
mLauncher.findObjectInContainer(mTask.getParent(), TASK_SNAPSHOT_1);
UiObject2 taskSnapshot2 =
mLauncher.findObjectInContainer(mTask.getParent(), TASK_SNAPSHOT_2);
int left = Math.min(
taskSnapshot1.getVisibleBounds().left, taskSnapshot2.getVisibleBounds().left);
@@ -141,8 +144,7 @@ public final class OverviewTask {
boolean taskWasFocused = mLauncher.isTablet() && getVisibleHeight() == mLauncher
.getFocusedTaskHeightForTablet();
List<Integer> originalTasksCenterX =
getCurrentTasksCenterXList().stream().sorted().toList();
List<Integer> originalTasksCenterX = getCurrentTasksCenterXList();
boolean isClearAllVisibleBeforeDismiss = mOverview.isClearAllVisible();
dismissBySwipingUp();
@@ -153,8 +155,7 @@ public final class OverviewTask {
mOverview.getFocusedTaskForTablet());
}
if (!isClearAllVisibleBeforeDismiss) {
List<Integer> currentTasksCenterX =
getCurrentTasksCenterXList().stream().sorted().toList();
List<Integer> currentTasksCenterX = getCurrentTasksCenterXList();
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
@@ -172,7 +173,7 @@ public final class OverviewTask {
// Dismiss the task via flinging it up.
final Rect taskBounds = mLauncher.getVisibleBounds(mTask);
final int centerX = taskBounds.centerX();
final int centerY = taskBounds.bottom - 1;
final int centerY = taskBounds.centerY();
mLauncher.executeAndWaitForLauncherEvent(
() -> mLauncher.linearGesture(centerX, centerY, centerX, 0, 10, false,
LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER),
@@ -199,7 +200,7 @@ public final class OverviewTask {
() -> mLauncher.clickLauncherObject(mTask),
event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
() -> "Launching task didn't open a new window: "
+ mTask.getContentDescription(),
+ mTask.getParent().getContentDescription(),
"clicking an overview task");
if (mOverview.getContainerType()
== LauncherInstrumentation.ContainerType.SPLIT_SCREEN_SELECT) {
@@ -226,7 +227,7 @@ public final class OverviewTask {
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to tap the task menu")) {
mLauncher.clickLauncherObject(
mLauncher.waitForObjectInContainer(mTask, "icon"));
mLauncher.waitForObjectInContainer(mTask.getParent(), "icon"));
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"tapped the task menu")) {
@@ -242,7 +243,7 @@ public final class OverviewTask {
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to tap the split task's menu")) {
mLauncher.clickLauncherObject(
mLauncher.waitForObjectInContainer(mTask, "bottomRight_icon"));
mLauncher.waitForObjectInContainer(mTask.getParent(), "bottomRight_icon"));
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"tapped the split task's menu")) {
@@ -252,10 +253,6 @@ public final class OverviewTask {
}
boolean isTaskSplit() {
return findObjectInTask(TASK_SNAPSHOT_2) != null;
}
private UiObject2 findObjectInTask(String resName) {
return mTask.findObject(mLauncher.getOverviewObjectSelector(resName));
return mLauncher.findObjectInContainer(mTask.getParent(), "bottomright_snapshot") != null;
}
}