Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tests/CodexTest.cpp

Issue 1273853004: Fix bmp RLE "bug" and add invalid image test to CodexTest (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/codec/SkBmpRLECodec.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Ensure that onGetScaledDimensions returns valid image dimensions to use for d ecodes 259 // Ensure that onGetScaledDimensions returns valid image dimensions to use for d ecodes
260 DEF_TEST(Codec_Dimensions, r) { 260 DEF_TEST(Codec_Dimensions, r) {
261 // JPG 261 // JPG
262 test_dimensions(r, "CMYK.jpg"); 262 test_dimensions(r, "CMYK.jpg");
263 test_dimensions(r, "color_wheel.jpg"); 263 test_dimensions(r, "color_wheel.jpg");
264 test_dimensions(r, "grayscale.jpg"); 264 test_dimensions(r, "grayscale.jpg");
265 test_dimensions(r, "mandrill_512_q075.jpg"); 265 test_dimensions(r, "mandrill_512_q075.jpg");
266 test_dimensions(r, "randPixels.jpg"); 266 test_dimensions(r, "randPixels.jpg");
267 } 267 }
268 268
269 static void test_empty(skiatest::Reporter* r, const char path[]) { 269 static void test_invalid(skiatest::Reporter* r, const char path[]) {
270 SkAutoTDelete<SkStream> stream(resource(path)); 270 SkAutoTDelete<SkStream> stream(resource(path));
271 if (!stream) { 271 if (!stream) {
272 SkDebugf("Missing resource '%s'\n", path); 272 SkDebugf("Missing resource '%s'\n", path);
273 return; 273 return;
274 } 274 }
275 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); 275 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
276 REPORTER_ASSERT(r, NULL == codec); 276 REPORTER_ASSERT(r, NULL == codec);
277 } 277 }
278 278
279 DEF_TEST(Codec_Empty, r) { 279 DEF_TEST(Codec_Empty, r) {
280 // Test images that should not be able to create a codec 280 // Test images that should not be able to create a codec
281 test_empty(r, "empty_images/zero-dims.gif"); 281 test_invalid(r, "empty_images/zero-dims.gif");
282 test_empty(r, "empty_images/zero-embedded.ico"); 282 test_invalid(r, "empty_images/zero-embedded.ico");
283 test_empty(r, "empty_images/zero-width.bmp"); 283 test_invalid(r, "empty_images/zero-width.bmp");
284 test_empty(r, "empty_images/zero-height.bmp"); 284 test_invalid(r, "empty_images/zero-height.bmp");
285 test_empty(r, "empty_images/zero-width.jpg"); 285 test_invalid(r, "empty_images/zero-width.jpg");
286 test_empty(r, "empty_images/zero-height.jpg"); 286 test_invalid(r, "empty_images/zero-height.jpg");
287 test_empty(r, "empty_images/zero-width.png"); 287 test_invalid(r, "empty_images/zero-width.png");
288 test_empty(r, "empty_images/zero-height.png"); 288 test_invalid(r, "empty_images/zero-height.png");
289 test_empty(r, "empty_images/zero-width.wbmp"); 289 test_invalid(r, "empty_images/zero-width.wbmp");
290 test_empty(r, "empty_images/zero-height.wbmp"); 290 test_invalid(r, "empty_images/zero-height.wbmp");
291 // This image is an ico with an embedded mask-bmp. This is illegal.
292 test_invalid(r, "invalid_images/mask-bmp-ico.ico");
291 } 293 }
292 294
293 static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { 295 static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) {
294 SkAutoTDelete<SkStream> stream(resource(path)); 296 SkAutoTDelete<SkStream> stream(resource(path));
295 if (!stream) { 297 if (!stream) {
296 SkDebugf("Missing resource '%s'\n", path); 298 SkDebugf("Missing resource '%s'\n", path);
297 return; 299 return;
298 } 300 }
299 SkAutoTDelete<SkScanlineDecoder> decoder(SkScanlineDecoder::NewFromStream( 301 SkAutoTDelete<SkScanlineDecoder> decoder(SkScanlineDecoder::NewFromStream(
300 stream.detach())); 302 stream.detach()));
(...skipping 16 matching lines...) Expand all
317 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); 319 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
318 result = decoder->start( 320 result = decoder->start(
319 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); 321 decoder->getInfo().makeColorType(kIndex_8_SkColorType));
320 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); 322 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
321 } 323 }
322 324
323 DEF_TEST(Codec_Params, r) { 325 DEF_TEST(Codec_Params, r) {
324 test_invalid_parameters(r, "index8.png"); 326 test_invalid_parameters(r, "index8.png");
325 test_invalid_parameters(r, "mandrill.wbmp"); 327 test_invalid_parameters(r, "mandrill.wbmp");
326 } 328 }
OLDNEW
« no previous file with comments | « src/codec/SkBmpRLECodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698