aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GifTest.cpp
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2015-05-14 14:44:13 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-14 14:44:14 -0700
commit9d214295e47405019d1494182a5182a92a22f0a6 (patch)
tree03ced2997834241035afb0b0702f25b54019a1ce /tests/GifTest.cpp
parent87a773c5b197964cb0ae67dc8bb402d7557be6ca (diff)
Add a test for decoding a gif with sampleSize 4.
Prior to https://codereview.chromium.org/1085253002/, this would crash. Only happens with interlaced gif images with an odd height. (Maybe there are more restrictions?) Test image provided by zoran.jovanovic@sonymobile.com for checking in. Add include before includes. Review URL: https://codereview.chromium.org/1091053002
Diffstat (limited to 'tests/GifTest.cpp')
-rw-r--r--tests/GifTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/GifTest.cpp b/tests/GifTest.cpp
index e2e03845ca..978e374539 100644
--- a/tests/GifTest.cpp
+++ b/tests/GifTest.cpp
@@ -5,12 +5,15 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+
// This tests out GIF decoder (SkImageDecoder_libgif.cpp)
// It is not used on these platforms:
#if (!defined(SK_BUILD_FOR_WIN32)) && \
(!defined(SK_BUILD_FOR_IOS)) && \
(!defined(SK_BUILD_FOR_MAC))
+#include "Resources.h"
#include "SkBitmap.h"
#include "SkData.h"
#include "SkForceLinking.h"
@@ -197,4 +200,25 @@ DEF_TEST(Gif, reporter) {
// "libgif warning [interlace DGifGetLine]"
}
+// Regression test for decoding a gif image with sampleSize of 4, which was
+// previously crashing.
+DEF_TEST(Gif_Sampled, r) {
+ SkFILEStream fileStream(GetResourcePath("test640x479.gif").c_str());
+ REPORTER_ASSERT(r, fileStream.isValid());
+ if (!fileStream.isValid()) {
+ return;
+ }
+
+ SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&fileStream));
+ REPORTER_ASSERT(r, decoder);
+ if (!decoder) {
+ return;
+ }
+ decoder->setSampleSize(4);
+ SkBitmap bm;
+ const SkImageDecoder::Result result = decoder->decode(&fileStream, &bm,
+ SkImageDecoder::kDecodePixels_Mode);
+ REPORTER_ASSERT(r, result == SkImageDecoder::kSuccess);
+}
+
#endif // !(SK_BUILD_FOR_WIN32||SK_BUILD_FOR_IOS||SK_BUILD_FOR_MAC)