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

Unified Diff: dm/DMExpectations.h

Issue 108963002: DM: Add support for reading a directory of images with --expectations (-r). (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: comments etc Created 7 years 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 | « dm/DMCpuTask.cpp ('k') | dm/DMExpectationsTask.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMExpectations.h
diff --git a/dm/DMExpectations.h b/dm/DMExpectations.h
new file mode 100644
index 0000000000000000000000000000000000000000..238d1c5beab77cf0820ed3dd32e6bf6a15adfa82
--- /dev/null
+++ b/dm/DMExpectations.h
@@ -0,0 +1,46 @@
+#ifndef DMExpectations_DEFINED
+#define DMExpectations_DEFINED
+
+#include "DMTask.h"
+#include "gm_expectations.h"
+
+namespace DM {
+
+struct Expectations {
+ virtual ~Expectations() {}
+
+ // Return true if bitmap is the correct output for task, else false.
+ virtual bool check(const Task& task, SkBitmap bitmap) const = 0;
+};
+
+class NoExpectations : public Expectations {
+public:
+ NoExpectations() {}
+ bool check(const Task&, SkBitmap) const SK_OVERRIDE { return true; }
+};
+
+class JsonExpectations : public Expectations {
+public:
+ explicit JsonExpectations(const char* path) : fGMExpectations(path) {}
+
+ bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE {
+ SkString filename = task.name();
+ filename.append(".png");
+ const skiagm::Expectations expectations = fGMExpectations.get(filename.c_str());
+
+ if (expectations.ignoreFailure() || expectations.empty()) {
+ return true;
+ }
+
+ // Delay this calculation as long as possible. It's expensive.
+ const skiagm::GmResultDigest digest(bitmap);
+ return expectations.match(digest);
+ }
+
+private:
+ skiagm::JsonExpectationsSource fGMExpectations;
+};
+
+} // namespace DM
+
+#endif // DMExpectations_DEFINED
« no previous file with comments | « dm/DMCpuTask.cpp ('k') | dm/DMExpectationsTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698