use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.
the class HierarcherImplTest method testBuildErrorDrawable_whenScaleTypeNull_thenDoNotWrapDrawable.
@Test
public void testBuildErrorDrawable_whenScaleTypeNull_thenDoNotWrapDrawable() {
ImageOptions options = ImageOptions.create().errorRes(RES_ID).errorScaleType(null).build();
Drawable errorDrawable = mHierarcher.buildErrorDrawable(mResources, options);
assertThat(errorDrawable).isEqualTo(mDrawable);
}
use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.
the class HierarcherImplTest method testBuildPlaceholderRes.
@Test
public void testBuildPlaceholderRes() {
ImageOptions options = ImageOptions.create().placeholderRes(RES_ID).build();
Drawable errorDrawable = mHierarcher.buildPlaceholderDrawable(mResources, options);
assertThat(errorDrawable).isNotNull();
assertThat(errorDrawable).isInstanceOf(ScaleTypeDrawable.class);
ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) errorDrawable;
assertThat(scaleTypeDrawable.getScaleType()).isEqualTo(ImageOptions.defaults().getPlaceholderScaleType());
assertThat(scaleTypeDrawable.getFocusPoint()).isEqualTo(ImageOptions.defaults().getPlaceholderFocusPoint());
assertThat(scaleTypeDrawable.getCurrent()).isEqualTo(mDrawable);
}
use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.
the class HierarcherImplTest method testBuildPlaceholderDrawable.
@Test
public void testBuildPlaceholderDrawable() {
final Drawable expected = new ColorDrawable(Color.YELLOW);
ImageOptions options = ImageOptions.create().placeholder(expected).placeholderScaleType(null).build();
final Drawable result = mHierarcher.buildPlaceholderDrawable(mResources, options);
assertThat(result).isEqualTo(expected);
}
use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.
the class BitmapDrawableFactoryTest method testCreateDrawable_whenRoundWithCornerRadii_thenReturnBitmapDrawable.
@Test
public void testCreateDrawable_whenRoundWithCornerRadii_thenReturnBitmapDrawable() {
final CloseableStaticBitmap closeableImage = mock(CloseableStaticBitmap.class);
final Bitmap bitmap = mock(Bitmap.class);
when(closeableImage.getUnderlyingBitmap()).thenReturn(bitmap);
final ImageOptions options = mock(ImageOptions.class);
when(options.getRoundingOptions()).thenReturn(RoundingOptions.forCornerRadii(1, 2, 3, 4));
when(closeableImage.getExtras()).thenReturn(mImageExtrasNotRounded);
Drawable drawable = mDrawableFactory.createDrawable(closeableImage, options);
assertThat(drawable).isNotNull();
assertThat(drawable).isInstanceOf(RoundedBitmapDrawable.class);
assertThat(((RoundedBitmapDrawable) drawable).getRadii()).isEqualTo(new float[] { 1, 1, 2, 2, 3, 3, 4, 4 });
}
use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.
the class BitmapDrawableFactoryTest method testCreateDrawable_whenAlreadyRoundedWithBorder_thenReturnBitmapDrawable.
@Test
public void testCreateDrawable_whenAlreadyRoundedWithBorder_thenReturnBitmapDrawable() {
final CloseableStaticBitmap closeableImage = mock(CloseableStaticBitmap.class);
final Bitmap bitmap = mock(Bitmap.class);
when(closeableImage.getUnderlyingBitmap()).thenReturn(bitmap);
when(closeableImage.getExtras()).thenReturn(mImageExtrasRounded);
final ImageOptions options = mock(ImageOptions.class);
BorderOptions borderOptions = BorderOptions.create(Color.YELLOW, 10);
when(options.getBorderOptions()).thenReturn(borderOptions);
when(options.getRoundingOptions()).thenReturn(RoundingOptions.asCircle(false, false));
Drawable drawable = mDrawableFactory.createDrawable(closeableImage, options);
assertThat(drawable).isNotNull();
assertThat(drawable).isInstanceOf(CircularBorderBitmapDrawable.class);
assertThat(((CircularBorderBitmapDrawable) drawable).getBorder()).isEqualTo(borderOptions);
}
Aggregations