use of com.facebook.imagepipeline.testing.FakeClock in project fresco by facebook.
the class LocalVideoThumbnailProducerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mExecutor = new TestExecutorService(new FakeClock());
mLocalVideoThumbnailProducer = new LocalVideoThumbnailProducer(mExecutor);
mFile = new File(RuntimeEnvironment.application.getExternalFilesDir(null), TEST_FILENAME);
mockStatic(ThumbnailUtils.class);
mProducerContext = new SettableProducerContext(mImageRequest, mRequestId, mProducerListener, mock(Object.class), ImageRequest.RequestLevel.FULL_FETCH, false, false, Priority.MEDIUM);
when(mImageRequest.getSourceFile()).thenReturn(mFile);
}
use of com.facebook.imagepipeline.testing.FakeClock in project fresco by facebook.
the class JobSchedulerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mFakeClockForTime = new FakeClock();
mFakeClockForWorker = new FakeClock();
mFakeClockForScheduled = new FakeClock();
mFakeClockForTime.incrementBy(1000);
mFakeClockForWorker.incrementBy(1000);
mFakeClockForScheduled.incrementBy(1000);
PowerMockito.mockStatic(SystemClock.class);
when(SystemClock.uptimeMillis()).thenAnswer(new Answer<Long>() {
@Override
public Long answer(InvocationOnMock invocation) throws Throwable {
return mFakeClockForTime.now();
}
});
mTestExecutorService = new TestExecutorService(mFakeClockForWorker);
mTestScheduledExecutorService = new TestScheduledExecutorService(mFakeClockForScheduled);
PowerMockito.mockStatic(JobScheduler.JobStartExecutorSupplier.class);
when(JobScheduler.JobStartExecutorSupplier.get()).thenReturn(mTestScheduledExecutorService);
mTestJobRunnable = new TestJobRunnable();
mJobScheduler = new JobScheduler(mTestExecutorService, mTestJobRunnable, INTERVAL);
}
use of com.facebook.imagepipeline.testing.FakeClock in project fresco by facebook.
the class LocalAssetFetchProducerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(mAssetManager.openFd(eq(TEST_FILENAME))).thenReturn(mAssetFileDescriptor);
when(mAssetFileDescriptor.getLength()).thenReturn((long) TEST_DATA_LENGTH);
when(mPooledByteBufferFactory.newByteBuffer(any(InputStream.class), eq(TEST_DATA_LENGTH))).thenReturn(mPooledByteBuffer);
mExecutor = new TestExecutorService(new FakeClock());
mLocalAssetFetchProducer = new LocalAssetFetchProducer(mExecutor, mPooledByteBufferFactory, mAssetManager);
mProducerContext = new SettableProducerContext(mImageRequest, mRequestId, mProducerListener, mock(Object.class), ImageRequest.RequestLevel.FULL_FETCH, false, true, Priority.MEDIUM);
when(mImageRequest.getSourceUri()).thenReturn(Uri.parse("asset:///" + TEST_FILENAME));
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.FakeClock in project fresco by facebook.
the class DiskStorageCacheTest method setUp.
@Before
public void setUp() {
mClock = mock(SystemClock.class);
PowerMockito.mockStatic(SystemClock.class);
PowerMockito.when(SystemClock.get()).thenReturn(mClock);
mBackgroundExecutor = new TestExecutorService(new FakeClock());
mDiskTrimmableRegistry = mock(DiskTrimmableRegistry.class);
mCacheEventListener = mock(CacheEventListener.class);
mCacheEventListenerInOrder = inOrder(mCacheEventListener);
// we know the directory will be this
mCacheDirectory = new File(RuntimeEnvironment.application.getCacheDir(), CACHE_TYPE);
mCacheDirectory.mkdirs();
if (!mCacheDirectory.exists()) {
throw new RuntimeException(String.format((Locale) null, "Cannot create cache dir: %s: directory %s", mCacheDirectory.getAbsolutePath(), mCacheDirectory.exists() ? "already exists" : "does not exist"));
}
mStorage = createDiskStorage(TESTCACHE_VERSION_START_OF_VERSIONING);
mCache = createDiskCache(mStorage, false);
mCache.clearAll();
reset(mCacheEventListener);
verify(mDiskTrimmableRegistry).registerDiskTrimmable(mCache);
}
use of com.facebook.imagepipeline.testing.FakeClock in project fresco by facebook.
the class AnimationBackendDelegateWithInactivityCheckTest method setup.
@Before
public void setup() {
mAnimationBackend = mock(AnimationBackend.class);
mInactivityListener = mock(AnimationBackendDelegateWithInactivityCheck.InactivityListener.class);
mParent = mock(Drawable.class);
mCanvas = mock(Canvas.class);
mFakeClock = new FakeClock();
mTestScheduledExecutorService = new TestScheduledExecutorService(mFakeClock);
mAnimationBackendDelegateWithInactivityCheck = AnimationBackendDelegateWithInactivityCheck.createForBackend(mAnimationBackend, mInactivityListener, mFakeClock, mTestScheduledExecutorService);
}
Aggregations