use of com.facebook.common.memory.PooledByteBuffer in project fresco by facebook.
the class JobSchedulerTest method fakeEncodedImage.
private EncodedImage fakeEncodedImage() {
PooledByteBuffer buf = mock(PooledByteBuffer.class);
CloseableReference<PooledByteBuffer> ref = CloseableReference.of(buf);
return new EncodedImage(ref);
}
use of com.facebook.common.memory.PooledByteBuffer in project fresco by facebook.
the class LocalAssetFetchProducerTest method testFetchAssetResource.
@Test
public void testFetchAssetResource() throws Exception {
PooledByteBuffer pooledByteBuffer = mock(PooledByteBuffer.class);
when(mAssetManager.open(eq(TEST_FILENAME), eq(AssetManager.ACCESS_STREAMING))).thenReturn(new ByteArrayInputStream(new byte[TEST_DATA_LENGTH]));
when(mPooledByteBufferFactory.newByteBuffer(any(InputStream.class), eq(TEST_DATA_LENGTH))).thenReturn(pooledByteBuffer);
mLocalAssetFetchProducer.produceResults(mConsumer, mProducerContext);
mExecutor.runUntilIdle();
}
use of com.facebook.common.memory.PooledByteBuffer in project fresco by facebook.
the class LocalContentUriFetchProducerTest method testFetchLocalContentUri.
@Test
public void testFetchLocalContentUri() throws Exception {
PooledByteBuffer pooledByteBuffer = mock(PooledByteBuffer.class);
when(mPooledByteBufferFactory.newByteBuffer(any(InputStream.class))).thenReturn(pooledByteBuffer);
when(mContentResolver.openInputStream(mContentUri)).thenReturn(mock(InputStream.class));
mLocalContentUriFetchProducer.produceResults(mConsumer, mProducerContext);
mExecutor.runUntilIdle();
}
use of com.facebook.common.memory.PooledByteBuffer in project fresco by facebook.
the class DecodeProducerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mProgressiveJpegConfig = new SimpleProgressiveJpegConfig(new SimpleProgressiveJpegConfig.DynamicValueConfig() {
public List<Integer> getScansToDecode() {
return Arrays.asList(PREVIEW_SCAN, GOOD_ENOUGH_SCAN);
}
public int getGoodEnoughScanNumber() {
return GOOD_ENOUGH_SCAN;
}
});
PowerMockito.mockStatic(ProgressiveJpegParser.class);
PowerMockito.whenNew(ProgressiveJpegParser.class).withAnyArguments().thenReturn(mProgressiveJpegParser);
PowerMockito.mockStatic(JobScheduler.class);
PowerMockito.whenNew(JobScheduler.class).withAnyArguments().thenReturn(mJobScheduler);
mDecodeProducer = new DecodeProducer(mByteArrayPool, mExecutor, mImageDecoder, mProgressiveJpegConfig, false, /* Set downsampleEnabled to false */
false, /* Set resizeAndRotateForNetwork to false */
false, /* We don't cancel when the request is cancelled */
mInputProducer);
PooledByteBuffer pooledByteBuffer = mockPooledByteBuffer(IMAGE_SIZE);
mByteBufferRef = CloseableReference.of(pooledByteBuffer);
mEncodedImage = new EncodedImage(mByteBufferRef);
}
use of com.facebook.common.memory.PooledByteBuffer 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));
}
Aggregations