use of com.facebook.imagepipeline.testing.TrivialPooledByteBuffer in project fresco by facebook.
the class KitKatPurgeableDecoderTest method setUp.
@Before
public void setUp() {
mFlexByteArrayPool = mock(FlexByteArrayPool.class);
mBitmap = MockBitmapFactory.create();
mBitmapCounter = new BitmapCounter(MAX_BITMAP_COUNT, MAX_BITMAP_SIZE);
mockStatic(BitmapCounterProvider.class);
when(BitmapCounterProvider.get()).thenReturn(mBitmapCounter);
mockStatic(BitmapFactory.class);
when(BitmapFactory.decodeByteArray(any(byte[].class), anyInt(), anyInt(), any(BitmapFactory.Options.class))).thenReturn(mBitmap);
mInputBuf = new byte[LENGTH];
PooledByteBuffer input = new TrivialPooledByteBuffer(mInputBuf, POINTER);
mByteBufferRef = CloseableReference.of(input);
mEncodedImage = new EncodedImage(mByteBufferRef);
mDecodeBuf = new byte[LENGTH + 2];
mDecodeBufRef = CloseableReference.of(mDecodeBuf, mock(ResourceReleaser.class));
when(mFlexByteArrayPool.get(Integer.valueOf(LENGTH))).thenReturn(mDecodeBufRef);
mockStatic(Bitmaps.class);
mKitKatPurgeableDecoder = new KitKatPurgeableDecoder(mFlexByteArrayPool);
}
use of com.facebook.imagepipeline.testing.TrivialPooledByteBuffer in project fresco by facebook.
the class ProgressiveJpegParserTest method testOnPartialWebp.
@Test
public void testOnPartialWebp() {
final TrivialPooledByteBuffer byteBuffer = new TrivialPooledByteBuffer(mPartialWebpBytes);
mProgressiveJpegParser.parseMoreData(buildEncodedImage(byteBuffer));
assertFalse(mProgressiveJpegParser.isJpeg());
}
use of com.facebook.imagepipeline.testing.TrivialPooledByteBuffer in project fresco by facebook.
the class EncodedImageTest method testIsJpegCompleteAt_notComplete.
@Test
public void testIsJpegCompleteAt_notComplete() {
byte[] encodedBytes = new byte[ENCODED_BYTES_LENGTH];
encodedBytes[ENCODED_BYTES_LENGTH - 2] = 0;
encodedBytes[ENCODED_BYTES_LENGTH - 1] = 0;
PooledByteBuffer buf = new TrivialPooledByteBuffer(encodedBytes);
EncodedImage encodedImage = new EncodedImage(CloseableReference.of(buf));
encodedImage.setImageFormat(DefaultImageFormats.JPEG);
assertFalse(encodedImage.isCompleteAt(ENCODED_BYTES_LENGTH));
}
use of com.facebook.imagepipeline.testing.TrivialPooledByteBuffer in project fresco by facebook.
the class EncodedImageTest method testParseMetaData_JPEG.
@Test
public void testParseMetaData_JPEG() throws IOException {
PooledByteBuffer buf = new TrivialPooledByteBuffer(ByteStreams.toByteArray(EncodedImageTest.class.getResourceAsStream("images/image.jpg")));
EncodedImage encodedImage = new EncodedImage(CloseableReference.of(buf));
encodedImage.parseMetaData();
assertSame(DefaultImageFormats.JPEG, encodedImage.getImageFormat());
assertEquals(550, encodedImage.getWidth());
assertEquals(468, encodedImage.getHeight());
assertEquals(0, encodedImage.getRotationAngle());
}
use of com.facebook.imagepipeline.testing.TrivialPooledByteBuffer in project fresco by facebook.
the class EncodedImageTest method testParseMetaData_PNG.
@Test
public void testParseMetaData_PNG() throws IOException {
PooledByteBuffer buf = new TrivialPooledByteBuffer(ByteStreams.toByteArray(EncodedImageTest.class.getResourceAsStream("images/image.png")));
EncodedImage encodedImage = new EncodedImage(CloseableReference.of(buf));
encodedImage.parseMetaData();
assertSame(DefaultImageFormats.PNG, encodedImage.getImageFormat());
assertEquals(800, encodedImage.getWidth());
assertEquals(600, encodedImage.getHeight());
assertEquals(0, encodedImage.getRotationAngle());
}
Aggregations