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

Unified Diff: tests/RecordTestUtils.h

Issue 290883004: Don't clobber initial transform with SetMatrix. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: setConcat 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/RecordOptsTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordTestUtils.h
diff --git a/tests/RecordTestUtils.h b/tests/RecordTestUtils.h
new file mode 100644
index 0000000000000000000000000000000000000000..db3f02d3a27e99f54bbc88aeeacb169919731fc7
--- /dev/null
+++ b/tests/RecordTestUtils.h
@@ -0,0 +1,31 @@
+#ifndef RecordTestUtils_DEFINED
+#define RecordTestUtils_DEFINED
+
+#include "SkRecord.h"
+#include "SkRecords.h"
+
+// If the command we're reading is a U, set ptr to it, otherwise set it to NULL.
+template <typename U>
+struct ReadAs {
+ ReadAs() : ptr(NULL), type(SkRecords::Type(~0)) {}
+
+ const U* ptr;
+ SkRecords::Type type;
+
+ void operator()(const U& r) { ptr = &r; type = U::kType; }
+
+ template <typename T>
+ void operator()(const T&) { type = U::kType; }
+};
+
+// Assert that the ith command in record is of type T, and return it.
+template <typename T>
+static const T* assert_type(skiatest::Reporter* r, const SkRecord& record, unsigned index) {
+ ReadAs<T> reader;
+ record.visit<void>(index, reader);
+ REPORTER_ASSERT(r, T::kType == reader.type);
+ REPORTER_ASSERT(r, NULL != reader.ptr);
+ return reader.ptr;
+}
+
+#endif//RecordTestUtils_DEFINED
« no previous file with comments | « tests/RecordOptsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698