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

Side by Side Diff: tests/JpegTest.cpp

Issue 100113004: Use DEFINE_TESTCLASS_SHORT macro in tests. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years 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/InfRectTest.cpp ('k') | tests/LListTest.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"
9 #include "TestClassDef.h"
8 #include "SkBitmap.h" 10 #include "SkBitmap.h"
9 #include "SkData.h" 11 #include "SkData.h"
10 #include "SkForceLinking.h" 12 #include "SkForceLinking.h"
11 #include "SkImageDecoder.h" 13 #include "SkImageDecoder.h"
12 #include "SkImage.h" 14 #include "SkImage.h"
13 #include "SkStream.h" 15 #include "SkStream.h"
14 #include "Test.h"
15 16
16 __SK_FORCE_IMAGE_DECODER_LINKING; 17 __SK_FORCE_IMAGE_DECODER_LINKING;
17 18
18 #define JPEG_TEST_WRITE_TO_FILE_FOR_DEBUGGING 0 // do not do this for 19 #define JPEG_TEST_WRITE_TO_FILE_FOR_DEBUGGING 0 // do not do this for
19 // normal unit testing. 20 // normal unit testing.
20 static unsigned char goodJpegImage[] = { 21 static unsigned char goodJpegImage[] = {
21 0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 22 0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46,
22 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x8F, 23 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x8F,
23 0x00, 0x8F, 0x00, 0x00, 0xFF, 0xDB, 0x00, 0x43, 24 0x00, 0x8F, 0x00, 0x00, 0xFF, 0xDB, 0x00, 0x43,
24 0x00, 0x05, 0x03, 0x04, 0x04, 0x04, 0x03, 0x05, 25 0x00, 0x05, 0x03, 0x04, 0x04, 0x04, 0x03, 0x05,
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 411
411 // https://code.google.com/p/android/issues/detail?id=42382 412 // https://code.google.com/p/android/issues/detail?id=42382
412 // https://code.google.com/p/android/issues/detail?id=9064 413 // https://code.google.com/p/android/issues/detail?id=9064
413 // https://code.google.com/p/skia/issues/detail?id=1649 414 // https://code.google.com/p/skia/issues/detail?id=1649
414 415
415 /** 416 /**
416 This test will test the ability of the SkImageDecoder to deal with 417 This test will test the ability of the SkImageDecoder to deal with
417 Jpeg files which have been mangled somehow. We want to display as 418 Jpeg files which have been mangled somehow. We want to display as
418 much of the jpeg as possible. 419 much of the jpeg as possible.
419 */ 420 */
420 static void TestJpeg(skiatest::Reporter* reporter) { 421 DEF_TEST(Jpeg, reporter) {
421 size_t len = sizeof(goodJpegImage) / 2; 422 size_t len = sizeof(goodJpegImage) / 2;
422 // I am explicitly not putting the entire image into the 423 // I am explicitly not putting the entire image into the
423 // DecodeMemory. This simulates a network error. 424 // DecodeMemory. This simulates a network error.
424 425
425 SkBitmap bm8888; 426 SkBitmap bm8888;
426 bool imageDecodeSuccess = SkImageDecoder::DecodeMemory( 427 bool imageDecodeSuccess = SkImageDecoder::DecodeMemory(
427 static_cast<void *>(goodJpegImage), len, &bm8888); 428 static_cast<void *>(goodJpegImage), len, &bm8888);
428 REPORTER_ASSERT(reporter, imageDecodeSuccess); 429 REPORTER_ASSERT(reporter, imageDecodeSuccess);
429 REPORTER_ASSERT(reporter, bm8888.width() == goodJpegImageWidth); 430 REPORTER_ASSERT(reporter, bm8888.width() == goodJpegImageWidth);
430 REPORTER_ASSERT(reporter, bm8888.height() == goodJpegImageHeight); 431 REPORTER_ASSERT(reporter, bm8888.height() == goodJpegImageHeight);
431 REPORTER_ASSERT(reporter, !(bm8888.empty())); 432 REPORTER_ASSERT(reporter, !(bm8888.empty()));
432 433
433 // Pick a few pixels and verify that their colors match the colors 434 // Pick a few pixels and verify that their colors match the colors
434 // we expect (given the original image). 435 // we expect (given the original image).
435 REPORTER_ASSERT(reporter, bm8888.getColor(7, 9) == 0xffffffff); 436 REPORTER_ASSERT(reporter, bm8888.getColor(7, 9) == 0xffffffff);
436 REPORTER_ASSERT(reporter, bm8888.getColor(28, 3) == 0xff000000); 437 REPORTER_ASSERT(reporter, bm8888.getColor(28, 3) == 0xff000000);
437 REPORTER_ASSERT(reporter, bm8888.getColor(27, 34) == 0xffffffff); 438 REPORTER_ASSERT(reporter, bm8888.getColor(27, 34) == 0xffffffff);
438 REPORTER_ASSERT(reporter, bm8888.getColor(71, 18) == 0xff000000); 439 REPORTER_ASSERT(reporter, bm8888.getColor(71, 18) == 0xff000000);
439 440
440 // This is the fill color 441 // This is the fill color
441 REPORTER_ASSERT(reporter, bm8888.getColor(127, 127) == SK_ColorWHITE); 442 REPORTER_ASSERT(reporter, bm8888.getColor(127, 127) == SK_ColorWHITE);
442 443
443 #if JPEG_TEST_WRITE_TO_FILE_FOR_DEBUGGING 444 #if JPEG_TEST_WRITE_TO_FILE_FOR_DEBUGGING
444 // Check to see that the resulting bitmap is nice 445 // Check to see that the resulting bitmap is nice
445 bool writeSuccess = (!(bm8888.empty())) && SkImageEncoder::EncodeFile( 446 bool writeSuccess = (!(bm8888.empty())) && SkImageEncoder::EncodeFile(
446 "HalfOfAJpeg.png", bm8888, SkImageEncoder::kPNG_Type, 100); 447 "HalfOfAJpeg.png", bm8888, SkImageEncoder::kPNG_Type, 100);
447 SkASSERT(writeSuccess); 448 SkASSERT(writeSuccess);
448 #endif 449 #endif
449 } 450 }
450
451 #include "TestClassDef.h"
452 DEFINE_TESTCLASS("JpegTest", JpegTestClass, TestJpeg)
OLDNEW
« no previous file with comments | « tests/InfRectTest.cpp ('k') | tests/LListTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698