Merge "Unifying constant app names used in Tests" into main

This commit is contained in:
Sebastián Franco
2023-10-13 18:28:38 +00:00
committed by Android (Google) Code Review
13 changed files with 139 additions and 106 deletions
@@ -37,7 +37,6 @@ import java.util.List;
public class AbstractTaplTestsTaskbar extends AbstractQuickStepTest {
protected static final String TEST_APP_NAME = "LauncherTestApp";
protected static final String TEST_APP_PACKAGE =
getInstrumentation().getContext().getPackageName();
protected static final String CALCULATOR_APP_PACKAGE =
@@ -64,7 +64,6 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class TaplTestsQuickstep extends AbstractQuickStepTest {
private static final String APP_NAME = "LauncherTestApp";
private static final String CALCULATOR_APP_PACKAGE =
resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);
private static final String READ_DEVICE_CONFIG_PERMISSION =
@@ -15,6 +15,7 @@
*/
package com.android.quickstep;
import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.android.quickstep.TaplTestsTaskbar.TaskbarMode.PERSISTENT;
import static com.android.quickstep.TaplTestsTaskbar.TaskbarMode.TRANSIENT;
@@ -16,6 +16,7 @@
package com.android.quickstep;
import static com.android.launcher3.config.FeatureFlags.ENABLE_CURSOR_HOVER_STATES;
import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
import androidx.test.filters.LargeTest;
+1
View File
@@ -53,6 +53,7 @@ filegroup {
"src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java",
"src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java",
"src/com/android/launcher3/util/LauncherLayoutBuilder.java",
"src/com/android/launcher3/util/TestConstants.java",
"src/com/android/launcher3/util/TestUtil.java",
"src/com/android/launcher3/util/Wait.java",
"src/com/android/launcher3/util/WidgetUtils.java",
@@ -15,7 +15,7 @@
*/
package com.android.launcher3.appiconmenu;
import static com.android.launcher3.ui.TaplTestsLauncher3.APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
import static org.junit.Assert.assertEquals;
@@ -64,7 +64,7 @@ public class TaplAppIconMenuTest extends AbstractLauncherUiTest {
final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
final AppIconMenu menu = allApps.getAppIcon(APP_NAME).openDeepShortcutMenu();
final AppIconMenu menu = allApps.getAppIcon(TEST_APP_NAME).openDeepShortcutMenu();
executeOnLauncher(
launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
@@ -89,9 +89,9 @@ public class TaplAppIconMenuTest extends AbstractLauncherUiTest {
final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
allApps.getAppIcon(TEST_APP_NAME).dragToWorkspace(false, false);
final AppIconMenu menu = mLauncher.getWorkspace().getWorkspaceAppIcon(
APP_NAME).openDeepShortcutMenu();
TEST_APP_NAME).openDeepShortcutMenu();
executeOnLauncher(
launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
@@ -15,10 +15,10 @@
*/
package com.android.launcher3.dragging;
import static com.android.launcher3.ui.TaplTestsLauncher3.APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.GMAIL_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.MAPS_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.STORE_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.GMAIL_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.STORE_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
import static org.junit.Assert.assertEquals;
@@ -118,7 +118,7 @@ public class TaplDragTest extends AbstractLauncherUiTest {
allApps.freeze();
try {
final HomeAppIconMenuItem menuItem = allApps
.getAppIcon(APP_NAME)
.getAppIcon(TEST_APP_NAME)
.openDeepShortcutMenu()
.getMenuItem(0);
final String actualShortcutName = menuItem.getText();
@@ -147,7 +147,7 @@ public class TaplDragTest extends AbstractLauncherUiTest {
final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
allApps.getAppIcon(APP_NAME)
allApps.getAppIcon(TEST_APP_NAME)
.openDeepShortcutMenu()
.getMenuItem(0)
.dragToWorkspace(target.x, target.y);
@@ -194,8 +194,8 @@ public class TaplDragTest extends AbstractLauncherUiTest {
final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName());
allApps.getAppIcon(TEST_APP_NAME).dragToWorkspace(false, false);
mLauncher.getWorkspace().getWorkspaceAppIcon(TEST_APP_NAME).launch(getAppPackageName());
} finally {
allApps.unfreeze();
}
@@ -222,7 +222,7 @@ public class TaplDragTest extends AbstractLauncherUiTest {
final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
allApps.getAppIcon(APP_NAME).dragToWorkspace(target.x, target.y);
allApps.getAppIcon(TEST_APP_NAME).dragToWorkspace(target.x, target.y);
} finally {
allApps.unfreeze();
}
@@ -235,7 +235,7 @@ public class TaplDragTest extends AbstractLauncherUiTest {
}
// test to move a shortcut to other cell.
final HomeAppIcon launcherTestAppIcon = createShortcutInCenterIfNotExist(APP_NAME);
final HomeAppIcon launcherTestAppIcon = createShortcutInCenterIfNotExist(TEST_APP_NAME);
for (Point target : targets) {
startTime = SystemClock.uptimeMillis();
launcherTestAppIcon.dragToWorkspace(target.x, target.y);
@@ -16,11 +16,12 @@
package com.android.launcher3.dragging;
import static com.android.launcher3.testing.shared.TestProtocol.ICON_MISSING;
import static com.android.launcher3.ui.TaplTestsLauncher3.APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.DUMMY_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.MAPS_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.STORE_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
import static com.android.launcher3.util.TestConstants.AppNames.DUMMY_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.GMAIL_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.STORE_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.google.common.truth.Truth.assertThat;
@@ -62,7 +63,7 @@ public class TaplUninstallRemove extends AbstractLauncherUiTest {
@Test
@PortraitLandscape
public void testDeleteFromWorkspace() {
for (String appName : new String[]{"Gmail", "Play Store", APP_NAME}) {
for (String appName : new String[]{GMAIL_APP_NAME, STORE_APP_NAME, TEST_APP_NAME}) {
final HomeAppIcon homeAppIcon = createShortcutInCenterIfNotExist(appName);
Workspace workspace = mLauncher.getWorkspace().deleteAppIcon(homeAppIcon);
workspace.verifyWorkspaceAppIconIsGone(
@@ -174,9 +175,9 @@ public class TaplUninstallRemove extends AbstractLauncherUiTest {
mLauncher.getWorkspace()
.deleteAppIcon(mLauncher.getWorkspace().getHotseatAppIcon(0))
.switchToAllApps()
.getAppIcon(APP_NAME)
.getAppIcon(TEST_APP_NAME)
.dragToHotseat(0);
mLauncher.getWorkspace().deleteAppIcon(
mLauncher.getWorkspace().getHotseatAppIcon(APP_NAME));
mLauncher.getWorkspace().getHotseatAppIcon(TEST_APP_NAME));
}
}
@@ -23,7 +23,6 @@ import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.LauncherState;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import org.junit.Before;
import org.junit.Test;
@@ -32,11 +31,6 @@ import org.junit.runner.RunWith;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
public static final String APP_NAME = "LauncherTestApp";
public static final String DUMMY_APP_NAME = "Aardwolf";
public static final String MAPS_APP_NAME = "Maps";
public static final String STORE_APP_NAME = "Play Store";
public static final String GMAIL_APP_NAME = "Gmail";
@Before
public void setUp() throws Exception {
@@ -16,6 +16,7 @@
package com.android.launcher3.ui.workspace;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
import static com.android.launcher3.util.TestConstants.AppNames.CHROME_APP_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -85,7 +86,8 @@ public class TaplWorkspaceTest extends AbstractLauncherUiTest {
isWorkspaceScrollable(launcher)));
assertEquals("Initial workspace doesn't have the correct page", workspace.pagesPerScreen(),
workspace.getPageCount());
workspace.verifyWorkspaceAppIconIsGone("Chrome app was found on empty workspace", "Chrome");
workspace.verifyWorkspaceAppIconIsGone("Chrome app was found on empty workspace",
CHROME_APP_NAME);
workspace.ensureWorkspaceIsScrollable();
executeOnLauncher(
@@ -96,7 +98,7 @@ public class TaplWorkspaceTest extends AbstractLauncherUiTest {
launcher -> assertTrue("ensureScrollable didn't make workspace scrollable",
isWorkspaceScrollable(launcher)));
assertNotNull("ensureScrollable didn't add Chrome app",
workspace.getWorkspaceAppIcon("Chrome"));
workspace.getWorkspaceAppIcon(CHROME_APP_NAME));
// Test flinging workspace.
workspace.flingBackward();
@@ -112,7 +114,7 @@ public class TaplWorkspaceTest extends AbstractLauncherUiTest {
assertTrue("Launcher internal state is not Home", isInState(() -> LauncherState.NORMAL));
// Test starting a workspace app.
final HomeAppIcon app = workspace.getWorkspaceAppIcon("Chrome");
final HomeAppIcon app = workspace.getWorkspaceAppIcon(CHROME_APP_NAME);
assertNotNull("No Chrome app in workspace", app);
}
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.ui.workspace;
import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -51,7 +53,6 @@ import java.util.Queue;
public class ThemeIconsTest extends AbstractLauncherUiTest {
private static final String APP_NAME = "IconThemedActivity";
private static final String SHORTCUT_APP_NAME = "LauncherTestApp";
private static final String SHORTCUT_NAME = "Shortcut 1";
@Test
@@ -81,7 +82,7 @@ public class ThemeIconsTest extends AbstractLauncherUiTest {
allApps.freeze();
try {
HomeAppIcon icon = allApps.getAppIcon(SHORTCUT_APP_NAME);
HomeAppIcon icon = allApps.getAppIcon(TEST_APP_NAME);
HomeAppIconMenuItem shortcutItem =
(HomeAppIconMenuItem) icon.openDeepShortcutMenu().getMenuItem(SHORTCUT_NAME);
shortcutItem.dragToWorkspace(false, false);
@@ -118,7 +119,7 @@ public class ThemeIconsTest extends AbstractLauncherUiTest {
allApps.freeze();
try {
HomeAppIcon icon = allApps.getAppIcon(SHORTCUT_APP_NAME);
HomeAppIcon icon = allApps.getAppIcon(TEST_APP_NAME);
HomeAppIconMenuItem shortcutItem =
(HomeAppIconMenuItem) icon.openDeepShortcutMenu().getMenuItem(SHORTCUT_NAME);
shortcutItem.dragToWorkspace(false, false);
@@ -16,6 +16,11 @@
package com.android.launcher3.ui.workspace;
import static com.android.launcher3.util.TestConstants.AppNames.CHROME_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.MESSAGES_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.STORE_APP_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -76,7 +81,7 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
executeOnLauncher(launcher -> {
launcher.enableHotseatEdu(false);
assertPagesExist(launcher, 0, 1);
assertItemsOnPage(launcher, 0, "Play Store", "Maps");
assertItemsOnPage(launcher, 0, STORE_APP_NAME, MAPS_APP_NAME);
assertPageEmpty(launcher, 1);
});
}
@@ -94,12 +99,12 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
public void testDragIconToRightPanel() {
Workspace workspace = mLauncher.getWorkspace();
workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 1);
workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
assertItemsOnPage(launcher, 0, "Maps", "Play Store");
assertItemsOnPage(launcher, 1, "Chrome");
assertItemsOnPage(launcher, 0, MAPS_APP_NAME, STORE_APP_NAME);
assertItemsOnPage(launcher, 1, CHROME_APP_NAME);
});
}
@@ -108,52 +113,52 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
public void testSinglePageDragIconWhenMultiplePageScrollingIsPossible() {
Workspace workspace = mLauncher.getWorkspace();
workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 2);
workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 2);
workspace.flingBackward();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Chrome");
assertItemsOnPage(launcher, 3, "Maps");
assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
assertItemsOnPage(launcher, 3, MAPS_APP_NAME);
});
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Chrome");
assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
assertPageEmpty(launcher, 3);
assertPageEmpty(launcher, 4);
assertItemsOnPage(launcher, 5, "Maps");
assertItemsOnPage(launcher, 5, MAPS_APP_NAME);
});
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), -1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Chrome");
assertItemsOnPage(launcher, 3, "Maps");
assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
assertItemsOnPage(launcher, 3, MAPS_APP_NAME);
});
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), -1);
workspace.flingForward();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Chrome"), -2);
workspace.dragIcon(workspace.getWorkspaceAppIcon(CHROME_APP_NAME), -2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
assertItemsOnPage(launcher, 0, "Chrome", "Play Store");
assertItemsOnPage(launcher, 1, "Maps");
assertItemsOnPage(launcher, 0, CHROME_APP_NAME, STORE_APP_NAME);
assertItemsOnPage(launcher, 1, MAPS_APP_NAME);
});
}
@@ -162,13 +167,13 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
public void testDragIconToPage2() {
Workspace workspace = mLauncher.getWorkspace();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Maps");
assertItemsOnPage(launcher, 2, MAPS_APP_NAME);
assertPageEmpty(launcher, 3);
});
}
@@ -179,14 +184,14 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
Workspace workspace = mLauncher.getWorkspace();
// b/299522368 sometimes the phone app is not present in the hotseat.
workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 3);
workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
assertItemsOnPage(launcher, 0, "Play Store", "Maps");
assertItemsOnPage(launcher, 0, STORE_APP_NAME, MAPS_APP_NAME);
assertPageEmpty(launcher, 1);
assertPageEmpty(launcher, 2);
assertItemsOnPage(launcher, 3, "Chrome");
assertItemsOnPage(launcher, 3, CHROME_APP_NAME);
});
}
@@ -195,44 +200,44 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
public void testMultiplePageDragIcon() {
Workspace workspace = mLauncher.getWorkspace();
workspace.dragIcon(workspace.getHotseatAppIcon("Messages"), 2);
workspace.dragIcon(workspace.getHotseatAppIcon(MESSAGES_APP_NAME), 2);
workspace.flingBackward();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 5);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 5);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Messages");
assertItemsOnPage(launcher, 2, MESSAGES_APP_NAME);
assertPageEmpty(launcher, 3);
assertPageEmpty(launcher, 4);
assertItemsOnPage(launcher, 5, "Maps");
assertItemsOnPage(launcher, 5, MAPS_APP_NAME);
});
workspace.flingBackward();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Messages"), 4);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MESSAGES_APP_NAME), 4);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 4, 5, 6, 7);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertPageEmpty(launcher, 4);
assertItemsOnPage(launcher, 5, "Maps");
assertItemsOnPage(launcher, 6, "Messages");
assertItemsOnPage(launcher, 5, MAPS_APP_NAME);
assertItemsOnPage(launcher, 6, MESSAGES_APP_NAME);
assertPageEmpty(launcher, 7);
});
workspace.dragIcon(workspace.getWorkspaceAppIcon("Messages"), -3);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MESSAGES_APP_NAME), -3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 4, 5);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 1, "Messages");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertItemsOnPage(launcher, 1, MESSAGES_APP_NAME);
assertPageEmpty(launcher, 4);
assertItemsOnPage(launcher, 5, "Maps");
assertItemsOnPage(launcher, 5, MAPS_APP_NAME);
});
}
@@ -241,38 +246,38 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
public void testEmptyPageDoesNotGetRemovedIfPagePairIsNotEmpty() {
Workspace workspace = mLauncher.getWorkspace();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 0);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 3);
workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 0);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Chrome");
assertItemsOnPage(launcher, 3, "Maps");
assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
assertItemsOnPage(launcher, 3, MAPS_APP_NAME);
});
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), -1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 1, "Maps");
assertItemsOnPage(launcher, 2, "Chrome");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertItemsOnPage(launcher, 1, MAPS_APP_NAME);
assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
assertPageEmpty(launcher, 3);
});
// Move Chrome to the right panel as well, to make sure pages are not deleted whichever
// page is the empty one
workspace.flingForward();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Chrome"), 1);
workspace.dragIcon(workspace.getWorkspaceAppIcon(CHROME_APP_NAME), 1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 1, "Maps");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertItemsOnPage(launcher, 1, MAPS_APP_NAME);
assertPageEmpty(launcher, 2);
assertItemsOnPage(launcher, 3, "Chrome");
assertItemsOnPage(launcher, 3, CHROME_APP_NAME);
});
}
@@ -281,25 +286,25 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
public void testEmptyPagesGetRemovedIfBothPagesAreEmpty() {
Workspace workspace = mLauncher.getWorkspace();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Play Store"), 2);
workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 1);
workspace.dragIcon(workspace.getWorkspaceAppIcon(STORE_APP_NAME), 2);
workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
assertItemsOnPage(launcher, 0, "Maps");
assertItemsOnPage(launcher, 0, MAPS_APP_NAME);
assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Play Store");
assertItemsOnPage(launcher, 3, "Chrome");
assertItemsOnPage(launcher, 2, STORE_APP_NAME);
assertItemsOnPage(launcher, 3, CHROME_APP_NAME);
});
workspace.dragIcon(workspace.getWorkspaceAppIcon("Chrome"), -1);
workspace.dragIcon(workspace.getWorkspaceAppIcon(CHROME_APP_NAME), -1);
workspace.flingForward();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Play Store"), -2);
workspace.dragIcon(workspace.getWorkspaceAppIcon(STORE_APP_NAME), -2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
assertItemsOnPage(launcher, 0, "Play Store", "Maps");
assertItemsOnPage(launcher, 1, "Chrome");
assertItemsOnPage(launcher, 0, STORE_APP_NAME, MAPS_APP_NAME);
assertItemsOnPage(launcher, 1, CHROME_APP_NAME);
});
}
@@ -308,28 +313,28 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
public void testMiddleEmptyPagesGetRemoved() {
Workspace workspace = mLauncher.getWorkspace();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
workspace.dragIcon(workspace.getHotseatAppIcon("Messages"), 3);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 2);
workspace.dragIcon(workspace.getHotseatAppIcon(MESSAGES_APP_NAME), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Maps");
assertItemsOnPage(launcher, 2, MAPS_APP_NAME);
assertPageEmpty(launcher, 3);
assertPageEmpty(launcher, 4);
assertItemsOnPage(launcher, 5, "Messages");
assertItemsOnPage(launcher, 5, MESSAGES_APP_NAME);
});
workspace.flingBackward();
workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 4, 5);
assertItemsOnPage(launcher, 0, "Play Store");
assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 4, "Maps");
assertItemsOnPage(launcher, 5, "Messages");
assertItemsOnPage(launcher, 4, MAPS_APP_NAME);
assertItemsOnPage(launcher, 5, MESSAGES_APP_NAME);
});
}
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.util;
public class TestConstants {
public static class AppNames {
public static final String TEST_APP_NAME = "LauncherTestApp";
public static final String DUMMY_APP_NAME = "Aardwolf";
public static final String MAPS_APP_NAME = "Maps";
public static final String STORE_APP_NAME = "Play Store";
public static final String GMAIL_APP_NAME = "Gmail";
public static final String CHROME_APP_NAME = "Chrome";
public static final String MESSAGES_APP_NAME = "Messages";
}
}