use of com.android.launcher3.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
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(2), eq(1), isNull());
}
use of com.android.launcher3.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListAdapterTest method generateWidgetItems.
private List<WidgetItem> generateWidgetItems(String packageName, int numOfWidgets) {
ShadowPackageManager packageManager = shadowOf(mContext.getPackageManager());
ArrayList<WidgetItem> widgetItems = new ArrayList<>();
for (int i = 0; i < numOfWidgets; i++) {
ComponentName cn = ComponentName.createRelative(packageName, ".SampleWidget" + i);
AppWidgetProviderInfo widgetInfo = new AppWidgetProviderInfo();
widgetInfo.provider = cn;
ReflectionHelpers.setField(widgetInfo, "providerInfo", packageManager.addReceiverIfNotPresent(cn));
widgetItems.add(new WidgetItem(LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, widgetInfo), mTestProfile, mIconCache));
}
return widgetItems;
}
use of com.android.launcher3.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListTableViewHolderBinderTest method generateWidgetItems.
private List<WidgetItem> generateWidgetItems(String packageName, int numOfWidgets) {
ShadowPackageManager packageManager = shadowOf(mContext.getPackageManager());
ArrayList<WidgetItem> widgetItems = new ArrayList<>();
for (int i = 0; i < numOfWidgets; i++) {
ComponentName cn = ComponentName.createRelative(packageName, ".SampleWidget" + i);
AppWidgetProviderInfo widgetInfo = new AppWidgetProviderInfo();
widgetInfo.provider = cn;
ReflectionHelpers.setField(widgetInfo, "providerInfo", packageManager.addReceiverIfNotPresent(cn));
widgetItems.add(new WidgetItem(LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, widgetInfo), mTestProfile, mIconCache));
}
return widgetItems;
}
use of com.android.launcher3.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
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.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class SimpleWidgetsSearchAlgorithmTest method createWidgetsHeaderEntry.
private WidgetsListHeaderEntry createWidgetsHeaderEntry(String packageName, String appName, int numOfWidgets) {
List<WidgetItem> widgetItems = generateWidgetItems(packageName, numOfWidgets);
PackageItemInfo pInfo = createPackageItemInfo(packageName, appName, widgetItems.get(0).user);
return new WidgetsListHeaderEntry(pInfo, /* titleSectionName= */
"", widgetItems);
}
Aggregations