Merge "Make OverviewActions tests more robust, wait for enabled" into sc-dev am: 05098deb73 am: b164127107
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15111718
Change-Id: I3509a96beeaba65054c0c1d1da6e1d6db483aa2d
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 31ec224..38cc3aa 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -950,6 +950,16 @@
}
}
+ void waitForObjectEnabled(UiObject2 object, String waitReason) {
+ try {
+ assertTrue("Timed out waiting for object to be enabled for " + waitReason + " "
+ + object.getResourceName(),
+ object.wait(Until.enabled(true), WAIT_TIME_MS));
+ } catch (StaleObjectException e) {
+ fail("The object disappeared from screen");
+ }
+ }
+
@NonNull
UiObject2 waitForObjectInContainer(UiObject2 container, BySelector selector) {
try {
@@ -1096,6 +1106,7 @@
}
void clickLauncherObject(UiObject2 object) {
+ waitForObjectEnabled(object, "clickLauncherObject");
expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_DOWN);
expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_UP);
if (!isLauncher3() && getNavigationModel() != NavigationModel.THREE_BUTTON) {
diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewActions.java b/tests/tapl/com/android/launcher3/tapl/OverviewActions.java
index e3e0f42..950c052 100644
--- a/tests/tapl/com/android/launcher3/tapl/OverviewActions.java
+++ b/tests/tapl/com/android/launcher3/tapl/OverviewActions.java
@@ -64,6 +64,7 @@
"want to click screenshot button and exit screenshot ui")) {
UiObject2 screenshot = mLauncher.waitForObjectInContainer(mOverviewActions,
"action_screenshot");
+
mLauncher.clickLauncherObject(screenshot);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"clicked screenshot button")) {