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

Side by Side Diff: tests/ImageDecodingTest.cpp

Issue 132843002: Add REPORTF test macro. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « tests/GpuBitmapCopyTest.cpp ('k') | tests/MathTest.cpp » ('j') | 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 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 #include "Test.h" 8 #include "Test.h"
9 #include "TestClassDef.h" 9 #include "TestClassDef.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 SkDecodingImageGenerator::Create(encodedStream->duplicate(), opts), 436 SkDecodingImageGenerator::Create(encodedStream->duplicate(), opts),
437 &bm, NULL); 437 &bm, NULL);
438 } 438 }
439 if (!success) { 439 if (!success) {
440 if (opts.fUseRequestedColorType 440 if (opts.fUseRequestedColorType
441 && (kARGB_4444_SkColorType == opts.fRequestedColorType)) { 441 && (kARGB_4444_SkColorType == opts.fRequestedColorType)) {
442 return; // Ignore known conversion inabilities. 442 return; // Ignore known conversion inabilities.
443 } 443 }
444 // If we get here, it's a failure and we will need more 444 // If we get here, it's a failure and we will need more
445 // information about why it failed. 445 // information about why it failed.
446 reporter->reportFailed(SkStringPrintf( 446 const char* colorTypeDesc
447 "Bounds decode failed " 447 = opts.fUseRequestedColorType
bungeman-skia 2014/01/09 23:43:56 With the line breaks like this, this is really har
hal.canary 2014/01/10 13:20:33 Fixed.
448 "[sampleSize=%d dither=%s colorType=%s %s] %s:%d", 448 ? SkColorType_to_string(opts.fRequestedColorType) : "(none)";
449 opts.fSampleSize, (opts.fDitherImage ? "yes" : "no"), 449 REPORTF(reporter,
450 (opts.fUseRequestedColorType 450 ("Bounds decode failed [sampleSize=%d dither=%s colorType=%s"
451 ? SkColorType_to_string(opts.fRequestedColorType) : "(none)"), 451 " %s]", opts.fSampleSize, (opts.fDitherImage ? "yes" : "no"),
452 path.c_str(), __FILE__, __LINE__)); 452 colorTypeDesc, path.c_str()));
453 return; 453 return;
454 } 454 }
455 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX) 455 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
456 // Android is the only system that use Skia's image decoders in 456 // Android is the only system that use Skia's image decoders in
457 // production. For now, we'll only verify that samplesize works 457 // production. For now, we'll only verify that samplesize works
458 // on systems where it already is known to work. 458 // on systems where it already is known to work.
459 REPORTER_ASSERT(reporter, check_rounding(bm.height(), kExpectedHeight, 459 REPORTER_ASSERT(reporter, check_rounding(bm.height(), kExpectedHeight,
460 opts.fSampleSize)); 460 opts.fSampleSize));
461 REPORTER_ASSERT(reporter, check_rounding(bm.width(), kExpectedWidth, 461 REPORTER_ASSERT(reporter, check_rounding(bm.width(), kExpectedWidth,
462 opts.fSampleSize)); 462 opts.fSampleSize));
463 #endif // SK_BUILD_FOR_ANDROID || SK_BUILD_FOR_UNIX 463 #endif // SK_BUILD_FOR_ANDROID || SK_BUILD_FOR_UNIX
464 SkAutoLockPixels alp(bm); 464 SkAutoLockPixels alp(bm);
465 if (bm.getPixels() == NULL) { 465 if (bm.getPixels() == NULL) {
466 reporter->reportFailed(SkStringPrintf( 466 const char* colorTypeDesc
467 "Pixel decode failed " 467 = opts.fUseRequestedColorType
468 "[sampleSize=%d dither=%s colorType=%s %s] %s:%d", 468 ? SkColorType_to_string(opts.fRequestedColorType) : "(none)";
469 opts.fSampleSize, (opts.fDitherImage ? "yes" : "no"), 469 REPORTF(reporter,
470 (opts.fUseRequestedColorType 470 ("Pixel decode failed [sampleSize=%d dither=%s colorType=%s"
471 ? SkColorType_to_string(opts.fRequestedColorType) : "(none)"), 471 " %s]", opts.fSampleSize, (opts.fDitherImage ? "yes" : "no"),
472 path.c_str(), __FILE__, __LINE__)); 472 colorTypeDesc, path.c_str()));
473 return; 473 return;
474 } 474 }
475 475
476 SkBitmap::Config requestedConfig 476 SkBitmap::Config requestedConfig
477 = SkColorTypeToBitmapConfig(opts.fRequestedColorType); 477 = SkColorTypeToBitmapConfig(opts.fRequestedColorType);
478 REPORTER_ASSERT(reporter, 478 REPORTER_ASSERT(reporter,
479 (!opts.fUseRequestedColorType) 479 (!opts.fUseRequestedColorType)
480 || (bm.config() == requestedConfig)); 480 || (bm.config() == requestedConfig));
481 481
482 // Condition under which we should check the decoding results: 482 // Condition under which we should check the decoding results:
483 if ((SkBitmap::kARGB_8888_Config == bm.config()) 483 if ((SkBitmap::kARGB_8888_Config == bm.config())
484 && (!path.endsWith(".jpg")) // lossy 484 && (!path.endsWith(".jpg")) // lossy
485 && (opts.fSampleSize == 1)) { // scaled 485 && (opts.fSampleSize == 1)) { // scaled
486 const SkColor* correctPixels = kExpectedPixels; 486 const SkColor* correctPixels = kExpectedPixels;
487 SkASSERT(bm.height() == kExpectedHeight); 487 SkASSERT(bm.height() == kExpectedHeight);
488 SkASSERT(bm.width() == kExpectedWidth); 488 SkASSERT(bm.width() == kExpectedWidth);
489 int pixelErrors = 0; 489 int pixelErrors = 0;
490 for (int y = 0; y < bm.height(); ++y) { 490 for (int y = 0; y < bm.height(); ++y) {
491 for (int x = 0; x < bm.width(); ++x) { 491 for (int x = 0; x < bm.width(); ++x) {
492 if (*correctPixels != bm.getColor(x, y)) { 492 if (*correctPixels != bm.getColor(x, y)) {
493 ++pixelErrors; 493 ++pixelErrors;
494 } 494 }
495 ++correctPixels; 495 ++correctPixels;
496 } 496 }
497 } 497 }
498 if (pixelErrors != 0) { 498 if (pixelErrors != 0) {
499 reporter->reportFailed(SkStringPrintf( 499 const char* colorTypeDesc
500 "Pixel-level mismatch (%d of %d) [sampleSize=%d " 500 = opts.fUseRequestedColorType
501 "dither=%s colorType=%s %s] %s:%d", 501 ? SkColorType_to_string(opts.fRequestedColorType) : "(none)";
502 pixelErrors, kExpectedHeight * kExpectedWidth, 502 REPORTF(reporter,
503 opts.fSampleSize, (opts.fDitherImage ? "yes" : "no"), 503 ("Pixel-level mismatch (%d of %d) [sampleSize=%d "
504 (opts.fUseRequestedColorType 504 "dither=%s colorType=%s %s]",
505 ? SkColorType_to_string(opts.fRequestedColorType) 505 pixelErrors, kExpectedHeight * kExpectedWidth,
506 : "(none)"), path.c_str(), __FILE__, __LINE__)); 506 opts.fSampleSize, (opts.fDitherImage ? "yes" : "no"),
507 colorTypeDesc, path.c_str()));
507 } 508 }
508 } 509 }
509 } 510 }
510 511
511 /** 512 /**
512 * SkDecodingImageGenerator has an Options struct which lets the 513 * SkDecodingImageGenerator has an Options struct which lets the
513 * client of the generator set sample size, dithering, and bitmap 514 * client of the generator set sample size, dithering, and bitmap
514 * config. This test loops through many possible options and tries 515 * config. This test loops through many possible options and tries
515 * them on a set of 5 small encoded images (each in a different 516 * them on a set of 5 small encoded images (each in a different
516 * format). We test both SkData and SkStreamRewindable decoding. 517 * format). We test both SkData and SkStreamRewindable decoding.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 SkDecodingImageGenerator::Options options(scaleList[i], 572 SkDecodingImageGenerator::Options options(scaleList[i],
572 ditherList[j]); 573 ditherList[j]);
573 test_options(reporter, options, encodedStream, encodedData, 574 test_options(reporter, options, encodedStream, encodedData,
574 useDataList[m], path); 575 useDataList[m], path);
575 } 576 }
576 } 577 }
577 } 578 }
578 } 579 }
579 } 580 }
580 //////////////////////////////////////////////////////////////////////////////// 581 ////////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « tests/GpuBitmapCopyTest.cpp ('k') | tests/MathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698