use of com.android.launcher3.icons.ComponentWithLabel in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsPredicationUpdateTaskTest method setup.
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
doAnswer(invocation -> {
ComponentWithLabel componentWithLabel = invocation.getArgument(0);
return componentWithLabel.getComponent().getShortClassName();
}).when(mIconCache).getTitleNoCache(any());
mContext = RuntimeEnvironment.application;
mModelHelper = new LauncherModelHelper();
mUserHandle = Process.myUserHandle();
mTestProfile = new InvariantDeviceProfile();
// 2 widgets, app4/provider1 & app5/provider1, have already been added to the workspace.
mModelHelper.initializeData("/widgets_predication_update_task_data.txt");
ShadowPackageManager packageManager = shadowOf(mContext.getPackageManager());
mApp1Provider1.provider = ComponentName.createRelative("app1", "provider1");
ReflectionHelpers.setField(mApp1Provider1, "providerInfo", packageManager.addReceiverIfNotPresent(mApp1Provider1.provider));
mApp1Provider2.provider = ComponentName.createRelative("app1", "provider2");
ReflectionHelpers.setField(mApp1Provider2, "providerInfo", packageManager.addReceiverIfNotPresent(mApp1Provider2.provider));
mApp2Provider1.provider = ComponentName.createRelative("app2", "provider1");
ReflectionHelpers.setField(mApp2Provider1, "providerInfo", packageManager.addReceiverIfNotPresent(mApp2Provider1.provider));
mApp4Provider1.provider = ComponentName.createRelative("app4", "provider1");
ReflectionHelpers.setField(mApp4Provider1, "providerInfo", packageManager.addReceiverIfNotPresent(mApp4Provider1.provider));
mApp4Provider2.provider = ComponentName.createRelative("app4", ".provider2");
ReflectionHelpers.setField(mApp4Provider2, "providerInfo", packageManager.addReceiverIfNotPresent(mApp4Provider2.provider));
mApp5Provider1.provider = ComponentName.createRelative("app5", "provider1");
ReflectionHelpers.setField(mApp5Provider1, "providerInfo", packageManager.addReceiverIfNotPresent(mApp5Provider1.provider));
ShadowAppWidgetManager shadowAppWidgetManager = shadowOf(mContext.getSystemService(AppWidgetManager.class));
shadowAppWidgetManager.addInstalledProvider(mApp1Provider1);
shadowAppWidgetManager.addInstalledProvider(mApp1Provider2);
shadowAppWidgetManager.addInstalledProvider(mApp2Provider1);
shadowAppWidgetManager.addInstalledProvider(mApp4Provider1);
shadowAppWidgetManager.addInstalledProvider(mApp4Provider2);
shadowAppWidgetManager.addInstalledProvider(mApp5Provider1);
mModelHelper.getModel().addCallbacks(mCallback);
MODEL_EXECUTOR.post(() -> mModelHelper.getBgDataModel().widgetsModel.update(LauncherAppState.getInstance(mContext), /* packageUser= */
null));
waitUntilIdle();
}
use of com.android.launcher3.icons.ComponentWithLabel in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListHeaderViewHolderBinderTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mTestProfile = new InvariantDeviceProfile();
mTestProfile.numRows = 5;
mTestProfile.numColumns = 5;
mActivityController = Robolectric.buildActivity(TestActivity.class);
mTestActivity = mActivityController.setup().get();
mTestActivity.setDeviceProfile(mDeviceProfile);
doAnswer(invocation -> {
ComponentWithLabel componentWithLabel = (ComponentWithLabel) invocation.getArgument(0);
return componentWithLabel.getComponent().getShortClassName();
}).when(mIconCache).getTitleNoCache(any());
WidgetsListAdapter widgetsListAdapter = new WidgetsListAdapter(mContext, LayoutInflater.from(mTestActivity), mWidgetPreviewLoader, mIconCache, /* iconClickListener= */
view -> {
}, /* iconLongClickListener= */
view -> false);
mViewHolderBinder = new WidgetsListHeaderViewHolderBinder(LayoutInflater.from(mTestActivity), mOnHeaderClickListener, new WidgetsListDrawableFactory(mTestActivity), widgetsListAdapter);
}
use of com.android.launcher3.icons.ComponentWithLabel in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListSearchHeaderViewHolderBinderTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mTestProfile = new InvariantDeviceProfile();
mTestProfile.numRows = 5;
mTestProfile.numColumns = 5;
mActivityController = Robolectric.buildActivity(TestActivity.class);
mTestActivity = mActivityController.setup().get();
mTestActivity.setDeviceProfile(mDeviceProfile);
doAnswer(invocation -> {
ComponentWithLabel componentWithLabel = (ComponentWithLabel) invocation.getArgument(0);
return componentWithLabel.getComponent().getShortClassName();
}).when(mIconCache).getTitleNoCache(any());
WidgetsListAdapter widgetsListAdapter = new WidgetsListAdapter(mContext, LayoutInflater.from(mTestActivity), mWidgetPreviewLoader, mIconCache, /* iconClickListener= */
view -> {
}, /* iconLongClickListener= */
view -> false);
mViewHolderBinder = new WidgetsListSearchHeaderViewHolderBinder(LayoutInflater.from(mTestActivity), mOnHeaderClickListener, new WidgetsListDrawableFactory(mTestActivity), widgetsListAdapter);
}
use of com.android.launcher3.icons.ComponentWithLabel in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListContentEntryTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mWidgetsToLabels.put(mWidget1, "Cat");
mWidgetsToLabels.put(mWidget2, "Dog");
mWidgetsToLabels.put(mWidget3, "Bird");
mContext = RuntimeEnvironment.application;
mTestProfile = new InvariantDeviceProfile();
mTestProfile.numRows = 5;
mTestProfile.numColumns = 5;
doAnswer(invocation -> {
ComponentWithLabel componentWithLabel = (ComponentWithLabel) invocation.getArgument(0);
return mWidgetsToLabels.get(componentWithLabel.getComponent());
}).when(mIconCache).getTitleNoCache(any());
}
use of com.android.launcher3.icons.ComponentWithLabel in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsTableUtilsTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mTestProfile = new InvariantDeviceProfile();
mTestProfile.numRows = 5;
mTestProfile.numColumns = 5;
initTestWidgets();
initTestShortcuts();
doAnswer(invocation -> ((ComponentWithLabel) invocation.getArgument(0)).getComponent().getPackageName()).when(mIconCache).getTitleNoCache(any());
}
Aggregations