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

Side by Side Diff: gm/gm_expectations.cpp

Issue 15986004: Revert "Add path utils, plus a test for it." (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | « gm/gm_expectations.h ('k') | gm/gmmain.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 "gm_expectations.h" 8 #include "gm_expectations.h"
9 #include "SkBitmapHasher.h" 9 #include "SkBitmapHasher.h"
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 19 matching lines...) Expand all
30 namespace skiagm { 30 namespace skiagm {
31 31
32 void gm_fprintf(FILE *stream, const char format[], ...) { 32 void gm_fprintf(FILE *stream, const char format[], ...) {
33 va_list args; 33 va_list args;
34 va_start(args, format); 34 va_start(args, format);
35 fprintf(stream, "GM: "); 35 fprintf(stream, "GM: ");
36 vfprintf(stream, format, args); 36 vfprintf(stream, format, args);
37 va_end(args); 37 va_end(args);
38 } 38 }
39 39
40 SkString SkPathJoin(const char *rootPath, const char *relativePath) {
41 SkString result(rootPath);
42 if (!result.endsWith(SkPATH_SEPARATOR)) {
43 result.appendUnichar(SkPATH_SEPARATOR);
44 }
45 result.append(relativePath);
46 return result;
47 }
48
40 Json::Value CreateJsonTree(Json::Value expectedResults, 49 Json::Value CreateJsonTree(Json::Value expectedResults,
41 Json::Value actualResultsFailed, 50 Json::Value actualResultsFailed,
42 Json::Value actualResultsFailureIgnored, 51 Json::Value actualResultsFailureIgnored,
43 Json::Value actualResultsNoComparison, 52 Json::Value actualResultsNoComparison,
44 Json::Value actualResultsSucceeded) { 53 Json::Value actualResultsSucceeded) {
45 Json::Value actualResults; 54 Json::Value actualResults;
46 actualResults[kJsonKey_ActualResults_Failed] = actualResultsFailed; 55 actualResults[kJsonKey_ActualResults_Failed] = actualResultsFailed;
47 actualResults[kJsonKey_ActualResults_FailureIgnored] = actualResultsFail ureIgnored; 56 actualResults[kJsonKey_ActualResults_FailureIgnored] = actualResultsFail ureIgnored;
48 actualResults[kJsonKey_ActualResults_NoComparison] = actualResultsNoComp arison; 57 actualResults[kJsonKey_ActualResults_NoComparison] = actualResultsNoComp arison;
49 actualResults[kJsonKey_ActualResults_Succeeded] = actualResultsSucceeded ; 58 actualResults[kJsonKey_ActualResults_Succeeded] = actualResultsSucceeded ;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 Json::Value jsonExpectations; 187 Json::Value jsonExpectations;
179 jsonExpectations[kJsonKey_ExpectedResults_AllowedDigests] = allowedDiges tArray; 188 jsonExpectations[kJsonKey_ExpectedResults_AllowedDigests] = allowedDiges tArray;
180 jsonExpectations[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignore Failure(); 189 jsonExpectations[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignore Failure();
181 return jsonExpectations; 190 return jsonExpectations;
182 } 191 }
183 192
184 193
185 // IndividualImageExpectationsSource class... 194 // IndividualImageExpectationsSource class...
186 195
187 Expectations IndividualImageExpectationsSource::get(const char *testName) { 196 Expectations IndividualImageExpectationsSource::get(const char *testName) {
188 SkString path = SkOSPath::SkPathJoin(fRootDir.c_str(), testName); 197 SkString path = SkPathJoin(fRootDir.c_str(), testName);
189 SkBitmap referenceBitmap; 198 SkBitmap referenceBitmap;
190 bool decodedReferenceBitmap = 199 bool decodedReferenceBitmap =
191 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, 200 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap,
192 SkBitmap::kARGB_8888_Config, 201 SkBitmap::kARGB_8888_Config,
193 SkImageDecoder::kDecodePixels_Mode, 202 SkImageDecoder::kDecodePixels_Mode,
194 NULL); 203 NULL);
195 if (decodedReferenceBitmap) { 204 if (decodedReferenceBitmap) {
196 return Expectations(referenceBitmap); 205 return Expectations(referenceBitmap);
197 } else { 206 } else {
198 return Expectations(); 207 return Expectations();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 Json::Reader reader; 258 Json::Reader reader;
250 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { 259 if (!reader.parse(bytes, bytes+size, *jsonRoot)) {
251 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); 260 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath);
252 DEBUGFAIL_SEE_STDERR; 261 DEBUGFAIL_SEE_STDERR;
253 return false; 262 return false;
254 } 263 }
255 return true; 264 return true;
256 } 265 }
257 266
258 } 267 }
OLDNEW
« no previous file with comments | « gm/gm_expectations.h ('k') | gm/gmmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698