use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class DownsampleUtilTest method whenImageWidthHeightAndRotation.
private void whenImageWidthHeightAndRotation(int width, int height, int rotationAngle) {
mEncodedImage = new EncodedImage(CloseableReference.of(mock(PooledByteBuffer.class)));
mEncodedImage.setWidth(width);
mEncodedImage.setHeight(height);
mEncodedImage.setRotationAngle(rotationAngle);
mEncodedImage.setExifOrientation(ExifInterface.ORIENTATION_NORMAL);
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class StagingAreaTest method setUp.
@Before
public void setUp() {
mStagingArea = StagingArea.getInstance();
mCloseableReference = CloseableReference.of(mock(PooledByteBuffer.class));
mCloseableReference2 = CloseableReference.of(mock(PooledByteBuffer.class));
mEncodedImage = new EncodedImage(mCloseableReference);
mSecondEncodedImage = new EncodedImage(mCloseableReference2);
mCacheKey = new SimpleCacheKey("http://this.is/uri");
mStagingArea.put(mCacheKey, mEncodedImage);
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class EncodedMemoryCacheProducerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mEncodedMemoryCacheProducer = new EncodedMemoryCacheProducer(mMemoryCache, mCacheKeyFactory, mInputProducer);
mPooledByteBuffer1 = mock(PooledByteBuffer.class);
mPooledByteBuffer2 = mock(PooledByteBuffer.class);
mFinalImageReference = CloseableReference.of(mPooledByteBuffer1);
mIntermediateImageReference = CloseableReference.of(mPooledByteBuffer2);
mFinalImageReferenceClone = mFinalImageReference.clone();
mFinalEncodedImage = new EncodedImage(mFinalImageReference);
mFinalEncodedImage.setImageFormat(new ImageFormat("jpeg", null));
mFinalEncodedImage.setWidth(100);
mFinalEncodedImage.setHeight(100);
mImagePipelineConfig = mock(ImagePipelineConfig.class);
mImagePipelineExperiments = mock(ImagePipelineExperiments.class);
mFinalEncodedImageFormatUnknown = new EncodedImage(mFinalImageReference);
mIntermediateEncodedImage = new EncodedImage(mIntermediateImageReference);
mFinalEncodedImageClone = new EncodedImage(mFinalImageReferenceClone);
List<CacheKey> list = new ArrayList<>();
list.add(new SimpleCacheKey("http://dummy.uri"));
mCacheKey = new MultiCacheKey(list);
when(mCacheKeyFactory.getEncodedCacheKey(mImageRequest, mCallerContext)).thenReturn(mCacheKey);
when(mMemoryCache.cache(mCacheKey, mFinalImageReference)).thenReturn(mFinalImageReferenceClone);
when(mProducerContext.getImageRequest()).thenReturn(mImageRequest);
when(mProducerContext.getCallerContext()).thenReturn(mCallerContext);
when(mProducerContext.getProducerListener()).thenReturn(mProducerListener);
when(mProducerListener.requiresExtraMap(mProducerContext, PRODUCER_NAME)).thenReturn(true);
when(mProducerContext.getLowestPermittedRequestLevel()).thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
when(mProducerContext.getImagePipelineConfig()).thenReturn(mImagePipelineConfig);
when(mImagePipelineConfig.getExperiments()).thenReturn(mImagePipelineExperiments);
when(mImagePipelineExperiments.isEncodedCacheEnabled()).thenReturn(true);
setUpCacheEnabled(true);
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class EncodedMemoryCacheProducerTest method testEncodedMemoryCacheGetSuccessful.
@Test
public void testEncodedMemoryCacheGetSuccessful() {
setupEncodedMemoryCacheGetSuccess();
when(mProducerContext.getLowestPermittedRequestLevel()).thenReturn(ImageRequest.RequestLevel.ENCODED_MEMORY_CACHE);
mEncodedMemoryCacheProducer.produceResults(mConsumer, mProducerContext);
ArgumentCaptor<EncodedImage> argumentCaptor = ArgumentCaptor.forClass(EncodedImage.class);
verify(mConsumer).onNewResult(argumentCaptor.capture(), eq(Consumer.IS_LAST));
EncodedImage encodedImage = argumentCaptor.getValue();
Assert.assertSame(mFinalEncodedImage.getUnderlyingReferenceTestOnly(), encodedImage.getUnderlyingReferenceTestOnly());
verify(mProducerListener).onProducerStart(mProducerContext, PRODUCER_NAME);
Map<String, String> extraMap = ImmutableMap.of(EncodedMemoryCacheProducer.EXTRA_CACHED_VALUE_FOUND, "true");
verify(mProducerListener).onProducerFinishWithSuccess(mProducerContext, PRODUCER_NAME, extraMap);
verify(mProducerListener).onUltimateProducerReached(mProducerContext, PRODUCER_NAME, true);
Assert.assertFalse(mFinalImageReference.isValid());
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class JobSchedulerTest method testClear.
@Test
public void testClear() throws Exception {
EncodedImage encodedImage = fakeEncodedImage();
mJobScheduler.updateJob(encodedImage, Consumer.IS_LAST);
mJobScheduler.clearJob();
assertEquals(null, mJobScheduler.mEncodedImage);
encodedImage.close();
assertNull(encodedImage.getByteBufferRef());
}
Aggregations