Loading tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +18 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ package com.android.launcher3.ui; import static androidx.test.InstrumentationRegistry.getInstrumentation; import android.platform.test.annotations.IwTest; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; Loading @@ -31,6 +29,7 @@ import static org.junit.Assume.assumeTrue; import android.content.Intent; import android.graphics.Point; import android.platform.test.annotations.IwTest; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -435,6 +434,23 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); } @Test @PortraitLandscape public void testDragAndCancelAppIcon() { final HomeAppIcon homeAppIcon = createShortcutInCenterIfNotExist(GMAIL_APP_NAME); Point positionBeforeDrag = mLauncher.getWorkspace().getWorkspaceIconsPositions().get(GMAIL_APP_NAME); assertNotNull("App not found in Workspace before dragging.", positionBeforeDrag); mLauncher.getWorkspace().dragAndCancelAppIcon(homeAppIcon); Point positionAfterDrag = mLauncher.getWorkspace().getWorkspaceIconsPositions().get(GMAIL_APP_NAME); assertNotNull("App not found in Workspace after dragging.", positionAfterDrag); assertEquals("App not returned to same position in Workspace after drag & cancel", positionBeforeDrag, positionAfterDrag); } @Test @PortraitLandscape public void testDeleteFromWorkspace() throws Exception { Loading tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +25 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,15 @@ public final class LauncherInstrumentation { OUTSIDE_WITH_KEYCODE, } /** * Represents a point in the code at which a callback can run. */ public enum CALLBACK_RUN_POINT { CALLBACK_HOLD_BEFORE_DROP } private Consumer<CALLBACK_RUN_POINT> mCallbackAtRunPoint = null; // Base class for launcher containers. abstract static class VisibleContainer { protected final LauncherInstrumentation mLauncher; Loading Loading @@ -1956,4 +1965,20 @@ public final class LauncherInstrumentation { LauncherInstrumentation.GestureScope.INSIDE); } } /** * Sets the consumer to run callbacks at all run-points. */ public void setRunPointCallback(Consumer<CALLBACK_RUN_POINT> callback) { mCallbackAtRunPoint = callback; } /** * Runs the callback at the specified point if it exists. */ void runCallbackIfActive(CALLBACK_RUN_POINT runPoint) { if (mCallbackAtRunPoint != null) { mCallbackAtRunPoint.accept(runPoint); } } } tests/tapl/com/android/launcher3/tapl/Workspace.java +27 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.launcher3.tapl; import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_SCROLLED; import static com.android.launcher3.tapl.LauncherInstrumentation.CALLBACK_RUN_POINT.CALLBACK_HOLD_BEFORE_DROP; import static com.android.launcher3.testing.shared.TestProtocol.ALL_APPS_STATE_ORDINAL; import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL; Loading Loading @@ -301,6 +302,31 @@ public final class Workspace extends Home { targetId).getVisibleCenter(); } /** * Drag the appIcon from the workspace and cancel by dragging icon to corner of screen where no * drop point exists. * * @param homeAppIcon to be dragged. */ @NonNull public Workspace dragAndCancelAppIcon(HomeAppIcon homeAppIcon) { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "dragging app icon across workspace")) { dragIconToWorkspace( mLauncher, homeAppIcon, () -> new Point(0, 0), () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT), null); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "dragged the app across workspace")) { return new Workspace(mLauncher); } } } /** * Delete the appIcon from the workspace. * Loading Loading @@ -493,6 +519,7 @@ public final class Workspace extends Home { launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating, downTime, SystemClock.uptimeMillis(), false, LauncherInstrumentation.GestureScope.INSIDE); launcher.runCallbackIfActive(CALLBACK_HOLD_BEFORE_DROP); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); } } Loading Loading
tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +18 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,6 @@ package com.android.launcher3.ui; import static androidx.test.InstrumentationRegistry.getInstrumentation; import android.platform.test.annotations.IwTest; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; Loading @@ -31,6 +29,7 @@ import static org.junit.Assume.assumeTrue; import android.content.Intent; import android.graphics.Point; import android.platform.test.annotations.IwTest; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -435,6 +434,23 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); } @Test @PortraitLandscape public void testDragAndCancelAppIcon() { final HomeAppIcon homeAppIcon = createShortcutInCenterIfNotExist(GMAIL_APP_NAME); Point positionBeforeDrag = mLauncher.getWorkspace().getWorkspaceIconsPositions().get(GMAIL_APP_NAME); assertNotNull("App not found in Workspace before dragging.", positionBeforeDrag); mLauncher.getWorkspace().dragAndCancelAppIcon(homeAppIcon); Point positionAfterDrag = mLauncher.getWorkspace().getWorkspaceIconsPositions().get(GMAIL_APP_NAME); assertNotNull("App not found in Workspace after dragging.", positionAfterDrag); assertEquals("App not returned to same position in Workspace after drag & cancel", positionBeforeDrag, positionAfterDrag); } @Test @PortraitLandscape public void testDeleteFromWorkspace() throws Exception { Loading
tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +25 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,15 @@ public final class LauncherInstrumentation { OUTSIDE_WITH_KEYCODE, } /** * Represents a point in the code at which a callback can run. */ public enum CALLBACK_RUN_POINT { CALLBACK_HOLD_BEFORE_DROP } private Consumer<CALLBACK_RUN_POINT> mCallbackAtRunPoint = null; // Base class for launcher containers. abstract static class VisibleContainer { protected final LauncherInstrumentation mLauncher; Loading Loading @@ -1956,4 +1965,20 @@ public final class LauncherInstrumentation { LauncherInstrumentation.GestureScope.INSIDE); } } /** * Sets the consumer to run callbacks at all run-points. */ public void setRunPointCallback(Consumer<CALLBACK_RUN_POINT> callback) { mCallbackAtRunPoint = callback; } /** * Runs the callback at the specified point if it exists. */ void runCallbackIfActive(CALLBACK_RUN_POINT runPoint) { if (mCallbackAtRunPoint != null) { mCallbackAtRunPoint.accept(runPoint); } } }
tests/tapl/com/android/launcher3/tapl/Workspace.java +27 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.launcher3.tapl; import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_SCROLLED; import static com.android.launcher3.tapl.LauncherInstrumentation.CALLBACK_RUN_POINT.CALLBACK_HOLD_BEFORE_DROP; import static com.android.launcher3.testing.shared.TestProtocol.ALL_APPS_STATE_ORDINAL; import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL; Loading Loading @@ -301,6 +302,31 @@ public final class Workspace extends Home { targetId).getVisibleCenter(); } /** * Drag the appIcon from the workspace and cancel by dragging icon to corner of screen where no * drop point exists. * * @param homeAppIcon to be dragged. */ @NonNull public Workspace dragAndCancelAppIcon(HomeAppIcon homeAppIcon) { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "dragging app icon across workspace")) { dragIconToWorkspace( mLauncher, homeAppIcon, () -> new Point(0, 0), () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT), null); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "dragged the app across workspace")) { return new Workspace(mLauncher); } } } /** * Delete the appIcon from the workspace. * Loading Loading @@ -493,6 +519,7 @@ public final class Workspace extends Home { launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating, downTime, SystemClock.uptimeMillis(), false, LauncherInstrumentation.GestureScope.INSIDE); launcher.runCallbackIfActive(CALLBACK_HOLD_BEFORE_DROP); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); } } Loading