Search in sources :

Example 1 with RepeatedPostprocessorConsumer

use of com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer in project fresco by facebook.

the class AnimatedRepeatedPostprocessorProducerTest method testNonStaticBitmapIsPassedOn.

@Test
public void testNonStaticBitmapIsPassedOn() {
    RepeatedPostprocessorConsumer postprocessorConsumer = produceResults();
    RepeatedPostprocessorRunner repeatedPostprocessorRunner = getRunner();
    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.NO_FLAGS));
    mInOrder.verifyNoMoreInteractions();
    assertEquals(1, mResults.size());
    CloseableReference<CloseableImage> res0 = mResults.get(0);
    assertTrue(CloseableReference.isValid(res0));
    assertSame(sourceCloseableAnimatedImage, res0.get());
    res0.close();
    performCancelAndVerifyOnCancellation();
    verify(sourceCloseableAnimatedImage).close();
}
Also used : RepeatedPostprocessorConsumer(com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer) CloseableAnimatedImage(com.facebook.imagepipeline.image.CloseableAnimatedImage) CloseableReference(com.facebook.common.references.CloseableReference) CloseableImage(com.facebook.imagepipeline.image.CloseableImage) RepeatedPostprocessorRunner(com.facebook.imagepipeline.request.RepeatedPostprocessorRunner)

Example 2 with RepeatedPostprocessorConsumer

use of com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer in project fresco by facebook.

the class RepeatedPostprocessorProducerTest method testIntermediateImageIsNotProcessed.

@Test
public void testIntermediateImageIsNotProcessed() {
    RepeatedPostprocessorConsumer postprocessorConsumer = produceResults();
    RepeatedPostprocessorRunner repeatedPostprocessorRunner = getRunner();
    setupNewSourceImage();
    postprocessorConsumer.onNewResult(mSourceCloseableImageRef, Consumer.NO_FLAGS);
    mSourceCloseableImageRef.close();
    mTestExecutorService.runUntilIdle();
    mInOrder.verifyNoMoreInteractions();
    assertEquals(0, mResults.size());
    verify(mSourceCloseableStaticBitmap).close();
    // final result should be post-processed
    performNewResult(postprocessorConsumer, true);
    verifyNewResultProcessed(0);
    performCancelAndVerifyOnCancellation();
    verify(mSourceCloseableStaticBitmap).close();
}
Also used : RepeatedPostprocessorConsumer(com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer) RepeatedPostprocessorRunner(com.facebook.imagepipeline.request.RepeatedPostprocessorRunner)

Example 3 with RepeatedPostprocessorConsumer

use of com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer in project fresco by facebook.

the class RepeatedPostprocessorProducerTest method testMultiplePostprocessThenClose.

@Test
public void testMultiplePostprocessThenClose() {
    RepeatedPostprocessorConsumer postprocessorConsumer = produceResults();
    RepeatedPostprocessorRunner repeatedPostprocessorRunner = getRunner();
    performNewResult(postprocessorConsumer, true);
    verifyNewResultProcessed(0);
    performUpdate(repeatedPostprocessorRunner, true);
    verifyNewResultProcessed(1);
    performUpdate(repeatedPostprocessorRunner, true);
    verifyNewResultProcessed(2);
    performUpdate(repeatedPostprocessorRunner, true);
    verifyNewResultProcessed(3);
    performCancelAndVerifyOnCancellation();
    verify(mSourceCloseableStaticBitmap).close();
    // Can't update now that the request is cancelled.
    performUpdate(repeatedPostprocessorRunner, true);
    mInOrder.verifyNoMoreInteractions();
}
Also used : RepeatedPostprocessorConsumer(com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer) RepeatedPostprocessorRunner(com.facebook.imagepipeline.request.RepeatedPostprocessorRunner)

Example 4 with RepeatedPostprocessorConsumer

use of com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer in project fresco by facebook.

the class RepeatedPostprocessorProducerTest method testPostprocessSuccessful.

@Test
public void testPostprocessSuccessful() {
    RepeatedPostprocessorConsumer postprocessorConsumer = produceResults();
    RepeatedPostprocessorRunner repeatedPostprocessorRunner = getRunner();
    performNewResult(postprocessorConsumer, true);
    verifyNewResultProcessed(0);
    performCancelAndVerifyOnCancellation();
    verify(mSourceCloseableStaticBitmap).close();
}
Also used : RepeatedPostprocessorConsumer(com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer) RepeatedPostprocessorRunner(com.facebook.imagepipeline.request.RepeatedPostprocessorRunner)

Example 5 with RepeatedPostprocessorConsumer

use of com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer in project fresco by facebook.

the class RepeatedPostprocessorProducerTest method runPostprocessAgainWhenDirty.

@Test
public void runPostprocessAgainWhenDirty() {
    final RepeatedPostprocessorConsumer postprocessorConsumer = produceResults();
    final RepeatedPostprocessorRunner repeatedPostprocessorRunner = getRunner();
    performNewResult(postprocessorConsumer, false);
    Bitmap destBitmap0 = mDestinationBitmap;
    performUpdateDuringTheNextPostprocessing(repeatedPostprocessorRunner);
    mTestExecutorService.runNextPendingCommand();
    verifyNewResultProcessed(0, destBitmap0);
    Bitmap destBitmap1 = mDestinationBitmap;
    performUpdateDuringTheNextPostprocessing(repeatedPostprocessorRunner);
    mTestExecutorService.runNextPendingCommand();
    verifyNewResultProcessed(1, destBitmap1);
    Bitmap destBitmap2 = mDestinationBitmap;
    mTestExecutorService.runNextPendingCommand();
    verifyNewResultProcessed(2, destBitmap2);
}
Also used : RepeatedPostprocessorConsumer(com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer) CloseableStaticBitmap(com.facebook.imagepipeline.image.CloseableStaticBitmap) Bitmap(android.graphics.Bitmap) RepeatedPostprocessorRunner(com.facebook.imagepipeline.request.RepeatedPostprocessorRunner)

Aggregations

RepeatedPostprocessorConsumer (com.facebook.imagepipeline.producers.PostprocessorProducer.RepeatedPostprocessorConsumer)7 RepeatedPostprocessorRunner (com.facebook.imagepipeline.request.RepeatedPostprocessorRunner)7 Bitmap (android.graphics.Bitmap)1 CloseableReference (com.facebook.common.references.CloseableReference)1 CloseableAnimatedImage (com.facebook.imagepipeline.image.CloseableAnimatedImage)1 CloseableImage (com.facebook.imagepipeline.image.CloseableImage)1 CloseableStaticBitmap (com.facebook.imagepipeline.image.CloseableStaticBitmap)1