Use correct indicator of a long-press success in tests
It's the presence of the context menu if we long-press a shortcut, and
the drop target bar if we press a menu item.
Change-Id: Ic02462fa766e23b74f41b8a73fefd519aea08407
(cherry picked from commit e77fc83222)
This commit is contained in:
@@ -50,4 +50,9 @@ public final class AppIcon extends Launchable {
|
||||
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, iconCenter);
|
||||
return new AppIconMenu(mLauncher, deepShortcutsContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLongPressIndicator() {
|
||||
return "deep_shortcuts_container";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,9 @@ public class AppIconMenuItem extends Launchable {
|
||||
public String getText() {
|
||||
return mObject.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLongPressIndicator() {
|
||||
return "drop_target_bar";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import androidx.test.uiautomator.Until;
|
||||
/**
|
||||
* Ancestor for AppIcon and AppMenuItem.
|
||||
*/
|
||||
class Launchable {
|
||||
abstract class Launchable {
|
||||
protected final LauncherInstrumentation mLauncher;
|
||||
|
||||
protected final UiObject2 mObject;
|
||||
@@ -76,10 +76,13 @@ class Launchable {
|
||||
Workspace.dragIconToWorkspace(
|
||||
mLauncher,
|
||||
this,
|
||||
new Point(device.getDisplayWidth() / 2, device.getDisplayHeight() / 2));
|
||||
new Point(device.getDisplayWidth() / 2, device.getDisplayHeight() / 2),
|
||||
getLongPressIndicator());
|
||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"dragged launchable to workspace")) {
|
||||
return new Workspace(mLauncher);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getLongPressIndicator();
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public final class Workspace extends Home {
|
||||
mLauncher,
|
||||
getHotseatAppIcon("Chrome"),
|
||||
new Point(mLauncher.getDevice().getDisplayWidth(),
|
||||
workspace.getVisibleBounds().centerY()));
|
||||
workspace.getVisibleBounds().centerY()), "deep_shortcuts_container");
|
||||
verifyActiveContainer();
|
||||
}
|
||||
assertTrue("Home screen workspace didn't become scrollable",
|
||||
@@ -136,12 +136,13 @@ public final class Workspace extends Home {
|
||||
}
|
||||
|
||||
static void dragIconToWorkspace(
|
||||
LauncherInstrumentation launcher, Launchable launchable, Point dest) {
|
||||
LauncherInstrumentation launcher, Launchable launchable, Point dest,
|
||||
String longPressIndicator) {
|
||||
LauncherInstrumentation.log("dragIconToWorkspace: begin");
|
||||
final Point launchableCenter = launchable.getObject().getVisibleCenter();
|
||||
final long downTime = SystemClock.uptimeMillis();
|
||||
launcher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, launchableCenter);
|
||||
launcher.waitForLauncherObject("deep_shortcuts_container");
|
||||
launcher.waitForLauncherObject(longPressIndicator);
|
||||
launcher.movePointer(downTime, DRAG_DURACTION, launchableCenter, dest);
|
||||
launcher.sendPointer(
|
||||
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest);
|
||||
|
||||
Reference in New Issue
Block a user