Loading tests/tapl/com/android/launcher3/tapl/Launchable.java +2 −4 Original line number Diff line number Diff line Loading @@ -65,11 +65,9 @@ public abstract class Launchable { + mLauncher.getVisibleBounds(mObject)); if (launcherStopsAfterLaunch()) { mLauncher.executeAndWaitForLauncherEvent( mLauncher.executeAndWaitForLauncherStop( () -> mLauncher.clickLauncherObject(mObject), event -> TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE .equals(event.getClassName().toString()), () -> "Launcher activity didn't stop", "clicking the launchable"); "clicking the launchable"); } else { mLauncher.clickLauncherObject(mObject); } Loading tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +8 −0 Original line number Diff line number Diff line Loading @@ -973,6 +973,14 @@ public final class LauncherInstrumentation { } } void executeAndWaitForLauncherStop(Runnable command, String actionName) { executeAndWaitForLauncherEvent( () -> command.run(), event -> TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE .equals(event.getClassName().toString()), () -> "Launcher activity didn't stop", actionName); } /** * Get the resource ID of visible floating view. */ Loading tests/tapl/com/android/launcher3/tapl/OverviewTask.java +1 −4 Original line number Diff line number Diff line Loading @@ -201,11 +201,8 @@ public final class OverviewTask { public LaunchedAppState open() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { verifyActiveContainer(); mLauncher.executeAndWaitForLauncherEvent( mLauncher.executeAndWaitForLauncherStop( () -> mLauncher.clickLauncherObject(mTask), event -> TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE .equals(event.getClassName().toString()), () -> "Launcher activity didn't stop", "clicking an overview task"); if (mOverview.getContainerType() == LauncherInstrumentation.ContainerType.SPLIT_SCREEN_SELECT) { Loading tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java +1 −6 Original line number Diff line number Diff line Loading @@ -20,8 +20,6 @@ import androidx.annotation.NonNull; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; import com.android.launcher3.testing.shared.TestProtocol; /** Represents the menu of an overview task. */ public class OverviewTaskMenu { Loading Loading @@ -61,12 +59,9 @@ public class OverviewTaskMenu { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "before tapping the app info menu item")) { mLauncher.executeAndWaitForLauncherEvent( mLauncher.executeAndWaitForLauncherStop( () -> mLauncher.clickLauncherObject( mLauncher.findObjectInContainer(mMenu, By.text("App info"))), event -> TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE .equals(event.getClassName().toString()), () -> "Launcher activity didn't stop", "tapped app info menu item"); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( Loading tests/tapl/com/android/launcher3/tapl/Workspace.java +38 −19 Original line number Diff line number Diff line Loading @@ -335,7 +335,8 @@ public final class Workspace extends Home { homeAppIcon, () -> new Point(0, 0), () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT), null); null, /* startsActivity = */ false); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "dragged the app across workspace")) { Loading @@ -359,7 +360,8 @@ public final class Workspace extends Home { homeAppIcon, () -> getDropPointFromDropTargetBar(mLauncher, DELETE_TARGET_TEXT_ID), () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT), /* expectDropEvents= */ null); /* expectDropEvents= */ null, /* startsActivity = */ false); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "dragged the app to the drop bar")) { Loading @@ -368,7 +370,6 @@ public final class Workspace extends Home { } } /** * Uninstall the appIcon by dragging it to the 'uninstall' drop point of the drop_target_bar. * Loading @@ -390,7 +391,8 @@ public final class Workspace extends Home { homeAppIcon, () -> getDropPointFromDropTargetBar(launcher, UNINSTALL_TARGET_TEXT_ID), expectLongClickEvents, /* expectDropEvents= */null); /* expectDropEvents= */null, /* startsActivity = */ false); launcher.waitUntilLauncherObjectGone(DROP_BAR_RES_ID); Loading Loading @@ -464,14 +466,25 @@ public final class Workspace extends Home { o -> new FolderIcon(mLauncher, o)).collect(Collectors.toList()); } private static void sendUp(LauncherInstrumentation launcher, Point dest, long downTime) { launcher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); } private static void dropDraggedIcon(LauncherInstrumentation launcher, Point dest, long downTime, @Nullable Runnable expectedEvents) { @Nullable Runnable expectedEvents, boolean startsActivity) { if (startsActivity) { launcher.executeAndWaitForLauncherStop( () -> sendUp(launcher, dest, downTime), "sending UP event"); } else { launcher.runToState( () -> launcher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER), () -> sendUp(launcher, dest, downTime), NORMAL_STATE_ORDINAL, "sending UP event"); } if (expectedEvents != null) { expectedEvents.run(); } Loading @@ -488,7 +501,8 @@ public final class Workspace extends Home { LauncherInstrumentation.EVENT_START); } dragIconToWorkspace( launcher, launchable, dest, expectLongClickEvents, expectDropEvents); launcher, launchable, dest, expectLongClickEvents, expectDropEvents, startsActivity); } static void dragIconToWorkspaceCellPosition(LauncherInstrumentation launcher, Loading Loading @@ -517,7 +531,8 @@ public final class Workspace extends Home { destSupplier, /* isDecelerating= */ false, () -> launcher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT), /* expectDropEvents= */ null); /* expectDropEvents= */ null, /* startsActivity = */ false); } static void dragIconToWorkspace( Loading @@ -525,9 +540,10 @@ public final class Workspace extends Home { Launchable launchable, Supplier<Point> dest, Runnable expectLongClickEvents, @Nullable Runnable expectDropEvents) { @Nullable Runnable expectDropEvents, boolean startsActivity) { dragIconToWorkspace(launcher, launchable, dest, /* isDecelerating */ true, expectLongClickEvents, expectDropEvents); expectLongClickEvents, expectDropEvents, startsActivity); } static void dragIconToWorkspace( Loading @@ -536,7 +552,8 @@ public final class Workspace extends Home { Supplier<Point> dest, boolean isDecelerating, Runnable expectLongClickEvents, @Nullable Runnable expectDropEvents) { @Nullable Runnable expectDropEvents, boolean startsActivity) { try (LauncherInstrumentation.Closable ignored = launcher.addContextLayer( "want to drag icon to workspace")) { final long downTime = SystemClock.uptimeMillis(); Loading Loading @@ -568,7 +585,7 @@ public final class Workspace extends Home { launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating, downTime, SystemClock.uptimeMillis(), false, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents, startsActivity); } } Loading Loading @@ -601,7 +618,8 @@ public final class Workspace extends Home { launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating, downTime, SystemClock.uptimeMillis(), false, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents, /* startsActivity = */ false); } } Loading Loading @@ -667,7 +685,8 @@ public final class Workspace extends Home { launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, true, downTime, SystemClock.uptimeMillis(), false, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents, /* startsActivity = */ false); } /** Loading Loading
tests/tapl/com/android/launcher3/tapl/Launchable.java +2 −4 Original line number Diff line number Diff line Loading @@ -65,11 +65,9 @@ public abstract class Launchable { + mLauncher.getVisibleBounds(mObject)); if (launcherStopsAfterLaunch()) { mLauncher.executeAndWaitForLauncherEvent( mLauncher.executeAndWaitForLauncherStop( () -> mLauncher.clickLauncherObject(mObject), event -> TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE .equals(event.getClassName().toString()), () -> "Launcher activity didn't stop", "clicking the launchable"); "clicking the launchable"); } else { mLauncher.clickLauncherObject(mObject); } Loading
tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +8 −0 Original line number Diff line number Diff line Loading @@ -973,6 +973,14 @@ public final class LauncherInstrumentation { } } void executeAndWaitForLauncherStop(Runnable command, String actionName) { executeAndWaitForLauncherEvent( () -> command.run(), event -> TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE .equals(event.getClassName().toString()), () -> "Launcher activity didn't stop", actionName); } /** * Get the resource ID of visible floating view. */ Loading
tests/tapl/com/android/launcher3/tapl/OverviewTask.java +1 −4 Original line number Diff line number Diff line Loading @@ -201,11 +201,8 @@ public final class OverviewTask { public LaunchedAppState open() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { verifyActiveContainer(); mLauncher.executeAndWaitForLauncherEvent( mLauncher.executeAndWaitForLauncherStop( () -> mLauncher.clickLauncherObject(mTask), event -> TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE .equals(event.getClassName().toString()), () -> "Launcher activity didn't stop", "clicking an overview task"); if (mOverview.getContainerType() == LauncherInstrumentation.ContainerType.SPLIT_SCREEN_SELECT) { Loading
tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java +1 −6 Original line number Diff line number Diff line Loading @@ -20,8 +20,6 @@ import androidx.annotation.NonNull; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; import com.android.launcher3.testing.shared.TestProtocol; /** Represents the menu of an overview task. */ public class OverviewTaskMenu { Loading Loading @@ -61,12 +59,9 @@ public class OverviewTaskMenu { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "before tapping the app info menu item")) { mLauncher.executeAndWaitForLauncherEvent( mLauncher.executeAndWaitForLauncherStop( () -> mLauncher.clickLauncherObject( mLauncher.findObjectInContainer(mMenu, By.text("App info"))), event -> TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE .equals(event.getClassName().toString()), () -> "Launcher activity didn't stop", "tapped app info menu item"); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( Loading
tests/tapl/com/android/launcher3/tapl/Workspace.java +38 −19 Original line number Diff line number Diff line Loading @@ -335,7 +335,8 @@ public final class Workspace extends Home { homeAppIcon, () -> new Point(0, 0), () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT), null); null, /* startsActivity = */ false); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "dragged the app across workspace")) { Loading @@ -359,7 +360,8 @@ public final class Workspace extends Home { homeAppIcon, () -> getDropPointFromDropTargetBar(mLauncher, DELETE_TARGET_TEXT_ID), () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT), /* expectDropEvents= */ null); /* expectDropEvents= */ null, /* startsActivity = */ false); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "dragged the app to the drop bar")) { Loading @@ -368,7 +370,6 @@ public final class Workspace extends Home { } } /** * Uninstall the appIcon by dragging it to the 'uninstall' drop point of the drop_target_bar. * Loading @@ -390,7 +391,8 @@ public final class Workspace extends Home { homeAppIcon, () -> getDropPointFromDropTargetBar(launcher, UNINSTALL_TARGET_TEXT_ID), expectLongClickEvents, /* expectDropEvents= */null); /* expectDropEvents= */null, /* startsActivity = */ false); launcher.waitUntilLauncherObjectGone(DROP_BAR_RES_ID); Loading Loading @@ -464,14 +466,25 @@ public final class Workspace extends Home { o -> new FolderIcon(mLauncher, o)).collect(Collectors.toList()); } private static void sendUp(LauncherInstrumentation launcher, Point dest, long downTime) { launcher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); } private static void dropDraggedIcon(LauncherInstrumentation launcher, Point dest, long downTime, @Nullable Runnable expectedEvents) { @Nullable Runnable expectedEvents, boolean startsActivity) { if (startsActivity) { launcher.executeAndWaitForLauncherStop( () -> sendUp(launcher, dest, downTime), "sending UP event"); } else { launcher.runToState( () -> launcher.sendPointer( downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER), () -> sendUp(launcher, dest, downTime), NORMAL_STATE_ORDINAL, "sending UP event"); } if (expectedEvents != null) { expectedEvents.run(); } Loading @@ -488,7 +501,8 @@ public final class Workspace extends Home { LauncherInstrumentation.EVENT_START); } dragIconToWorkspace( launcher, launchable, dest, expectLongClickEvents, expectDropEvents); launcher, launchable, dest, expectLongClickEvents, expectDropEvents, startsActivity); } static void dragIconToWorkspaceCellPosition(LauncherInstrumentation launcher, Loading Loading @@ -517,7 +531,8 @@ public final class Workspace extends Home { destSupplier, /* isDecelerating= */ false, () -> launcher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT), /* expectDropEvents= */ null); /* expectDropEvents= */ null, /* startsActivity = */ false); } static void dragIconToWorkspace( Loading @@ -525,9 +540,10 @@ public final class Workspace extends Home { Launchable launchable, Supplier<Point> dest, Runnable expectLongClickEvents, @Nullable Runnable expectDropEvents) { @Nullable Runnable expectDropEvents, boolean startsActivity) { dragIconToWorkspace(launcher, launchable, dest, /* isDecelerating */ true, expectLongClickEvents, expectDropEvents); expectLongClickEvents, expectDropEvents, startsActivity); } static void dragIconToWorkspace( Loading @@ -536,7 +552,8 @@ public final class Workspace extends Home { Supplier<Point> dest, boolean isDecelerating, Runnable expectLongClickEvents, @Nullable Runnable expectDropEvents) { @Nullable Runnable expectDropEvents, boolean startsActivity) { try (LauncherInstrumentation.Closable ignored = launcher.addContextLayer( "want to drag icon to workspace")) { final long downTime = SystemClock.uptimeMillis(); Loading Loading @@ -568,7 +585,7 @@ public final class Workspace extends Home { launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating, downTime, SystemClock.uptimeMillis(), false, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents, startsActivity); } } Loading Loading @@ -601,7 +618,8 @@ public final class Workspace extends Home { launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating, downTime, SystemClock.uptimeMillis(), false, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents, /* startsActivity = */ false); } } Loading Loading @@ -667,7 +685,8 @@ public final class Workspace extends Home { launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, true, downTime, SystemClock.uptimeMillis(), false, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents, /* startsActivity = */ false); } /** Loading