Chromium Code Reviews| Index: gm/gm_expectations.h |
| =================================================================== |
| --- gm/gm_expectations.h (revision 9256) |
| +++ gm/gm_expectations.h (working copy) |
| @@ -30,15 +30,6 @@ |
| namespace skiagm { |
| - // The actual type we use to represent a checksum is hidden in here. |
| - typedef Json::UInt64 Checksum; |
| - static inline Json::Value asJsonValue(Checksum checksum) { |
| - return checksum; |
| - } |
| - static inline Checksum asChecksum(Json::Value jsonValue) { |
| - return jsonValue.asUInt64(); |
| - } |
| - |
| void gm_fprintf(FILE *stream, const char format[], ...); |
| /** |
| @@ -51,7 +42,7 @@ |
| */ |
| SkString SkPathJoin(const char *rootPath, const char *relativePath); |
| - Json::Value ActualResultAsJsonValue(const SkHashDigest& result); |
| + Json::Value ActualResultAsJsonValue(uint64_t result); |
| Json::Value CreateJsonTree(Json::Value expectedResults, |
| Json::Value actualResultsFailed, |
| @@ -60,8 +51,57 @@ |
| Json::Value actualResultsSucceeded); |
| /** |
| - * Test expectations (allowed image checksums, etc.) |
| + * The digest of a GM test result. |
| + * |
| + * Currently, this is always a uint64_t hash digest of an SkBitmap... |
| + * but we will add other flavors soon. |
| */ |
| + class GmResultDigest { |
|
epoger
2013/05/23 18:19:12
In patchset 2, we replace the Checksum typedef wit
|
| + public: |
| + /** |
| + * Create a ResultDigest representing an actual image result. |
| + */ |
| + GmResultDigest(const SkBitmap &bitmap); |
| + |
| + /** |
| + * Create a ResultDigest representing an allowed result |
| + * checksum within JSON expectations file. |
| + * |
| + * TODO(epoger): Replace this constructor with one that takes |
| + * a JSON type/value pair, such as ["bitmap-64bitMD5", 12345]. |
| + */ |
| + GmResultDigest(uint64_t checksum); |
| + |
| + /** |
| + * Returns true if this and other GmResultDigest could |
| + * represent identical results. |
| + */ |
| + bool equals(const GmResultDigest &other) const; |
| + |
| + /** |
| + * Returns a JSON type/value pair representing this result, |
| + * such as ["bitmap-64bitMD5", 12345]. |
| + */ |
| + Json::Value asJsonTypeValuePair() const; |
| + |
| + /** |
| + * Returns the value of this GmResultDigest (perhaps a bitmap hash?) |
| + * as a Json::Value. |
| + * |
| + * TODO(epoger): delete this method; make callers use |
| + * asJsonTypeValuePair() instead, so that the callers won't |
| + * make any assumptions about what type of ResultDigest this |
| + * is. |
| + */ |
| + Json::Value getValueAsJsonValue() const; |
| + |
| + private: |
| + uint64_t fHashDigest; |
| + }; |
| + |
| + /** |
| + * Test expectations (allowed image results, etc.) |
| + */ |
| class Expectations { |
| public: |
| /** |
| @@ -90,16 +130,16 @@ |
| bool ignoreFailure() const { return this->fIgnoreFailure; } |
| /** |
| - * Returns true iff there are no allowed checksums. |
| + * Returns true iff there are no allowed results. |
| */ |
| - bool empty() const { return this->fAllowedBitmapChecksums.empty(); } |
| + bool empty() const { return this->fAllowedResultDigests.empty(); } |
| /** |
| - * Returns true iff actualChecksum matches any allowedChecksum, |
| + * Returns true iff resultDigest matches any allowed result, |
| * regardless of fIgnoreFailure. (The caller can check |
| * that separately.) |
| */ |
| - bool match(Checksum actualChecksum) const; |
| + bool match(GmResultDigest resultDigest) const; |
| /** |
| * If this Expectation is based on a single SkBitmap, return a |
| @@ -119,7 +159,7 @@ |
| private: |
| const static bool kDefaultIgnoreFailure = false; |
| - SkTArray<Checksum> fAllowedBitmapChecksums; |
| + SkTArray<GmResultDigest> fAllowedResultDigests; |
| bool fIgnoreFailure; |
| SkBitmap fBitmap; |
| }; |