diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index db447ee46a..ec62188950 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -531,6 +531,14 @@ public final class LauncherInstrumentation { return object; } + @NonNull + UiObject2 waitForLauncherObjectByClass(String clazz) { + final BySelector selector = getLauncherObjectSelectorByClass(clazz); + final UiObject2 object = mDevice.wait(Until.findObject(selector), WAIT_TIME_MS); + assertNotNull("Can't find a launcher object; selector: " + selector, object); + return object; + } + @NonNull UiObject2 waitForFallbackLauncherObject(String resName) { final BySelector selector = getFallbackLauncherObjectSelector(resName); @@ -543,6 +551,10 @@ public final class LauncherInstrumentation { return By.res(getLauncherPackageName(), resName); } + BySelector getLauncherObjectSelectorByClass(String clazz) { + return By.pkg(getLauncherPackageName()).clazz(clazz); + } + BySelector getFallbackLauncherObjectSelector(String resName) { return By.res(getOverviewPackageName(), resName); } diff --git a/tests/tapl/com/android/launcher3/tapl/Overview.java b/tests/tapl/com/android/launcher3/tapl/Overview.java index 08d974c99a..ec99d26c19 100644 --- a/tests/tapl/com/android/launcher3/tapl/Overview.java +++ b/tests/tapl/com/android/launcher3/tapl/Overview.java @@ -49,11 +49,12 @@ public final class Overview extends BaseOverview { "want to switch from overview to all apps")) { verifyActiveContainer(); - // Swipe from the prediction row to the top. + // Swipe from an app icon to the top. LauncherInstrumentation.log("Overview.switchToAllApps before swipe"); - final UiObject2 predictionRow = mLauncher.waitForLauncherObject("prediction_row"); + final UiObject2 appIcon = mLauncher.waitForLauncherObjectByClass( + "android.widget.TextView"); mLauncher.swipeToState(mLauncher.getDevice().getDisplayWidth() / 2, - predictionRow.getVisibleBounds().centerY(), + appIcon.getVisibleBounds().centerY(), mLauncher.getDevice().getDisplayWidth() / 2, 0, 50, ALL_APPS_STATE_ORDINAL);