use of android.graphics.drawable.BitmapDrawable in project robolectric by robolectric.
the class ShadowBitmapDrawableTest method withColorFilterSet_draw_shouldCopyDescriptionToCanvas.
@Test
public void withColorFilterSet_draw_shouldCopyDescriptionToCanvas() throws Exception {
BitmapDrawable drawable = (BitmapDrawable) resources.getDrawable(R.drawable.an_image);
drawable.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix()));
Canvas canvas = new Canvas();
drawable.draw(canvas);
assertThat(shadowOf(canvas).getDescription()).isEqualTo("Bitmap for resource:org.robolectric:drawable/an_image with ColorMatrixColorFilter<1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0>");
}
use of android.graphics.drawable.BitmapDrawable in project robolectric by robolectric.
the class ShadowBitmapDrawableTest method constructors_shouldSetBitmap.
@Test
public void constructors_shouldSetBitmap() throws Exception {
Bitmap bitmap = Shadow.newInstanceOf(Bitmap.class);
BitmapDrawable drawable = new BitmapDrawable(bitmap);
assertThat(drawable.getBitmap()).isEqualTo(bitmap);
drawable = new BitmapDrawable(resources, bitmap);
assertThat(drawable.getBitmap()).isEqualTo(bitmap);
}
use of android.graphics.drawable.BitmapDrawable in project robolectric by robolectric.
the class ShadowBitmapDrawableTest method constructor_shouldSetTheIntrinsicWidthAndHeightToTheWidthAndHeightOfTheBitmap.
@Test
public void constructor_shouldSetTheIntrinsicWidthAndHeightToTheWidthAndHeightOfTheBitmap() throws Exception {
Bitmap bitmap = Bitmap.createBitmap(5, 10, Bitmap.Config.ARGB_8888);
BitmapDrawable drawable = new BitmapDrawable(RuntimeEnvironment.application.getResources(), bitmap);
assertThat(drawable.getIntrinsicWidth()).isEqualTo(5);
assertThat(drawable.getIntrinsicHeight()).isEqualTo(10);
}
use of android.graphics.drawable.BitmapDrawable in project robolectric by robolectric.
the class DrawableAssert method isResource.
public void isResource(int resourceId) {
assertThat(actual).isInstanceOf(BitmapDrawable.class);
BitmapDrawable bitmapDrawable = (BitmapDrawable) actual;
assertThat(shadowOf(bitmapDrawable.getBitmap()).getCreatedFromResId()).isEqualTo(resourceId);
}
use of android.graphics.drawable.BitmapDrawable in project robolectric by robolectric.
the class ShadowViewTest method shouldRecordBackgroundDrawable.
@Test
public void shouldRecordBackgroundDrawable() {
Drawable drawable = new BitmapDrawable(BitmapFactory.decodeFile("some/fake/file"));
view.setBackgroundDrawable(drawable);
assertThat(view.getBackground()).isSameAs(drawable);
assertThat(ShadowView.visualize(view)).isEqualTo("background:\nBitmap for file:some/fake/file");
}
Aggregations