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

Commit 93513ce3 authored by Vadim Tryshev's avatar Vadim Tryshev Committed by Android (Google) Code Review
Browse files

Merge "Speeding up testDragShortcutToMultipleWorkspaceCells in presubmit" into main

parents 2bccda4d a2c32f79
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import org.junit.Before;
import org.junit.Test;

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

/**
@@ -98,7 +99,6 @@ public class TaplUninstallRemove extends AbstractLauncherUiTest {

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

    /**
     * Makes sure you can uninstall an app from AllApps.
     * @throws Exception
     */
    @Test
    @PortraitLandscape
@@ -145,15 +144,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