diff options
author | Sam Judd <judds@google.com> | 2014-10-19 13:13:28 -0700 |
---|---|---|
committer | Sam Judd <judds@google.com> | 2014-10-19 13:30:55 -0700 |
commit | 855776275d8ca409f968c8fceff4d11f51bf8592 (patch) | |
tree | c715c2b06dd4fa84f37e76ae34beafaded9c42c9 /third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/GifDecoderTest.java | |
parent | 2c259f532bee14a4f3f6be419bcfb58ef5e22ff5 (diff) | |
download | glide-855776275d8ca409f968c8fceff4d11f51bf8592.tar.gz |
Decode GIFs with more codes than can fit in table.
Fixes #203
Diffstat (limited to 'third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/GifDecoderTest.java')
-rw-r--r-- | third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/GifDecoderTest.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/GifDecoderTest.java b/third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/GifDecoderTest.java new file mode 100644 index 00000000..aaf65558 --- /dev/null +++ b/third_party/gif_decoder/src/androidTest/java/com/bumptech/glide/gifdecoder/GifDecoderTest.java @@ -0,0 +1,51 @@ +package com.bumptech.glide.gifdecoder; + +import android.graphics.Bitmap; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.Robolectric; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +/** + * Tests for {@link com.bumptech.glide.gifdecoder.GifDecoder}. + */ +@RunWith(RobolectricTestRunner.class) +@Config(emulateSdk = 18) +public class GifDecoderTest { + + private MockProvider provider; + + @Before + public void setUp() { + provider = new MockProvider(); + } + + @Test + public void testCanDecodeFramesFromTestGif() { + byte[] data = TestUtil.readResourceData("partial_gif_decode.gif"); + GifHeaderParser headerParser = new GifHeaderParser(); + headerParser.setData(data); + GifHeader header = headerParser.parseHeader(); + GifDecoder decoder = new GifDecoder(provider); + decoder.setData(header, data); + decoder.advance(); + Bitmap bitmap = decoder.getNextFrame(); + assertNotNull(bitmap); + assertEquals(GifDecoder.STATUS_OK, decoder.getStatus()); + } + + private static class MockProvider implements GifDecoder.BitmapProvider { + + @Override + public Bitmap obtain(int width, int height, Bitmap.Config config) { + Bitmap result = Bitmap.createBitmap(width, height, config); + Robolectric.shadowOf(result).setMutable(true); + return result; + } + } +} |