Search in sources :

Example 1 with TrivialBufferPooledByteBuffer

use of com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer in project fresco by facebook.

the class AnimatedImageFactoryGifImplTest method testCreateWithDecodeAlFramesUsingByteBuffer.

@Test
public void testCreateWithDecodeAlFramesUsingByteBuffer() throws Exception {
    GifImage mockGifImage = mock(GifImage.class);
    Bitmap mockBitmap1 = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
    Bitmap mockBitmap2 = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
    // Expect a call to GifImage.createFromByteBuffer
    TrivialBufferPooledByteBuffer byteBuffer = createDirectByteBuffer();
    when(mGifImageMock.decodeFromByteBuffer(eq(byteBuffer.getByteBuffer()), any(ImageDecodeOptions.class))).thenReturn(mockGifImage);
    when(mockGifImage.getWidth()).thenReturn(50);
    when(mockGifImage.getHeight()).thenReturn(50);
    testCreateWithDecodeAlFrames(mockGifImage, mockBitmap1, mockBitmap2, byteBuffer);
}
Also used : GifImage(com.facebook.animated.gif.GifImage) Bitmap(android.graphics.Bitmap) TrivialBufferPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer) ImageDecodeOptions(com.facebook.imagepipeline.common.ImageDecodeOptions) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Example 2 with TrivialBufferPooledByteBuffer

use of com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer in project fresco by facebook.

the class AnimatedImageFactoryWebPImplTest method testCreateDefaultsUsingByteBuffer.

@Test
public void testCreateDefaultsUsingByteBuffer() {
    WebPImage mockWebPImage = mock(WebPImage.class);
    // Expect a call to WebPImage.createFromByteBuffer
    TrivialBufferPooledByteBuffer byteBuffer = createDirectByteBuffer();
    when(mWebPImageMock.decodeFromByteBuffer(eq(byteBuffer.getByteBuffer()), any(ImageDecodeOptions.class))).thenReturn(mockWebPImage);
    testCreateDefaults(mockWebPImage, byteBuffer);
}
Also used : TrivialBufferPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer) WebPImage(com.facebook.animated.webp.WebPImage) ImageDecodeOptions(com.facebook.imagepipeline.common.ImageDecodeOptions) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Example 3 with TrivialBufferPooledByteBuffer

use of com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer in project fresco by facebook.

the class AnimatedImageFactoryWebPImplTest method testCreateWithPreviewBitmapUsingByteBuffer.

@Test
public void testCreateWithPreviewBitmapUsingByteBuffer() throws Exception {
    WebPImage mockWebPImage = mock(WebPImage.class);
    Bitmap mockBitmap = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
    // Expect a call to WebPImage.createFromByteBuffer
    TrivialBufferPooledByteBuffer byteBuffer = createDirectByteBuffer();
    when(mWebPImageMock.decodeFromByteBuffer(eq(byteBuffer.getByteBuffer()), any(ImageDecodeOptions.class))).thenReturn(mockWebPImage);
    when(mockWebPImage.getWidth()).thenReturn(50);
    when(mockWebPImage.getHeight()).thenReturn(50);
    testCreateWithPreviewBitmap(mockWebPImage, byteBuffer, mockBitmap);
}
Also used : Bitmap(android.graphics.Bitmap) TrivialBufferPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer) WebPImage(com.facebook.animated.webp.WebPImage) ImageDecodeOptions(com.facebook.imagepipeline.common.ImageDecodeOptions) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Example 4 with TrivialBufferPooledByteBuffer

use of com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer in project fresco by facebook.

the class AnimatedImageFactoryGifImplTest method testCreateDefaultsUsingByteBuffer.

@Test
public void testCreateDefaultsUsingByteBuffer() {
    GifImage mockGifImage = mock(GifImage.class);
    // Expect a call to GifImage.createFromByteBuffer
    TrivialBufferPooledByteBuffer byteBuffer = createDirectByteBuffer();
    when(mGifImageMock.decodeFromByteBuffer(eq(byteBuffer.getByteBuffer()), any(ImageDecodeOptions.class))).thenReturn(mockGifImage);
    testCreateDefaults(mockGifImage, byteBuffer);
}
Also used : GifImage(com.facebook.animated.gif.GifImage) TrivialBufferPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer) ImageDecodeOptions(com.facebook.imagepipeline.common.ImageDecodeOptions) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Example 5 with TrivialBufferPooledByteBuffer

use of com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer in project fresco by facebook.

the class AnimatedImageFactoryGifImplTest method testCreateWithPreviewBitmapUsingByteBuffer.

@Test
public void testCreateWithPreviewBitmapUsingByteBuffer() throws Exception {
    GifImage mockGifImage = mock(GifImage.class);
    Bitmap mockBitmap = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
    // Expect a call to GifImage.createFromByteBuffer
    TrivialBufferPooledByteBuffer byteBuffer = createDirectByteBuffer();
    when(mGifImageMock.decodeFromByteBuffer(eq(byteBuffer.getByteBuffer()), any(ImageDecodeOptions.class))).thenReturn(mockGifImage);
    when(mockGifImage.getWidth()).thenReturn(50);
    when(mockGifImage.getHeight()).thenReturn(50);
    testCreateWithPreviewBitmap(mockGifImage, mockBitmap, byteBuffer);
}
Also used : GifImage(com.facebook.animated.gif.GifImage) Bitmap(android.graphics.Bitmap) TrivialBufferPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer) ImageDecodeOptions(com.facebook.imagepipeline.common.ImageDecodeOptions) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Aggregations

ImageDecodeOptions (com.facebook.imagepipeline.common.ImageDecodeOptions)6 TrivialBufferPooledByteBuffer (com.facebook.imagepipeline.testing.TrivialBufferPooledByteBuffer)6 Test (org.junit.Test)6 PrepareOnlyThisForTest (org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)6 Bitmap (android.graphics.Bitmap)4 GifImage (com.facebook.animated.gif.GifImage)3 WebPImage (com.facebook.animated.webp.WebPImage)3