OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "gm_expectations.h" | 8 #include "gm_expectations.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkBitmapHasher.h" | 10 #include "SkBitmapHasher.h" |
scroggo
2013/05/23 20:42:58
This file no longer needs to be included.
epoger
2013/05/23 21:06:18
Done.
| |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkCommandLineFlags.h" | 12 #include "SkCommandLineFlags.h" |
13 #include "SkData.h" | 13 #include "SkData.h" |
14 #include "SkGraphics.h" | 14 #include "SkGraphics.h" |
15 #include "SkImageDecoder.h" | 15 #include "SkImageDecoder.h" |
16 #include "SkImageEncoder.h" | 16 #include "SkImageEncoder.h" |
17 #include "SkOSFile.h" | 17 #include "SkOSFile.h" |
18 #include "SkRandom.h" | 18 #include "SkRandom.h" |
19 #include "SkStream.h" | 19 #include "SkStream.h" |
20 #include "SkTArray.h" | 20 #include "SkTArray.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 SkASSERT(rect.fBottom < maxY); | 173 SkASSERT(rect.fBottom < maxY); |
174 } | 174 } |
175 } | 175 } |
176 return rect; | 176 return rect; |
177 } | 177 } |
178 | 178 |
179 // Stored expectations to be written to a file if createExpectationsPath is spec ified. | 179 // Stored expectations to be written to a file if createExpectationsPath is spec ified. |
180 static Json::Value gExpectationsToWrite; | 180 static Json::Value gExpectationsToWrite; |
181 | 181 |
182 /** | 182 /** |
183 * If expectations are to be recorded, record the expected checksum of bitmap i nto global | 183 * If expectations are to be recorded, record the bitmap expectations into glob al |
184 * expectations array. | 184 * expectations array. |
185 */ | 185 */ |
186 static void write_expectations(const SkBitmap& bitmap, const char* filename) { | 186 static void write_expectations(const SkBitmap& bitmap, const char* filename) { |
187 if (!FLAGS_createExpectationsPath.isEmpty()) { | 187 if (!FLAGS_createExpectationsPath.isEmpty()) { |
188 // Creates an Expectations object, and add it to the list to write. | 188 // Creates an Expectations object, and add it to the list to write. |
189 skiagm::Expectations expectation(bitmap); | 189 skiagm::Expectations expectation(bitmap); |
190 Json::Value value = expectation.asJsonValue(); | 190 Json::Value value = expectation.asJsonValue(); |
191 gExpectationsToWrite[filename] = value; | 191 gExpectationsToWrite[filename] = value; |
192 } | 192 } |
193 } | 193 } |
(...skipping 18 matching lines...) Expand all Loading... | |
212 | 212 |
213 skiagm::Expectations jsExpectation = gJsonExpectations->get(filename); | 213 skiagm::Expectations jsExpectation = gJsonExpectations->get(filename); |
214 if (jsExpectation.empty()) { | 214 if (jsExpectation.empty()) { |
215 if (failureArray != NULL) { | 215 if (failureArray != NULL) { |
216 failureArray->push_back().printf("decoded %s, but could not find exp ectation.", | 216 failureArray->push_back().printf("decoded %s, but could not find exp ectation.", |
217 filename); | 217 filename); |
218 } | 218 } |
219 return false; | 219 return false; |
220 } | 220 } |
221 | 221 |
222 SkHashDigest checksum; | 222 skiagm::GmResultDigest resultDigest(bitmap); |
223 if (!SkBitmapHasher::ComputeDigest(bitmap, &checksum)) { | 223 if (jsExpectation.match(resultDigest)) { |
epoger
2013/05/23 21:06:18
Added code to check the new isValid() method, rega
| |
224 if (failureArray != NULL) { | |
225 failureArray->push_back().printf("decoded %s, but could not create a checksum.", | |
226 filename); | |
227 } | |
228 return false; | |
229 } | |
230 | |
231 if (jsExpectation.match(checksum)) { | |
232 return true; | 224 return true; |
233 } | 225 } |
234 | 226 |
235 if (failureArray != NULL) { | 227 if (failureArray != NULL) { |
236 failureArray->push_back().printf("decoded %s, but the result does not ma tch " | 228 failureArray->push_back().printf("decoded %s, but the result does not ma tch " |
237 "expectations.", | 229 "expectations.", |
238 filename); | 230 filename); |
239 } | 231 } |
240 return false; | 232 return false; |
241 } | 233 } |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 } | 557 } |
566 | 558 |
567 return failed ? -1 : 0; | 559 return failed ? -1 : 0; |
568 } | 560 } |
569 | 561 |
570 #if !defined SK_BUILD_FOR_IOS | 562 #if !defined SK_BUILD_FOR_IOS |
571 int main(int argc, char * const argv[]) { | 563 int main(int argc, char * const argv[]) { |
572 return tool_main(argc, (char**) argv); | 564 return tool_main(argc, (char**) argv); |
573 } | 565 } |
574 #endif | 566 #endif |
OLD | NEW |