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

Side by Side Diff: tests/PathUtilsTest.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/PathTest.cpp ('k') | tests/PictureTest.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
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 7
9 #include "SkPathUtils.h" 8 #include "Test.h"
10 9 #include "TestClassDef.h"
11 #include "SkBitmap.h" 10 #include "SkBitmap.h"
12 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkPathUtils.h"
13 #include "SkRandom.h" 13 #include "SkRandom.h"
14 #include "SkTime.h" 14 #include "SkTime.h"
15 #include "Test.h"
16 15
17 const int kNumIt = 100; 16 const int kNumIt = 100;
18 17
19 static void fill_random_bits(int chars, char* bits){ 18 static void fill_random_bits(int chars, char* bits){
20 SkRandom rand(SkTime::GetMSecs()); 19 SkRandom rand(SkTime::GetMSecs());
21 20
22 for (int i = 0; i < chars; ++i){ 21 for (int i = 0; i < chars; ++i){
23 bits[i] = rand.nextU(); 22 bits[i] = rand.nextU();
24 } 23 }
25 } 24 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 static void test_region(skiatest::Reporter* reporter, const SkBitmap* truth, 122 static void test_region(skiatest::Reporter* reporter, const SkBitmap* truth,
124 const char* bin_bmp, int w, int h, int rowBytes){ 123 const char* bin_bmp, int w, int h, int rowBytes){
125 //generate bitmap 124 //generate bitmap
126 SkPath path; 125 SkPath path;
127 SkPathUtils::BitsToPath_Region(&path, bin_bmp, w, h, rowBytes); 126 SkPathUtils::BitsToPath_Region(&path, bin_bmp, w, h, rowBytes);
128 127
129 //test for correctness 128 //test for correctness
130 test_path_eq(reporter, &path, truth, w, h); 129 test_path_eq(reporter, &path, truth, w, h);
131 } 130 }
132 131
133 static void TestPathUtils(skiatest::Reporter* reporter) { 132 DEF_TEST(PathUtils, reporter) {
134 const int w[] = {4, 8, 12, 16}; 133 const int w[] = {4, 8, 12, 16};
135 const int h = 8, rowBytes = 4; 134 const int h = 8, rowBytes = 4;
136 135
137 char bits[ h * rowBytes ]; 136 char bits[ h * rowBytes ];
138 static char* binBmp = &bits[0]; 137 static char* binBmp = &bits[0];
139 138
140 //loop to run randomized test lots of times 139 //loop to run randomized test lots of times
141 for (int it = 0; it < kNumIt; ++it) 140 for (int it = 0; it < kNumIt; ++it)
142 { 141 {
143 // generate a random binary bitmap 142 // generate a random binary bitmap
144 fill_random_bits( h * rowBytes, binBmp); // generate random bitmap 143 fill_random_bits( h * rowBytes, binBmp); // generate random bitmap
145 144
146 // for each bitmap width, use subset of binary bitmap 145 // for each bitmap width, use subset of binary bitmap
147 for (unsigned int i = 0; i < SK_ARRAY_COUNT(w); ++i) { 146 for (unsigned int i = 0; i < SK_ARRAY_COUNT(w); ++i) {
148 // generate truth bitmap 147 // generate truth bitmap
149 SkBitmap bmpTruth; 148 SkBitmap bmpTruth;
150 binary_to_skbitmap(binBmp, &bmpTruth, w[i], h, rowBytes); 149 binary_to_skbitmap(binBmp, &bmpTruth, w[i], h, rowBytes);
151 150
152 test_path(reporter, &bmpTruth, binBmp, w[i], h, rowBytes); 151 test_path(reporter, &bmpTruth, binBmp, w[i], h, rowBytes);
153 test_region(reporter, &bmpTruth, binBmp, w[i], h, rowBytes); 152 test_region(reporter, &bmpTruth, binBmp, w[i], h, rowBytes);
154 } 153 }
155 } 154 }
156 } 155 }
157
158 #include "TestClassDef.h"
159 DEFINE_TESTCLASS("PathUtils", PathUtils, TestPathUtils)
OLDNEW
« no previous file with comments | « tests/PathTest.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698