Add TAPL tests for hiding the actions view when scrolling away from
focused task in overview.
Test: TaplTestsQuickstep.java
Bug: 197630182
Change-Id: Ie44a5bd99d7c9ffbc5405973c0ba1950cd90665c
diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
index f752822..cfd330d 100644
--- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
+++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
@@ -2,6 +2,7 @@
import android.app.Activity;
import android.content.Context;
+import android.graphics.Rect;
import android.os.Bundle;
import com.android.launcher3.LauncherState;
@@ -58,6 +59,17 @@
FeatureFlags.ENABLE_OVERVIEW_SHARE.get());
return response;
}
+
+ case TestProtocol.REQUEST_GET_FOCUSED_TASK_WIDTH_FOR_TABLET: {
+ if (!mDeviceProfile.isTablet) {
+ return null;
+ }
+ Rect focusedTaskRect = new Rect();
+ LauncherActivityInterface.INSTANCE.calculateTaskSize(mContext, mDeviceProfile,
+ focusedTaskRect);
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.width());
+ return response;
+ }
}
return super.call(method, arg);
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index 232acd9..304e76a 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -102,6 +102,8 @@
public static final String REQUEST_GET_ACTIVITIES_CREATED_COUNT =
"get-activities-created-count";
public static final String REQUEST_GET_ACTIVITIES = "get-activities";
+ public static final String REQUEST_GET_FOCUSED_TASK_WIDTH_FOR_TABLET =
+ "get-focused-task-width-for-tablet";
public static Long sForcePauseTimeout;
public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout";
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index 588b6b8..7137c00 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -35,6 +35,7 @@
BaseOverview(LauncherInstrumentation launcher) {
super(launcher);
verifyActiveContainer();
+ verifyActionsViewVisibility();
}
@Override
@@ -59,7 +60,11 @@
final int leftMargin = mLauncher.getTargetInsets().left;
mLauncher.scroll(
overview, Direction.LEFT, new Rect(leftMargin + 1, 0, 0, 0), 20, false);
- verifyActiveContainer();
+ try (LauncherInstrumentation.Closable c2 =
+ mLauncher.addContextLayer("flung forwards")) {
+ verifyActiveContainer();
+ verifyActionsViewVisibility();
+ }
}
}
@@ -95,7 +100,11 @@
final int rightMargin = mLauncher.getTargetInsets().right;
mLauncher.scroll(
overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20, false);
- verifyActiveContainer();
+ try (LauncherInstrumentation.Closable c2 =
+ mLauncher.addContextLayer("flung backwards")) {
+ verifyActiveContainer();
+ verifyActionsViewVisibility();
+ }
}
}
@@ -150,4 +159,55 @@
return new OverviewActions(overviewActions, mLauncher);
}
}
+
+ /* TODO(b/197630182): Once b/188790554 is fixed, remove instanceof check. Currently, when
+ swiping from app to overview in Fallback Recents, taskbar remains and no action buttons
+ are visible, so we are only testing Overview for now, not BaseOverview. */
+ private void verifyActionsViewVisibility() {
+ if (!(this instanceof Overview)) {
+ return;
+ }
+ try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "want to assert overview actions view visibility")) {
+ if (mLauncher.isTablet() && !isOverviewSnappedToFocusedTask()) {
+ mLauncher.waitUntilLauncherObjectGone("action_buttons");
+ } else {
+ mLauncher.waitForLauncherObject("action_buttons");
+ }
+ }
+ }
+
+ /**
+ * Returns if focused task is currently snapped task in overview.
+ */
+ private boolean isOverviewSnappedToFocusedTask() {
+ if (!mLauncher.isTablet()) {
+ // Focused task only exists in tablet's grid-overview
+ return false;
+ }
+ UiObject2 focusedTask = getFocusedTask();
+ if (focusedTask == null) {
+ return false;
+ }
+ return Math.abs(
+ focusedTask.getVisibleBounds().exactCenterX() - mLauncher.getExactScreenCenterX())
+ < 1;
+ }
+
+ /**
+ * Returns Overview focused task if it exists.
+ */
+ private UiObject2 getFocusedTask() {
+ final List<UiObject2> taskViews = getTasks();
+ if (taskViews.size() == 0) {
+ return null;
+ }
+ int focusedTaskWidth = mLauncher.getFocusedTaskWidth();
+ for (UiObject2 task : taskViews) {
+ if (task.getVisibleBounds().width() == focusedTaskWidth) {
+ return task;
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 69c97c5..3e73c12 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -321,6 +321,15 @@
.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
+ int getFocusedTaskWidth() {
+ return getTestInfo(TestProtocol.REQUEST_GET_FOCUSED_TASK_WIDTH_FOR_TABLET).getInt(
+ TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ }
+
+ float getExactScreenCenterX() {
+ return getRealDisplaySize().x / 2f;
+ }
+
private void setForcePauseTimeout(long timeout) {
getTestInfo(TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT, Long.toString(timeout));
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Overview.java b/tests/tapl/com/android/launcher3/tapl/Overview.java
index 4d673a8..0d06be3 100644
--- a/tests/tapl/com/android/launcher3/tapl/Overview.java
+++ b/tests/tapl/com/android/launcher3/tapl/Overview.java
@@ -30,7 +30,6 @@
Overview(LauncherInstrumentation launcher) {
super(launcher);
- verifyActiveContainer();
}
@Override