Hopefully reducing flakes by waiting for SysUI objects
Looks like when orientation change is involved, it takes some time for
SysUI object to reappear.
Change-Id: Id08d385ea1a535d8bcd87b123f0373cd28d90a92
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 3220691..7031cd3 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -71,7 +71,7 @@
mLauncher.swipe(centerX, startY, centerX, startY - swipeHeight - slop, expectedState);
} else {
- mLauncher.getSystemUiObject("recent_apps").click();
+ mLauncher.waitForSystemUiObject("recent_apps").click();
}
}
@@ -80,6 +80,6 @@
}
protected int getSwipeStartY() {
- return mLauncher.getSystemUiObject("home").getVisibleBounds().centerY();
+ return mLauncher.waitForSystemUiObject("home").getVisibleBounds().centerY();
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 926e470..ce37348 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -288,7 +288,7 @@
executeAndWaitForEvent(
() -> {
log("LauncherInstrumentation.pressHome before clicking");
- getSystemUiObject("home").click();
+ waitForSystemUiObject("home").click();
},
event -> true,
"Pressing Home didn't produce any events");
@@ -298,7 +298,7 @@
executeAndWaitForEvent(
() -> {
log("LauncherInstrumentation.pressHome before clicking");
- getSystemUiObject("home").click();
+ waitForSystemUiObject("home").click();
},
event -> true,
"Pressing Home didn't produce any events");
@@ -394,8 +394,9 @@
}
@NonNull
- UiObject2 getSystemUiObject(String resId) {
- final UiObject2 object = mDevice.findObject(By.res(SYSTEMUI_PACKAGE, resId));
+ UiObject2 waitForSystemUiObject(String resId) {
+ final UiObject2 object = mDevice.wait(
+ Until.findObject(By.res(SYSTEMUI_PACKAGE, resId)), WAIT_TIME_MS);
assertNotNull("Can't find a systemui object with id: " + resId, object);
return object;
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Overview.java b/tests/tapl/com/android/launcher3/tapl/Overview.java
index 0208144..5c8d5eb 100644
--- a/tests/tapl/com/android/launcher3/tapl/Overview.java
+++ b/tests/tapl/com/android/launcher3/tapl/Overview.java
@@ -50,7 +50,7 @@
verifyActiveContainer();
// Swipe from navbar to the top.
- final UiObject2 navBar = mLauncher.getSystemUiObject("navigation_bar_frame");
+ final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
final Point start = navBar.getVisibleCenter();
LauncherInstrumentation.log("Overview.switchToAllApps before swipe");
mLauncher.swipe(start.x, start.y, start.x, 0, ALL_APPS_STATE_ORDINAL);