Search in sources :

Example 76 with WidgetsListContentEntry

use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by ArrowOS.

the class WidgetsListContentEntryTest method unsortedWidgets_sameLabels_differentSize_shouldSortWidgetItems.

@Test
public void unsortedWidgets_sameLabels_differentSize_shouldSortWidgetItems() {
    // GIVEN a list of widgets in unsorted order.
    // Cat 3x3
    WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
    3, /* spanY= */
    3);
    // Cat 1x2
    WidgetItem widgetItem2 = createWidgetItem(mWidget1, /* spanX= */
    1, /* spanY= */
    2);
    // Cat 2x2
    WidgetItem widgetItem3 = createWidgetItem(mWidget1, /* spanX= */
    2, /* spanY= */
    2);
    // WHEN creates a WidgetsListRowEntry with the unsorted widgets.
    WidgetsListContentEntry widgetsListRowEntry = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
    "T", List.of(widgetItem1, widgetItem2, widgetItem3));
    // THEN the widgets list is sorted by their gird sizes in an ascending order:
    // [1x2, 2x2, 3x3].
    assertThat(widgetsListRowEntry.mWidgets).containsExactly(widgetItem2, widgetItem3, widgetItem1).inOrder();
    assertThat(widgetsListRowEntry.mTitleSectionName).isEqualTo("T");
    assertThat(widgetsListRowEntry.mPkgItem).isEqualTo(mPackageItemInfo1);
}
Also used : WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetItem(com.android.launcher3.model.WidgetItem) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 77 with WidgetsListContentEntry

use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by ArrowOS.

the class WidgetsListContentEntryTest method unsortedWidgets_hodgepodge_shouldSortWidgetItems.

@Test
public void unsortedWidgets_hodgepodge_shouldSortWidgetItems() {
    // GIVEN a list of widgets in unsorted order.
    // Cat 3x3
    WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
    3, /* spanY= */
    3);
    // Cat 1x2
    WidgetItem widgetItem2 = createWidgetItem(mWidget1, /* spanX= */
    1, /* spanY= */
    2);
    // Dog 2x2
    WidgetItem widgetItem3 = createWidgetItem(mWidget2, /* spanX= */
    2, /* spanY= */
    2);
    // Bird 2x2
    WidgetItem widgetItem4 = createWidgetItem(mWidget3, /* spanX= */
    2, /* spanY= */
    2);
    // WHEN creates a WidgetsListRowEntry with the unsorted widgets.
    WidgetsListContentEntry widgetsListRowEntry = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
    "T", List.of(widgetItem1, widgetItem2, widgetItem3, widgetItem4));
    // THEN the widgets list is first sorted by labels alphabetically. Then, for widgets with
    // same labels, they are sorted by their gird sizes in an ascending order:
    // [Bird 2x2, Cat 1x2, Cat 3x3, Dog 2x2]
    assertThat(widgetsListRowEntry.mWidgets).containsExactly(widgetItem4, widgetItem2, widgetItem1, widgetItem3).inOrder();
    assertThat(widgetsListRowEntry.mTitleSectionName).isEqualTo("T");
    assertThat(widgetsListRowEntry.mPkgItem).isEqualTo(mPackageItemInfo1);
}
Also used : WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetItem(com.android.launcher3.model.WidgetItem) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 78 with WidgetsListContentEntry

use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by ArrowOS.

the class WidgetsDiffReporterTest method createWidgetsContentEntry.

private WidgetsListContentEntry createWidgetsContentEntry(String packageName, String appName, int numOfWidgets) {
    List<WidgetItem> widgetItems = generateWidgetItems(packageName, numOfWidgets);
    PackageItemInfo pInfo = createPackageItemInfo(packageName, appName, widgetItems.get(0).user);
    return new WidgetsListContentEntry(pInfo, /* titleSectionName= */
    "", widgetItems);
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetItem(com.android.launcher3.model.WidgetItem)

Example 79 with WidgetsListContentEntry

use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsDiffReporterTest method createWidgetsContentEntry.

private WidgetsListContentEntry createWidgetsContentEntry(String packageName, String appName, int numOfWidgets) {
    List<WidgetItem> widgetItems = generateWidgetItems(packageName, numOfWidgets);
    PackageItemInfo pInfo = createPackageItemInfo(packageName, appName, widgetItems.get(0).user);
    return new WidgetsListContentEntry(pInfo, /* titleSectionName= */
    "", widgetItems);
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) WidgetItem(com.android.launcher3.model.WidgetItem)

Example 80 with WidgetsListContentEntry

use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WidgetsListAdapterTest method setWidgets_expandedApp_moreWidgets_shouldNotifyItemChangedWithWidgetItemInfoDiff.

@Test
public void setWidgets_expandedApp_moreWidgets_shouldNotifyItemChangedWithWidgetItemInfoDiff() {
    // GIVEN the adapter was first populated with com.google.test0 & com.google.test1. Each app
    // has one widget.
    ArrayList<WidgetsListBaseEntry> allEntries = generateSampleMap(2);
    mAdapter.setWidgets(allEntries);
    // GIVEN test com.google.test1 is expanded.
    // Visible entries in the adapter are:
    // [com.google.test0, com.google.test1, com.google.test1 content]
    mAdapter.onHeaderClicked(/* showWidgets= */
    true, new PackageUserKey(TEST_PACKAGE_PLACEHOLDER + 1, mUserHandle));
    Mockito.reset(mListener);
    // WHEN the adapter is updated with the same list of apps but com.google.test1 has 2 widgets
    // now.
    WidgetsListContentEntry testPackage1ContentEntry = (WidgetsListContentEntry) allEntries.get(3);
    WidgetItem widgetItem = testPackage1ContentEntry.mWidgets.get(0);
    WidgetsListContentEntry newTestPackage1ContentEntry = new WidgetsListContentEntry(testPackage1ContentEntry.mPkgItem, testPackage1ContentEntry.mTitleSectionName, List.of(widgetItem, widgetItem));
    allEntries.set(3, newTestPackage1ContentEntry);
    mAdapter.setWidgets(allEntries);
    // THEN the onItemRangeChanged is invoked for "com.google.test1 content" at index 2.
    verify(mListener).onItemRangeChanged(eq(3), eq(1), isNull());
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) PackageUserKey(com.android.launcher3.util.PackageUserKey) WidgetItem(com.android.launcher3.model.WidgetItem) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Aggregations

WidgetsListContentEntry (com.android.launcher3.widget.model.WidgetsListContentEntry)101 WidgetItem (com.android.launcher3.model.WidgetItem)77 Test (org.junit.Test)55 SmallTest (androidx.test.filters.SmallTest)44 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)36 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)30 ArrayList (java.util.ArrayList)30 WidgetsListHeaderEntry (com.android.launcher3.widget.model.WidgetsListHeaderEntry)20 List (java.util.List)20 PackageUserKey (com.android.launcher3.util.PackageUserKey)15 Map (java.util.Map)15 Collectors (java.util.stream.Collectors)15 TableRow (android.widget.TableRow)11 Log (android.util.Log)10 NonNull (androidx.annotation.NonNull)10 Nullable (androidx.annotation.Nullable)10 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)10 WidgetsListSearchHeaderEntry (com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry)10 Arrays (java.util.Arrays)10 HashMap (java.util.HashMap)10