OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "Resources.h" | 8 #include "Resources.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Ensure that onGetScaledDimensions returns valid image dimensions to use for d
ecodes | 189 // Ensure that onGetScaledDimensions returns valid image dimensions to use for d
ecodes |
190 DEF_TEST(Codec_Dimensions, r) { | 190 DEF_TEST(Codec_Dimensions, r) { |
191 // JPG | 191 // JPG |
192 test_dimensions(r, "CMYK.jpg"); | 192 test_dimensions(r, "CMYK.jpg"); |
193 test_dimensions(r, "color_wheel.jpg"); | 193 test_dimensions(r, "color_wheel.jpg"); |
194 test_dimensions(r, "grayscale.jpg"); | 194 test_dimensions(r, "grayscale.jpg"); |
195 test_dimensions(r, "mandrill_512_q075.jpg"); | 195 test_dimensions(r, "mandrill_512_q075.jpg"); |
196 test_dimensions(r, "randPixels.jpg"); | 196 test_dimensions(r, "randPixels.jpg"); |
197 } | 197 } |
198 | 198 |
| 199 static void test_empty(skiatest::Reporter* r, const char path[]) { |
| 200 SkAutoTDelete<SkStream> stream(resource(path)); |
| 201 if (!stream) { |
| 202 SkDebugf("Missing resource '%s'\n", path); |
| 203 return; |
| 204 } |
| 205 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); |
| 206 REPORTER_ASSERT(r, NULL == codec); |
| 207 } |
199 | 208 |
200 | 209 DEF_TEST(Codec_Empty, r) { |
| 210 // Test images that should not be able to create a codec |
| 211 test_empty(r, "empty_images/zero-dims.gif"); |
| 212 test_empty(r, "empty_images/zero-embedded.ico"); |
| 213 test_empty(r, "empty_images/zero-width.bmp"); |
| 214 test_empty(r, "empty_images/zero-height.bmp"); |
| 215 test_empty(r, "empty_images/zero-width.jpg"); |
| 216 test_empty(r, "empty_images/zero-height.jpg"); |
| 217 test_empty(r, "empty_images/zero-width.png"); |
| 218 test_empty(r, "empty_images/zero-height.png"); |
| 219 test_empty(r, "empty_images/zero-width.wbmp"); |
| 220 test_empty(r, "empty_images/zero-height.wbmp"); |
| 221 } |
OLD | NEW |