From 1b5975c205796448dd5b207275a1c9e2e03a4e84 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Tue, 26 Oct 2021 18:08:45 +0100 Subject: [PATCH] Fix scroll task off screen to support different screen dimensions. This will fix the breaks on cuttlefish as seen in b/203781041. Test: TaplTestsQuickstep.java Bug: 197630182 Change-Id: I3b582a9df1790543c4e1521b45494fb462bb5c1c --- .../android/quickstep/TaplTestsQuickstep.java | 2 -- .../android/launcher3/tapl/BaseOverview.java | 10 +++----- .../tapl/LauncherInstrumentation.java | 24 +++++++++++++++++++ .../android/launcher3/tapl/OverviewTask.java | 4 ++++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 710afe00c2..4895b107e1 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -43,7 +43,6 @@ import com.android.quickstep.views.RecentsView; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -289,7 +288,6 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @PortraitLandscape - @Ignore("b/203781041") public void testOverviewForTablet() throws Exception { if (!mLauncher.isTablet()) { return; diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java index 0e3b5013d8..d5479fbd9e 100644 --- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java @@ -54,18 +54,14 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { } private void flingForwardImpl() { - flingForwardImpl(0); - } - - private void flingForwardImpl(int rightMargin) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer("want to fling forward in overview")) { LauncherInstrumentation.log("Overview.flingForward before fling"); final UiObject2 overview = verifyActiveContainer(); final int leftMargin = mLauncher.getTargetInsets().left + mLauncher.getEdgeSensitivityWidth(); - mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin + 1, 0, rightMargin, 0), - 20, false); + mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin + 1, 0, 0, 0), 20, + false); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("flung forwards")) { verifyActiveContainer(); @@ -131,7 +127,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { OverviewTask task = getCurrentTask(); mLauncher.assertNotNull("current task is null", task); - flingForwardImpl(task.getTaskCenterX()); + mLauncher.scrollLeftByDistance(verifyActiveContainer(), task.getVisibleWidth()); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("scrolled task off screen")) { diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 9ee0e25bd7..7ffdf4cef8 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1190,10 +1190,19 @@ public final class LauncherInstrumentation { return getVisibleBounds(container).bottom - bottomGestureStartOnScreen; } + int getRightGestureMarginInContainer(UiObject2 container) { + final int rightGestureStartOnScreen = getRightGestureStartOnScreen(); + return getVisibleBounds(container).right - rightGestureStartOnScreen; + } + int getBottomGestureStartOnScreen() { return getRealDisplaySize().y - getBottomGestureSize(); } + int getRightGestureStartOnScreen() { + return getRealDisplaySize().x - getWindowInsets().right; + } + void clickLauncherObject(UiObject2 object) { waitForObjectEnabled(object, "clickLauncherObject"); expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_DOWN); @@ -1235,6 +1244,21 @@ public final class LauncherInstrumentation { true); } + void scrollLeftByDistance(UiObject2 container, int distance) { + final Rect containerRect = getVisibleBounds(container); + final int rightGestureMarginInContainer = getRightGestureMarginInContainer(container); + scroll( + container, + Direction.LEFT, + new Rect( + 0, + containerRect.width() - distance - rightGestureMarginInContainer, + 0, + rightGestureMarginInContainer), + 10, + true); + } + void scroll( UiObject2 container, Direction direction, Rect margins, int steps, boolean slowDown) { final Rect rect = getVisibleBounds(container); diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java index 15bddd7c88..a860e7d894 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java @@ -53,6 +53,10 @@ public final class OverviewTask { return mTask.getVisibleBounds().height(); } + int getVisibleWidth() { + return mTask.getVisibleBounds().width(); + } + int getTaskCenterX() { return mTask.getVisibleCenter().x; }