aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/gm_expectations.h
diff options
context:
space:
mode:
authorGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-24 14:33:28 +0000
committerGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-24 14:33:28 +0000
commitd4993ff3605102036f83d5834d9a022d780e5488 (patch)
tree694753d66dc8af18950fbdf6ea9ffc29f4c2005a /gm/gm_expectations.h
parent3e2345a8d56cb76bc43e4421a3e9e3681ecd9eba (diff)
GM: create GmResultDigest that encapsulates digest type ("bitmap-64bitMD5") and value (12345)
R=scroggo@google.com Review URL: https://codereview.chromium.org/15883004 git-svn-id: http://skia.googlecode.com/svn/trunk@9271 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/gm_expectations.h')
-rw-r--r--gm/gm_expectations.h66
1 files changed, 49 insertions, 17 deletions
diff --git a/gm/gm_expectations.h b/gm/gm_expectations.h
index a8b29cd6bd..8efb986713 100644
--- a/gm/gm_expectations.h
+++ b/gm/gm_expectations.h
@@ -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,8 +42,6 @@ namespace skiagm {
*/
SkString SkPathJoin(const char *rootPath, const char *relativePath);
- Json::Value ActualResultAsJsonValue(const SkHashDigest& result);
-
Json::Value CreateJsonTree(Json::Value expectedResults,
Json::Value actualResultsFailed,
Json::Value actualResultsFailureIgnored,
@@ -60,7 +49,50 @@ namespace skiagm {
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 {
+ 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, in the form
+ * ["bitmap-64bitMD5", 12345].
+ */
+ GmResultDigest(const Json::Value &jsonTypeValuePair);
+
+ /**
+ * Returns true if this GmResultDigest was fully and successfully
+ * created.
+ */
+ bool isValid() const;
+
+ /**
+ * 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;
+
+ private:
+ bool fIsValid; // always check this first--if it's false, other fields are meaningless
+ uint64_t fHashDigest;
+ };
+
+ /**
+ * Test expectations (allowed image results, etc.)
*/
class Expectations {
public:
@@ -90,16 +122,16 @@ namespace skiagm {
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 +151,7 @@ namespace skiagm {
private:
const static bool kDefaultIgnoreFailure = false;
- SkTArray<Checksum> fAllowedBitmapChecksums;
+ SkTArray<GmResultDigest> fAllowedResultDigests;
bool fIgnoreFailure;
SkBitmap fBitmap;
};