diff options
author | vadimt <vadimt@google.com> | 2019-05-14 17:49:28 -0700 |
---|---|---|
committer | vadimt <vadimt@google.com> | 2019-05-14 17:49:28 -0700 |
commit | 1824b562b28d401d41326f34a6ec2d00396ee422 (patch) | |
tree | 4c2ba79685ca89f2f8bed0456e315bb0f446477b /tests/tapl/com/android/launcher3/tapl | |
parent | e60e2bab65235db9dff901508c2bf3891aac1879 (diff) | |
download | android_packages_apps_Trebuchet-1824b562b28d401d41326f34a6ec2d00396ee422.tar.gz android_packages_apps_Trebuchet-1824b562b28d401d41326f34a6ec2d00396ee422.tar.bz2 android_packages_apps_Trebuchet-1824b562b28d401d41326f34a6ec2d00396ee422.zip |
Using model-time for Overview.switchToAllApps
Change-Id: I35efcc2f04d4d31f9b2a8d42a3fce29c481951f5
Diffstat (limited to 'tests/tapl/com/android/launcher3/tapl')
4 files changed, 16 insertions, 18 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index 7ad7b7431..a296975c3 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -114,7 +114,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { "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 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { // 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 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { 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 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { 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 6d039d332..db447ee46 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -365,10 +365,10 @@ public final class LauncherInstrumentation { ? 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 @@ public final class LauncherInstrumentation { () -> 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 @@ public final class LauncherInstrumentation { } 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 @@ public final class LauncherInstrumentation { // 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 e62551087..08d974c99 100644 --- a/tests/tapl/com/android/launcher3/tapl/Overview.java +++ b/tests/tapl/com/android/launcher3/tapl/Overview.java @@ -52,10 +52,10 @@ public final class Overview extends BaseOverview { // 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 21a371c09..3cab1a1ad 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -66,13 +66,13 @@ public final class Workspace extends Home { "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")) { |