diff --git a/tests/Launcher3Tests.xml b/tests/Launcher3Tests.xml new file mode 100644 index 0000000000..3fff622857 --- /dev/null +++ b/tests/Launcher3Tests.xml @@ -0,0 +1,50 @@ + + + + + diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index b6c17df730..e32250eaa5 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -27,7 +27,6 @@ import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.Direction; import androidx.test.uiautomator.UiObject2; -import com.android.launcher3.ResourceUtils; import com.android.launcher3.testing.TestProtocol; import java.util.stream.Collectors; @@ -108,26 +107,24 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { "apps_list_view"); final UiObject2 searchBox = getSearchBox(allAppsContainer); - int bottomGestureMargin = ResourceUtils.getNavbarSize( - ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1; - int deviceHeight = mLauncher.getDevice().getDisplayHeight(); - int displayBottom = deviceHeight - bottomGestureMargin; + int deviceHeight = mLauncher.getRealDisplaySize().y; + int bottomGestureStartOnScreen = mLauncher.getBottomGestureStartOnScreen(); final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher); if (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector, - displayBottom)) { + bottomGestureStartOnScreen)) { scrollBackToBeginning(); int attempts = 0; int scroll = getAllAppsScroll(); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled")) { while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector, - displayBottom)) { + bottomGestureStartOnScreen)) { mLauncher.scrollToLastVisibleRow( allAppsContainer, mLauncher.getObjectsInContainer(allAppsContainer, "icon") .stream() .filter(icon -> - mLauncher.getVisibleBounds(icon).bottom - <= displayBottom) + mLauncher.getVisibleBounds(icon).top + < bottomGestureStartOnScreen) .collect(Collectors.toList()), mLauncher.getVisibleBounds(searchBox).bottom - mLauncher.getVisibleBounds(allAppsContainer).top); diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index f279a82475..64fc3609ae 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1028,16 +1028,20 @@ public final class LauncherInstrumentation { expectedState); } - int getBottomGestureSize() { + private int getBottomGestureSize() { return ResourceUtils.getNavbarSize( ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources()) + 1; } int getBottomGestureMarginInContainer(UiObject2 container) { - final int bottomGestureStartOnScreen = getRealDisplaySize().y - getBottomGestureSize(); + final int bottomGestureStartOnScreen = getBottomGestureStartOnScreen(); return getVisibleBounds(container).bottom - bottomGestureStartOnScreen; } + int getBottomGestureStartOnScreen() { + return getRealDisplaySize().y - getBottomGestureSize(); + } + void clickLauncherObject(UiObject2 object) { expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_DOWN); expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_UP);