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

Unified Diff: gm/gm_expectations.h

Issue 15883004: GM: create GmResultDigest that encapsulates digest type ("bitmap-64bitMD5") and value (12345) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: type_properly_encapsulated_within_GmResultDigest 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gm/gm_expectations.cpp » ('j') | gm/gm_expectations.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,44 @@
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);
epoger 2013/05/23 19:18:31 As of patchset 3, the digest type (e.g., "bitmap-6
+
+ /**
+ * 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:
+ uint64_t fHashDigest;
+ };
+
+ /**
+ * Test expectations (allowed image results, etc.)
+ */
class Expectations {
public:
/**
@@ -90,16 +117,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 +146,7 @@
private:
const static bool kDefaultIgnoreFailure = false;
- SkTArray<Checksum> fAllowedBitmapChecksums;
+ SkTArray<GmResultDigest> fAllowedResultDigests;
bool fIgnoreFailure;
SkBitmap fBitmap;
};
« no previous file with comments | « no previous file | gm/gm_expectations.cpp » ('j') | gm/gm_expectations.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698