use of com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback in project android_packages_apps_Launcher3 by crdroidandroid.
the class CachingWidgetPreviewLoaderTest method loadPreview_multipleCallbacks_shouldForwardResultToEachCallback.
@Test
public void loadPreview_multipleCallbacks_shouldForwardResultToEachCallback() {
mLoader.loadPreview(mTestActivity, mWidgetItem, SIZE_10_10, mPreviewLoadedCallback);
mLoader.loadPreview(mTestActivity, mWidgetItem, SIZE_10_10, mPreviewLoadedCallback2);
verify(mDelegate).loadPreview(any(), any(), any(), mCallbackCaptor.capture());
WidgetPreviewLoadedCallback loaderCallback = mCallbackCaptor.getValue();
loaderCallback.onPreviewLoaded(BITMAP);
verify(mPreviewLoadedCallback).onPreviewLoaded(BITMAP);
verify(mPreviewLoadedCallback2).onPreviewLoaded(BITMAP);
}
use of com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback in project android_packages_apps_Launcher3 by crdroidandroid.
the class CachingWidgetPreviewLoaderTest method loadPreview_thenLoaded_thenCancelled_shouldNotRemovePreviewFromCache.
@Test
public void loadPreview_thenLoaded_thenCancelled_shouldNotRemovePreviewFromCache() {
CancellationSignal cancellationSignal = mLoader.loadPreview(mTestActivity, mWidgetItem, SIZE_10_10, mPreviewLoadedCallback);
verify(mDelegate).loadPreview(any(), any(), any(), mCallbackCaptor.capture());
WidgetPreviewLoadedCallback loaderCallback = mCallbackCaptor.getValue();
loaderCallback.onPreviewLoaded(BITMAP);
cancellationSignal.cancel();
assertThat(mLoader.getPreview(mWidgetItem, SIZE_10_10)).isEqualTo(BITMAP);
}
use of com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback in project android_packages_apps_Launcher3 by crdroidandroid.
the class CachingWidgetPreviewLoaderTest method loadPreview_thenLoaded_shouldCallBack.
@Test
public void loadPreview_thenLoaded_shouldCallBack() {
mLoader.loadPreview(mTestActivity, mWidgetItem, SIZE_10_10, mPreviewLoadedCallback);
verify(mDelegate).loadPreview(any(), any(), any(), mCallbackCaptor.capture());
WidgetPreviewLoadedCallback loaderCallback = mCallbackCaptor.getValue();
loaderCallback.onPreviewLoaded(BITMAP);
verify(mPreviewLoadedCallback).onPreviewLoaded(BITMAP);
}
use of com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback in project android_packages_apps_Launcher3 by crdroidandroid.
the class CachingWidgetPreviewLoaderTest method loadPreview_thenCancelled_otherCallListening_loaded_shouldCallBackToNonCancelled.
@Test
public void loadPreview_thenCancelled_otherCallListening_loaded_shouldCallBackToNonCancelled() {
CancellationSignal cancellationSignal1 = mLoader.loadPreview(mTestActivity, mWidgetItem, SIZE_10_10, mPreviewLoadedCallback);
mLoader.loadPreview(mTestActivity, mWidgetItem, SIZE_10_10, mPreviewLoadedCallback2);
verify(mDelegate).loadPreview(any(), any(), any(), mCallbackCaptor.capture());
WidgetPreviewLoadedCallback loaderCallback = mCallbackCaptor.getValue();
cancellationSignal1.cancel();
loaderCallback.onPreviewLoaded(BITMAP);
verifyZeroInteractions(mPreviewLoadedCallback);
verify(mPreviewLoadedCallback2).onPreviewLoaded(BITMAP);
assertThat(mLoader.getPreview(mWidgetItem, SIZE_10_10)).isEqualTo(BITMAP);
}
use of com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback in project android_packages_apps_Launcher3 by crdroidandroid.
the class CachingWidgetPreviewLoaderTest method loadPreviewIntoCache.
private void loadPreviewIntoCache(WidgetItem widgetItem, Size size, Bitmap bitmap) {
reset(mDelegate);
mLoader.loadPreview(mTestActivity, widgetItem, size, ignored -> {
});
verify(mDelegate).loadPreview(any(), any(), any(), mCallbackCaptor.capture());
WidgetPreviewLoadedCallback loaderCallback = mCallbackCaptor.getValue();
loaderCallback.onPreviewLoaded(bitmap);
}
Aggregations