Searching icons only in apps_list_view
This should help avoiding situations when an icon is intermittently
found in the suggested row vs. the recycler.
Change-Id: I71b17caa5f827999f0901d5c4d4348de7e16f053
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index 988e674..792ec43 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -49,8 +49,9 @@
return LauncherInstrumentation.ContainerType.ALL_APPS;
}
- private boolean hasClickableIcon(UiObject2 allAppsContainer, BySelector appIconSelector) {
- final UiObject2 icon = allAppsContainer.findObject(appIconSelector);
+ private boolean hasClickableIcon(
+ UiObject2 allAppsContainer, UiObject2 appListRecycler, BySelector appIconSelector) {
+ final UiObject2 icon = appListRecycler.findObject(appIconSelector);
if (icon == null) return false;
if (mLauncher.getNavigationModel() == ZERO_BUTTON) return true;
final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
@@ -77,6 +78,8 @@
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to get app icon on all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
+ final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
+ "apps_list_view");
allAppsContainer.setGestureMargins(
0,
getSearchBox(allAppsContainer).getVisibleBounds().bottom + 1,
@@ -84,11 +87,11 @@
ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE,
mLauncher.getResources()) + 1);
final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher);
- if (!hasClickableIcon(allAppsContainer, appIconSelector)) {
+ if (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) {
scrollBackToBeginning();
int attempts = 0;
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled")) {
- while (!hasClickableIcon(allAppsContainer, appIconSelector) &&
+ while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector) &&
allAppsContainer.scroll(Direction.DOWN, 0.8f)) {
mLauncher.assertTrue(
"Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
@@ -101,7 +104,7 @@
final UiObject2 appIcon = mLauncher.getObjectInContainer(allAppsContainer,
appIconSelector);
- ensureIconVisible(appIcon, allAppsContainer);
+ ensureIconVisible(appIcon, allAppsContainer, appListRecycler);
return new AppIcon(mLauncher, appIcon);
}
}
@@ -138,13 +141,14 @@
getInt(TestProtocol.SCROLL_Y_FIELD, -1);
}
- private void ensureIconVisible(UiObject2 appIcon, UiObject2 allAppsContainer) {
+ private void ensureIconVisible(
+ UiObject2 appIcon, UiObject2 allAppsContainer, UiObject2 appListRecycler) {
final int appHeight = appIcon.getVisibleBounds().height();
if (appHeight < MIN_INTERACT_SIZE) {
// Try to figure out how much percentage of the container needs to be scrolled in order
// to reveal the app icon to have the MIN_INTERACT_SIZE
final float pct = Math.max(((float) (MIN_INTERACT_SIZE - appHeight)) / mHeight, 0.2f);
- mLauncher.scroll(allAppsContainer, Direction.DOWN, pct, null, 10);
+ mLauncher.scroll(appListRecycler, Direction.DOWN, pct, null, 10);
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"scrolled an icon in all apps to make it visible - and then")) {
mLauncher.waitForIdle();