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

Unified Diff: tests/RecorderTest.cpp

Issue 227673011: More SkRecord TODOs: (Closed) Base URL: https://skia.googlesource.com/skia.git@tests
Patch Set: Created 6 years, 8 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 | « gyp/tools.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecorderTest.cpp
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6cca6919763c1f9b7af8d2e7e70ce4138bb5a238
--- /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 = 0 + SK_RECORD_TYPES(COUNT);
f(malita) 2014/04/08 19:48:34 I guess it evals correctly, but I think we could d
mtklein 2014/04/08 19:51:40 Oooh, good call. This was left over from before I
+#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]);
+}
« no previous file with comments | « gyp/tools.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698