Search in sources :

Example 1 with ComponentWithLabel

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();
}
Also used : ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) ShadowAppWidgetManager(org.robolectric.shadows.ShadowAppWidgetManager) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) ShadowAppWidgetManager(org.robolectric.shadows.ShadowAppWidgetManager) Before(org.junit.Before)

Example 2 with ComponentWithLabel

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);
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) TestActivity(com.android.launcher3.testing.TestActivity) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) Before(org.junit.Before)

Example 3 with ComponentWithLabel

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);
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) TestActivity(com.android.launcher3.testing.TestActivity) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) Before(org.junit.Before)

Example 4 with ComponentWithLabel

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());
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) Before(org.junit.Before)

Example 5 with ComponentWithLabel

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());
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) Before(org.junit.Before)

Aggregations

InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)9 ComponentWithLabel (com.android.launcher3.icons.ComponentWithLabel)9 Before (org.junit.Before)9 TestActivity (com.android.launcher3.testing.TestActivity)3 AppWidgetManager (android.appwidget.AppWidgetManager)1 LauncherModelHelper (com.android.launcher3.util.LauncherModelHelper)1 CachingWidgetPreviewLoader (com.android.launcher3.widget.CachingWidgetPreviewLoader)1 ShadowAppWidgetManager (org.robolectric.shadows.ShadowAppWidgetManager)1 ShadowPackageManager (org.robolectric.shadows.ShadowPackageManager)1