From 4d93df51a348125f2f85d310bb555e39d35be7b2 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 10 Jul 2019 17:32:58 -0700 Subject: [PATCH] Switching flinging gestures injection to model time This is a right thing to do in any case. Change-Id: I34eeecac6d9eb13130eb1015f9a9a5e2a32974ec --- src/com/android/launcher3/PagedView.java | 2 ++ .../com/android/launcher3/tapl/BaseOverview.java | 12 ++++++------ .../launcher3/tapl/LauncherInstrumentation.java | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index f8e4c9dfc7..bd52ffe4b2 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -47,6 +47,7 @@ import android.view.animation.Interpolator; import android.widget.ScrollView; import com.android.launcher3.anim.Interpolators; +import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.pageindicators.PageIndicator; import com.android.launcher3.touch.OverScroll; @@ -367,6 +368,7 @@ public abstract class PagedView extends ViewGrou */ protected void onPageEndTransition() { mWasInOverscroll = false; + AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext()); } protected int getUnboundedScrollX() { diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java index ace49e9cea..ae93867191 100644 --- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java @@ -16,6 +16,8 @@ package com.android.launcher3.tapl; +import android.graphics.Rect; + import androidx.annotation.NonNull; import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.Direction; @@ -49,9 +51,8 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { mLauncher.addContextLayer("want to fling forward in overview")) { LauncherInstrumentation.log("Overview.flingForward before fling"); final UiObject2 overview = verifyActiveContainer(); - overview.setGestureMargins(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0); - overview.fling(Direction.LEFT, (int) (FLING_SPEED * mLauncher.getDisplayDensity())); - mLauncher.waitForIdle(); + mLauncher.scroll(overview, Direction.LEFT, 1, + new Rect(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0), 20); verifyActiveContainer(); } } @@ -86,9 +87,8 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { mLauncher.addContextLayer("want to fling backward in overview")) { LauncherInstrumentation.log("Overview.flingBackward before fling"); final UiObject2 overview = verifyActiveContainer(); - overview.setGestureMargins(0, 0, mLauncher.getEdgeSensitivityWidth(), 0); - overview.fling(Direction.RIGHT, (int) (FLING_SPEED * mLauncher.getDisplayDensity())); - mLauncher.waitForIdle(); + mLauncher.scroll(overview, Direction.RIGHT, 1, + new Rect(0, 0, mLauncher.getEdgeSensitivityWidth(), 0), 20); verifyActiveContainer(); } } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 11b0665d95..72fc31903c 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -820,6 +820,22 @@ public final class LauncherInstrumentation { endY = (int) (vertCenter - halfGestureHeight); } break; + case LEFT: { + startY = endY = rect.centerY(); + final int horizCenter = rect.centerX(); + final float halfGestureWidth = rect.width() * percent / 2.0f; + startX = (int) (horizCenter - halfGestureWidth); + endX = (int) (horizCenter + halfGestureWidth); + } + break; + case RIGHT: { + startY = endY = rect.centerY(); + final int horizCenter = rect.centerX(); + final float halfGestureWidth = rect.width() * percent / 2.0f; + startX = (int) (horizCenter + halfGestureWidth); + endX = (int) (horizCenter - halfGestureWidth); + } + break; default: fail("Unsupported direction"); return;