diff --git a/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/CenterInsideTest.java b/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/CenterInsideTest.java index bcdc8c454e..327360d3f0 100644 --- a/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/CenterInsideTest.java +++ b/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/CenterInsideTest.java @@ -10,9 +10,6 @@ import android.app.Application; import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Matrix; -import android.graphics.Paint; import androidx.test.core.app.ApplicationProvider; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; @@ -33,14 +30,9 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; -import org.robolectric.shadows.ShadowCanvas; @RunWith(RobolectricTestRunner.class) -@Config( - sdk = 18, - shadows = {CenterInsideTest.DrawNothingCanvas.class}) +@Config(sdk = 18) public class CenterInsideTest { @Rule public final KeyTester keyTester = new KeyTester(); @@ -119,14 +111,4 @@ public void testEquals() throws NoSuchAlgorithmException { new CenterInside(), "acf83850a2e8e9e809c8bfb999e2aede9e932cb897a15367fac9856b96f3ba33") .test(); } - - @Implements(Canvas.class) - public static final class DrawNothingCanvas extends ShadowCanvas { - - @Implementation - @Override - public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) { - // Do nothing. - } - } } diff --git a/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/FitCenterTest.java b/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/FitCenterTest.java index 81a9f5691f..7417052145 100644 --- a/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/FitCenterTest.java +++ b/library/test/src/test/java/com/bumptech/glide/load/resource/bitmap/FitCenterTest.java @@ -9,9 +9,6 @@ import android.app.Application; import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Matrix; -import android.graphics.Paint; import androidx.test.core.app.ApplicationProvider; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; @@ -32,14 +29,9 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; -import org.robolectric.shadows.ShadowCanvas; @RunWith(RobolectricTestRunner.class) -@Config( - sdk = 18, - shadows = {FitCenterTest.DrawNothingCanvas.class}) +@Config(sdk = 18) public class FitCenterTest { @Rule public final KeyTester keyTester = new KeyTester(); @@ -103,14 +95,4 @@ public void testEquals() throws NoSuchAlgorithmException { new FitCenter(), "eda03bc6969032145110add4bfe399915897406f4ca3a1a7512d07750e60f90d") .test(); } - - @Implements(Canvas.class) - public static final class DrawNothingCanvas extends ShadowCanvas { - - @Implementation - @Override - public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) { - // Do nothing. - } - } } diff --git a/library/test/src/test/java/com/bumptech/glide/load/resource/gif/GifDrawableTest.java b/library/test/src/test/java/com/bumptech/glide/load/resource/gif/GifDrawableTest.java index 336c03c3d1..1aee6a7dfb 100644 --- a/library/test/src/test/java/com/bumptech/glide/load/resource/gif/GifDrawableTest.java +++ b/library/test/src/test/java/com/bumptech/glide/load/resource/gif/GifDrawableTest.java @@ -31,12 +31,9 @@ import androidx.test.core.app.ApplicationProvider; import com.bumptech.glide.gifdecoder.GifDecoder; import com.bumptech.glide.load.Transformation; -import com.bumptech.glide.load.resource.gif.GifDrawableTest.BitmapTrackingShadowCanvas; import com.bumptech.glide.tests.TearDownGlide; import com.bumptech.glide.tests.Util; import com.bumptech.glide.util.Preconditions; -import java.util.HashSet; -import java.util.Set; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -47,15 +44,11 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; import org.robolectric.shadow.api.Shadow; import org.robolectric.shadows.ShadowCanvas; @RunWith(RobolectricTestRunner.class) -@Config( - sdk = 18, - shadows = {BitmapTrackingShadowCanvas.class}) +@Config(sdk = 18) public class GifDrawableTest { @Rule public final TearDownGlide tearDownGlide = new TearDownGlide(); @@ -100,15 +93,19 @@ public void tearDown() { Util.setSdkVersionInt(initialSdkVersion); } - // containsExactly doesn't need its return value checked. - @SuppressWarnings("ResultOfMethodCallIgnored") @Test public void testShouldDrawFirstFrameBeforeAnyFrameRead() { Canvas canvas = new Canvas(); drawable.draw(canvas); - BitmapTrackingShadowCanvas shadowCanvas = Shadow.extract(canvas); - assertThat(shadowCanvas.getDrawnBitmaps()).containsExactly(firstFrame); + ShadowCanvas shadowCanvas = Shadow.extract(canvas); + assertThat(shadowCanvas.getDescription()) + .isEqualTo( + "Bitmap (" + + firstFrame.getWidth() + + " x " + + firstFrame.getHeight() + + ") at (0,0) with height=0 and width=0"); } @Test @@ -633,20 +630,4 @@ private void runLoops(int loopCount, int frameCount) { } } } - - /** Keeps track of the set of Bitmaps drawn to the canvas. */ - @Implements(Canvas.class) - public static final class BitmapTrackingShadowCanvas extends ShadowCanvas { - private final Set drawnBitmaps = new HashSet<>(); - - @Implementation - @Override - public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) { - drawnBitmaps.add(bitmap); - } - - private Iterable getDrawnBitmaps() { - return drawnBitmaps; - } - } }