OLD | NEW |
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 Loading... |
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 | |
49 Json::Value CreateJsonTree(Json::Value expectedResults, | 40 Json::Value CreateJsonTree(Json::Value expectedResults, |
50 Json::Value actualResultsFailed, | 41 Json::Value actualResultsFailed, |
51 Json::Value actualResultsFailureIgnored, | 42 Json::Value actualResultsFailureIgnored, |
52 Json::Value actualResultsNoComparison, | 43 Json::Value actualResultsNoComparison, |
53 Json::Value actualResultsSucceeded) { | 44 Json::Value actualResultsSucceeded) { |
54 Json::Value actualResults; | 45 Json::Value actualResults; |
55 actualResults[kJsonKey_ActualResults_Failed] = actualResultsFailed; | 46 actualResults[kJsonKey_ActualResults_Failed] = actualResultsFailed; |
56 actualResults[kJsonKey_ActualResults_FailureIgnored] = actualResultsFail
ureIgnored; | 47 actualResults[kJsonKey_ActualResults_FailureIgnored] = actualResultsFail
ureIgnored; |
57 actualResults[kJsonKey_ActualResults_NoComparison] = actualResultsNoComp
arison; | 48 actualResults[kJsonKey_ActualResults_NoComparison] = actualResultsNoComp
arison; |
58 actualResults[kJsonKey_ActualResults_Succeeded] = actualResultsSucceeded
; | 49 actualResults[kJsonKey_ActualResults_Succeeded] = actualResultsSucceeded
; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 Json::Value jsonExpectations; | 178 Json::Value jsonExpectations; |
188 jsonExpectations[kJsonKey_ExpectedResults_AllowedDigests] = allowedDiges
tArray; | 179 jsonExpectations[kJsonKey_ExpectedResults_AllowedDigests] = allowedDiges
tArray; |
189 jsonExpectations[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignore
Failure(); | 180 jsonExpectations[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignore
Failure(); |
190 return jsonExpectations; | 181 return jsonExpectations; |
191 } | 182 } |
192 | 183 |
193 | 184 |
194 // IndividualImageExpectationsSource class... | 185 // IndividualImageExpectationsSource class... |
195 | 186 |
196 Expectations IndividualImageExpectationsSource::get(const char *testName) { | 187 Expectations IndividualImageExpectationsSource::get(const char *testName) { |
197 SkString path = SkPathJoin(fRootDir.c_str(), testName); | 188 SkString path = SkOSPath::SkPathJoin(fRootDir.c_str(), testName); |
198 SkBitmap referenceBitmap; | 189 SkBitmap referenceBitmap; |
199 bool decodedReferenceBitmap = | 190 bool decodedReferenceBitmap = |
200 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, | 191 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, |
201 SkBitmap::kARGB_8888_Config, | 192 SkBitmap::kARGB_8888_Config, |
202 SkImageDecoder::kDecodePixels_Mode, | 193 SkImageDecoder::kDecodePixels_Mode, |
203 NULL); | 194 NULL); |
204 if (decodedReferenceBitmap) { | 195 if (decodedReferenceBitmap) { |
205 return Expectations(referenceBitmap); | 196 return Expectations(referenceBitmap); |
206 } else { | 197 } else { |
207 return Expectations(); | 198 return Expectations(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 Json::Reader reader; | 249 Json::Reader reader; |
259 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { | 250 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { |
260 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); | 251 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); |
261 DEBUGFAIL_SEE_STDERR; | 252 DEBUGFAIL_SEE_STDERR; |
262 return false; | 253 return false; |
263 } | 254 } |
264 return true; | 255 return true; |
265 } | 256 } |
266 | 257 |
267 } | 258 } |
OLD | NEW |