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

Commit 766cd2b4 authored by Alex Chau's avatar Alex Chau
Browse files

Remove unnecessary GridDisplayOption_defaultSplitDisplayLayoutId attribute

- Can use deviceCategory to make grid specific to splitDisplay instead
- Update TwoPanelWorkspaceTest for new workspace items

Fix: 233736588
Test: Clear launcher and check the default
Test: TwoPanelWorkspaceTest
Change-Id: I6ad3a2d866d847af281e10b802edbd4bcc892c39
parent 7b467add
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -176,7 +176,6 @@

        <attr name="dbFile" format="string" />
        <attr name="defaultLayoutId" format="reference" />
        <attr name="defaultSplitDisplayLayoutId" format="reference" />
        <attr name="demoModeLayoutId" format="reference" />
        <attr name="isScalable" format="boolean" />
        <attr name="devicePaddingId" format="reference" />
+2 −4
Original line number Diff line number Diff line
@@ -777,10 +777,8 @@ public class InvariantDeviceProfile {
                    R.styleable.GridDisplayOption_numSearchContainerColumns, numColumns);

            dbFile = a.getString(R.styleable.GridDisplayOption_dbFile);
            defaultLayoutId = a.getResourceId(deviceType == TYPE_MULTI_DISPLAY && a.hasValue(
                    R.styleable.GridDisplayOption_defaultSplitDisplayLayoutId)
                    ? R.styleable.GridDisplayOption_defaultSplitDisplayLayoutId
                    : R.styleable.GridDisplayOption_defaultLayoutId, 0);
            defaultLayoutId = a.getResourceId(
                    R.styleable.GridDisplayOption_defaultLayoutId, 0);
            demoModeLayoutId = a.getResourceId(
                    R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);

+74 −61
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

import android.view.View;

import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;

@@ -55,11 +57,15 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        assumeTrue(mLauncher.isTwoPanels());

        // Removing the Gmail widget so there are space in the right panel to run the test.
        Workspace workspace = mLauncher.getWorkspace();
        workspace.deleteWidget(workspace.tryGetWidget("Gmail", DEFAULT_UI_TIMEOUT));

        // Pre verifying the screens
        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Maps");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "Photos", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
        });
    }

@@ -72,8 +78,8 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1);
            assertItemsOnPage(launcher, 0, "Maps", "Play Store");
            assertItemsOnPage(launcher, 1, "Chrome");
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "Photos", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather", "Chrome");
        });
    }

@@ -86,39 +92,39 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        workspace.flingBackward();

        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 3);

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertItemsOnPage(launcher, 2, "Chrome");
            assertItemsOnPage(launcher, 3, "Maps");
            assertItemsOnPage(launcher, 3, "Photos");
        });

        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 3);

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertItemsOnPage(launcher, 2, "Chrome");
            assertPageEmpty(launcher, 3);
            assertPageEmpty(launcher, 4);
            assertItemsOnPage(launcher, 5, "Maps");
            assertItemsOnPage(launcher, 5, "Photos");
        });

        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), -1);

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertItemsOnPage(launcher, 2, "Chrome");
            assertItemsOnPage(launcher, 3, "Maps");
            assertItemsOnPage(launcher, 3, "Photos");
        });

        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), -1);

        workspace.flingForward();

@@ -126,8 +132,8 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1);
            assertItemsOnPage(launcher, 0, "Chrome", "Play Store");
            assertItemsOnPage(launcher, 1, "Maps");
            assertItemsOnPage(launcher, 0, "Chrome", "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather", "Photos");
        });
    }

@@ -136,13 +142,13 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
    public void testDragIconToPage2() {
        Workspace workspace = mLauncher.getWorkspace();

        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 2);

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 2, "Maps");
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertItemsOnPage(launcher, 2, "Photos");
            assertPageEmpty(launcher, 3);
        });
    }
@@ -156,8 +162,8 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3);
            assertItemsOnPage(launcher, 0, "Play Store", "Maps");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "Photos", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertPageEmpty(launcher, 2);
            assertItemsOnPage(launcher, 3, "Phone");
        });
@@ -172,16 +178,16 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        workspace.flingBackward();

        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 5);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 5);

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertItemsOnPage(launcher, 2, "Messages");
            assertPageEmpty(launcher, 3);
            assertPageEmpty(launcher, 4);
            assertItemsOnPage(launcher, 5, "Maps");
            assertItemsOnPage(launcher, 5, "Photos");
        });

        workspace.flingBackward();
@@ -190,10 +196,10 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 4, 5, 6, 7);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertPageEmpty(launcher, 4);
            assertItemsOnPage(launcher, 5, "Maps");
            assertItemsOnPage(launcher, 5, "Photos");
            assertItemsOnPage(launcher, 6, "Messages");
            assertPageEmpty(launcher, 7);
        });
@@ -202,10 +208,10 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 4, 5);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertItemsOnPage(launcher, 1, "Messages");
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather", "Messages");
            assertPageEmpty(launcher, 4);
            assertItemsOnPage(launcher, 5, "Maps");
            assertItemsOnPage(launcher, 5, "Photos");
        });
    }

