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

Side by Side Diff: gm/gm_expectations.cpp

Issue 15747004: Add path utils, plus a test for it. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Remove unnecessary changes. 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') | gm/image.cpp » ('J')
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 16 matching lines...) Expand all
27 namespace skiagm { 27 namespace skiagm {
28 28
29 void gm_fprintf(FILE *stream, const char format[], ...) { 29 void gm_fprintf(FILE *stream, const char format[], ...) {
30 va_list args; 30 va_list args;
31 va_start(args, format); 31 va_start(args, format);
32 fprintf(stream, "GM: "); 32 fprintf(stream, "GM: ");
33 vfprintf(stream, format, args); 33 vfprintf(stream, format, args);
34 va_end(args); 34 va_end(args);
35 } 35 }
36 36
37 SkString SkPathJoin(const char *rootPath, const char *relativePath) {
38 SkString result(rootPath);
39 if (!result.endsWith(SkPATH_SEPARATOR)) {
40 result.appendUnichar(SkPATH_SEPARATOR);
41 }
42 result.append(relativePath);
43 return result;
44 }
45
46 // TODO(epoger): This currently assumes that the result SkHashDigest was 37 // TODO(epoger): This currently assumes that the result SkHashDigest was
47 // generated as an SkHashDigest of an SkBitmap. We'll need to allow for oth er 38 // generated as an SkHashDigest of an SkBitmap. We'll need to allow for oth er
48 // hash types to cover non-bitmaps. 39 // hash types to cover non-bitmaps.
49 Json::Value ActualResultAsJsonValue(const SkHashDigest& result) { 40 Json::Value ActualResultAsJsonValue(const SkHashDigest& result) {
50 Json::Value jsonValue; 41 Json::Value jsonValue;
51 jsonValue[kJsonKey_ActualResults_AnyStatus_BitmapHash] = asJsonValue(res ult); 42 jsonValue[kJsonKey_ActualResults_AnyStatus_BitmapHash] = asJsonValue(res ult);
52 return jsonValue; 43 return jsonValue;
53 } 44 }
54 45
55 Json::Value CreateJsonTree(Json::Value expectedResults, 46 Json::Value CreateJsonTree(Json::Value expectedResults,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 Json::Value jsonValue; 144 Json::Value jsonValue;
154 jsonValue[kJsonKey_ExpectedResults_AllowedBitmapHashes] = allowedChecksu mArray; 145 jsonValue[kJsonKey_ExpectedResults_AllowedBitmapHashes] = allowedChecksu mArray;
155 jsonValue[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignoreFailure( ); 146 jsonValue[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignoreFailure( );
156 return jsonValue; 147 return jsonValue;
157 } 148 }
158 149
159 150
160 // IndividualImageExpectationsSource class... 151 // IndividualImageExpectationsSource class...
161 152
162 Expectations IndividualImageExpectationsSource::get(const char *testName) { 153 Expectations IndividualImageExpectationsSource::get(const char *testName) {
163 SkString path = SkPathJoin(fRootDir.c_str(), testName); 154 SkString path = SkOSPathUtils::SkPathJoin(fRootDir.c_str(), testName);
164 SkBitmap referenceBitmap; 155 SkBitmap referenceBitmap;
165 bool decodedReferenceBitmap = 156 bool decodedReferenceBitmap =
166 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, 157 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap,
167 SkBitmap::kARGB_8888_Config, 158 SkBitmap::kARGB_8888_Config,
168 SkImageDecoder::kDecodePixels_Mode, 159 SkImageDecoder::kDecodePixels_Mode,
169 NULL); 160 NULL);
170 if (decodedReferenceBitmap) { 161 if (decodedReferenceBitmap) {
171 return Expectations(referenceBitmap); 162 return Expectations(referenceBitmap);
172 } else { 163 } else {
173 return Expectations(); 164 return Expectations();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 Json::Reader reader; 215 Json::Reader reader;
225 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { 216 if (!reader.parse(bytes, bytes+size, *jsonRoot)) {
226 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); 217 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath);
227 DEBUGFAIL_SEE_STDERR; 218 DEBUGFAIL_SEE_STDERR;
228 return false; 219 return false;
229 } 220 }
230 return true; 221 return true;
231 } 222 }
232 223
233 } 224 }
OLDNEW
« no previous file with comments | « gm/gm_expectations.h ('k') | gm/gmmain.cpp » ('j') | gm/image.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698