blob: e04a9e9f6033d1919411cca3d0f5f5f93085de46 [file] [log] [blame]
commit-bot@chromium.orgb7369622014-04-08 20:17:26 +00001#include "Test.h"
2
3#include "SkRecord.h"
4#include "SkRecorder.h"
5#include "SkRecords.h"
6
7#define COUNT(T) + 1
8static const int kRecordTypes = SK_RECORD_TYPES(COUNT);
9#undef COUNT
10
11// Tallies the types of commands it sees into histogram.
12class Tally {
13public:
14 explicit Tally(int histogram[kRecordTypes]) : fHistogram(histogram) {}
15
16 template <typename T> void operator()(const T&) {
17 ++fHistogram[T::kType];
18 }
19
20private:
21 int* fHistogram;
22};
23
24DEF_TEST(Recorder, r) {
25 SkRecord record;
26 SkRecorder recorder(&record, 1920, 1080);
27
28 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
29
30 int histogram[kRecordTypes];
31 bzero(&histogram, sizeof(histogram));
32
33 record.visit(Tally(histogram));
34
35 REPORTER_ASSERT(r, 1 == histogram[SkRecords::DrawRect::kType]);
36}