summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorvadimt <vadimt@google.com>2019-06-13 13:35:01 -0700
committervadimt <vadimt@google.com>2019-06-13 13:35:01 -0700
commit91cd0b78e695a9e6170d267a641a47ced79af73b (patch)
tree158906d375ad5edec3b68015e9a4e0a938464549 /tests
parentc1fa3abd2e441d4acfdf6ca8d3ba628776f2ba6d (diff)
downloadandroid_packages_apps_Trebuchet-91cd0b78e695a9e6170d267a641a47ced79af73b.tar.gz
android_packages_apps_Trebuchet-91cd0b78e695a9e6170d267a641a47ced79af73b.tar.bz2
android_packages_apps_Trebuchet-91cd0b78e695a9e6170d267a641a47ced79af73b.zip
Switched scrolling in all apps to the model-time scrolling
Plus, removed unnecessary code. Bug: 132900132 Change-Id: Ia6ebca15e4e8730787bfe782dbdd83bbe9186ee6
Diffstat (limited to 'tests')
-rw-r--r--tests/tapl/com/android/launcher3/tapl/AllApps.java43
1 files changed, 11 insertions, 32 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index d03035a87..049d183c8 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -16,8 +16,6 @@
package com.android.launcher3.tapl;
-import static com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel.ZERO_BUTTON;
-
import android.graphics.Point;
import android.graphics.Rect;
import android.widget.TextView;
@@ -36,7 +34,6 @@ import com.android.launcher3.testing.TestProtocol;
*/
public class AllApps extends LauncherInstrumentation.VisibleContainer {
private static final int MAX_SCROLL_ATTEMPTS = 40;
- private static final int MIN_INTERACT_SIZE = 100;
private final int mHeight;
@@ -64,13 +61,6 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
}
final Rect iconBounds = icon.getVisibleBounds();
LauncherInstrumentation.log("hasClickableIcon: icon bounds: " + iconBounds);
- if (mLauncher.getNavigationModel() != ZERO_BUTTON) {
- final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
- if (iconBounds.bottom >= navBar.getVisibleBounds().top) {
- LauncherInstrumentation.log("hasClickableIcon: icon intersects with nav bar");
- return false;
- }
- }
if (iconCenterInSearchBox(allAppsContainer, icon)) {
LauncherInstrumentation.log("hasClickableIcon: icon center is under search box");
return false;
@@ -95,7 +85,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
@NonNull
public AppIcon getAppIcon(String appName) {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
- "want to get app icon " + appName + " on all apps")) {
+ "getting app icon " + appName + " on all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
"apps_list_view");
@@ -109,21 +99,28 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
if (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) {
scrollBackToBeginning();
int attempts = 0;
+ int scroll = getScroll(allAppsContainer);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled")) {
- while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector) &&
- allAppsContainer.scroll(Direction.DOWN, 0.8f)) {
+ while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) {
+ mLauncher.scroll(allAppsContainer, Direction.DOWN, 0.8f, null, 50);
+ final int newScroll = getScroll(allAppsContainer);
+ if (newScroll == scroll) break;
+
mLauncher.assertTrue(
"Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
++attempts <= MAX_SCROLL_ATTEMPTS);
verifyActiveContainer();
+ scroll = newScroll;
}
}
verifyActiveContainer();
}
+ mLauncher.assertTrue("Unable to scroll to a clickable icon: " + appName,
+ hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector));
+
final UiObject2 appIcon = mLauncher.getObjectInContainer(appListRecycler,
appIconSelector);
- ensureIconVisible(appIcon, allAppsContainer, appListRecycler);
return new AppIcon(mLauncher, appIcon);
}
}
@@ -161,24 +158,6 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
getInt(TestProtocol.SCROLL_Y_FIELD, -1);
}
- 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(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();
- verifyActiveContainer();
- }
- }
- mLauncher.assertTrue("Couldn't scroll app icon to not intersect with the search box",
- !iconCenterInSearchBox(allAppsContainer, appIcon));
- }
-
private UiObject2 getSearchBox(UiObject2 allAppsContainer) {
return mLauncher.waitForObjectInContainer(allAppsContainer, "search_container_all_apps");
}