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

Side by Side Diff: gm/gm_expectations.h

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

Powered by Google App Engine
This is Rietveld 408576698