summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2018-07-25 16:29:06 -0700
committerVadim Tryshev <vadimt@google.com>2018-08-02 14:15:05 -0700
commitff3fa34a7ab5feb0bbe11893022a832be73536d5 (patch)
tree4ef7e91e914194cf9e1a19dc27b945c871473a28 /tests
parent899c08aee8dba224ac12b5dce27ec1635f4ad07e (diff)
downloadandroid_packages_apps_Trebuchet-ff3fa34a7ab5feb0bbe11893022a832be73536d5.tar.gz
android_packages_apps_Trebuchet-ff3fa34a7ab5feb0bbe11893022a832be73536d5.tar.bz2
android_packages_apps_Trebuchet-ff3fa34a7ab5feb0bbe11893022a832be73536d5.zip
Fixing scrolling up in App Apps.
Done by scrolling only when scroll position is not zero. This way, the scroll gesture can't close All Apps. Bug: 110103162 Test: TaplTests suite Change-Id: Icfe47d2bcc0210ae221df169d6c35cd1be10ff86
Diffstat (limited to 'tests')
-rw-r--r--tests/tapl/com/android/launcher3/tapl/AllApps.java23
-rw-r--r--tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java5
-rw-r--r--tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java22
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.
*