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

Side by Side Diff: tests/BitmapHasherTest.cpp

Issue 122943004: Convert two more tests to DEF_TEST() macro. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix typo 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/ARGBImageEncoderTest.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
2 /* 1 /*
3 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 #include "Test.h" 7
8 #include "SkBitmapHasher.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkBitmapHasher.h"
12 #include "SkColor.h" 11 #include "SkColor.h"
12 #include "Test.h"
13 #include "TestClassDef.h"
13 14
14 // Word size that is large enough to hold results of any checksum type. 15 // Word size that is large enough to hold results of any checksum type.
15 typedef uint64_t checksum_result; 16 typedef uint64_t checksum_result;
16 17
17 namespace skiatest { 18 // Fill in bitmap with test data.
18 class BitmapHasherTestClass : public Test { 19 static void CreateTestBitmap(SkBitmap &bitmap, SkBitmap::Config config, int widt h, int height,
19 public: 20 SkColor color, skiatest::Reporter* reporter) {
20 static Test* Factory(void*) {return SkNEW(BitmapHasherTestClass); } 21 bitmap.setConfig(config, width, height);
21 protected: 22 REPORTER_ASSERT(reporter, bitmap.allocPixels());
22 virtual void onGetName(SkString* name) { name->set("BitmapHasher"); } 23 bitmap.setAlphaType(kOpaque_SkAlphaType);
23 virtual void onRun(Reporter* reporter) { 24 bitmap.eraseColor(color);
24 this->fReporter = reporter; 25 }
25 RunTest();
26 }
27 private:
28 26
29 // Fill in bitmap with test data. 27 DEF_TEST(BitmapHasher, reporter) {
30 void CreateTestBitmap(SkBitmap &bitmap, SkBitmap::Config config, int wid th, int height, 28 // Test SkBitmapHasher
31 SkColor color) { 29 SkBitmap bitmap;
32 bitmap.setConfig(config, width, height); 30 uint64_t digest;
33 REPORTER_ASSERT(fReporter, bitmap.allocPixels()); 31 // initial test case
34 bitmap.setAlphaType(kOpaque_SkAlphaType); 32 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 333, 555, SK_ColorBLUE , reporter);
35 bitmap.eraseColor(color); 33 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
36 } 34 REPORTER_ASSERT(reporter, digest == 0xfb2903562766ef87ULL);
37 35 // same pixel data but different dimensions should yield a different checksu m
38 void RunTest() { 36 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorBLUE , reporter);
39 // Test SkBitmapHasher 37 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
40 SkBitmap bitmap; 38 REPORTER_ASSERT(reporter, digest == 0xfe04023fb97d0f61ULL);
41 uint64_t digest; 39 // same dimensions but different color should yield a different checksum
42 // initial test case 40 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorGREE N, reporter);
43 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 333, 555, SK_C olorBLUE); 41 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
44 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di gest)); 42 REPORTER_ASSERT(reporter, digest == 0x2423c51cad6d1edcULL);
45 REPORTER_ASSERT(fReporter, digest == 0xfb2903562766ef87ULL);
46 // same pixel data but different dimensions should yield a different checksum
47 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_C olorBLUE);
48 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di gest));
49 REPORTER_ASSERT(fReporter, digest == 0xfe04023fb97d0f61ULL);
50 // same dimensions but different color should yield a different chec ksum
51 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_C olorGREEN);
52 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di gest));
53 REPORTER_ASSERT(fReporter, digest == 0x2423c51cad6d1edcULL);
54 }
55
56 Reporter* fReporter;
57 };
58
59 static TestRegistry gReg(BitmapHasherTestClass::Factory);
60 } 43 }
OLDNEW
« no previous file with comments | « tests/ARGBImageEncoderTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698