use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.
the class HierarcherImplTest method testBuildErrorDrawable_whenNoScaleTypeSet_thenUseDefaultScaleType.
@Test
public void testBuildErrorDrawable_whenNoScaleTypeSet_thenUseDefaultScaleType() {
ImageOptions options = ImageOptions.create().errorRes(RES_ID).build();
Drawable errorDrawable = mHierarcher.buildErrorDrawable(mResources, options);
assertThat(errorDrawable).isNotNull();
assertThat(errorDrawable).isInstanceOf(ScaleTypeDrawable.class);
ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) errorDrawable;
assertThat(scaleTypeDrawable.getScaleType()).isEqualTo(ImageOptions.defaults().getErrorScaleType());
assertThat(scaleTypeDrawable.getFocusPoint()).isEqualTo(ImageOptions.defaults().getErrorFocusPoint());
assertThat(scaleTypeDrawable.getCurrent()).isEqualTo(mDrawable);
}
use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.
the class HierarcherImplTest method testBuildProgressDrawable.
@Test
public void testBuildProgressDrawable() {
final Drawable drawable = new ColorDrawable(0x0);
final ImageOptions imageOptions = ImageOptions.create().progress(drawable).progressScaleType(ScalingUtils.ScaleType.FIT_CENTER).build();
final Drawable actual = mHierarcher.buildProgressDrawable(mResources, imageOptions);
assertThat(actual).isInstanceOf(ScaleTypeDrawable.class);
final ScaleTypeDrawable scaleTypeActual = (ScaleTypeDrawable) actual;
assertThat(scaleTypeActual.getScaleType()).isEqualTo(ScalingUtils.ScaleType.FIT_CENTER);
assertThat(scaleTypeActual.getCurrent()).isEqualTo(drawable);
}
use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.
the class HierarcherImplTest method testApplyRoundingOptions_whenRoundWithCornerRadius_thenReturnDrawable.
@Test
public void testApplyRoundingOptions_whenRoundWithCornerRadius_thenReturnDrawable() {
final BitmapDrawable drawable = mock(BitmapDrawable.class);
final Bitmap bitmap = mock(Bitmap.class);
when(drawable.getBitmap()).thenReturn(bitmap);
ImageOptions options = mock(ImageOptions.class);
when(options.getRoundingOptions()).thenReturn(RoundingOptions.forCornerRadiusPx(123));
when(options.getPlaceholderDrawable()).thenReturn(drawable);
when(options.getPlaceholderApplyRoundingOptions()).thenReturn(true);
Drawable result = mHierarcher.buildPlaceholderDrawable(mResources, options);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(RoundedBitmapDrawable.class);
assertThat(((RoundedBitmapDrawable) result).getRadii()).isEqualTo(new float[] { 123, 123, 123, 123, 123, 123, 123, 123 });
}
use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.
the class HierarcherImplTest method testApplyRoundingOptions_whenRoundWithCornerRadii_thenReturnDrawable.
@Test
public void testApplyRoundingOptions_whenRoundWithCornerRadii_thenReturnDrawable() {
final BitmapDrawable drawable = mock(BitmapDrawable.class);
final Bitmap bitmap = mock(Bitmap.class);
when(drawable.getBitmap()).thenReturn(bitmap);
ImageOptions options = mock(ImageOptions.class);
when(options.getRoundingOptions()).thenReturn(RoundingOptions.forCornerRadii(1, 2, 3, 4));
when(options.getPlaceholderDrawable()).thenReturn(drawable);
when(options.getPlaceholderApplyRoundingOptions()).thenReturn(true);
Drawable result = mHierarcher.buildPlaceholderDrawable(mResources, options);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(RoundedBitmapDrawable.class);
assertThat(((RoundedBitmapDrawable) result).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 HierarcherImplTest method testBuildErrorDrawable_whenInvalidResId_thenThrowNotFoundException.
@Test(expected = Resources.NotFoundException.class)
public void testBuildErrorDrawable_whenInvalidResId_thenThrowNotFoundException() {
ImageOptions options = ImageOptions.create().errorRes(INVALID_RES_ID).build();
mHierarcher.buildErrorDrawable(mResources, options);
}
Aggregations