aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/RecorderTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/RecorderTest.cpp')
-rw-r--r--tests/RecorderTest.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
new file mode 100644
index 0000000000..e04a9e9f60
--- /dev/null
+++ b/tests/RecorderTest.cpp
@@ -0,0 +1,36 @@
+#include "Test.h"
+
+#include "SkRecord.h"
+#include "SkRecorder.h"
+#include "SkRecords.h"
+
+#define COUNT(T) + 1
+static const int kRecordTypes = SK_RECORD_TYPES(COUNT);
+#undef COUNT
+
+// Tallies the types of commands it sees into histogram.
+class Tally {
+public:
+ explicit Tally(int histogram[kRecordTypes]) : fHistogram(histogram) {}
+
+ template <typename T> void operator()(const T&) {
+ ++fHistogram[T::kType];
+ }
+
+private:
+ int* fHistogram;
+};
+
+DEF_TEST(Recorder, r) {
+ SkRecord record;
+ SkRecorder recorder(&record, 1920, 1080);
+
+ recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
+
+ int histogram[kRecordTypes];
+ bzero(&histogram, sizeof(histogram));
+
+ record.visit(Tally(histogram));
+
+ REPORTER_ASSERT(r, 1 == histogram[SkRecords::DrawRect::kType]);
+}