use of com.facebook.imagepipeline.testing.TestExecutorService in project fresco by facebook.
the class AnimatedDrawableCachingBackendImplTest method setup.
@Before
public void setup() {
mActivityManager = (ActivityManager) RuntimeEnvironment.application.getSystemService(Context.ACTIVITY_SERVICE);
mFakeClock = new FakeClock();
mExecutorService = new TestExecutorService(mFakeClock);
mAnimatedDrawableUtil = new AnimatedDrawableUtil();
mDrawableBackend = new TestAnimatedDrawableBackend(WIDTH, HEIGHT, FRAME_DURATIONS);
}
use of com.facebook.imagepipeline.testing.TestExecutorService in project fresco by facebook.
the class AnimatedSingleUsePostprocessorProducerTest 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);
}
use of com.facebook.imagepipeline.testing.TestExecutorService in project fresco by facebook.
the class BufferedDiskCacheTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mCloseableReference = CloseableReference.of(mPooledByteBuffer);
mEncodedImage = new EncodedImage(mCloseableReference);
List<CacheKey> keys = new ArrayList<>();
keys.add(new SimpleCacheKey("http://test.uri"));
keys.add(new SimpleCacheKey("http://tyrone.uri"));
keys.add(new SimpleCacheKey("http://ian.uri"));
mCacheKey = new MultiCacheKey(keys);
mIsCancelled = new AtomicBoolean(false);
FakeClock fakeClock = new FakeClock();
mReadPriorityExecutor = new TestExecutorService(fakeClock);
mWritePriorityExecutor = new TestExecutorService(fakeClock);
when(mBinaryResource.openStream()).thenReturn(mInputStream);
when(mBinaryResource.size()).thenReturn(123L);
when(mByteBufferFactory.newByteBuffer(same(mInputStream), eq(123))).thenReturn(mPooledByteBuffer);
mockStatic(StagingArea.class);
when(StagingArea.getInstance()).thenReturn(mStagingArea);
mBufferedDiskCache = new BufferedDiskCache(mFileCache, mByteBufferFactory, mPooledByteStreams, mReadPriorityExecutor, mWritePriorityExecutor, mImageCacheStatsTracker);
}
use of com.facebook.imagepipeline.testing.TestExecutorService in project fresco by facebook.
the class LocalExifThumbnailProducerTest method setUp.
@Before
public void setUp() throws IOException {
MockitoAnnotations.initMocks(this);
PowerMockito.mockStatic(JfifUtil.class, BitmapUtil.class);
mTestExecutorService = new TestExecutorService(new FakeClock());
mTestLocalExifThumbnailProducer = new TestLocalExifThumbnailProducer(mTestExecutorService, mPooledByteBufferFactory, mContentResolver);
when(mProducerContext.getImageRequest()).thenReturn(mImageRequest);
when(mImageRequest.getSourceUri()).thenReturn(mUri);
when(mProducerContext.getListener()).thenReturn(mProducerListener);
mThumbnailBytes = new byte[100];
when(mExifInterface.hasThumbnail()).thenReturn(true);
when(mExifInterface.getThumbnail()).thenReturn(mThumbnailBytes);
when(mPooledByteBufferFactory.newByteBuffer(mThumbnailBytes)).thenReturn(mThumbnailByteBuffer);
when(mExifInterface.getAttribute(ExifInterface.TAG_ORIENTATION)).thenReturn(Integer.toString(ORIENTATION));
when(JfifUtil.getAutoRotateAngleFromOrientation(ORIENTATION)).thenReturn(ANGLE);
when(BitmapUtil.decodeDimensions(any(InputStream.class))).thenReturn(new Pair(WIDTH, HEIGHT));
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());
}
use of com.facebook.imagepipeline.testing.TestExecutorService in project fresco by facebook.
the class LocalFileFetchProducerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mExecutor = new TestExecutorService(new FakeClock());
mLocalFileFetchProducer = new LocalFileFetchProducer(mExecutor, mPooledByteBufferFactory);
mFile = new File(RuntimeEnvironment.application.getExternalFilesDir(null), TEST_FILENAME);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(mFile));
bos.write(new byte[INPUT_STREAM_LENGTH], 0, INPUT_STREAM_LENGTH);
bos.close();
mProducerContext = new SettableProducerContext(mImageRequest, mRequestId, mProducerListener, mock(Object.class), ImageRequest.RequestLevel.FULL_FETCH, false, true, Priority.MEDIUM);
when(mImageRequest.getSourceFile()).thenReturn(mFile);
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());
}
Aggregations