Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00d19519 authored by Tracy Zhou's avatar Tracy Zhou Committed by Automerger Merge Worker
Browse files

Merge "Add drag icon to folder use case back" into tm-dev am: 517f26ae

parents 24b9ebfd 517f26ae
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import com.android.launcher3.tapl.HomeAppIconMenuItem;
import com.android.launcher3.tapl.Widgets;
import com.android.launcher3.tapl.Workspace;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.rule.ScreenRecordRule;
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
import com.android.launcher3.widget.picker.WidgetsFullSheet;
import com.android.launcher3.widget.picker.WidgetsRecyclerView;
@@ -70,9 +69,6 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
    private static final String STORE_APP_NAME = "Play Store";
    private static final String GMAIL_APP_NAME = "Gmail";

    @Rule
    public ScreenRecordRule mScreenRecordRule = new ScreenRecordRule();

    @Before
    public void setUp() throws Exception {
        super.setUp();
@@ -380,7 +376,6 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {

    @Test
    @PortraitLandscape
    @ScreenRecord
    public void testDragToFolder() {
        // TODO: add the use case to drag an icon to an existing folder. Currently it either fails
        // on tablets or phones due to difference in resolution.
@@ -397,6 +392,15 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
                workspace.tryGetWorkspaceAppIcon(STORE_APP_NAME));
        assertNull(GMAIL_APP_NAME + " should be moved to a folder.",
                workspace.tryGetWorkspaceAppIcon(GMAIL_APP_NAME));

        final HomeAppIcon mapIcon = createShortcutInCenterIfNotExist(MAPS_APP_NAME);
        folderIcon = mapIcon.dragToIcon(folderIcon);
        folder = folderIcon.open();
        folder.getAppIcon(MAPS_APP_NAME);
        workspace = folder.close();

        assertNull(MAPS_APP_NAME + " should be moved to a folder.",
                workspace.tryGetWorkspaceAppIcon(MAPS_APP_NAME));
    }

    @Test
+13 −1
Original line number Diff line number Diff line
@@ -394,6 +394,7 @@ public final class Workspace extends Home {
                launcher,
                launchable,
                destSupplier,
                /* isDecelerating= */ false,
                () -> launcher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT),
                /* expectDropEvents= */ null);
    }
@@ -404,6 +405,17 @@ public final class Workspace extends Home {
            Supplier<Point> dest,
            Runnable expectLongClickEvents,
            @Nullable Runnable expectDropEvents) {
        dragIconToWorkspace(launcher, launchable, dest, /* isDecelerating */ true,
                expectLongClickEvents, expectDropEvents);
    }

    static void dragIconToWorkspace(
            LauncherInstrumentation launcher,
            Launchable launchable,
            Supplier<Point> dest,
            boolean isDecelerating,
            Runnable expectLongClickEvents,
            @Nullable Runnable expectDropEvents) {
        try (LauncherInstrumentation.Closable ignored = launcher.addContextLayer(
                "want to drag icon to workspace")) {
            final long downTime = SystemClock.uptimeMillis();
@@ -430,7 +442,7 @@ public final class Workspace extends Home {

            // targetDest.x is now between 0 and displayX so we found the target page,
            // we just have to put move the icon to the destination and drop it
            launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, true,
            launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating,
                    downTime, SystemClock.uptimeMillis(), false,
                    LauncherInstrumentation.GestureScope.INSIDE);
            dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents);