From 982ea561225d9859f1dd7518fe434fec81e1c0dd Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 17 May 2019 19:42:45 -0700 Subject: [PATCH] Making sure that the icon in all apps is not under search box Bug: 133011252 Bug: 133010447 Change-Id: Ie735ac36fa063d0d9290c59f6ad4af9e05600ddf --- .../com/android/launcher3/tapl/AllApps.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index 096a1d8cc3..a4d0e75320 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -53,7 +53,14 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { if (icon == null) return false; if (mLauncher.getNavigationModel() == ZERO_BUTTON) return true; final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame"); - return icon.getVisibleBounds().bottom < navBar.getVisibleBounds().top; + if (icon.getVisibleBounds().bottom >= navBar.getVisibleBounds().top) return false; + if (iconIntersectsWithSearchBox(allAppsContainer, icon)) return false; + return true; + } + + private boolean iconIntersectsWithSearchBox(UiObject2 allAppsContainer, UiObject2 icon) { + return Rect.intersects(icon.getVisibleBounds(), + getSearchBox(allAppsContainer).getVisibleBounds()); } /** @@ -68,7 +75,10 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get app icon on all apps")) { final UiObject2 allAppsContainer = verifyActiveContainer(); - allAppsContainer.setGestureMargins(0, 0, 0, + allAppsContainer.setGestureMargins( + 0, + getSearchBox(allAppsContainer).getVisibleBounds().bottom + 1, + 0, ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE, mLauncher.getResources()) + 1); final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher); @@ -98,9 +108,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to scroll back in all apps")) { final UiObject2 allAppsContainer = verifyActiveContainer(); - final UiObject2 searchBox = - mLauncher.waitForObjectInContainer(allAppsContainer, - "search_container_all_apps"); + final UiObject2 searchBox = getSearchBox(allAppsContainer); int attempts = 0; final Rect margins = new Rect(0, searchBox.getVisibleBounds().bottom + 1, 0, 5); @@ -141,6 +149,12 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { verifyActiveContainer(); } } + mLauncher.assertTrue("Couldn't scroll app icon to not intersect with the search box", + !iconIntersectsWithSearchBox(allAppsContainer, appIcon)); + } + + private UiObject2 getSearchBox(UiObject2 allAppsContainer) { + return mLauncher.waitForObjectInContainer(allAppsContainer, "search_container_all_apps"); } /**