summaryrefslogtreecommitdiffstats
path: root/tests/tapl/com/android/launcher3/tapl/Background.java
diff options
context:
space:
mode:
authorvadimt <vadimt@google.com>2019-03-13 18:37:41 -0700
committervadimt <vadimt@google.com>2019-03-21 12:01:23 -0700
commit8bba01874a8ee4663b85c4a540745377468e740b (patch)
treeb61a243623918f2741596057ad1e1d1f6e53e003 /tests/tapl/com/android/launcher3/tapl/Background.java
parent16675c566a15059f56d2a788590a559137636d6f (diff)
downloadpackages_apps_Trebuchet-8bba01874a8ee4663b85c4a540745377468e740b.tar.gz
packages_apps_Trebuchet-8bba01874a8ee4663b85c4a540745377468e740b.tar.bz2
packages_apps_Trebuchet-8bba01874a8ee4663b85c4a540745377468e740b.zip
Initial implementation for TAPL support for gestural navigation
It cuts some corners, flaky and has magic constants, which will be addressed later. Change-Id: I0acc75338a3c6d0ead3afda01e25ba43eb095913
Diffstat (limited to 'tests/tapl/com/android/launcher3/tapl/Background.java')
-rw-r--r--tests/tapl/com/android/launcher3/tapl/Background.java56
1 files changed, 42 insertions, 14 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 2cde8ecd2..ef509edeb 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -22,6 +22,10 @@ import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
import static org.junit.Assert.assertTrue;
+import android.graphics.Point;
+import android.os.SystemClock;
+import android.view.MotionEvent;
+
import androidx.annotation.NonNull;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.Until;
@@ -33,6 +37,8 @@ import com.android.launcher3.TestProtocol;
* indicate Launcher as long as Launcher is not in Overview state.
*/
public class Background extends LauncherInstrumentation.VisibleContainer {
+ private static final int ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION = 500;
+ private static final int ZERO_BUTTON_SWIPE_UP_HOLD_DURATION = 400;
Background(LauncherInstrumentation launcher) {
super(launcher);
@@ -59,19 +65,41 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
}
protected void goToOverviewUnchecked(int expectedState) {
- if (mLauncher.isSwipeUpEnabled()) {
- final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
- final int startY = getSwipeStartY();
- final int swipeHeight = mLauncher.getTestInfo(
- getSwipeHeightRequestName()).
- getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
-
- mLauncher.swipe(
- centerX, startY, centerX,
- startY - swipeHeight - mLauncher.getTouchSlop(),
- expectedState);
- } else {
- mLauncher.waitForSystemUiObject("recent_apps").click();
+ switch (mLauncher.getNavigationModel()) {
+ case ZERO_BUTTON: {
+ final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
+ final int startY = getSwipeStartY();
+ final int swipeHeight = mLauncher.getTestInfo(getSwipeHeightRequestName()).
+ getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ final Point start = new Point(centerX, startY);
+ final Point end =
+ new Point(centerX, startY - swipeHeight - mLauncher.getTouchSlop());
+
+ final long downTime = SystemClock.uptimeMillis();
+ mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start);
+ mLauncher.movePointer(downTime, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, start, end);
+ LauncherInstrumentation.sleep(ZERO_BUTTON_SWIPE_UP_HOLD_DURATION);
+ mLauncher.sendPointer(
+ downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end);
+ break;
+ }
+
+ case TWO_BUTTON: {
+ final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
+ final int startY = getSwipeStartY();
+ final int swipeHeight = mLauncher.getTestInfo(getSwipeHeightRequestName()).
+ getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+
+ mLauncher.swipe(
+ centerX, startY, centerX,
+ startY - swipeHeight - mLauncher.getTouchSlop(),
+ expectedState);
+ break;
+ }
+
+ case THREE_BUTTON:
+ mLauncher.waitForSystemUiObject("recent_apps").click();
+ break;
}
}
@@ -80,6 +108,6 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
}
protected int getSwipeStartY() {
- return mLauncher.waitForSystemUiObject("home").getVisibleBounds().centerY();
+ return mLauncher.waitForSystemUiObject("navigation_bar_frame").getVisibleBounds().centerY();
}
}