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

Side by Side Diff: tools/skimage_main.cpp

Issue 15094011: skimage: report failure if expectation not found. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments. Created 7 years, 7 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 | « no previous file | 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 /* 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"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 if (NULL == filename || ++filename == '\0') { 195 if (NULL == filename || ++filename == '\0') {
196 filename = fullPath; 196 filename = fullPath;
197 } 197 }
198 return filename; 198 return filename;
199 } 199 }
200 200
201 /** 201 /**
202 * Compare against an expectation for this filename, if there is one. 202 * Compare against an expectation for this filename, if there is one.
203 * @param bitmap SkBitmap to compare to the expected value. 203 * @param bitmap SkBitmap to compare to the expected value.
204 * @param filename String used to find the expected value. 204 * @param filename String used to find the expected value.
205 * @return bool True if the bitmap matched the expectation, or if there was no expectation. False 205 * @return bool True in any of these cases:
206 * if there was an expecation that the bitmap did not match, or if an expec tation could not be 206 * - the bitmap matches the expectation.
207 * computed from an expectation. 207 * - there is no expectations file.
208 * False in any of these cases:
209 * - there is an expectations file, but no expectation for this bitmap.
210 * - there is an expectation for this bitmap, but it did not ma tch.
211 * - expectation could not be computed from the bitmap.
208 */ 212 */
209 static bool compare_to_expectations_if_necessary(const SkBitmap& bitmap, const c har* filename, 213 static bool compare_to_expectations_if_necessary(const SkBitmap& bitmap, const c har* filename,
210 SkTArray<SkString, false>* fail ureArray) { 214 SkTArray<SkString, false>* fail ureArray) {
211 if (NULL == gJsonExpectations.get()) { 215 if (NULL == gJsonExpectations.get()) {
212 return true; 216 return true;
213 } 217 }
214 218
215 skiagm::Expectations jsExpectation = gJsonExpectations->get(filename); 219 skiagm::Expectations jsExpectation = gJsonExpectations->get(filename);
216 if (jsExpectation.empty()) { 220 if (jsExpectation.empty()) {
217 return true; 221 if (failureArray != NULL) {
222 failureArray->push_back().printf("decoded %s, but could not find exp ectation.",
223 filename);
224 }
225 return false;
218 } 226 }
219 227
220 SkHashDigest checksum; 228 SkHashDigest checksum;
221 if (!SkBitmapHasher::ComputeDigest(bitmap, &checksum)) { 229 if (!SkBitmapHasher::ComputeDigest(bitmap, &checksum)) {
222 if (failureArray != NULL) { 230 if (failureArray != NULL) {
223 failureArray->push_back().printf("decoded %s, but could not create a checksum.", 231 failureArray->push_back().printf("decoded %s, but could not create a checksum.",
224 filename); 232 filename);
225 } 233 }
226 return false; 234 return false;
227 } 235 }
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 513 }
506 514
507 return failed ? -1 : 0; 515 return failed ? -1 : 0;
508 } 516 }
509 517
510 #if !defined SK_BUILD_FOR_IOS 518 #if !defined SK_BUILD_FOR_IOS
511 int main(int argc, char * const argv[]) { 519 int main(int argc, char * const argv[]) {
512 return tool_main(argc, (char**) argv); 520 return tool_main(argc, (char**) argv);
513 } 521 }
514 #endif 522 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698