Search in sources :

Example 16 with TestExecutorService

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

the class SingleUsePostprocessorProducerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mTestExecutorService = new TestExecutorService(new FakeClock());
    mPostprocessorProducer = new PostprocessorProducer(mInputProducer, mPlatformBitmapFactory, mTestExecutorService);
    when(mImageRequest.getPostprocessor()).thenReturn(mPostprocessor);
    when(mProducerContext.getId()).thenReturn(mRequestId);
    when(mProducerContext.getListener()).thenReturn(mProducerListener);
    when(mProducerContext.getImageRequest()).thenReturn(mImageRequest);
    mResults = new ArrayList<>();
    when(mPostprocessor.getName()).thenReturn(POSTPROCESSOR_NAME);
    when(mProducerListener.requiresExtraMap(mRequestId)).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), anyBoolean());
    mInOrder = inOrder(mPostprocessor, mProducerListener, mConsumer);
    mSourceBitmap = mock(Bitmap.class);
    mSourceCloseableStaticBitmap = mock(CloseableStaticBitmap.class);
    when(mSourceCloseableStaticBitmap.getUnderlyingBitmap()).thenReturn(mSourceBitmap);
    mSourceCloseableImageRef = CloseableReference.<CloseableImage>of(mSourceCloseableStaticBitmap);
    mDestinationBitmap = mock(Bitmap.class);
    mDestinationCloseableBitmapRef = CloseableReference.of(mDestinationBitmap, mBitmapResourceReleaser);
}
Also used : Bitmap(android.graphics.Bitmap) CloseableStaticBitmap(com.facebook.imagepipeline.image.CloseableStaticBitmap) FakeClock(com.facebook.imagepipeline.testing.FakeClock) TestExecutorService(com.facebook.imagepipeline.testing.TestExecutorService) CloseableReference(com.facebook.common.references.CloseableReference) CloseableStaticBitmap(com.facebook.imagepipeline.image.CloseableStaticBitmap)

Example 17 with TestExecutorService

use of com.facebook.imagepipeline.testing.TestExecutorService 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);
    mTestExecutorService = new TestExecutorService(new FakeClock());
    mThreadHandoffProducer = new ThreadHandoffProducer(mInputProducer, new ThreadHandoffProducerQueue(mTestExecutorService));
}
Also used : FakeClock(com.facebook.imagepipeline.testing.FakeClock) TestExecutorService(com.facebook.imagepipeline.testing.TestExecutorService) ThreadHandoffProducerQueue(com.facebook.imagepipeline.producers.ThreadHandoffProducerQueue)

Aggregations

FakeClock (com.facebook.imagepipeline.testing.FakeClock)17 TestExecutorService (com.facebook.imagepipeline.testing.TestExecutorService)17 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)6 CloseableReference (com.facebook.common.references.CloseableReference)4 Before (org.junit.Before)4 File (java.io.File)3 Bitmap (android.graphics.Bitmap)2 CloseableStaticBitmap (com.facebook.imagepipeline.image.CloseableStaticBitmap)2 TestScheduledExecutorService (com.facebook.imagepipeline.testing.TestScheduledExecutorService)2 InputStream (java.io.InputStream)2 Pair (android.util.Pair)1 CacheEventListener (com.facebook.cache.common.CacheEventListener)1 CacheKey (com.facebook.cache.common.CacheKey)1 MultiCacheKey (com.facebook.cache.common.MultiCacheKey)1 SimpleCacheKey (com.facebook.cache.common.SimpleCacheKey)1 DiskTrimmableRegistry (com.facebook.common.disk.DiskTrimmableRegistry)1 UiThreadImmediateExecutorService (com.facebook.common.executors.UiThreadImmediateExecutorService)1 SystemClock (com.facebook.common.time.SystemClock)1 TestAnimatedDrawableBackend (com.facebook.imagepipeline.animated.testing.TestAnimatedDrawableBackend)1 AnimatedDrawableUtil (com.facebook.imagepipeline.animated.util.AnimatedDrawableUtil)1