Search in sources :

Example 16 with TrivialPooledByteBuffer

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

the class ProgressiveJpegParserTest method testOnShortestJpeg.

@Test
public void testOnShortestJpeg() {
    final TrivialPooledByteBuffer shortByteBuffer = new TrivialPooledByteBuffer(new byte[] { (byte) 0xff, (byte) 0xd8 });
    assertFalse(mProgressiveJpegParser.parseMoreData(buildEncodedImage(shortByteBuffer)));
    assertTrue(mProgressiveJpegParser.isJpeg());
    assertEquals(0, mProgressiveJpegParser.getBestScanEndOffset());
    assertEquals(0, mProgressiveJpegParser.getBestScanNumber());
}
Also used : TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer)

Example 17 with TrivialPooledByteBuffer

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

the class ProgressiveJpegParserTest method testOnTooShortImage.

@Test
public void testOnTooShortImage() {
    final TrivialPooledByteBuffer shortByteBuffer = new TrivialPooledByteBuffer(new byte[] { (byte) 0xff });
    assertFalse(mProgressiveJpegParser.isJpeg());
    assertFalse(mProgressiveJpegParser.parseMoreData(buildEncodedImage(shortByteBuffer)));
    assertFalse(mProgressiveJpegParser.isJpeg());
    assertEquals(0, mProgressiveJpegParser.getBestScanEndOffset());
    assertEquals(0, mProgressiveJpegParser.getBestScanNumber());
}
Also used : TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer)

Example 18 with TrivialPooledByteBuffer

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

the class ProgressiveJpegParserTest method testOnWebp.

@Test
public void testOnWebp() {
    final TrivialPooledByteBuffer byteBuffer = new TrivialPooledByteBuffer(mWebpBytes);
    mProgressiveJpegParser.parseMoreData(buildEncodedImage(byteBuffer));
    assertFalse(mProgressiveJpegParser.isJpeg());
}
Also used : TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer)

Example 19 with TrivialPooledByteBuffer

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

the class PooledByteBufferInputStreamTest method testCreatingStreamAfterClose.

@Test(expected = IllegalArgumentException.class)
public void testCreatingStreamAfterClose() {
    PooledByteBuffer buffer = new TrivialPooledByteBuffer(new byte[] {});
    buffer.close();
    new PooledByteBufferInputStream(buffer);
}
Also used : TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer) TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer) Test(org.junit.Test)

Example 20 with TrivialPooledByteBuffer

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

the class PooledByteBufferInputStreamTest method testCreateEmptyStream.

@Test
public void testCreateEmptyStream() throws Exception {
    PooledByteBufferInputStream is = new PooledByteBufferInputStream(new TrivialPooledByteBuffer(new byte[] {}));
    assertEquals(-1, is.read());
}
Also used : TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer) Test(org.junit.Test)

Aggregations

TrivialPooledByteBuffer (com.facebook.imagepipeline.testing.TrivialPooledByteBuffer)23 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)9 PooledByteBuffer (com.facebook.common.memory.PooledByteBuffer)8 Test (org.junit.Test)8 AnimatedImageResult (com.facebook.imagepipeline.animated.base.AnimatedImageResult)6 CloseableAnimatedImage (com.facebook.imagepipeline.image.CloseableAnimatedImage)6 PrepareOnlyThisForTest (org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)6 Bitmap (android.graphics.Bitmap)5 Rect (android.graphics.Rect)5 AnimatedDrawableBackend (com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend)4 AnimatedImageCompositor (com.facebook.imagepipeline.animated.impl.AnimatedImageCompositor)4 ImageDecodeOptions (com.facebook.imagepipeline.common.ImageDecodeOptions)4 Before (org.junit.Before)4 GifImage (com.facebook.animated.gif.GifImage)3 WebPImage (com.facebook.animated.webp.WebPImage)3 BitmapCounter (com.facebook.imagepipeline.memory.BitmapCounter)2 BitmapFactory (android.graphics.BitmapFactory)1 UiThreadImmediateExecutorService (com.facebook.common.executors.UiThreadImmediateExecutorService)1 BitmapPool (com.facebook.imagepipeline.memory.BitmapPool)1 FlexByteArrayPool (com.facebook.imagepipeline.memory.FlexByteArrayPool)1