use of com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget in project glide by bumptech.
the class GifFrameLoaderTest method testDelayTargetSetsResourceOnResourceReady.
@Test
public void testDelayTargetSetsResourceOnResourceReady() {
DelayTarget delayTarget = new DelayTarget(handler, 1, 1);
Bitmap expected = Bitmap.createBitmap(100, 200, Bitmap.Config.RGB_565);
delayTarget.onResourceReady(expected, null);
assertEquals(expected, delayTarget.getResource());
}
use of com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget in project glide by bumptech.
the class GifFrameLoaderTest method testOnFrameReadyClearsPreviousFrame.
@Test
public void testOnFrameReadyClearsPreviousFrame() {
// Force the loader to create a real Handler.
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(Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565));
loader.onFrameReady(previous);
loader.onFrameReady(current);
verify(requestManager).clear(eq(previous));
}
use of com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget in project glide by bumptech.
the class GifFrameLoaderTest method testGetCurrentFrameReturnsCurrentBitmapAfterLoadHasCompleted.
@Test
public void testGetCurrentFrameReturnsCurrentBitmapAfterLoadHasCompleted() {
final Bitmap result = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888);
DelayTarget target = mock(DelayTarget.class);
when(target.getResource()).thenReturn(result);
loader.onFrameReady(target);
assertEquals(result, loader.getCurrentFrame());
}
use of com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget in project glide by bumptech.
the class GifFrameLoaderTest method testDoesNotReturnResourceForCompletedFrameInGetCurrentFrameIfLoadCompletesWhileCleared.
@Test
public void testDoesNotReturnResourceForCompletedFrameInGetCurrentFrameIfLoadCompletesWhileCleared() {
loader.clear();
DelayTarget delayTarget = mock(DelayTarget.class);
Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
when(delayTarget.getResource()).thenReturn(bitmap);
loader.onFrameReady(delayTarget);
assertNull(loader.getCurrentFrame());
}
use of com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget in project glide by bumptech.
the class GifFrameLoaderTest method testDelayTargetSendsMessageWithHandlerDelayed.
@Test
public void testDelayTargetSendsMessageWithHandlerDelayed() {
long targetTime = 1234;
DelayTarget delayTarget = new DelayTarget(handler, 1, targetTime);
delayTarget.onResourceReady(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888), null);
verify(handler).sendMessageAtTime(isA(Message.class), eq(targetTime));
}
Aggregations