Search in sources :

Example 1 with WidgetPreviewLoadedCallback

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);
}
Also used : WidgetPreviewLoadedCallback(com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback) Test(org.junit.Test)

Example 2 with WidgetPreviewLoadedCallback

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);
}
Also used : WidgetPreviewLoadedCallback(com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback) CancellationSignal(android.os.CancellationSignal) Test(org.junit.Test)

Example 3 with WidgetPreviewLoadedCallback

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);
}
Also used : WidgetPreviewLoadedCallback(com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback) Test(org.junit.Test)

Example 4 with WidgetPreviewLoadedCallback

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);
}
Also used : WidgetPreviewLoadedCallback(com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback) CancellationSignal(android.os.CancellationSignal) Test(org.junit.Test)

Example 5 with WidgetPreviewLoadedCallback

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);
}
Also used : WidgetPreviewLoadedCallback(com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback)

Aggregations

WidgetPreviewLoadedCallback (com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback)5 Test (org.junit.Test)4 CancellationSignal (android.os.CancellationSignal)2