diff options
author | vadimt <vadimt@google.com> | 2019-04-12 11:10:20 -0700 |
---|---|---|
committer | vadimt <vadimt@google.com> | 2019-04-12 18:19:38 -0700 |
commit | 679b09d6bd9d76f3284a29bdff6a67e5b3f696ff (patch) | |
tree | d54ba513bf223460db9ef0f0632dde9255622a4b /tests/tapl | |
parent | c6d9ddfddbc70aa1f486b3ed730111741566989f (diff) | |
download | android_packages_apps_Trebuchet-679b09d6bd9d76f3284a29bdff6a67e5b3f696ff.tar.gz android_packages_apps_Trebuchet-679b09d6bd9d76f3284a29bdff6a67e5b3f696ff.tar.bz2 android_packages_apps_Trebuchet-679b09d6bd9d76f3284a29bdff6a67e5b3f696ff.zip |
Gestures for zero-button mode
Change-Id: If17ba764ede132694ccf0c56269df1a4117ec0f6
Diffstat (limited to 'tests/tapl')
4 files changed, 29 insertions, 34 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index 98fb07f7f..4685c7db2 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -16,6 +16,8 @@ package com.android.launcher3.tapl; +import static com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel.ZERO_BUTTON; + import androidx.annotation.NonNull; import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.Direction; @@ -47,6 +49,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { private boolean hasClickableIcon(UiObject2 allAppsContainer, BySelector appIconSelector) { final UiObject2 icon = allAppsContainer.findObject(appIconSelector); if (icon == null) return false; + if (mLauncher.getNavigationModel() == ZERO_BUTTON) return true; final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame"); return icon.getVisibleBounds().bottom < navBar.getVisibleBounds().top; } @@ -63,8 +66,10 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get app icon on all apps")) { final UiObject2 allAppsContainer = verifyActiveContainer(); - final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame"); - allAppsContainer.setGestureMargins(0, 0, 0, navBar.getVisibleBounds().height() + 1); + if (mLauncher.getNavigationModel() != ZERO_BUTTON) { + final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame"); + allAppsContainer.setGestureMargins(0, 0, 0, navBar.getVisibleBounds().height() + 1); + } final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher); if (!hasClickableIcon(allAppsContainer, appIconSelector)) { scrollBackToBeginning(); diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java index 358d5e907..3b2a7b8d1 100644 --- a/tests/tapl/com/android/launcher3/tapl/Background.java +++ b/tests/tapl/com/android/launcher3/tapl/Background.java @@ -109,6 +109,6 @@ public class Background extends LauncherInstrumentation.VisibleContainer { } protected int getSwipeStartY() { - return mLauncher.waitForSystemUiObject("navigation_bar_frame").getVisibleBounds().centerY(); + return mLauncher.getRealDisplaySize().y - 1; } } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 08f2681ea..7ccdc769f 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -38,6 +38,7 @@ import android.view.InputDevice; import android.view.MotionEvent; import android.view.Surface; import android.view.ViewConfiguration; +import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import androidx.annotation.NonNull; @@ -350,36 +351,17 @@ public final class LauncherInstrumentation { final String action; if (getNavigationModel() == NavigationModel.ZERO_BUTTON) { if (hasLauncherObject(WORKSPACE_RES_ID)) { - log(action = "0-button: already in workspace"); - } else if (hasLauncherObject(OVERVIEW_RES_ID)) { - log(action = "0-button: from overview"); - final UiObject2 navBar = waitForSystemUiObject("navigation_bar_frame"); - - swipe( - navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(), - navBar.getVisibleBounds().centerX(), 0, - NORMAL_STATE_ORDINAL, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME); - } else if (hasLauncherObject(WIDGETS_RES_ID)) { - log(action = "0-button: from widgets"); - mDevice.pressHome(); - } else if (hasLauncherObject(APPS_RES_ID)) { - log(action = "0-button: from all apps"); - final UiObject2 navBar = waitForSystemUiObject("navigation_bar_frame"); - - swipe( - navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(), - navBar.getVisibleBounds().centerX(), 0, - NORMAL_STATE_ORDINAL, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME); + log(action = "already at home"); } else { - log(action = "0-button: from another app"); - assertTrue("Launcher is visible, don't know how to go home", - !mDevice.hasObject(By.pkg(getLauncherPackageName()))); - final UiObject2 navBar = waitForSystemUiObject("navigation_bar_frame"); + log(action = "swiping up to home"); + final int finalState = mDevice.hasObject(By.pkg(getLauncherPackageName())) + ? NORMAL_STATE_ORDINAL : BACKGROUND_APP_STATE_ORDINAL; + final Point displaySize = getRealDisplaySize(); swipe( - navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(), - navBar.getVisibleBounds().centerX(), 0, - BACKGROUND_APP_STATE_ORDINAL, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME); + displaySize.x / 2, displaySize.y - 1, + displaySize.x / 2, 0, + finalState, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME); } } else { log(action = "clicking home button"); @@ -690,4 +672,10 @@ public final class LauncherInstrumentation { return 0; } } + + Point getRealDisplaySize() { + final Point size = new Point(); + getContext().getSystemService(WindowManager.class).getDefaultDisplay().getRealSize(size); + return size; + } }
\ No newline at end of file diff --git a/tests/tapl/com/android/launcher3/tapl/Overview.java b/tests/tapl/com/android/launcher3/tapl/Overview.java index b88da3a02..e62551087 100644 --- a/tests/tapl/com/android/launcher3/tapl/Overview.java +++ b/tests/tapl/com/android/launcher3/tapl/Overview.java @@ -49,11 +49,13 @@ public final class Overview extends BaseOverview { "want to switch from overview to all apps")) { verifyActiveContainer(); - // Swipe from navbar to the top. - final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame"); + // Swipe from the prediction row to the top. LauncherInstrumentation.log("Overview.switchToAllApps before swipe"); - final int x = navBar.getVisibleCenter().x; - mLauncher.swipe(x, navBar.getVisibleBounds().top - 1, x, 0, ALL_APPS_STATE_ORDINAL); + final UiObject2 predictionRow = mLauncher.waitForLauncherObject("prediction_row"); + mLauncher.swipe(mLauncher.getDevice().getDisplayWidth() / 2, + predictionRow.getVisibleBounds().centerY(), + mLauncher.getDevice().getDisplayWidth() / 2, + 0, ALL_APPS_STATE_ORDINAL); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "swiped all way up from overview")) { |