diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-08-02 22:58:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-08-02 22:58:25 +0000 |
commit | e98aab058ed566fe94530d3e3bd118ec00bc52e4 (patch) | |
tree | eecd9b10041f5b70d4fa70141f07ae40af3ccf44 /tests | |
parent | d9d4b5b2dcbe5ec98f6ec57285bdaebd288df5f6 (diff) | |
parent | ff3fa34a7ab5feb0bbe11893022a832be73536d5 (diff) | |
download | android_packages_apps_Trebuchet-e98aab058ed566fe94530d3e3bd118ec00bc52e4.tar.gz android_packages_apps_Trebuchet-e98aab058ed566fe94530d3e3bd118ec00bc52e4.tar.bz2 android_packages_apps_Trebuchet-e98aab058ed566fe94530d3e3bd118ec00bc52e4.zip |
Merge "Fixing scrolling up in App Apps." into ub-launcher3-master
Diffstat (limited to 'tests')
3 files changed, 31 insertions, 19 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index d849e2d80..e270b4605 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -72,28 +72,33 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { return new AppIcon(mLauncher, appIcon); } - protected int getBottomMarginForSwipeUp() { - return 5; - } - private void scrollBackToBeginning() { final UiObject2 allAppsContainer = verifyActiveContainer(); + final UiObject2 searchBox = + mLauncher.waitForObjectInContainer(allAppsContainer, "search_container_all_apps"); int attempts = 0; - allAppsContainer.setGestureMargins(5, 600, 5, getBottomMarginForSwipeUp()); + allAppsContainer.setGestureMargins(0, searchBox.getVisibleBounds().bottom + 1, 0, 5); - while (allAppsContainer.scroll(Direction.UP, 0.5f)) { - mLauncher.waitForIdle(); - verifyActiveContainer(); + for (int scroll = getScroll(allAppsContainer); + scroll != 0; + scroll = getScroll(allAppsContainer)) { + assertTrue("Negative scroll position", scroll > 0); assertTrue("Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS, ++attempts <= MAX_SCROLL_ATTEMPTS); + + allAppsContainer.scroll(Direction.UP, 1); } - mLauncher.waitForIdle(); verifyActiveContainer(); } + private int getScroll(UiObject2 allAppsContainer) { + return mLauncher.getAnswerFromLauncher(allAppsContainer, "TAPL_GET_SCROLL"). + getInt("scrollY", -1); + } + private void ensureIconVisible(UiObject2 appIcon, UiObject2 allAppsContainer) { final int appHeight = appIcon.getVisibleBounds().height(); if (appHeight < MIN_INTERACT_SIZE) { diff --git a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java index bc0dfc646..7ed2dc2f6 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java @@ -30,11 +30,6 @@ public final class AllAppsFromOverview extends AllApps { verifyActiveContainer(); } - @Override - protected int getBottomMarginForSwipeUp() { - return 600; - } - /** * Swipes down to switch back to Overview whence we came from. * diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index fc32fed2c..0be09f0d9 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -23,6 +23,7 @@ import static org.junit.Assert.fail; import android.app.ActivityManager; import android.app.UiAutomation; import android.content.res.Resources; +import android.os.Bundle; import android.provider.Settings; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -32,8 +33,7 @@ import android.support.test.uiautomator.BySelector; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.UiObject2; import android.support.test.uiautomator.Until; - -import org.junit.Assert; +import android.view.accessibility.AccessibilityEvent; import java.lang.ref.WeakReference; import java.util.concurrent.TimeoutException; @@ -156,18 +156,30 @@ public final class LauncherInstrumentation { } } - private void executeAndWaitForEvent(Runnable command, + private Bundle executeAndWaitForEvent(Runnable command, UiAutomation.AccessibilityEventFilter eventFilter, String message) { try { - assertNotNull("executeAndWaitForEvent returned null (this can't happen)", + final AccessibilityEvent event = InstrumentationRegistry.getInstrumentation().getUiAutomation() .executeAndWaitForEvent( - command, eventFilter, WAIT_TIME_MS)); + command, eventFilter, WAIT_TIME_MS); + assertNotNull("executeAndWaitForEvent returned null (this can't happen)", event); + return (Bundle) event.getParcelableData(); } catch (TimeoutException e) { fail(message); + return null; } } + Bundle getAnswerFromLauncher(UiObject2 view, String requestTag) { + // Send a fake set-text request to Launcher to initiate a response with requested data. + final String responseTag = requestTag + "_RESPONSE"; + return executeAndWaitForEvent( + () -> view.setText(requestTag), + event -> responseTag.equals(event.getClassName()), + "Launcher didn't respond to request: " + requestTag); + } + /** * Presses nav bar home button. * |