Search in sources :

Example 11 with FakeClock

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

the class AnimatedDrawableTest method setup.

@Before
public void setup() {
    mFakeClock = new FakeClock();
    mTestScheduledExecutorService = new TestScheduledExecutorService(mFakeClock);
    mBackend = new TestAnimatedDrawableBackend(WIDTH, HEIGHT, FRAME_DURATIONS);
    mCachingBackend = new TestAnimatedDrawableCachingBackend(mBackend);
    mCallback = new MyCallback(mFakeClock);
    mDrawable = new AnimatedDrawable(mTestScheduledExecutorService, mCachingBackend, AnimatedDrawableDiagnosticsNoop.getInstance(), mFakeClock);
    mDrawable.setCallback(mCallback);
}
Also used : TestAnimatedDrawableBackend(com.facebook.imagepipeline.animated.testing.TestAnimatedDrawableBackend) FakeClock(com.facebook.imagepipeline.testing.FakeClock) TestScheduledExecutorService(com.facebook.imagepipeline.testing.TestScheduledExecutorService) Before(org.junit.Before)

Example 12 with FakeClock

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

the class AnimatedRepeatedPostprocessorProducerTest 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);
    when(mImageRequest.getPostprocessor()).thenReturn(mPostprocessor);
    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);
}
Also used : FakeClock(com.facebook.imagepipeline.testing.FakeClock) TestExecutorService(com.facebook.imagepipeline.testing.TestExecutorService) CloseableReference(com.facebook.common.references.CloseableReference)

Example 13 with FakeClock

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

the class AnimatedDrawableSupportTest method setup.

@Before
public void setup() {
    mFakeClock = new FakeClock();
    mTestScheduledExecutorService = new TestScheduledExecutorService(mFakeClock);
    mBackend = new TestAnimatedDrawableSupportBackend(WIDTH, HEIGHT, FRAME_DURATIONS);
    mCachingBackend = new TestAnimatedDrawableCachingBackend(mBackend);
    mCallback = new MyCallback(mFakeClock);
    mDrawable = new AnimatedDrawableSupport(mTestScheduledExecutorService, mCachingBackend, AnimatedDrawableDiagnosticsNoop.getInstance(), mFakeClock);
    mDrawable.setCallback(mCallback);
}
Also used : FakeClock(com.facebook.imagepipeline.testing.FakeClock) TestScheduledExecutorService(com.facebook.imagepipeline.testing.TestScheduledExecutorService) TestAnimatedDrawableSupportBackend(com.facebook.imagepipeline.animated.testing.TestAnimatedDrawableSupportBackend) Before(org.junit.Before)

Example 14 with FakeClock

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

the class LocalContentUriFetchProducerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mExecutor = new TestExecutorService(new FakeClock());
    mLocalContentUriFetchProducer = new LocalContentUriFetchProducer(mExecutor, mPooledByteBufferFactory, mContentResolver);
    mContentUri = Uri.fromFile(mock(File.class));
    mProducerContext = new SettableProducerContext(mImageRequest, mRequestId, mProducerListener, mock(Object.class), ImageRequest.RequestLevel.FULL_FETCH, false, true, Priority.MEDIUM);
    when(mImageRequest.getSourceUri()).thenReturn(mContentUri);
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            mCapturedEncodedImage = EncodedImage.cloneOrNull((EncodedImage) invocation.getArguments()[0]);
            return null;
        }
    }).when(mConsumer).onNewResult(notNull(EncodedImage.class), anyBoolean());
}
Also used : FakeClock(com.facebook.imagepipeline.testing.FakeClock) TestExecutorService(com.facebook.imagepipeline.testing.TestExecutorService) EncodedImage(com.facebook.imagepipeline.image.EncodedImage)

Example 15 with FakeClock

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

the class LocalContentUriThumbnailFetchProducerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mExecutor = new TestExecutorService(new FakeClock());
    mLocalContentUriThumbnailFetchProducer = new LocalContentUriThumbnailFetchProducer(mExecutor, mPooledByteBufferFactory, mContentResolver);
    mContentUri = Uri.parse("content://media/external/images/media/1");
    mProducerContext = new SettableProducerContext(mImageRequest, mRequestId, mProducerListener, mock(Object.class), ImageRequest.RequestLevel.FULL_FETCH, false, true, Priority.MEDIUM);
    when(mImageRequest.getSourceUri()).thenReturn(mContentUri);
    mockMediaStoreCursor();
    mockThumbnailFile();
    mockContentResolver();
}
Also used : FakeClock(com.facebook.imagepipeline.testing.FakeClock) TestExecutorService(com.facebook.imagepipeline.testing.TestExecutorService)

Aggregations

FakeClock (com.facebook.imagepipeline.testing.FakeClock)20 TestExecutorService (com.facebook.imagepipeline.testing.TestExecutorService)17 Before (org.junit.Before)7 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)6 TestScheduledExecutorService (com.facebook.imagepipeline.testing.TestScheduledExecutorService)5 CloseableReference (com.facebook.common.references.CloseableReference)4 File (java.io.File)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 Canvas (android.graphics.Canvas)1 Drawable (android.graphics.drawable.Drawable)1 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