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
This commit is contained in:
parent
e0c5f5d0ab
commit
446bf0092e
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue