use of com.facebook.drawee.drawable.RoundedBitmapDrawable in project fresco by facebook.
the class RoundingUtilsTest method testRoundedDrawablesWithoutBorder_withBitmap_withNotAlreadyRounded_thenReturnBitmapDrawable.
@Test
public void testRoundedDrawablesWithoutBorder_withBitmap_withNotAlreadyRounded_thenReturnBitmapDrawable() {
RoundingUtils roundingUtils = new RoundingUtils();
final Bitmap bitmap = mock(Bitmap.class);
Drawable drawable = roundingUtils.roundedDrawable(mResources, bitmap, null, RoundingOptions.asCircle());
assertThat(drawable).isNotNull();
assertThat(drawable).isInstanceOf(RoundedBitmapDrawable.class);
assertThat(((RoundedBitmapDrawable) drawable).isCircle()).isTrue();
}
use of com.facebook.drawee.drawable.RoundedBitmapDrawable in project fresco by facebook.
the class RoundingUtilsTest method testRoundedDrawablesWithBorder_withDrawable_thenReturnBitmapDrawable.
@Test
public void testRoundedDrawablesWithBorder_withDrawable_thenReturnBitmapDrawable() {
RoundingUtils roundingUtils = new RoundingUtils();
Drawable drawable = mock(BitmapDrawable.class);
RoundingOptions roundingOptions = RoundingOptions.asCircle();
BorderOptions borderOptions = BorderOptions.create(Color.YELLOW, 10);
Drawable result = roundingUtils.roundedDrawable(mResources, drawable, borderOptions, RoundingOptions.asCircle());
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(RoundedBitmapDrawable.class);
assertThat(((RoundedBitmapDrawable) result).getBorderWidth()).isEqualTo(borderOptions.width);
assertThat(((RoundedBitmapDrawable) result).getBorderColor()).isEqualTo(borderOptions.color);
assertThat(((RoundedBitmapDrawable) result).isCircle()).isTrue();
drawable = mock(ColorDrawable.class);
result = roundingUtils.roundedDrawable(mResources, drawable, borderOptions, RoundingOptions.asCircle());
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(RoundedColorDrawable.class);
assertThat(((RoundedColorDrawable) result).getBorderWidth()).isEqualTo(borderOptions.width);
assertThat(((RoundedColorDrawable) result).getBorderColor()).isEqualTo(borderOptions.color);
assertThat(((RoundedColorDrawable) result).isCircle()).isTrue();
drawable = mock(NinePatchDrawable.class);
result = roundingUtils.roundedDrawable(mResources, drawable, borderOptions, RoundingOptions.asCircle());
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(RoundedNinePatchDrawable.class);
assertThat(((RoundedNinePatchDrawable) result).getBorderWidth()).isEqualTo(borderOptions.width);
assertThat(((RoundedNinePatchDrawable) result).getBorderColor()).isEqualTo(borderOptions.color);
assertThat(((RoundedNinePatchDrawable) result).isCircle()).isTrue();
}
use of com.facebook.drawee.drawable.RoundedBitmapDrawable 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.drawee.drawable.RoundedBitmapDrawable in project fresco by facebook.
the class RoundingUtilsTest method testRoundedDrawablesWithoutBorder_withDrawable_thenReturnBitmapDrawable.
@Test
public void testRoundedDrawablesWithoutBorder_withDrawable_thenReturnBitmapDrawable() {
RoundingUtils roundingUtils = new RoundingUtils();
RoundingOptions roundingOptions = RoundingOptions.asCircle();
Drawable drawable = mock(BitmapDrawable.class);
Drawable result = roundingUtils.roundedDrawable(mResources, drawable, null, roundingOptions);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(RoundedBitmapDrawable.class);
assertThat(((RoundedBitmapDrawable) result).isCircle()).isTrue();
drawable = mock(ColorDrawable.class);
result = roundingUtils.roundedDrawable(mResources, drawable, null, roundingOptions);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(RoundedColorDrawable.class);
assertThat(((RoundedColorDrawable) result).isCircle()).isTrue();
drawable = mock(NinePatchDrawable.class);
result = roundingUtils.roundedDrawable(mResources, drawable, null, roundingOptions);
assertThat(result).isNotNull();
assertThat(result).isInstanceOf(RoundedNinePatchDrawable.class);
assertThat(((RoundedNinePatchDrawable) result).isCircle()).isTrue();
}
Aggregations