use of com.facebook.imagepipeline.testing.TestScheduledExecutorService 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.TestScheduledExecutorService 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);
}
use of com.facebook.imagepipeline.testing.TestScheduledExecutorService 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);
}
use of com.facebook.imagepipeline.testing.TestScheduledExecutorService 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);
}
use of com.facebook.imagepipeline.testing.TestScheduledExecutorService in project fresco by facebook.
the class ResizeAndRotateProducerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mFakeClockForWorker = new FakeClock();
mFakeClockForScheduled = new FakeClock();
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 mFakeClockForWorker.now();
}
});
when(mImageRequest.getSourceUri()).thenReturn(Uri.parse("http://testuri"));
mTestExecutorService = new TestExecutorService(mFakeClockForWorker);
mTestScheduledExecutorService = new TestScheduledExecutorService(mFakeClockForScheduled);
mUiThreadImmediateExecutorService = mock(UiThreadImmediateExecutorService.class);
when(mUiThreadImmediateExecutorService.schedule(any(Runnable.class), anyLong(), any(TimeUnit.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return mTestScheduledExecutorService.schedule((Runnable) invocation.getArguments()[0], (long) invocation.getArguments()[1], (TimeUnit) invocation.getArguments()[2]);
}
});
PowerMockito.mockStatic(NativeJpegTranscoder.class);
PowerMockito.mockStatic(UiThreadImmediateExecutorService.class);
when(UiThreadImmediateExecutorService.getInstance()).thenReturn(mUiThreadImmediateExecutorService);
mTestExecutorService = new TestExecutorService(mFakeClockForWorker);
when(mProducerContext.getImageRequest()).thenReturn(mImageRequest);
when(mProducerContext.getProducerListener()).thenReturn(mProducerListener);
when(mProducerListener.requiresExtraMap(eq(mProducerContext), anyString())).thenReturn(true);
mIntermediateResult = CloseableReference.of(mock(PooledByteBuffer.class));
mFinalResult = CloseableReference.of(mock(PooledByteBuffer.class));
mResizeAndRotateProducerConsumer = null;
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
mResizeAndRotateProducerConsumer = (Consumer<EncodedImage>) invocation.getArguments()[0];
return null;
}
}).when(mInputProducer).produceResults(any(Consumer.class), any(ProducerContext.class));
doReturn(mPooledByteBufferOutputStream).when(mPooledByteBufferFactory).newOutputStream();
mPooledByteBuffer = new TrivialPooledByteBuffer(new byte[] { 1 }, 0);
doReturn(mPooledByteBuffer).when(mPooledByteBufferOutputStream).toByteBuffer();
}
Aggregations