Merge "Account for magnetic detach when dismissing tasks in TAPL tests." into main

This commit is contained in:
Treehugger Robot
2025-05-09 08:12:58 -07:00
committed by Android (Google) Code Review
4 changed files with 26 additions and 1 deletions
@@ -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);
@@ -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) {
@@ -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);
}
}
@@ -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 + ", "