|
31 | 31 | import androidx.test.core.app.ApplicationProvider;
|
32 | 32 | import com.bumptech.glide.gifdecoder.GifDecoder;
|
33 | 33 | import com.bumptech.glide.load.Transformation;
|
34 |
| -import com.bumptech.glide.load.resource.gif.GifDrawableTest.BitmapTrackingShadowCanvas; |
35 | 34 | import com.bumptech.glide.tests.TearDownGlide;
|
36 | 35 | import com.bumptech.glide.tests.Util;
|
37 | 36 | import com.bumptech.glide.util.Preconditions;
|
38 |
| -import java.util.HashSet; |
39 |
| -import java.util.Set; |
40 | 37 | import org.junit.After;
|
41 | 38 | import org.junit.Before;
|
42 | 39 | import org.junit.Rule;
|
|
47 | 44 | import org.mockito.MockitoAnnotations;
|
48 | 45 | import org.robolectric.RobolectricTestRunner;
|
49 | 46 | import org.robolectric.annotation.Config;
|
50 |
| -import org.robolectric.annotation.Implementation; |
51 |
| -import org.robolectric.annotation.Implements; |
52 | 47 | import org.robolectric.shadow.api.Shadow;
|
53 | 48 | import org.robolectric.shadows.ShadowCanvas;
|
54 | 49 |
|
55 | 50 | @RunWith(RobolectricTestRunner.class)
|
56 |
| -@Config( |
57 |
| - sdk = 18, |
58 |
| - shadows = {BitmapTrackingShadowCanvas.class}) |
| 51 | +@Config(sdk = 18) |
59 | 52 | public class GifDrawableTest {
|
60 | 53 | @Rule public final TearDownGlide tearDownGlide = new TearDownGlide();
|
61 | 54 |
|
@@ -100,15 +93,19 @@ public void tearDown() {
|
100 | 93 | Util.setSdkVersionInt(initialSdkVersion);
|
101 | 94 | }
|
102 | 95 |
|
103 |
| - // containsExactly doesn't need its return value checked. |
104 |
| - @SuppressWarnings("ResultOfMethodCallIgnored") |
105 | 96 | @Test
|
106 | 97 | public void testShouldDrawFirstFrameBeforeAnyFrameRead() {
|
107 | 98 | Canvas canvas = new Canvas();
|
108 | 99 | drawable.draw(canvas);
|
109 | 100 |
|
110 |
| - BitmapTrackingShadowCanvas shadowCanvas = Shadow.extract(canvas); |
111 |
| - assertThat(shadowCanvas.getDrawnBitmaps()).containsExactly(firstFrame); |
| 101 | + ShadowCanvas shadowCanvas = Shadow.extract(canvas); |
| 102 | + assertThat(shadowCanvas.getDescription()) |
| 103 | + .isEqualTo( |
| 104 | + "Bitmap (" |
| 105 | + + firstFrame.getWidth() |
| 106 | + + " x " |
| 107 | + + firstFrame.getHeight() |
| 108 | + + ") at (0,0) with height=0 and width=0"); |
112 | 109 | }
|
113 | 110 |
|
114 | 111 | @Test
|
@@ -633,20 +630,4 @@ private void runLoops(int loopCount, int frameCount) {
|
633 | 630 | }
|
634 | 631 | }
|
635 | 632 | }
|
636 |
| - |
637 |
| - /** Keeps track of the set of Bitmaps drawn to the canvas. */ |
638 |
| - @Implements(Canvas.class) |
639 |
| - public static final class BitmapTrackingShadowCanvas extends ShadowCanvas { |
640 |
| - private final Set<Bitmap> drawnBitmaps = new HashSet<>(); |
641 |
| - |
642 |
| - @Implementation |
643 |
| - @Override |
644 |
| - public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) { |
645 |
| - drawnBitmaps.add(bitmap); |
646 |
| - } |
647 |
| - |
648 |
| - private Iterable<Bitmap> getDrawnBitmaps() { |
649 |
| - return drawnBitmaps; |
650 |
| - } |
651 |
| - } |
652 | 633 | }
|
0 commit comments