Search in sources :

Example 26 with FakeClock

use of com.facebook.imagepipeline.testing.FakeClock in project fresco by facebook.

the class RepeatedPostprocessorProducerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mTestExecutorService = new TestExecutorService(new FakeClock());
    mPostprocessorProducer = new PostprocessorProducer(mInputProducer, mPlatformBitmapFactory, mTestExecutorService);
    mProducerContext = new SettableProducerContext(mImageRequest, mRequestId, mProducerListener, mock(Object.class), ImageRequest.RequestLevel.FULL_FETCH, false, /* isPrefetch */
    false, /* isIntermediateResultExpected */
    Priority.MEDIUM, mConfig);
    when(mImageRequest.getPostprocessor()).thenReturn(mPostprocessor);
    mResults = new ArrayList<>();
    when(mPostprocessor.getName()).thenReturn(POSTPROCESSOR_NAME);
    when(mProducerListener.requiresExtraMap(mProducerContext, PRODUCER_NAME)).thenReturn(true);
    doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            mResults.add(((CloseableReference<CloseableImage>) invocation.getArguments()[0]).clone());
            return null;
        }
    }).when(mConsumer).onNewResult(any(CloseableReference.class), anyInt());
    mInOrder = inOrder(mPostprocessor, mProducerListener, mConsumer);
}
Also used : FakeClock(com.facebook.imagepipeline.testing.FakeClock) TestExecutorService(com.facebook.imagepipeline.testing.TestExecutorService) CloseableReference(com.facebook.common.references.CloseableReference)

Example 27 with FakeClock

use of com.facebook.imagepipeline.testing.FakeClock in project fresco by facebook.

the class ThreadHandoffProducerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mProducerContext = new SettableProducerContext(mImageRequest, mRequestId, mProducerListener, mock(Object.class), ImageRequest.RequestLevel.FULL_FETCH, false, true, Priority.MEDIUM, mConfig);
    mTestExecutorService = new TestExecutorService(new FakeClock());
    mThreadHandoffProducer = new ThreadHandoffProducer(mInputProducer, new ThreadHandoffProducerQueueImpl(mTestExecutorService));
    mImagePipelineExperiments = mock(ImagePipelineExperiments.class);
    doReturn(mImagePipelineExperiments).when(mConfig).getExperiments();
    doReturn(false).when(mImagePipelineExperiments).getHandOffOnUiThreadOnly();
}
Also used : ImagePipelineExperiments(com.facebook.imagepipeline.core.ImagePipelineExperiments) FakeClock(com.facebook.imagepipeline.testing.FakeClock) TestExecutorService(com.facebook.imagepipeline.testing.TestExecutorService)

Aggregations

FakeClock (com.facebook.imagepipeline.testing.FakeClock)27 TestExecutorService (com.facebook.imagepipeline.testing.TestExecutorService)19 Before (org.junit.Before)10 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)6 PriorityFetchState (com.facebook.imagepipeline.producers.PriorityNetworkFetcher.PriorityFetchState)5 TestScheduledExecutorService (com.facebook.imagepipeline.testing.TestScheduledExecutorService)5 Test (org.junit.Test)5 CloseableReference (com.facebook.common.references.CloseableReference)4 File (java.io.File)3 IOException (java.io.IOException)3 ConnectException (java.net.ConnectException)3 SocketTimeoutException (java.net.SocketTimeoutException)3 UnknownHostException (java.net.UnknownHostException)3 Bitmap (android.graphics.Bitmap)2 TestAnimatedDrawableBackend (com.facebook.imagepipeline.animated.testing.TestAnimatedDrawableBackend)2 CloseableStaticBitmap (com.facebook.imagepipeline.image.CloseableStaticBitmap)2 InputStream (java.io.InputStream)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Canvas (android.graphics.Canvas)1 Drawable (android.graphics.drawable.Drawable)1