Loading tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.graphics.Point; import android.os.Debug; import android.os.Process; import android.os.RemoteException; Loading @@ -55,6 +56,8 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.Utilities; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.tapl.HomeAllApps; import com.android.launcher3.tapl.HomeAppIcon; import com.android.launcher3.tapl.LauncherInstrumentation; import com.android.launcher3.tapl.LauncherInstrumentation.ContainerType; import com.android.launcher3.tapl.TestHelpers; Loading Loading @@ -602,4 +605,26 @@ public abstract class AbstractLauncherUiTest { protected void onLauncherActivityClose(Launcher launcher) { } protected HomeAppIcon createShortcutInCenterIfNotExist(String name) { Point dimension = mLauncher.getWorkspace().getIconGridDimensions(); return createShortcutIfNotExist(name, dimension.x / 2, dimension.y / 2); } protected HomeAppIcon createShortcutIfNotExist(String name, int cellX, int cellY) { HomeAppIcon homeAppIcon = mLauncher.getWorkspace().tryGetWorkspaceAppIcon(name); if (homeAppIcon == null) { HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); allApps.freeze(); try { allApps.getAppIcon(name).dragToWorkspace(cellX, cellY); } finally { allApps.unfreeze(); } homeAppIcon = mLauncher.getWorkspace().getWorkspaceAppIcon(name); } return homeAppIcon; } } tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +7 −23 Original line number Diff line number Diff line Loading @@ -365,27 +365,11 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } } private HomeAppIcon createShortcutIfNotExist(String name) { HomeAppIcon homeAppIcon = mLauncher.getWorkspace().tryGetWorkspaceAppIcon(name); if (homeAppIcon == null) { HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); allApps.freeze(); try { allApps.getAppIcon(name).dragToWorkspace(false, false); } finally { allApps.unfreeze(); } homeAppIcon = mLauncher.getWorkspace().getWorkspaceAppIcon(name); } return homeAppIcon; } @Ignore("b/205014516") @Test @PortraitLandscape public void testDragToFolder() throws Exception { final HomeAppIcon playStoreIcon = createShortcutIfNotExist("Play Store"); final HomeAppIcon gmailIcon = createShortcutIfNotExist("Gmail"); final HomeAppIcon playStoreIcon = createShortcutIfNotExist("Play Store", 0, 1); final HomeAppIcon gmailIcon = createShortcutIfNotExist("Gmail", 1, 1); FolderIcon folderIcon = gmailIcon.dragToIcon(playStoreIcon); Loading @@ -399,7 +383,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { assertNull("Play Store should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Play Store")); final HomeAppIcon youTubeIcon = createShortcutIfNotExist("YouTube"); final HomeAppIcon youTubeIcon = createShortcutInCenterIfNotExist("YouTube"); folderIcon = youTubeIcon.dragToIcon(folderIcon); folder = folderIcon.open(); Loading Loading @@ -434,7 +418,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { public void testDeleteFromWorkspace() throws Exception { // test delete both built-in apps and user-installed app from workspace for (String appName : new String[]{"Gmail", "Play Store", APP_NAME}) { final HomeAppIcon homeAppIcon = createShortcutIfNotExist(appName); final HomeAppIcon homeAppIcon = createShortcutInCenterIfNotExist(appName); Workspace workspace = mLauncher.getWorkspace().deleteAppIcon(homeAppIcon); assertNull(appName + " app was found after being deleted from workspace", workspace.tryGetWorkspaceAppIcon(appName)); Loading @@ -458,7 +442,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { TestUtil.installDummyApp(); try { verifyAppUninstalledFromAllApps( createShortcutIfNotExist(DUMMY_APP_NAME).uninstall(), DUMMY_APP_NAME); createShortcutInCenterIfNotExist(DUMMY_APP_NAME).uninstall(), DUMMY_APP_NAME); } finally { TestUtil.uninstallDummyApp(); } Loading Loading @@ -509,7 +493,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } // test to move a shortcut to other cell. final HomeAppIcon launcherTestAppIcon = createShortcutIfNotExist(APP_NAME); final HomeAppIcon launcherTestAppIcon = createShortcutInCenterIfNotExist(APP_NAME); for (Point target : targets) { launcherTestAppIcon.dragToWorkspace(target.x, target.y); } Loading tests/tapl/com/android/launcher3/tapl/HomeAppIcon.java +1 −1 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ public abstract class HomeAppIcon extends AppIcon implements FolderDragTarget, W String.format("want to drag the icon to cell(%d, %d)", cellX, cellY)) ) { final Supplier<Point> dest = () -> Workspace.getCellCenter(mLauncher, cellX, cellY); Workspace.dragIconToWorkspace(mLauncher, this, dest, true, getLongPressIndicator(), Workspace.dragIconToWorkspace(mLauncher, this, dest, getLongPressIndicator(), () -> addExpectedEventsForLongClick(), null); try (LauncherInstrumentation.Closable ignore = mLauncher.addContextLayer("dragged")) { WorkspaceAppIcon appIcon = Loading tests/tapl/com/android/launcher3/tapl/Launchable.java +1 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ abstract class Launchable { mLauncher.waitForLauncherObject(longPressIndicator); LauncherInstrumentation.log("movePointerForStartDrag: indicator"); mLauncher.movePointer(iconCenter, dragStartCenter, DEFAULT_DRAG_STEPS, false, downTime, true, LauncherInstrumentation.GestureScope.INSIDE); downTime, downTime, true, LauncherInstrumentation.GestureScope.INSIDE); } private int getStartDragThreshold() { Loading tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +8 −6 Original line number Diff line number Diff line Loading @@ -1107,11 +1107,13 @@ public final class LauncherInstrumentation { } } @NonNull UiObject2 waitForObjectInContainer(UiObject2 container, BySelector selector) { @NonNull UiObject2 waitForObjectInContainer(UiObject2 container, BySelector selector) { return waitForObjectsInContainer(container, selector).get(0); } @NonNull List<UiObject2> waitForObjectsInContainer( @NonNull List<UiObject2> waitForObjectsInContainer( UiObject2 container, BySelector selector) { try { final List<UiObject2> objects = container.wait( Loading Loading @@ -1406,13 +1408,13 @@ public final class LauncherInstrumentation { final Point end = new Point(endX, endY); sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start, gestureScope); final long endTime = movePointer( start, end, steps, false, downTime, slowDown, gestureScope); start, end, steps, false, downTime, downTime, slowDown, gestureScope); sendPointer(downTime, endTime, MotionEvent.ACTION_UP, end, gestureScope); } long movePointer(Point start, Point end, int steps, boolean isDecelerating, long downTime, boolean slowDown, GestureScope gestureScope) { long endTime = movePointer(downTime, downTime, steps * GESTURE_STEP_MS, long movePointer(Point start, Point end, int steps, boolean isDecelerating, long downTime, long startTime, boolean slowDown, GestureScope gestureScope) { long endTime = movePointer(downTime, startTime, steps * GESTURE_STEP_MS, isDecelerating, start, end, gestureScope); if (slowDown) { endTime = movePointer(downTime, endTime + GESTURE_STEP_MS, 5 * GESTURE_STEP_MS, end, Loading Loading
tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.graphics.Point; import android.os.Debug; import android.os.Process; import android.os.RemoteException; Loading @@ -55,6 +56,8 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.Utilities; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.tapl.HomeAllApps; import com.android.launcher3.tapl.HomeAppIcon; import com.android.launcher3.tapl.LauncherInstrumentation; import com.android.launcher3.tapl.LauncherInstrumentation.ContainerType; import com.android.launcher3.tapl.TestHelpers; Loading Loading @@ -602,4 +605,26 @@ public abstract class AbstractLauncherUiTest { protected void onLauncherActivityClose(Launcher launcher) { } protected HomeAppIcon createShortcutInCenterIfNotExist(String name) { Point dimension = mLauncher.getWorkspace().getIconGridDimensions(); return createShortcutIfNotExist(name, dimension.x / 2, dimension.y / 2); } protected HomeAppIcon createShortcutIfNotExist(String name, int cellX, int cellY) { HomeAppIcon homeAppIcon = mLauncher.getWorkspace().tryGetWorkspaceAppIcon(name); if (homeAppIcon == null) { HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); allApps.freeze(); try { allApps.getAppIcon(name).dragToWorkspace(cellX, cellY); } finally { allApps.unfreeze(); } homeAppIcon = mLauncher.getWorkspace().getWorkspaceAppIcon(name); } return homeAppIcon; } }
tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +7 −23 Original line number Diff line number Diff line Loading @@ -365,27 +365,11 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } } private HomeAppIcon createShortcutIfNotExist(String name) { HomeAppIcon homeAppIcon = mLauncher.getWorkspace().tryGetWorkspaceAppIcon(name); if (homeAppIcon == null) { HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); allApps.freeze(); try { allApps.getAppIcon(name).dragToWorkspace(false, false); } finally { allApps.unfreeze(); } homeAppIcon = mLauncher.getWorkspace().getWorkspaceAppIcon(name); } return homeAppIcon; } @Ignore("b/205014516") @Test @PortraitLandscape public void testDragToFolder() throws Exception { final HomeAppIcon playStoreIcon = createShortcutIfNotExist("Play Store"); final HomeAppIcon gmailIcon = createShortcutIfNotExist("Gmail"); final HomeAppIcon playStoreIcon = createShortcutIfNotExist("Play Store", 0, 1); final HomeAppIcon gmailIcon = createShortcutIfNotExist("Gmail", 1, 1); FolderIcon folderIcon = gmailIcon.dragToIcon(playStoreIcon); Loading @@ -399,7 +383,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { assertNull("Play Store should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Play Store")); final HomeAppIcon youTubeIcon = createShortcutIfNotExist("YouTube"); final HomeAppIcon youTubeIcon = createShortcutInCenterIfNotExist("YouTube"); folderIcon = youTubeIcon.dragToIcon(folderIcon); folder = folderIcon.open(); Loading Loading @@ -434,7 +418,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { public void testDeleteFromWorkspace() throws Exception { // test delete both built-in apps and user-installed app from workspace for (String appName : new String[]{"Gmail", "Play Store", APP_NAME}) { final HomeAppIcon homeAppIcon = createShortcutIfNotExist(appName); final HomeAppIcon homeAppIcon = createShortcutInCenterIfNotExist(appName); Workspace workspace = mLauncher.getWorkspace().deleteAppIcon(homeAppIcon); assertNull(appName + " app was found after being deleted from workspace", workspace.tryGetWorkspaceAppIcon(appName)); Loading @@ -458,7 +442,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { TestUtil.installDummyApp(); try { verifyAppUninstalledFromAllApps( createShortcutIfNotExist(DUMMY_APP_NAME).uninstall(), DUMMY_APP_NAME); createShortcutInCenterIfNotExist(DUMMY_APP_NAME).uninstall(), DUMMY_APP_NAME); } finally { TestUtil.uninstallDummyApp(); } Loading Loading @@ -509,7 +493,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } // test to move a shortcut to other cell. final HomeAppIcon launcherTestAppIcon = createShortcutIfNotExist(APP_NAME); final HomeAppIcon launcherTestAppIcon = createShortcutInCenterIfNotExist(APP_NAME); for (Point target : targets) { launcherTestAppIcon.dragToWorkspace(target.x, target.y); } Loading
tests/tapl/com/android/launcher3/tapl/HomeAppIcon.java +1 −1 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ public abstract class HomeAppIcon extends AppIcon implements FolderDragTarget, W String.format("want to drag the icon to cell(%d, %d)", cellX, cellY)) ) { final Supplier<Point> dest = () -> Workspace.getCellCenter(mLauncher, cellX, cellY); Workspace.dragIconToWorkspace(mLauncher, this, dest, true, getLongPressIndicator(), Workspace.dragIconToWorkspace(mLauncher, this, dest, getLongPressIndicator(), () -> addExpectedEventsForLongClick(), null); try (LauncherInstrumentation.Closable ignore = mLauncher.addContextLayer("dragged")) { WorkspaceAppIcon appIcon = Loading
tests/tapl/com/android/launcher3/tapl/Launchable.java +1 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ abstract class Launchable { mLauncher.waitForLauncherObject(longPressIndicator); LauncherInstrumentation.log("movePointerForStartDrag: indicator"); mLauncher.movePointer(iconCenter, dragStartCenter, DEFAULT_DRAG_STEPS, false, downTime, true, LauncherInstrumentation.GestureScope.INSIDE); downTime, downTime, true, LauncherInstrumentation.GestureScope.INSIDE); } private int getStartDragThreshold() { Loading
tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +8 −6 Original line number Diff line number Diff line Loading @@ -1107,11 +1107,13 @@ public final class LauncherInstrumentation { } } @NonNull UiObject2 waitForObjectInContainer(UiObject2 container, BySelector selector) { @NonNull UiObject2 waitForObjectInContainer(UiObject2 container, BySelector selector) { return waitForObjectsInContainer(container, selector).get(0); } @NonNull List<UiObject2> waitForObjectsInContainer( @NonNull List<UiObject2> waitForObjectsInContainer( UiObject2 container, BySelector selector) { try { final List<UiObject2> objects = container.wait( Loading Loading @@ -1406,13 +1408,13 @@ public final class LauncherInstrumentation { final Point end = new Point(endX, endY); sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start, gestureScope); final long endTime = movePointer( start, end, steps, false, downTime, slowDown, gestureScope); start, end, steps, false, downTime, downTime, slowDown, gestureScope); sendPointer(downTime, endTime, MotionEvent.ACTION_UP, end, gestureScope); } long movePointer(Point start, Point end, int steps, boolean isDecelerating, long downTime, boolean slowDown, GestureScope gestureScope) { long endTime = movePointer(downTime, downTime, steps * GESTURE_STEP_MS, long movePointer(Point start, Point end, int steps, boolean isDecelerating, long downTime, long startTime, boolean slowDown, GestureScope gestureScope) { long endTime = movePointer(downTime, startTime, steps * GESTURE_STEP_MS, isDecelerating, start, end, gestureScope); if (slowDown) { endTime = movePointer(downTime, endTime + GESTURE_STEP_MS, 5 * GESTURE_STEP_MS, end, Loading