use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_404Launcher by P-404.
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);
}
use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_404Launcher by P-404.
the class WidgetsDiffReporterTest method headersContentsMix_contentMaxSpanSizeModified_shouldInvokeCorrectCallbacks.
@Test
public void headersContentsMix_contentMaxSpanSizeModified_shouldInvokeCorrectCallbacks() {
// GIVEN the current list has app headers [A, B, E content].
ArrayList<WidgetsListBaseEntry> currentList = new ArrayList<>(List.of(mHeaderA, mHeaderB, mContentE));
// GIVEN the new list has max span size in "E content" modified.
List<WidgetsListBaseEntry> newList = List.of(mHeaderA, mHeaderB, new WidgetsListContentEntry(mContentE.mPkgItem, mContentE.mTitleSectionName, mContentE.mWidgets, mContentE.getMaxSpanSizeInCells() + 1));
// WHEN computing the list difference.
mWidgetsDiffReporter.process(currentList, newList, COMPARATOR);
// THEN notify "E content" has been changed.
verify(mAdapter).notifyItemChanged(/* position= */
2);
// THEN the current list contains all elements from the new list.
assertThat(currentList).containsExactlyElementsIn(newList);
}
use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_404Launcher by P-404.
the class WidgetsListContentEntryTest method equals_entriesWithSameContents_returnTrue.
@Test
public void equals_entriesWithSameContents_returnTrue() {
WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
2, /* spanY= */
3);
WidgetsListContentEntry widgetsListRowEntry1 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
3);
WidgetsListContentEntry widgetsListRowEntry2 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
3);
assertThat(widgetsListRowEntry1.equals(widgetsListRowEntry2)).isTrue();
}
use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_404Launcher by P-404.
the class WidgetsListContentEntryTest method unsortedWidgets_diffLabels_shouldSortWidgetItems.
@Test
public void unsortedWidgets_diffLabels_shouldSortWidgetItems() {
// GIVEN a list of widgets in unsorted order.
// Cat 2x3
WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
2, /* spanY= */
3);
// Dog 2x3
WidgetItem widgetItem2 = createWidgetItem(mWidget2, /* spanX= */
2, /* spanY= */
3);
// Bird 2x3
WidgetItem widgetItem3 = createWidgetItem(mWidget3, /* spanX= */
2, /* spanY= */
3);
// 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 labels alphabetically: [Bird, Cat, Dog].
assertThat(widgetsListRowEntry.mWidgets).containsExactly(widgetItem3, widgetItem1, widgetItem2).inOrder();
assertThat(widgetsListRowEntry.mTitleSectionName).isEqualTo("T");
assertThat(widgetsListRowEntry.mPkgItem).isEqualTo(mPackageItemInfo1);
}
use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_404Launcher by P-404.
the class WidgetsListContentEntryTest method equals_entriesWithDifferentMaxSpanSize_returnFalse.
@Test
public void equals_entriesWithDifferentMaxSpanSize_returnFalse() {
WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
2, /* spanY= */
3);
WidgetsListContentEntry widgetsListRowEntry1 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
3);
WidgetsListContentEntry widgetsListRowEntry2 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
2);
assertThat(widgetsListRowEntry1.equals(widgetsListRowEntry2)).isFalse();
}
Aggregations