From 749b2b8493cd18e84edba277ea0e14b90965f060 Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Tue, 13 Sep 2022 15:42:33 -0700 Subject: [PATCH] Prevent dragging widgets to another page in tests when starting a drag. The function Launchable.startDrag it's supposed to grab and icon or widget and start the dragging by moving it only in the verticall position but because it uses the coordinates of the object before entering the SPRING_LOADED_STATE_ORDINAL state then the coordiates where it moves are outisde of the cell layout and it moves to a new page. This only happens if the phone is too slow and it triggers the page change, otherwise it would be too fast. To fix it, I'm moving the icon/widget to the center of the screen minus getStartDragThreshold() to ensure the drag is always triggered. Fix: 242323136 Fix: 244224955 Fix: 241019568 Fix: 241583798 Test: atest ReorderWidgets Change-Id: I0e431b994aa4a3d5c8be45b6c73263732553b36c --- .../com/android/launcher3/celllayout/ReorderWidgets.java | 5 ----- tests/tapl/com/android/launcher3/tapl/Launchable.java | 7 ++++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java b/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java index 93fbf97e99..83d15ef679 100644 --- a/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java +++ b/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java @@ -35,7 +35,6 @@ import com.android.launcher3.tapl.Widget; import com.android.launcher3.tapl.WidgetResizeFrame; import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.ui.TaplTestsLauncher3; -import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord; import com.android.launcher3.util.rule.ShellCommandRule; import com.android.launcher3.views.DoubleShadowBubbleTextView; import com.android.launcher3.widget.LauncherAppWidgetHostView; @@ -141,26 +140,22 @@ public class ReorderWidgets extends AbstractLauncherUiTest { runTestCase(testCaseMap.get(iconGridDimensions)); } - @ScreenRecord // b/242323136 @Test public void simpleReorder() { runTestCaseMap(SimpleReorderCase.TEST_BY_GRID_SIZE, SimpleReorderCase.class.getSimpleName()); } - @ScreenRecord // b/242323136 @Test public void pushTest() { runTestCaseMap(PushReorderCase.TEST_BY_GRID_SIZE, PushReorderCase.class.getSimpleName()); } - @ScreenRecord // b/242323136 @Test public void fullReorder() { runTestCaseMap(FullReorderCase.TEST_BY_GRID_SIZE, FullReorderCase.class.getSimpleName()); } - @ScreenRecord // b/242323136 @Test public void moveOutReorder() { runTestCaseMap(MoveOutReorderCase.TEST_BY_GRID_SIZE, diff --git a/tests/tapl/com/android/launcher3/tapl/Launchable.java b/tests/tapl/com/android/launcher3/tapl/Launchable.java index 3dcb4377e7..15f74dc76b 100644 --- a/tests/tapl/com/android/launcher3/tapl/Launchable.java +++ b/tests/tapl/com/android/launcher3/tapl/Launchable.java @@ -85,9 +85,10 @@ public abstract class Launchable { } Point startDrag(long downTime, Runnable expectLongClickEvents, boolean runToSpringLoadedState) { - final Point iconCenter = getObject().getVisibleCenter(); - final Point dragStartCenter = new Point(iconCenter.x, - iconCenter.y - getStartDragThreshold()); + Point iconCenter = getObject().getVisibleCenter(); + final Point displaySize = mLauncher.getRealDisplaySize(); + final Point dragStartCenter = new Point(displaySize.x / 2, + displaySize.y / 2 - getStartDragThreshold()); if (runToSpringLoadedState) { mLauncher.runToState(() -> movePointerForStartDrag(