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
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index f270b10..4d45710 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -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" />
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 1f97535..9ceef40 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -777,10 +777,8 @@
                     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);
 
diff --git a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
index f646b50..b7ad7f2 100644
--- a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
@@ -21,6 +21,8 @@
 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 @@
 
         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 @@
 
         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 @@
 
         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 @@
 
         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 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 @@
 
         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 @@
 
         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 @@
 
         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 @@
 
         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 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 @@
 
         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 @@
 
         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 @@
 
         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 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 @@
         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());
     }
 }
diff --git a/tests/tapl/com/android/launcher3/tapl/Widget.java b/tests/tapl/com/android/launcher3/tapl/Widget.java
index 29eb46c..046308b 100644
--- a/tests/tapl/com/android/launcher3/tapl/Widget.java
+++ b/tests/tapl/com/android/launcher3/tapl/Widget.java
@@ -32,7 +32,7 @@
  */
 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);
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 425a90a..7ed5788 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -334,14 +334,28 @@
      * @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 @@
         }
     }
 
+
     /**
      * Uninstall the appIcon by dragging it to the 'uninstall' drop point of the drop_target_bar.
      *