Search in sources :

Example 1 with DelayTarget

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());
}
Also used : Bitmap(android.graphics.Bitmap) DelayTarget(com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget) Test(org.junit.Test)

Example 2 with DelayTarget

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));
}
Also used : Request(com.bumptech.glide.request.Request) DelayTarget(com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget) Test(org.junit.Test)

Example 3 with DelayTarget

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());
}
Also used : Bitmap(android.graphics.Bitmap) DelayTarget(com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget) Test(org.junit.Test)

Example 4 with DelayTarget

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());
}
Also used : Bitmap(android.graphics.Bitmap) DelayTarget(com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget) Test(org.junit.Test)

Example 5 with DelayTarget

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));
}
Also used : Message(android.os.Message) 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