@@ -214,23 +220,23 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
    public void testEmptyPageDoesNotGetRemovedIfPagePairIsNotEmpty() {
        Workspace workspace = mLauncher.getWorkspace();

        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 3);
        workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 0);

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertItemsOnPage(launcher, 2, "Chrome");
            assertItemsOnPage(launcher, 3, "Maps");
            assertItemsOnPage(launcher, 3, "Photos");
        });

        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), -1);

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertItemsOnPage(launcher, 1, "Maps");
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather", "Photos");
            assertItemsOnPage(launcher, 2, "Chrome");
            assertPageEmpty(launcher, 3);
        });
@@ -242,8 +248,8 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertItemsOnPage(launcher, 1, "Maps");
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather", "Photos");
            assertPageEmpty(launcher, 2);
            assertItemsOnPage(launcher, 3, "Chrome");
        });
@@ -259,8 +265,8 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3);
            assertItemsOnPage(launcher, 0, "Maps");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 0, "Gmail", "Photos", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertItemsOnPage(launcher, 2, "Play Store");
            assertItemsOnPage(launcher, 3, "Chrome");
        });
@@ -271,8 +277,8 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1);
            assertItemsOnPage(launcher, 0, "Play Store", "Maps");
            assertItemsOnPage(launcher, 1, "Chrome");
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "Photos", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather", "Chrome");
        });
    }

@@ -281,27 +287,27 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
    public void testMiddleEmptyPagesGetRemoved() {
        Workspace workspace = mLauncher.getWorkspace();

        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 2);
        workspace.dragIcon(workspace.getHotseatAppIcon("Messages"), 3);

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 2, "Maps");
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertItemsOnPage(launcher, 2, "Photos");
            assertPageEmpty(launcher, 3);
            assertPageEmpty(launcher, 4);
            assertItemsOnPage(launcher, 5, "Messages");
        });

        workspace.flingBackward();
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
        workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 2);

        executeOnLauncher(launcher -> {
            assertPagesExist(launcher, 0, 1, 4, 5);
            assertItemsOnPage(launcher, 0, "Play Store");
            assertPageEmpty(launcher, 1);
            assertItemsOnPage(launcher, 4, "Maps");
            assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
            assertItemsOnPage(launcher, 1, "Weather");
            assertItemsOnPage(launcher, 4, "Photos");
            assertItemsOnPage(launcher, 5, "Messages");
        });
    }
@@ -329,14 +335,21 @@ public class TwoPanelWorkspaceTest extends AbstractLauncherUiTest {
        CellLayout page = launcher.getWorkspace().getScreenWithId(pageId);
        int itemCount = page.getShortcutsAndWidgets().getChildCount();
        for (int i = 0; i < itemCount; i++) {
            ItemInfo itemInfo = (ItemInfo) page.getShortcutsAndWidgets().getChildAt(i).getTag();
            CharSequence title = null;
            View child = page.getShortcutsAndWidgets().getChildAt(i);
            ItemInfo itemInfo = (ItemInfo) child.getTag();
            if (itemInfo != null) {
                assertTrue("There was an extra item on page " + pageId + ": " + itemInfo.title,
                        itemTitleSet.remove(itemInfo.title));
                title = itemInfo.title;
            }
            if (title == null) {
                title = child.getContentDescription();
            }
            if (title != null) {
                assertTrue("There was an extra item on page " + pageId + ": " + title,
                        itemTitleSet.remove(title));
            }
        }
        assertTrue("Could NOT find some of the items on page " + pageId + ": "
                        + itemTitleSet.stream().collect(Collectors.joining(",")),
                itemTitleSet.isEmpty());
                        + String.join(",", itemTitleSet), itemTitleSet.isEmpty());
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
 */
public final class Widget extends Launchable implements WorkspaceDragSource {

    private static final Pattern LONG_CLICK_EVENT = Pattern.compile("Widgets.onLongClick");
    static final Pattern LONG_CLICK_EVENT = Pattern.compile("Widgets.onLongClick");

    Widget(LauncherInstrumentation launcher, UiObject2 icon) {
        super(launcher, icon);
+17 −2
Original line number Diff line number Diff line
@@ -334,14 +334,28 @@ public final class Workspace extends Home {
     * @return validated workspace after the existing appIcon being deleted.
     */
    public Workspace deleteAppIcon(HomeAppIcon homeAppIcon) {
        return deleteLaunchable(homeAppIcon, LONG_CLICK_EVENT);
    }

    /**
     * Delete the widget from the workspace.
     *
     * @param widget to be deleted.
     * @return validated workspace after the existing widget being deleted.
     */
    public Workspace deleteWidget(Widget widget) {
        return deleteLaunchable(widget, Widget.LONG_CLICK_EVENT);
    }

    private Workspace deleteLaunchable(Launchable launchable, Pattern longClickEvent) {
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
             LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                     "removing app icon from workspace")) {
            dragIconToWorkspace(
                    mLauncher,
                    homeAppIcon,
                    launchable,
                    () -> getDropPointFromDropTargetBar(mLauncher, DELETE_TARGET_TEXT_ID),
                    () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT),
                    () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, longClickEvent),
                    /* expectDropEvents= */ null);

            try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
@@ -351,6 +365,7 @@ public final class Workspace extends Home {
        }
    }


    /**
     * Uninstall the appIcon by dragging it to the 'uninstall' drop point of the drop_target_bar.
     *