Add test to dismiss AllApps bottom sheet
- http://docs/document/d/1ITZDMchoMndfa0nMuOTXbhKhK2aMDz0AT9dgusgxEro
Bug: 236360930
Test: TaplTestsLauncher3.testAllAppsDeadzoneForTablet
Test: TaplTestsNexus.testSearchDeadzoneForTablet
Change-Id: I62adb1d6ef237f9bca3812b8cdce9e5a8383158f
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 0f29abc..8fa4560 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -25,6 +25,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
import android.content.Intent;
import android.graphics.Point;
@@ -191,6 +192,17 @@
}
@Test
+ @PortraitLandscape
+ public void testAllAppsDeadzoneForTablet() throws Exception {
+ assumeTrue(mLauncher.isTablet());
+
+ mLauncher.getWorkspace().switchToAllApps().dismissByTappingOutsideForTablet(
+ true /* tapRight */);
+ mLauncher.getWorkspace().switchToAllApps().dismissByTappingOutsideForTablet(
+ false /* tapRight */);
+ }
+
+ @Test
@ScreenRecord // b/202433017
public void testWorkspace() throws Exception {
final Workspace workspace = mLauncher.getWorkspace();
diff --git a/tests/tapl/com/android/launcher3/tapl/Folder.java b/tests/tapl/com/android/launcher3/tapl/Folder.java
index 26f0a8b..1352cc0 100644
--- a/tests/tapl/com/android/launcher3/tapl/Folder.java
+++ b/tests/tapl/com/android/launcher3/tapl/Folder.java
@@ -16,11 +16,6 @@
package com.android.launcher3.tapl;
-import android.graphics.Point;
-import android.graphics.Rect;
-import android.os.SystemClock;
-import android.view.MotionEvent;
-
import androidx.annotation.NonNull;
import androidx.test.uiautomator.UiObject2;
@@ -50,25 +45,15 @@
}
}
- private void touchOutsideFolder() {
- Rect containerBounds = mLauncher.getVisibleBounds(this.mContainer);
- final long downTime = SystemClock.uptimeMillis();
- Point containerLeftTopCorner = new Point(containerBounds.left - 1, containerBounds.top - 1);
- mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN,
- containerLeftTopCorner, LauncherInstrumentation.GestureScope.INSIDE);
- mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP,
- containerLeftTopCorner, LauncherInstrumentation.GestureScope.INSIDE);
- }
-
/**
- * CLose opened folder if possible. It throws assertion error if the folder is already closed.
+ * Close opened folder if possible. It throws assertion error if the folder is already closed.
*/
public Workspace close() {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"Want to close opened folder")) {
mLauncher.waitForLauncherObject(FOLDER_CONTENT_RES_ID);
- touchOutsideFolder();
+ mLauncher.touchOutsideContainer(this.mContainer, false /* tapRight */);
mLauncher.waitUntilLauncherObjectGone(FOLDER_CONTENT_RES_ID);
return mLauncher.getWorkspace();
}
diff --git a/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java b/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java
index c275f3b..7123de4 100644
--- a/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java
@@ -19,6 +19,7 @@
import androidx.test.uiautomator.UiObject2;
public class HomeAllApps extends AllApps {
+ private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
HomeAllApps(LauncherInstrumentation launcher) {
super(launcher);
@@ -45,4 +46,23 @@
protected boolean hasSearchBox() {
return true;
}
+
+ /**
+ * Taps outside bottom sheet to dismiss and return to workspace. Available on tablets only.
+ * @param tapRight Tap on the right of bottom sheet if true, or left otherwise.
+ */
+ public Workspace dismissByTappingOutsideForTablet(boolean tapRight) {
+ try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
+ LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "want to tap outside AllApps bottom sheet on the "
+ + (tapRight ? "right" : "left"))) {
+ final UiObject2 allAppsBottomSheet =
+ mLauncher.waitForLauncherObject(BOTTOM_SHEET_RES_ID);
+ mLauncher.touchOutsideContainer(allAppsBottomSheet, tapRight);
+ try (LauncherInstrumentation.Closable tapped = mLauncher.addContextLayer(
+ "tapped outside AllApps bottom sheet")) {
+ return mLauncher.getWorkspace();
+ }
+ }
+ }
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 99cab84..ae7c46a 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -1831,4 +1831,26 @@
return ResourceUtils.getBoolByName(
"config_supportsRoundedCornersOnWindows", resources, false);
}
+
+ /**
+ * Taps outside container to dismiss.
+ * @param container container to be dismissed
+ * @param tapRight tap on the right of the container if true, or left otherwise
+ */
+ void touchOutsideContainer(UiObject2 container, boolean tapRight) {
+ try (LauncherInstrumentation.Closable c = addContextLayer(
+ "want to tap outside container on the " + (tapRight ? "right" : "left"))) {
+ Rect containerBounds = getVisibleBounds(container);
+ final long downTime = SystemClock.uptimeMillis();
+ final Point tapTarget = new Point(
+ tapRight
+ ? (containerBounds.right + getRealDisplaySize().x) / 2
+ : containerBounds.left / 2,
+ containerBounds.top + 1);
+ sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget,
+ LauncherInstrumentation.GestureScope.INSIDE);
+ sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget,
+ LauncherInstrumentation.GestureScope.INSIDE);
+ }
+ }
}
diff --git a/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java b/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java
index 82652c7..ddeeac2 100644
--- a/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java
+++ b/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java
@@ -26,6 +26,7 @@
public class SearchResultFromQsb {
// The input resource id in the search box.
private static final String INPUT_RES = "input";
+ private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
private final LauncherInstrumentation mLauncher;
SearchResultFromQsb(LauncherInstrumentation launcher) {
@@ -47,4 +48,23 @@
UiObject2 icon = mLauncher.waitForLauncherObject(By.clazz(TextView.class).text(appName));
return new AllAppsAppIcon(mLauncher, icon);
}
+
+ /**
+ * Taps outside bottom sheet to dismiss and return to workspace. Available on tablets only.
+ * @param tapRight Tap on the right of bottom sheet if true, or left otherwise.
+ */
+ public Workspace dismissByTappingOutsideForTablet(boolean tapRight) {
+ try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
+ LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "want to tap outside AllApps bottom sheet on the "
+ + (tapRight ? "right" : "left"))) {
+ final UiObject2 allAppsBottomSheet =
+ mLauncher.waitForLauncherObject(BOTTOM_SHEET_RES_ID);
+ mLauncher.touchOutsideContainer(allAppsBottomSheet, tapRight);
+ try (LauncherInstrumentation.Closable tapped = mLauncher.addContextLayer(
+ "tapped outside AllApps bottom sheet")) {
+ return mLauncher.getWorkspace();
+ }
+ }
+ }
}