Not waiting for animations for Launcher clicks
Waiting for animations to finish can make the test wait for too long if there is an ongoing animation somewhere, for example, in an app we are trying to swipe from.
Test: presubmit
Bug: 256567004
Change-Id: Ida494128a18342bee3dbdae6d713c854c86912c1
diff --git a/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java b/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java
index 98eb32e..10afe13 100644
--- a/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java
+++ b/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java
@@ -45,7 +45,8 @@
mLauncher.clickObject(
mLauncher.waitForObjectInContainer(
mWidgetCell.getParent().getParent().getParent().getParent(),
- By.text(ADD_AUTOMATICALLY)));
+ By.text(ADD_AUTOMATICALLY)),
+ LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER);
mLauncher.waitUntilLauncherObjectGone(getSelector());
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 302fabd..ae9ba67 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -1466,19 +1466,22 @@
return getRealDisplaySize().x - getWindowInsets().right - 1;
}
- void clickObject(UiObject2 object) {
- waitForObjectEnabled(object, "clickObject");
- if (!isLauncher3() && getNavigationModel() != NavigationModel.THREE_BUTTON) {
- expectEvent(TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_DOWN_TIS);
- expectEvent(TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_UP_TIS);
- }
- object.click();
+ /**
+ * Click on the ui object right away without waiting for animation.
+ *
+ * [UiObject2.click] would wait for all animations finished before clicking. Not waiting for
+ * animations because in some scenarios there is a playing animations when the click is
+ * attempted.
+ */
+ void clickObject(UiObject2 uiObject, GestureScope gestureScope) {
+ final long clickTime = SystemClock.uptimeMillis();
+ final Point center = uiObject.getVisibleCenter();
+ sendPointer(clickTime, clickTime, MotionEvent.ACTION_DOWN, center, gestureScope);
+ sendPointer(clickTime, clickTime, MotionEvent.ACTION_UP, center, gestureScope);
}
void clickLauncherObject(UiObject2 object) {
- expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_DOWN);
- expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_UP);
- clickObject(object);
+ clickObject(object, GestureScope.INSIDE);
}
void scrollToLastVisibleRow(
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index b2a2937..2c82c50 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -385,7 +385,7 @@
Until.hasObject(installerAlert), LauncherInstrumentation.WAIT_TIME_MS));
final UiObject2 ok = device.findObject(By.text("OK"));
assertNotNull("OK button is not shown", ok);
- launcher.clickObject(ok);
+ launcher.clickObject(ok, LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER);
assertTrue("Uninstall alert is not dismissed after clicking OK", device.wait(
Until.gone(installerAlert), LauncherInstrumentation.WAIT_TIME_MS));