Speeding up testDragShortcutToMultipleWorkspaceCells in presubmit

On foldable, presubmit P90 is 38 min, and the requirement is to fit in
30 min.

testDragShortcutToMultipleWorkspaceCells takes around 3 min.
Making it enumerate less combinations in presubmit.

Bug: 295939967
Test: presubmit
Flag: N/A
Change-Id: Ic47223b3800fe502ed152488a2940f41c0edfb88
diff --git a/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java b/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java
index a690543..27bea1f 100644
--- a/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java
+++ b/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java
@@ -42,6 +42,7 @@
 import org.junit.Test;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Map;
 
 /**
@@ -96,7 +97,6 @@
 
     /**
      * Makes sure you can uninstall an app from the Workspace.
-     * @throws Exception
      */
     @Test
     @PortraitLandscape
@@ -114,7 +114,6 @@
 
     /**
      * Makes sure you can uninstall an app from AllApps.
-     * @throws Exception
      */
     @Test
     @PortraitLandscape
@@ -143,15 +142,23 @@
             sb.append(p).append(", ");
         }
         Log.d(ICON_MISSING, "allGridPositions: " + sb);
-        createShortcutIfNotExist(STORE_APP_NAME, gridPositions[0]);
-        createShortcutIfNotExist(MAPS_APP_NAME, gridPositions[1]);
-        installDummyAppAndWaitForUIUpdate();
         try {
-            createShortcutIfNotExist(DUMMY_APP_NAME, gridPositions[2]);
+            installDummyAppAndWaitForUIUpdate();
+
+            final String[] appNameCandidates = {DUMMY_APP_NAME, MAPS_APP_NAME, STORE_APP_NAME};
+
+            // List of test apps trimmed down to the length of grid positions.
+            final String[] appNames = Arrays.copyOfRange(
+                    appNameCandidates,
+                    0, Math.min(gridPositions.length, appNameCandidates.length));
+
+            for (int i = 0; i < appNames.length; ++i) {
+                createShortcutIfNotExist(appNames[i], gridPositions[i]);
+            }
+
             Map<String, Point> initialPositions =
                     mLauncher.getWorkspace().getWorkspaceIconsPositions();
-            assertThat(initialPositions.keySet())
-                    .containsAtLeast(DUMMY_APP_NAME, MAPS_APP_NAME, STORE_APP_NAME);
+            assertThat(initialPositions.keySet()).containsAtLeastElementsIn(appNames);
 
             mLauncher.getWorkspace().getWorkspaceAppIcon(DUMMY_APP_NAME).uninstall();
             mLauncher.getWorkspace().verifyWorkspaceAppIconIsGone(
diff --git a/tests/src/com/android/launcher3/util/TestUtil.java b/tests/src/com/android/launcher3/util/TestUtil.java
index 957bf95..2786f02 100644
--- a/tests/src/com/android/launcher3/util/TestUtil.java
+++ b/tests/src/com/android/launcher3/util/TestUtil.java
@@ -49,6 +49,7 @@
 import com.android.launcher3.config.FeatureFlags.IntFlag;
 import com.android.launcher3.tapl.LauncherInstrumentation;
 import com.android.launcher3.tapl.Workspace;
+import com.android.launcher3.util.rule.TestStabilityRule;
 
 import org.junit.Assert;
 
@@ -133,13 +134,20 @@
      */
     public static Point[] getCornersAndCenterPositions(LauncherInstrumentation launcher) {
         final Point dimensions = launcher.getWorkspace().getIconGridDimensions();
-        return new Point[]{
-                new Point(0, 1),
-                new Point(0, dimensions.y - 2),
-                new Point(dimensions.x - 1, 1),
-                new Point(dimensions.x - 1, dimensions.y - 2),
-                new Point(dimensions.x / 2, dimensions.y / 2)
-        };
+        if (TestStabilityRule.isPresubmit()) {
+            // Return only center in presubmit to fit under the presubmit SLO.
+            return new Point[]{
+                    new Point(dimensions.x / 2, dimensions.y / 2)
+            };
+        } else {
+            return new Point[]{
+                    new Point(0, 1),
+                    new Point(0, dimensions.y - 2),
+                    new Point(dimensions.x - 1, 1),
+                    new Point(dimensions.x - 1, dimensions.y - 2),
+                    new Point(dimensions.x / 2, dimensions.y / 2)
+            };
+        }
     }
 
     /**