diff --git a/library/test/src/test/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPoolTest.java b/library/test/src/test/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPoolTest.java index 35af88e7dd..7c303ea4ca 100644 --- a/library/test/src/test/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPoolTest.java +++ b/library/test/src/test/java/com/bumptech/glide/load/engine/bitmap_recycle/LruBitmapPoolTest.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; -import org.robolectric.Shadows; import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) @@ -52,8 +51,9 @@ public void testICanAddAndGetABitmap() { @Test public void testImmutableBitmapsAreNotAdded() { Bitmap bitmap = createMutableBitmap(); - Shadows.shadowOf(bitmap).setMutable(false); - pool.put(bitmap); + Bitmap immutable = bitmap.copy(Bitmap.Config.ARGB_8888, /*isMutable=*/ false); + assertThat(immutable.isMutable()).isFalse(); + pool.put(immutable); assertThat(strategy.bitmaps).isEmpty(); } @@ -249,7 +249,7 @@ private Bitmap createMutableBitmap() { private Bitmap createMutableBitmap(Bitmap.Config config) { Bitmap bitmap = Bitmap.createBitmap(100, 100, config); - Shadows.shadowOf(bitmap).setMutable(true); + assertThat(bitmap.isMutable()).isTrue(); return bitmap; } diff --git a/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/TransformationUtilsTest.java b/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/TransformationUtilsTest.java index bfbd22c5ca..01bc7d3b81 100644 --- a/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/TransformationUtilsTest.java +++ b/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/TransformationUtilsTest.java @@ -13,6 +13,7 @@ import static org.mockito.Mockito.when; import android.graphics.Bitmap; +import android.graphics.Color; import android.graphics.Matrix; import androidx.exifinterface.media.ExifInterface; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; @@ -350,12 +351,20 @@ public void testGetExifOrientationDegrees() { @Test public void testRotateImage() { Bitmap toRotate = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888); - + toRotate.setPixel(0, 0, Color.BLUE); + toRotate.setPixel(0, 1, Color.RED); Bitmap zero = TransformationUtils.rotateImage(toRotate, 0); assertTrue(toRotate == zero); Bitmap ninety = TransformationUtils.rotateImage(toRotate, 90); - assertThat(Shadows.shadowOf(ninety).getDescription()).contains("rotate=90.0"); + // Checks if native graphics is enabled. + if (Boolean.getBoolean("robolectric.nativeruntime.enableGraphics")) { + assertThat(ninety.getPixel(0, 0)).isEqualTo(Color.RED); + assertThat(ninety.getPixel(1, 0)).isEqualTo(Color.BLUE); + } else { + // Use legacy shadow APIs + assertThat(Shadows.shadowOf(ninety).getDescription()).contains("rotate=90.0"); + } assertEquals(toRotate.getWidth(), toRotate.getHeight()); }