diff options
author | vadimt <vadimt@google.com> | 2019-01-28 18:46:49 -0800 |
---|---|---|
committer | vadimt <vadimt@google.com> | 2019-01-29 11:40:59 -0800 |
commit | 446bf0092e8db2811d2ce47eea1bac76851f7c9b (patch) | |
tree | c45eed6d10ed07bbb6176982caff5bf94916a35d | |
parent | e0c5f5d0ab86417e21992f520a53dc5ec410f29a (diff) | |
download | android_packages_apps_Trebuchet-446bf0092e8db2811d2ce47eea1bac76851f7c9b.tar.gz android_packages_apps_Trebuchet-446bf0092e8db2811d2ce47eea1bac76851f7c9b.tar.bz2 android_packages_apps_Trebuchet-446bf0092e8db2811d2ce47eea1bac76851f7c9b.zip |
Fixing flakiness of ShortcutsToHomeTest
More precisely, an experiment on whether this will help. The theory is
that the current implementation where we long-press an icon for a fixed
period of time sometimes doesn't work because Launcher might start
measuring the press time with some delay.
Now we keep pressed the icon until the menu appears.
Change-Id: I1cead505726a998316a73d81b10160517f17f08f
Tests:ShortcutsToHomeTest.testDragIcon
-rw-r--r-- | tests/tapl/com/android/launcher3/tapl/AppIcon.java | 4 | ||||
-rw-r--r-- | tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java | 15 |
2 files changed, 13 insertions, 6 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/AppIcon.java b/tests/tapl/com/android/launcher3/tapl/AppIcon.java index 3ffd30c86..d39a38ea1 100644 --- a/tests/tapl/com/android/launcher3/tapl/AppIcon.java +++ b/tests/tapl/com/android/launcher3/tapl/AppIcon.java @@ -17,6 +17,7 @@ package com.android.launcher3.tapl; import android.graphics.Point; +import android.view.MotionEvent; import android.widget.TextView; import androidx.test.uiautomator.By; @@ -40,9 +41,10 @@ public final class AppIcon extends Launchable { */ public AppIconMenu openMenu() { final Point iconCenter = mObject.getVisibleCenter(); - mLauncher.longTap(iconCenter.x, iconCenter.y); + mLauncher.sendPointer(MotionEvent.ACTION_DOWN, iconCenter); final UiObject2 deepShortcutsContainer = mLauncher.waitForLauncherObject( "deep_shortcuts_container"); + mLauncher.sendPointer(MotionEvent.ACTION_UP, iconCenter); return new AppIconMenu(mLauncher, deepShortcutsContainer); } } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 49bd73a17..444f3bd64 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -21,10 +21,13 @@ import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING import android.app.ActivityManager; import android.app.Instrumentation; import android.app.UiAutomation; +import android.graphics.Point; import android.os.Bundle; import android.os.Parcelable; +import android.os.SystemClock; import android.provider.Settings; import android.util.Log; +import android.view.MotionEvent; import android.view.Surface; import android.view.accessibility.AccessibilityEvent; @@ -403,11 +406,6 @@ public final class LauncherInstrumentation { return mDevice; } - void longTap(int x, int y) { - mDevice.drag(x, y, x, y, 0); - } - - void swipe(int startX, int startY, int endX, int endY) { executeAndWaitForEvent( () -> mDevice.swipe(startX, startY, endX, endY, 60), @@ -419,4 +417,11 @@ public final class LauncherInstrumentation { void waitForIdle() { mDevice.waitForIdle(); } + + void sendPointer(int action, Point point) { + final MotionEvent event = MotionEvent.obtain(SystemClock.uptimeMillis(), + SystemClock.uptimeMillis(), action, point.x, point.y, 0); + mInstrumentation.sendPointerSync(event); + event.recycle(); + } }
\ No newline at end of file |