use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class ThumbnailBranchProducerTest method testFinalProducerUsedIfFirstTwoReturnNullOrFailure.
@Test
public void testFinalProducerUsedIfFirstTwoReturnNullOrFailure() {
mockRequestWithResizeOptions(THUMBNAIL_WIDTHS[0] - 50, THUMBNAIL_HEIGHTS[0] - 50);
EncodedImage thirdImage = mockEncodedImage(THUMBNAIL_WIDTHS[2], THUMBNAIL_HEIGHTS[2], 0);
mockProducersToProduce(THROW_FAILURE, null, thirdImage);
mProducer.produceResults(mImageConsumer, mProducerContext);
verify(mImageConsumer).onNewResult(thirdImage, true);
verifyAllProducersRequestedForResults();
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class ThumbnailBranchProducerTest method mockProducersToProduce.
private void mockProducersToProduce(final EncodedImage... images) {
for (int i = 0; i < images.length; i++) {
final EncodedImage image = images[i];
whenProduceResultsCalledTrigger(mThumbnailProducers[i], new ConsumerCallback() {
@Override
public void callback(Consumer<EncodedImage> consumer) {
if (image == THROW_FAILURE) {
consumer.onFailure(new IOException("IMAGE FAILED"));
} else {
consumer.onNewResult(image, true);
}
}
});
}
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class ThumbnailSizeCheckerTest method testWithImageNotBigEnoughForResizeOptions.
private static void testWithImageNotBigEnoughForResizeOptions(int[] imageWidths, int[] imageHeights, int startRotation, int additionalRequestWidth, int additionalRequestHeight) {
for (int rotation = startRotation; rotation < 360; rotation += 180) {
for (int i = 0; i < TEST_COUNT; i++) {
ResizeOptions resizeOptions = new ResizeOptions(REQUEST_WIDTHS[i] + additionalRequestWidth, REQUEST_HEIGHTS[i] + additionalRequestHeight);
EncodedImage encodedImage = mockImage(imageWidths[i], imageHeights[i], rotation);
assertFalse(ThumbnailSizeChecker.isImageBigEnough(encodedImage, resizeOptions));
}
}
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class ThumbnailSizeCheckerTest method mockImage.
private static EncodedImage mockImage(int width, int height, int rotation) {
EncodedImage image = mock(EncodedImage.class);
when(image.getWidth()).thenReturn(width);
when(image.getHeight()).thenReturn(height);
when(image.getRotationAngle()).thenReturn(rotation);
return image;
}
use of com.facebook.imagepipeline.image.EncodedImage in project fresco by facebook.
the class ThumbnailSizeCheckerTest method testWithImageBigEnoughForResizeOptions.
private static void testWithImageBigEnoughForResizeOptions(int[] imageWidths, int[] imageHeights, int startRotation) {
for (int rotation = startRotation; rotation < 360; rotation += 180) {
for (int i = 0; i < TEST_COUNT; i++) {
EncodedImage encodedImage = mockImage(imageWidths[i], imageHeights[i], rotation);
ResizeOptions resizeOptions = new ResizeOptions(REQUEST_WIDTHS[i], REQUEST_HEIGHTS[i]);
assertTrue(ThumbnailSizeChecker.isImageBigEnough(encodedImage, resizeOptions));
}
}
}
Aggregations