Add a test for BitmapDrawable#setBitmap
Bug: 154628299
Test: this
Change-Id: I20d4f94a145474394bc660368d9ddd1897001f4a
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java
index 60f7b0a..a371932 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java
@@ -559,4 +559,19 @@
resources.getDrawable(R.drawable.testimage).setAlpha(restoreAlpha);
}
}
+
+ @Test
+ public void testSetBitmap() {
+ Resources resources = mContext.getResources();
+ Bitmap source = BitmapFactory.decodeResource(resources, R.raw.testimage);
+ BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, source);
+ assertSame(source, bitmapDrawable.getBitmap());
+
+ Bitmap bm = Bitmap.createBitmap(100, 100, Config.ARGB_8888);
+ bitmapDrawable.setBitmap(bm);
+ assertSame(bm, bitmapDrawable.getBitmap());
+
+ bitmapDrawable.setBitmap(null);
+ assertNull(bitmapDrawable.getBitmap());
+ }
}