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

Side by Side Diff: gm/gm_expectations.h

Issue 303913002: In Android framework, make tools depend on jsoncpp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Do as Thoreau would do. Created 6 years, 6 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
« no previous file with comments | « dm/DMExpectations.h ('k') | gm/gm_expectations.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 * TODO(epoger): Combine this with tools/image_expectations.h, or eliminate one of the two. 7 * TODO(epoger): Combine this with tools/image_expectations.h, or eliminate one of the two.
8 */ 8 */
9 #ifndef gm_expectations_DEFINED 9 #ifndef gm_expectations_DEFINED
10 #define gm_expectations_DEFINED 10 #define gm_expectations_DEFINED
11 11
12 #include "gm.h" 12 #include "gm.h"
13 #include "SkBitmap.h" 13 #include "SkBitmap.h"
14 #include "SkBitmapHasher.h" 14 #include "SkBitmapHasher.h"
15 #include "SkData.h" 15 #include "SkData.h"
16 #include "SkJSONCPP.h" 16 #include "SkJSONCPP.h"
17 #include "SkOSFile.h" 17 #include "SkOSFile.h"
18 #include "SkRefCnt.h" 18 #include "SkRefCnt.h"
19 #include "SkStream.h" 19 #include "SkStream.h"
20 #include "SkTArray.h" 20 #include "SkTArray.h"
21 21
22 22
23 namespace skiagm { 23 namespace skiagm {
24 24
25 #ifdef SK_BUILD_JSON_WRITER
26 Json::Value CreateJsonTree(Json::Value expectedResults, 25 Json::Value CreateJsonTree(Json::Value expectedResults,
27 Json::Value actualResultsFailed, 26 Json::Value actualResultsFailed,
28 Json::Value actualResultsFailureIgnored, 27 Json::Value actualResultsFailureIgnored,
29 Json::Value actualResultsNoComparison, 28 Json::Value actualResultsNoComparison,
30 Json::Value actualResultsSucceeded); 29 Json::Value actualResultsSucceeded);
31 #endif
32 /** 30 /**
33 * The digest of a GM test result. 31 * The digest of a GM test result.
34 * 32 *
35 * Currently, this is always a uint64_t hash digest of an SkBitmap... 33 * Currently, this is always a uint64_t hash digest of an SkBitmap...
36 * but we will add other flavors soon. 34 * but we will add other flavors soon.
37 */ 35 */
38 class GmResultDigest { 36 class GmResultDigest {
39 public: 37 public:
40 /** 38 /**
41 * Create a ResultDigest representing an actual image result. 39 * Create a ResultDigest representing an actual image result.
42 */ 40 */
43 explicit GmResultDigest(const SkBitmap &bitmap); 41 explicit GmResultDigest(const SkBitmap &bitmap);
44 42
45 #ifdef SK_BUILD_JSON_WRITER
46 /** 43 /**
47 * Create a ResultDigest representing an allowed result 44 * Create a ResultDigest representing an allowed result
48 * checksum within JSON expectations file, in the form 45 * checksum within JSON expectations file, in the form
49 * ["bitmap-64bitMD5", 12345]. 46 * ["bitmap-64bitMD5", 12345].
50 */ 47 */
51 explicit GmResultDigest(const Json::Value &jsonTypeValuePair); 48 explicit GmResultDigest(const Json::Value &jsonTypeValuePair);
52 #endif
53 49
54 /** 50 /**
55 * Returns true if this GmResultDigest was fully and successfully 51 * Returns true if this GmResultDigest was fully and successfully
56 * created. 52 * created.
57 */ 53 */
58 bool isValid() const; 54 bool isValid() const;
59 55
60 /** 56 /**
61 * Returns true if this and other GmResultDigest could 57 * Returns true if this and other GmResultDigest could
62 * represent identical results. 58 * represent identical results.
63 */ 59 */
64 bool equals(const GmResultDigest &other) const; 60 bool equals(const GmResultDigest &other) const;
65 61
66 #ifdef SK_BUILD_JSON_WRITER
67 /** 62 /**
68 * Returns a JSON type/value pair representing this result, 63 * Returns a JSON type/value pair representing this result,
69 * such as ["bitmap-64bitMD5", 12345]. 64 * such as ["bitmap-64bitMD5", 12345].
70 */ 65 */
71 Json::Value asJsonTypeValuePair() const; 66 Json::Value asJsonTypeValuePair() const;
72 #endif
73 67
74 /** 68 /**
75 * Returns the hashtype, such as "bitmap-64bitMD5", as an SkString. 69 * Returns the hashtype, such as "bitmap-64bitMD5", as an SkString.
76 */ 70 */
77 SkString getHashType() const; 71 SkString getHashType() const;
78 72
79 /** 73 /**
80 * Returns the hash digest value, such as "12345", as an SkString. 74 * Returns the hash digest value, such as "12345", as an SkString.
81 */ 75 */
82 SkString getDigestValue() const; 76 SkString getDigestValue() const;
(...skipping 28 matching lines...) Expand all
111 * Expect exactly one image (appropriate for the case when we 105 * Expect exactly one image (appropriate for the case when we
112 * are comparing against a single PNG file). 106 * are comparing against a single PNG file).
113 */ 107 */
114 explicit Expectations(const SkBitmap& bitmap, bool ignoreFailure=kDefaul tIgnoreFailure); 108 explicit Expectations(const SkBitmap& bitmap, bool ignoreFailure=kDefaul tIgnoreFailure);
115 109
116 /** 110 /**
117 * Expect exactly one image, whose digest has already been computed. 111 * Expect exactly one image, whose digest has already been computed.
118 */ 112 */
119 explicit Expectations(const BitmapAndDigest& bitmapAndDigest); 113 explicit Expectations(const BitmapAndDigest& bitmapAndDigest);
120 114
121 #ifdef SK_BUILD_JSON_WRITER
122 /** 115 /**
123 * Create Expectations from a JSON element as found within the 116 * Create Expectations from a JSON element as found within the
124 * kJsonKey_ExpectedResults section. 117 * kJsonKey_ExpectedResults section.
125 * 118 *
126 * It's fine if the jsonElement is null or empty; in that case, we just 119 * It's fine if the jsonElement is null or empty; in that case, we just
127 * don't have any expectations. 120 * don't have any expectations.
128 */ 121 */
129 explicit Expectations(Json::Value jsonElement); 122 explicit Expectations(Json::Value jsonElement);
130 #endif
131 123
132 /** 124 /**
133 * Returns true iff we want to ignore failed expectations. 125 * Returns true iff we want to ignore failed expectations.
134 */ 126 */
135 bool ignoreFailure() const { return this->fIgnoreFailure; } 127 bool ignoreFailure() const { return this->fIgnoreFailure; }
136 128
137 /** 129 /**
138 * Override default setting of fIgnoreFailure. 130 * Override default setting of fIgnoreFailure.
139 */ 131 */
140 void setIgnoreFailure(bool val) { this->fIgnoreFailure = val; } 132 void setIgnoreFailure(bool val) { this->fIgnoreFailure = val; }
(...skipping 13 matching lines...) Expand all
154 /** 146 /**
155 * If this Expectation is based on a single SkBitmap, return a 147 * If this Expectation is based on a single SkBitmap, return a
156 * pointer to that SkBitmap. Otherwise (if the Expectation is 148 * pointer to that SkBitmap. Otherwise (if the Expectation is
157 * empty, or if it was based on a list of checksums rather 149 * empty, or if it was based on a list of checksums rather
158 * than a single bitmap), returns NULL. 150 * than a single bitmap), returns NULL.
159 */ 151 */
160 const SkBitmap *asBitmap() const { 152 const SkBitmap *asBitmap() const {
161 return (kUnknown_SkColorType == fBitmap.colorType()) ? NULL : &fBitm ap; 153 return (kUnknown_SkColorType == fBitmap.colorType()) ? NULL : &fBitm ap;
162 } 154 }
163 155
164 #ifdef SK_BUILD_JSON_WRITER
165 /** 156 /**
166 * Return a JSON representation of the expectations. 157 * Return a JSON representation of the expectations.
167 */ 158 */
168 Json::Value asJsonValue() const; 159 Json::Value asJsonValue() const;
169 #endif
170 160
171 private: 161 private:
172 const static bool kDefaultIgnoreFailure = false; 162 const static bool kDefaultIgnoreFailure = false;
173 163
174 SkTArray<GmResultDigest> fAllowedResultDigests; 164 SkTArray<GmResultDigest> fAllowedResultDigests;
175 bool fIgnoreFailure; 165 bool fIgnoreFailure;
176 SkBitmap fBitmap; 166 SkBitmap fBitmap;
177 }; 167 };
178 168
179 /** 169 /**
(...skipping 22 matching lines...) Expand all
202 * (this string will be copied to storage within this object) 192 * (this string will be copied to storage within this object)
203 */ 193 */
204 explicit IndividualImageExpectationsSource(const char *rootDir) : fRootD ir(rootDir) {} 194 explicit IndividualImageExpectationsSource(const char *rootDir) : fRootD ir(rootDir) {}
205 195
206 Expectations get(const char *testName) const SK_OVERRIDE ; 196 Expectations get(const char *testName) const SK_OVERRIDE ;
207 197
208 private: 198 private:
209 const SkString fRootDir; 199 const SkString fRootDir;
210 }; 200 };
211 201
212 #ifdef SK_BUILD_JSON_WRITER
213 /** 202 /**
214 * Return Expectations based on JSON summary file. 203 * Return Expectations based on JSON summary file.
215 */ 204 */
216 class JsonExpectationsSource : public ExpectationsSource { 205 class JsonExpectationsSource : public ExpectationsSource {
217 public: 206 public:
218 /** 207 /**
219 * Create an ExpectationsSource that will return Expectations based on 208 * Create an ExpectationsSource that will return Expectations based on
220 * a JSON file. 209 * a JSON file.
221 * 210 *
222 * jsonPath: path to JSON file to read 211 * jsonPath: path to JSON file to read
223 */ 212 */
224 explicit JsonExpectationsSource(const char *jsonPath); 213 explicit JsonExpectationsSource(const char *jsonPath);
225 214
226 Expectations get(const char *testName) const SK_OVERRIDE; 215 Expectations get(const char *testName) const SK_OVERRIDE;
227 216
228 private: 217 private:
229 218
230 /** 219 /**
231 * Read the file contents from jsonPath and parse them into jsonRoot. 220 * Read the file contents from jsonPath and parse them into jsonRoot.
232 * 221 *
233 * Returns true if successful. 222 * Returns true if successful.
234 */ 223 */
235 static bool Parse(const char *jsonPath, Json::Value *jsonRoot); 224 static bool Parse(const char *jsonPath, Json::Value *jsonRoot);
236 225
237 Json::Value fJsonRoot; 226 Json::Value fJsonRoot;
238 Json::Value fJsonExpectedResults; 227 Json::Value fJsonExpectedResults;
239 }; 228 };
240 #endif // SK_BUILD_JSON_WRITER
241 229
242 } 230 }
243 #endif 231 #endif
OLDNEW
« no previous file with comments | « dm/DMExpectations.h ('k') | gm/gm_expectations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698