| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 // This tests out GIF decoder (SkImageDecoder_libgif.cpp) | 8 // This tests out GIF decoder (SkImageDecoder_libgif.cpp) |
| 9 // It is not used on these platforms: | 9 // It is not used on these platforms: |
| 10 #if (!defined(SK_BUILD_FOR_WIN32)) && \ | 10 #if (!defined(SK_BUILD_FOR_WIN32)) && \ |
| 11 (!defined(SK_BUILD_FOR_IOS)) && \ | 11 (!defined(SK_BUILD_FOR_IOS)) && \ |
| 12 (!defined(SK_BUILD_FOR_MAC)) | 12 (!defined(SK_BUILD_FOR_MAC)) |
| 13 | 13 |
| 14 #include "Test.h" |
| 15 #include "TestClassDef.h" |
| 14 #include "SkBitmap.h" | 16 #include "SkBitmap.h" |
| 15 #include "SkData.h" | 17 #include "SkData.h" |
| 16 #include "SkForceLinking.h" | 18 #include "SkForceLinking.h" |
| 19 #include "SkImage.h" |
| 17 #include "SkImageDecoder.h" | 20 #include "SkImageDecoder.h" |
| 18 #include "SkImage.h" | |
| 19 #include "SkStream.h" | 21 #include "SkStream.h" |
| 20 #include "Test.h" | |
| 21 | 22 |
| 22 __SK_FORCE_IMAGE_DECODER_LINKING; | 23 __SK_FORCE_IMAGE_DECODER_LINKING; |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 unsigned char gifData[] = { | 26 unsigned char gifData[] = { |
| 26 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x03, 0x00, | 27 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x03, 0x00, |
| 27 0x03, 0x00, 0xe3, 0x08, 0x00, 0x00, 0x00, 0x00, | 28 0x03, 0x00, 0xe3, 0x08, 0x00, 0x00, 0x00, 0x00, |
| 28 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, | 29 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, |
| 29 0xff, 0x80, 0x80, 0x80, 0x00, 0xff, 0x00, 0x00, | 30 0xff, 0x80, 0x80, 0x80, 0x00, 0xff, 0x00, 0x00, |
| 30 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, | 31 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 REPORTER_ASSERT(r, bm.getColor(1, 1) == 0xff000000); | 141 REPORTER_ASSERT(r, bm.getColor(1, 1) == 0xff000000); |
| 141 REPORTER_ASSERT(r, bm.getColor(2, 1) == 0xff00ff00); | 142 REPORTER_ASSERT(r, bm.getColor(2, 1) == 0xff00ff00); |
| 142 } | 143 } |
| 143 } | 144 } |
| 144 | 145 |
| 145 /** | 146 /** |
| 146 This test will test the ability of the SkImageDecoder to deal with | 147 This test will test the ability of the SkImageDecoder to deal with |
| 147 GIF files which have been mangled somehow. We want to display as | 148 GIF files which have been mangled somehow. We want to display as |
| 148 much of the GIF as possible. | 149 much of the GIF as possible. |
| 149 */ | 150 */ |
| 150 static void TestGif(skiatest::Reporter* reporter) { | 151 DEF_TEST(Gif, reporter) { |
| 151 // test perfectly good images. | 152 // test perfectly good images. |
| 152 test_gif_data(reporter, static_cast<void *>(gifData), sizeof(gifData)); | 153 test_gif_data(reporter, static_cast<void *>(gifData), sizeof(gifData)); |
| 153 test_interlaced_gif_data(reporter, static_cast<void *>(interlacedGif), | 154 test_interlaced_gif_data(reporter, static_cast<void *>(interlacedGif), |
| 154 sizeof(interlacedGif)); | 155 sizeof(interlacedGif)); |
| 155 | 156 |
| 156 unsigned char badData[sizeof(gifData)]; | 157 unsigned char badData[sizeof(gifData)]; |
| 157 | 158 |
| 158 /* If you set the environment variable | 159 /* If you set the environment variable |
| 159 skia_images_gif_suppressDecoderWarnings to 'false', you will | 160 skia_images_gif_suppressDecoderWarnings to 'false', you will |
| 160 see warnings on stderr. This is a feature. */ | 161 see warnings on stderr. This is a feature. */ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 198 |
| 198 // test short Gif. 80 is missing a few bytes. | 199 // test short Gif. 80 is missing a few bytes. |
| 199 test_gif_data_short(reporter, static_cast<void *>(gifData), 80); | 200 test_gif_data_short(reporter, static_cast<void *>(gifData), 80); |
| 200 // "libgif warning [DGifGetLine]" | 201 // "libgif warning [DGifGetLine]" |
| 201 | 202 |
| 202 test_interlaced_gif_data(reporter, static_cast<void *>(interlacedGif), | 203 test_interlaced_gif_data(reporter, static_cast<void *>(interlacedGif), |
| 203 100); // 100 is missing a few bytes | 204 100); // 100 is missing a few bytes |
| 204 // "libgif warning [interlace DGifGetLine]" | 205 // "libgif warning [interlace DGifGetLine]" |
| 205 } | 206 } |
| 206 | 207 |
| 207 #include "TestClassDef.h" | |
| 208 DEFINE_TESTCLASS("GifTest", GifTestClass, TestGif) | |
| 209 | |
| 210 #endif // !(SK_BUILD_FOR_WIN32||SK_BUILD_FOR_IOS||SK_BUILD_FOR_MAC) | 208 #endif // !(SK_BUILD_FOR_WIN32||SK_BUILD_FOR_IOS||SK_BUILD_FOR_MAC) |
| OLD | NEW |