summaryrefslogtreecommitdiff
path: root/tests/tapl/com/android/launcher3/tapl/AllApps.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tapl/com/android/launcher3/tapl/AllApps.java')
-rw-r--r--tests/tapl/com/android/launcher3/tapl/AllApps.java74
1 files changed, 73 insertions, 1 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index fb08ea44eb..0e785659a6 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -16,6 +16,9 @@
package com.android.launcher3.tapl;
+import static android.view.KeyEvent.KEYCODE_ESCAPE;
+import static android.view.KeyEvent.KEYCODE_META_RIGHT;
+
import static com.android.launcher3.tapl.LauncherInstrumentation.DEFAULT_POLL_INTERVAL;
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
@@ -37,17 +40,27 @@ import com.android.launcher3.testing.shared.TestProtocol;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* Operations on AllApps opened from Home. Also a parent for All Apps opened from Overview.
*/
-public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
+public abstract class AllApps extends LauncherInstrumentation.VisibleContainer
+ implements KeyboardQuickSwitchSource {
// Defer updates flag used to defer all apps updates by a test's request.
private static final int DEFER_UPDATES_TEST = 1 << 1;
private static final int MAX_SCROLL_ATTEMPTS = 40;
+ private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
+ private static final String FAST_SCROLLER_RES_ID = "fast_scroller";
+
+ private static final Pattern EVENT_ALT_ESC_DOWN = Pattern.compile(
+ "Key event: KeyEvent.*?action=ACTION_DOWN.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
+ private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile(
+ "Key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
+
private final int mHeight;
private final int mIconHeight;
@@ -63,6 +76,16 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
+ @Override
+ public LauncherInstrumentation getLauncher() {
+ return mLauncher;
+ }
+
+ @Override
+ public LauncherInstrumentation.ContainerType getStartingContainerType() {
+ return getContainerType();
+ }
+
private boolean hasClickableIcon(UiObject2 allAppsContainer, UiObject2 appListRecycler,
BySelector appIconSelector, int displayBottom) {
final UiObject2 icon;
@@ -338,6 +361,55 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
}
/**
+ * Taps outside bottom sheet to dismiss it. Available on tablets only.
+ * @param tapRight Tap on the right of bottom sheet if true, or left otherwise.
+ */
+ public void dismissByTappingOutsideForTablet(boolean tapRight) {
+ mLauncher.assertTrue("Device must be a tablet", mLauncher.isTablet());
+ 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 container = (tapRight)
+ ? mLauncher.waitForLauncherObject(FAST_SCROLLER_RES_ID) :
+ mLauncher.waitForLauncherObject(BOTTOM_SHEET_RES_ID);
+
+ mLauncher.touchOutsideContainer(container, tapRight, false);
+ try (LauncherInstrumentation.Closable tapped = mLauncher.addContextLayer(
+ "tapped outside AllApps bottom sheet")) {
+ verifyVisibleContainerOnDismiss();
+ }
+ }
+ }
+
+ /** Presses the meta keyboard shortcut to dismiss AllApps. */
+ public void dismissByKeyboardShortcut() {
+ try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
+ mLauncher.getDevice().pressKeyCode(KEYCODE_META_RIGHT);
+ try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "pressed meta key")) {
+ verifyVisibleContainerOnDismiss();
+ }
+ }
+ }
+
+ /** Presses the esc key to dismiss AllApps. */
+ public void dismissByEscKey() {
+ try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
+ mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_DOWN);
+ mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_UP);
+ mLauncher.getDevice().pressKeyCode(KEYCODE_ESCAPE);
+ try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "pressed esc key")) {
+ verifyVisibleContainerOnDismiss();
+ }
+ }
+ }
+
+ protected abstract void verifyVisibleContainerOnDismiss();
+
+ /**
* Return the QSB UI object on the AllApps screen.
* @return the QSB UI object.
*/