Merge "Using model-time for Overview.switchToAllApps" into ub-launcher3-qt-dev
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index 7ad7b74..a296975 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -114,7 +114,7 @@
"Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
++attempts <= MAX_SCROLL_ATTEMPTS);
- mLauncher.scrollWithModelTime(allAppsContainer, Direction.UP, 1, margins, 50);
+ mLauncher.scroll(allAppsContainer, Direction.UP, 1, margins, 50);
}
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled up")) {
@@ -134,7 +134,7 @@
// Try to figure out how much percentage of the container needs to be scrolled in order
// to reveal the app icon to have the MIN_INTERACT_SIZE
final float pct = Math.max(((float) (MIN_INTERACT_SIZE - appHeight)) / mHeight, 0.2f);
- mLauncher.scrollWithModelTime(allAppsContainer, Direction.DOWN, pct, null, 10);
+ mLauncher.scroll(allAppsContainer, Direction.DOWN, pct, null, 10);
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"scrolled an icon in all apps to make it visible - and then")) {
mLauncher.waitForIdle();
@@ -151,7 +151,7 @@
mLauncher.addContextLayer("want to fling forward in all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
// Start the gesture in the center to avoid starting at elements near the top.
- mLauncher.scrollWithModelTime(
+ mLauncher.scroll(
allAppsContainer, Direction.DOWN, 1, new Rect(0, 0, 0, mHeight / 2), 10);
verifyActiveContainer();
}
@@ -165,7 +165,7 @@
mLauncher.addContextLayer("want to fling backward in all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
// Start the gesture in the center, for symmetry with forward.
- mLauncher.scrollWithModelTime(
+ mLauncher.scroll(
allAppsContainer, Direction.UP, 1, new Rect(0, mHeight / 2, 0, 0), 10);
verifyActiveContainer();
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 6d039d3..db447ee 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -365,10 +365,10 @@
? NORMAL_STATE_ORDINAL : BACKGROUND_APP_STATE_ORDINAL;
final Point displaySize = getRealDisplaySize();
- swipeWithModelTime(
+ swipeToState(
displaySize.x / 2, displaySize.y - 1,
displaySize.x / 2, 0,
- finalState, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME);
+ ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME, finalState);
}
} else {
log(action = "clicking home button");
@@ -565,14 +565,12 @@
() -> mDevice.swipe(startX, startY, endX, endY, steps));
}
- void swipeWithModelTime(
- int startX, int startY, int endX, int endY, int expectedState, int steps) {
+ void swipeToState(int startX, int startY, int endX, int endY, int steps, int expectedState) {
changeStateViaGesture(startX, startY, endX, endY, expectedState,
- () -> swipeWithModelTime(startX, startY, endX, endY, steps));
+ () -> linearGesture(startX, startY, endX, endY, steps));
}
- void scrollWithModelTime(
- UiObject2 container, Direction direction, float percent, Rect margins, int steps) {
+ void scroll(UiObject2 container, Direction direction, float percent, Rect margins, int steps) {
final Rect rect = container.getVisibleBounds();
if (margins != null) {
rect.left += margins.left;
@@ -609,7 +607,7 @@
}
executeAndWaitForEvent(
- () -> swipeWithModelTime(startX, startY, endX, endY, steps),
+ () -> linearGesture(startX, startY, endX, endY, steps),
event -> TestProtocol.SCROLL_FINISHED_MESSAGE.equals(event.getClassName()),
"Didn't receive a scroll end message: " + startX + ", " + startY
+ ", " + endX + ", " + endY);
@@ -617,7 +615,7 @@
// Inject a swipe gesture. Inject exactly 'steps' motion points, incrementing event time by a
// fixed interval each time.
- void swipeWithModelTime(int startX, int startY, int endX, int endY, int steps) {
+ private void linearGesture(int startX, int startY, int endX, int endY, int steps) {
final long downTime = SystemClock.uptimeMillis();
final Point start = new Point(startX, startY);
final Point end = new Point(endX, endY);
diff --git a/tests/tapl/com/android/launcher3/tapl/Overview.java b/tests/tapl/com/android/launcher3/tapl/Overview.java
index e625510..08d974c 100644
--- a/tests/tapl/com/android/launcher3/tapl/Overview.java
+++ b/tests/tapl/com/android/launcher3/tapl/Overview.java
@@ -52,10 +52,10 @@
// Swipe from the prediction row to the top.
LauncherInstrumentation.log("Overview.switchToAllApps before swipe");
final UiObject2 predictionRow = mLauncher.waitForLauncherObject("prediction_row");
- mLauncher.swipe(mLauncher.getDevice().getDisplayWidth() / 2,
+ mLauncher.swipeToState(mLauncher.getDevice().getDisplayWidth() / 2,
predictionRow.getVisibleBounds().centerY(),
mLauncher.getDevice().getDisplayWidth() / 2,
- 0, ALL_APPS_STATE_ORDINAL);
+ 0, 50, ALL_APPS_STATE_ORDINAL);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"swiped all way up from overview")) {
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 21a371c..3cab1a1 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -66,13 +66,13 @@
"switchToAllApps: swipeHeight = " + swipeHeight + ", slop = "
+ mLauncher.getTouchSlop());
- mLauncher.swipeWithModelTime(
+ mLauncher.swipeToState(
start.x,
start.y,
start.x,
start.y - swipeHeight - mLauncher.getTouchSlop(),
- ALL_APPS_STATE_ORDINAL
- );
+ 60,
+ ALL_APPS_STATE_ORDINAL);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"swiped to all apps")) {