Search in sources :

Example 1 with CachingWidgetPreviewLoader

use of com.android.launcher3.widget.CachingWidgetPreviewLoader in project android_packages_apps_Launcher3 by crdroidandroid.

the class CachingWidgetPreviewLoaderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mLoader = new CachingWidgetPreviewLoader(mDelegate);
    mTestActivity = Robolectric.buildActivity(TestActivity.class).setup().get();
    mTestActivity.setDeviceProfile(mDeviceProfile);
    when(mDelegate.loadPreview(any(), any(), any(), any())).thenReturn(mCancellationSignal);
    mProviderInfo.provider = TEST_PROVIDER;
    when(mProviderInfo.getProfile()).thenReturn(new UserHandle(0));
    mProviderInfo2.provider = TEST_PROVIDER2;
    when(mProviderInfo2.getProfile()).thenReturn(new UserHandle(0));
    InvariantDeviceProfile testProfile = new InvariantDeviceProfile();
    testProfile.numRows = 5;
    testProfile.numColumns = 5;
    mWidgetItem = new WidgetItem(mProviderInfo, testProfile, mIconCache);
    mWidgetItem2 = new WidgetItem(mProviderInfo2, testProfile, mIconCache);
}
Also used : UserHandle(android.os.UserHandle) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) TestActivity(com.android.launcher3.testing.TestActivity) WidgetItem(com.android.launcher3.model.WidgetItem) Before(org.junit.Before)

Example 2 with CachingWidgetPreviewLoader

use of com.android.launcher3.widget.CachingWidgetPreviewLoader in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetsListTableViewHolderBinderTest 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 WidgetsListTableViewHolderBinder(LayoutInflater.from(mTestActivity), mOnIconClickListener, mOnLongClickListener, new CachingWidgetPreviewLoader(mWidgetPreviewLoader), new WidgetsListDrawableFactory(mTestActivity), widgetsListAdapter);
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) CachingWidgetPreviewLoader(com.android.launcher3.widget.CachingWidgetPreviewLoader) TestActivity(com.android.launcher3.testing.TestActivity) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel) Before(org.junit.Before)

Aggregations

InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)2 TestActivity (com.android.launcher3.testing.TestActivity)2 Before (org.junit.Before)2 UserHandle (android.os.UserHandle)1 ComponentWithLabel (com.android.launcher3.icons.ComponentWithLabel)1 WidgetItem (com.android.launcher3.model.WidgetItem)1 CachingWidgetPreviewLoader (com.android.launcher3.widget.CachingWidgetPreviewLoader)1