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

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 extra SkPathJoin implementation. 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"
11 #include "SkOSPathUtils.h"
11 12
12 #define DEBUGFAIL_SEE_STDERR SkDEBUGFAIL("see stderr for message") 13 #define DEBUGFAIL_SEE_STDERR SkDEBUGFAIL("see stderr for message")
13 14
14 // These constants must be kept in sync with the JSONKEY_ constants in 15 // These constants must be kept in sync with the JSONKEY_ constants in
15 // display_json_results.py ! 16 // display_json_results.py !
16 const static char kJsonKey_ActualResults[] = "actual-results"; 17 const static char kJsonKey_ActualResults[] = "actual-results";
17 const static char kJsonKey_ActualResults_Failed[] = "failed"; 18 const static char kJsonKey_ActualResults_Failed[] = "failed";
18 const static char kJsonKey_ActualResults_FailureIgnored[]= "failure-ignored"; 19 const static char kJsonKey_ActualResults_FailureIgnored[]= "failure-ignored";
19 const static char kJsonKey_ActualResults_NoComparison[] = "no-comparison"; 20 const static char kJsonKey_ActualResults_NoComparison[] = "no-comparison";
20 const static char kJsonKey_ActualResults_Succeeded[] = "succeeded"; 21 const static char kJsonKey_ActualResults_Succeeded[] = "succeeded";
21 const static char kJsonKey_ActualResults_AnyStatus_BitmapHash[] = "bitmap-64bit MD5"; 22 const static char kJsonKey_ActualResults_AnyStatus_BitmapHash[] = "bitmap-64bit MD5";
22 23
23 const static char kJsonKey_ExpectedResults[] = "expected-results"; 24 const static char kJsonKey_ExpectedResults[] = "expected-results";
24 const static char kJsonKey_ExpectedResults_AllowedBitmapHashes[] = "allowed-bitm ap-64bitMD5s"; 25 const static char kJsonKey_ExpectedResults_AllowedBitmapHashes[] = "allowed-bitm ap-64bitMD5s";
25 const static char kJsonKey_ExpectedResults_IgnoreFailure[] = "ignore-f ailure"; 26 const static char kJsonKey_ExpectedResults_IgnoreFailure[] = "ignore-f ailure";
26 27
27 namespace skiagm { 28 namespace skiagm {
28 29
29 void gm_fprintf(FILE *stream, const char format[], ...) { 30 void gm_fprintf(FILE *stream, const char format[], ...) {
30 va_list args; 31 va_list args;
31 va_start(args, format); 32 va_start(args, format);
32 fprintf(stream, "GM: "); 33 fprintf(stream, "GM: ");
33 vfprintf(stream, format, args); 34 vfprintf(stream, format, args);
34 va_end(args); 35 va_end(args);
35 } 36 }
36 37
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 38 // 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 39 // generated as an SkHashDigest of an SkBitmap. We'll need to allow for oth er
48 // hash types to cover non-bitmaps. 40 // hash types to cover non-bitmaps.
49 Json::Value ActualResultAsJsonValue(const SkHashDigest& result) { 41 Json::Value ActualResultAsJsonValue(const SkHashDigest& result) {
50 Json::Value jsonValue; 42 Json::Value jsonValue;
51 jsonValue[kJsonKey_ActualResults_AnyStatus_BitmapHash] = asJsonValue(res ult); 43 jsonValue[kJsonKey_ActualResults_AnyStatus_BitmapHash] = asJsonValue(res ult);
52 return jsonValue; 44 return jsonValue;
53 } 45 }
54 46
55 Json::Value CreateJsonTree(Json::Value expectedResults, 47 Json::Value CreateJsonTree(Json::Value expectedResults,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 Json::Reader reader; 216 Json::Reader reader;
225 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { 217 if (!reader.parse(bytes, bytes+size, *jsonRoot)) {
226 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); 218 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath);
227 DEBUGFAIL_SEE_STDERR; 219 DEBUGFAIL_SEE_STDERR;
228 return false; 220 return false;
229 } 221 }
230 return true; 222 return true;
231 } 223 }
232 224
233 } 225 }
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