Search in sources :

Example 6 with DelayTarget

use of com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget in project glide by bumptech.

the class GifFrameLoaderTest method testOnFrameReadyWithNullResourceDoesNotClearPreviousFrame.

@Test
public void testOnFrameReadyWithNullResourceDoesNotClearPreviousFrame() {
    // Force the loader to create a real Handler by passing null.
    loader = createGifFrameLoader(null);
    DelayTarget previous = mock(DelayTarget.class);
    Request previousRequest = mock(Request.class);
    when(previous.getRequest()).thenReturn(previousRequest);
    when(previous.getResource()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888));
    DelayTarget current = mock(DelayTarget.class);
    when(current.getResource()).thenReturn(null);
    loader.onFrameReady(previous);
    loader.onFrameReady(current);
    verify(previousRequest, never()).clear();
}
Also used : Request(com.bumptech.glide.request.Request) DelayTarget(com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget) Test(org.junit.Test)

Example 7 with DelayTarget

use of com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget in project glide by bumptech.

the class GifFrameLoaderTest method testClearsCompletedLoadOnFrameReadyIfCleared.

@Test
public void testClearsCompletedLoadOnFrameReadyIfCleared() {
    // Force the loader to create a real Handler by passing null;
    loader = createGifFrameLoader(null);
    loader.clear();
    DelayTarget delayTarget = mock(DelayTarget.class);
    Request request = mock(Request.class);
    when(delayTarget.getRequest()).thenReturn(request);
    loader.onFrameReady(delayTarget);
    verify(requestManager).clear(eq(delayTarget));
}
Also used : Request(com.bumptech.glide.request.Request) DelayTarget(com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget) Test(org.junit.Test)

Aggregations

DelayTarget (com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget)7 Test (org.junit.Test)7 Bitmap (android.graphics.Bitmap)3 Request (com.bumptech.glide.request.Request)3 Message (android.os.Message)1