Merge "Using model-time for Overview.switchToAllApps" into ub-launcher3-qt-dev

This commit is contained in:
Vadim Tryshev
2019-05-15 01:03:49 +00:00
committed by Android (Google) Code Review
4 changed files with 16 additions and 18 deletions
@@ -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();
}
@@ -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);
@@ -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")) {
@@ -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")) {