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

Commit a2c32f79 authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

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
parent dacb0765
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

/**
@@ -96,7 +97,6 @@ public class TaplUninstallRemove extends AbstractLauncherUiTest {

    /**
     * Makes sure you can uninstall an app from the Workspace.
     * @throws Exception
     */
    @Test
    @PortraitLandscape
@@ -114,7 +114,6 @@ public class TaplUninstallRemove extends AbstractLauncherUiTest {

    /**
     * Makes sure you can uninstall an app from AllApps.
     * @throws Exception
     */
    @Test
    @PortraitLandscape
@@ -143,15 +142,23 @@ public class TaplUninstallRemove extends AbstractLauncherUiTest {
            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(
+15 −7
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.launcher3.config.FeatureFlags.BooleanFlag;
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,6 +134,12 @@ public class TestUtil {
     */
    public static Point[] getCornersAndCenterPositions(LauncherInstrumentation launcher) {
        final Point dimensions = launcher.getWorkspace().getIconGridDimensions();
        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),
@@ -141,6 +148,7 @@ public class TestUtil {
                    new Point(dimensions.x / 2, dimensions.y / 2)
            };
        }
    }

    /**
     * Utility class to override a boolean flag during test. Note that the returned SafeCloseable