use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class JobSchedulerTest method testSchedule_Intermediate.
@Test
public void testSchedule_Intermediate() {
EncodedImage encodedImage = fakeEncodedImage();
mJobScheduler.updateJob(encodedImage, Consumer.NO_FLAGS);
assertTrue(mJobScheduler.scheduleJob());
assertEquals(0, mTestScheduledExecutorService.getPendingCount());
assertEquals(1, mTestExecutorService.getPendingCount());
assertEquals(0, mTestJobRunnable.jobs.size());
mFakeClockForTime.incrementBy(1234);
mFakeClockForWorker.incrementBy(1234);
mFakeClockForScheduled.incrementBy(1234);
assertEquals(1, mTestJobRunnable.jobs.size());
assertJobsEqual(mTestJobRunnable.jobs.get(0), encodedImage, Consumer.NO_FLAGS);
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class JobSchedulerTest method testUpdate_Intermediate.
@Test
public void testUpdate_Intermediate() {
EncodedImage encodedImage = fakeEncodedImage();
assertTrue(mJobScheduler.updateJob(encodedImage, Consumer.NO_FLAGS));
assertNotSame(encodedImage, mJobScheduler.mEncodedImage);
assertReferencesEqual(encodedImage, mJobScheduler.mEncodedImage);
assertEquals(Consumer.NO_FLAGS, mJobScheduler.mStatus);
assertEquals(0, mTestScheduledExecutorService.getPendingCount());
assertEquals(0, mTestExecutorService.getPendingCount());
assertEquals(0, mTestJobRunnable.jobs.size());
}
use of com.facebook.imagepipeline.image.EncodedImage 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, mConfig);
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), anyInt());
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class AddImageTransformMetaDataProducerTest method testOnNewResultNotLast_RotationNotFound.
@Test
public void testOnNewResultNotLast_RotationNotFound() {
when(ImageFormatChecker.getImageFormat_WrapIOException(any(InputStream.class))).thenReturn(DefaultImageFormats.JPEG);
when(JfifUtil.getOrientation(any(InputStream.class))).thenReturn(0);
when(BitmapUtil.decodeDimensionsAndColorSpace(any(InputStream.class))).thenReturn(new ImageMetaData(-1, -1, null));
mAddMetaDataConsumer.onNewResult(mIntermediateResult, Consumer.NO_FLAGS);
ArgumentCaptor<EncodedImage> argumentCaptor = ArgumentCaptor.forClass(EncodedImage.class);
verify(mConsumer).onNewResult(argumentCaptor.capture(), eq(Consumer.NO_FLAGS));
EncodedImage encodedImage = argumentCaptor.getValue();
assertTrue(EncodedImage.isValid(encodedImage));
assertEquals(-1, encodedImage.getRotationAngle());
assertEquals(-1, encodedImage.getWidth());
assertEquals(-1, encodedImage.getHeight());
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class AddImageTransformMetaDataProducerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
PowerMockito.mockStatic(ImageFormatChecker.class, JfifUtil.class, BitmapUtil.class);
mAddMetaDataProducer = new AddImageTransformMetaDataProducer(mInputProducer);
mIntermediateResultBufferRef = CloseableReference.of(mock(PooledByteBuffer.class));
mFinalResultBufferRef = CloseableReference.of(mock(PooledByteBuffer.class));
mIntermediateResult = new EncodedImage(mIntermediateResultBufferRef);
mFinalResult = new EncodedImage(mFinalResultBufferRef);
mAddMetaDataConsumer = null;
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
mAddMetaDataConsumer = (Consumer<EncodedImage>) invocation.getArguments()[0];
return null;
}
}).when(mInputProducer).produceResults(any(Consumer.class), any(ProducerContext.class));
mAddMetaDataProducer.produceResults(mConsumer, mProducerContext);
}
Aggregations