diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-08 20:17:26 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-08 20:17:26 +0000 |
commit | b73696262c21ec7b020b80bac52812fd7517b7f0 (patch) | |
tree | 52d323eba0332126e7a2e008d0acb590c9cbd048 /tests/RecorderTest.cpp | |
parent | eefd8a01fc984e15ca108cb2951c52b3ea17d6b8 (diff) |
More SkRecord TODOs:
- add basic test for SkRecorder
- rejigger GYPs so that the include dir comes along with the dependency
BUG=skia:2378
R=fmalita@chromium.org, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/227673011
git-svn-id: http://skia.googlecode.com/svn/trunk@14099 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/RecorderTest.cpp')
-rw-r--r-- | tests/RecorderTest.cpp | 36 |
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]); +} |