diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index 76881d3e62..f808b1f722 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -219,6 +219,13 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { return getTISBinderUIProperty(Bundle::putInt, tisBinder -> tisBinder.getTaskbarManager().getPrimaryDisplayId()); } + + case TestProtocol.REQUEST_DISMISS_MAGNETIC_DETACH_THRESHOLD: { + final Resources resources = mContext.getResources(); + response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, + resources.getDimensionPixelSize(R.dimen.task_dismiss_detach_threshold)); + return response; + } } return super.call(method, arg, extras); diff --git a/shared/src/com/android/launcher3/testing/shared/TestProtocol.java b/shared/src/com/android/launcher3/testing/shared/TestProtocol.java index 1abfed29e8..b02695c137 100644 --- a/shared/src/com/android/launcher3/testing/shared/TestProtocol.java +++ b/shared/src/com/android/launcher3/testing/shared/TestProtocol.java @@ -186,6 +186,9 @@ public final class TestProtocol { public static final String REQUEST_TASKBAR_PRIMARY_DISPLAY_ID = "taskbar-primary-display-id"; + public static final String REQUEST_DISMISS_MAGNETIC_DETACH_THRESHOLD = + "dismiss-magnetic-detach-threshold"; + /** Logs {@link Log#d(String, String)} if {@link #sDebugTracing} is true. */ public static void testLogD(String tag, String message) { if (!sDebugTracing) { diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index db02a9ecf4..0b9ab06d0c 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -2735,4 +2735,10 @@ public final class LauncherInstrumentation { () -> "Didn't detect finishing wallpaper-open animation", actionName); } + + /** Returns the magnetic detach threshold when dismissing a task view. */ + public int getMagneticDetachThreshold() { + return getTestInfo(TestProtocol.REQUEST_DISMISS_MAGNETIC_DETACH_THRESHOLD).getInt( + TestProtocol.TEST_INFO_RESPONSE_FIELD); + } } diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java index 0579a0767b..8049ec6ebf 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java @@ -185,8 +185,17 @@ public final class OverviewTask { final Rect taskBounds = mLauncher.getVisibleBounds(mTask); final int centerX = taskBounds.centerX(); final int centerY = taskBounds.centerY(); + // Magnetic detach interpolates during the attached region with y = 0.3x. We must account + // for this in the dismiss length to ensure the task is dragged far enough to dismiss. + int magneticDetachLength = mLauncher.getMagneticDetachThreshold(); + int lengthTaskWillTravel = + (int) ((magneticDetachLength * 0.3f) + (centerY - magneticDetachLength)); + int minimumDismissLength = taskBounds.bottom / 2; + int extraDismissLength = Math.max(minimumDismissLength - lengthTaskWillTravel, 0); + // Bound touch to a max of the bottom of the task, account for extra required dismiss length + final int startY = Math.min(centerY + extraDismissLength, taskBounds.bottom); mLauncher.executeAndWaitForLauncherEvent( - () -> mLauncher.linearGesture(centerX, centerY, centerX, 0, 10, false, + () -> mLauncher.linearGesture(centerX, startY, centerX, 0, 10, false, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER), event -> TestProtocol.DISMISS_ANIMATION_ENDS_MESSAGE.equals(event.getClassName()), () -> "Didn't receive a dismiss animation ends message: " + centerX + ", "