use of com.facebook.imagepipeline.producers.PostprocessorProducer.SingleUsePostprocessorConsumer in project fresco by facebook.
the class SingleUsePostprocessorProducerTest method testSuccess.
@Test
public void testSuccess() {
SingleUsePostprocessorConsumer postprocessorConsumer = produceResults();
doReturn(mDestinationCloseableBitmapRef).when(mPostprocessor).process(mSourceBitmap, mPlatformBitmapFactory);
postprocessorConsumer.onNewResult(mSourceCloseableImageRef, Consumer.IS_LAST);
mSourceCloseableImageRef.close();
mTestExecutorService.runUntilIdle();
mInOrder.verify(mProducerListener).onProducerStart(mProducerContext, PostprocessorProducer.NAME);
mInOrder.verify(mPostprocessor).process(mSourceBitmap, mPlatformBitmapFactory);
mInOrder.verify(mProducerListener).requiresExtraMap(mProducerContext, PostprocessorProducer.NAME);
mInOrder.verify(mProducerListener).onProducerFinishWithSuccess(mProducerContext, PostprocessorProducer.NAME, mExtraMap);
mInOrder.verify(mConsumer).onNewResult(any(CloseableReference.class), eq(Consumer.IS_LAST));
mInOrder.verifyNoMoreInteractions();
assertEquals(1, mResults.size());
CloseableReference<CloseableImage> res0 = mResults.get(0);
assertTrue(CloseableReference.isValid(res0));
assertSame(mDestinationBitmap, ((CloseableStaticBitmap) res0.get()).getUnderlyingBitmap());
res0.close();
verify(mBitmapResourceReleaser).release(mDestinationBitmap);
verify(mSourceCloseableStaticBitmap).close();
}
use of com.facebook.imagepipeline.producers.PostprocessorProducer.SingleUsePostprocessorConsumer in project fresco by facebook.
the class SingleUsePostprocessorProducerTest method testIntermediateImageIsNotProcessed.
@Test
public void testIntermediateImageIsNotProcessed() {
SingleUsePostprocessorConsumer postprocessorConsumer = produceResults();
postprocessorConsumer.onNewResult(mSourceCloseableImageRef, Consumer.NO_FLAGS);
mSourceCloseableImageRef.close();
mTestExecutorService.runUntilIdle();
mInOrder.verifyNoMoreInteractions();
assertEquals(0, mResults.size());
verify(mSourceCloseableStaticBitmap).close();
}
use of com.facebook.imagepipeline.producers.PostprocessorProducer.SingleUsePostprocessorConsumer in project fresco by facebook.
the class AnimatedSingleUsePostprocessorProducerTest method testNonStaticBitmapIsPassedOn.
@Test
public void testNonStaticBitmapIsPassedOn() {
SingleUsePostprocessorConsumer postprocessorConsumer = produceResults();
CloseableAnimatedImage sourceCloseableAnimatedImage = mock(CloseableAnimatedImage.class);
CloseableReference<CloseableImage> sourceCloseableImageRef = CloseableReference.<CloseableImage>of(sourceCloseableAnimatedImage);
postprocessorConsumer.onNewResult(sourceCloseableImageRef, Consumer.IS_LAST);
sourceCloseableImageRef.close();
mTestExecutorService.runUntilIdle();
mInOrder.verify(mConsumer).onNewResult(any(CloseableReference.class), eq(Consumer.IS_LAST));
mInOrder.verifyNoMoreInteractions();
assertEquals(1, mResults.size());
CloseableReference<CloseableImage> res0 = mResults.get(0);
assertTrue(CloseableReference.isValid(res0));
assertSame(sourceCloseableAnimatedImage, res0.get());
res0.close();
verify(sourceCloseableAnimatedImage).close();
}
use of com.facebook.imagepipeline.producers.PostprocessorProducer.SingleUsePostprocessorConsumer in project fresco by facebook.
the class SingleUsePostprocessorProducerTest method testFailure.
@Test
public void testFailure() {
SingleUsePostprocessorConsumer postprocessorConsumer = produceResults();
doThrow(new RuntimeException()).when(mPostprocessor).process(eq(mSourceBitmap), eq(mPlatformBitmapFactory));
postprocessorConsumer.onNewResult(mSourceCloseableImageRef, Consumer.IS_LAST);
mSourceCloseableImageRef.close();
mTestExecutorService.runUntilIdle();
mInOrder.verify(mProducerListener).onProducerStart(mProducerContext, PostprocessorProducer.NAME);
mInOrder.verify(mPostprocessor).process(mSourceBitmap, mPlatformBitmapFactory);
mInOrder.verify(mProducerListener).requiresExtraMap(mProducerContext, PostprocessorProducer.NAME);
mInOrder.verify(mProducerListener).onProducerFinishWithFailure(eq(mProducerContext), eq(PostprocessorProducer.NAME), any(RuntimeException.class), eq(mExtraMap));
mInOrder.verify(mConsumer).onFailure(nullable(Throwable.class));
mInOrder.verifyNoMoreInteractions();
assertEquals(0, mResults.size());
verify(mSourceCloseableStaticBitmap).close();
}
Aggregations