Index: tests/RecorderTest.cpp |
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp |
index 4f8e357533c5a5614794b4dddba4760e5bca9efa..3c7b0082b1a71475a48edad368807606da3e1f9b 100644 |
--- a/tests/RecorderTest.cpp |
+++ b/tests/RecorderTest.cpp |
@@ -8,17 +8,19 @@ |
static const int kRecordTypes = SK_RECORD_TYPES(COUNT); |
#undef COUNT |
-// Tallies the types of commands it sees into histogram. |
+// Tallies the types of commands it sees into a histogram. |
class Tally { |
public: |
- explicit Tally(int histogram[kRecordTypes]) : fHistogram(histogram) {} |
+ Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); } |
- template <typename T> void operator()(const T&) { |
- ++fHistogram[T::kType]; |
- } |
+ template <typename T> |
+ void operator()(const T&) { ++fHistogram[T::kType]; } |
+ |
+ template <typename T> |
+ int count() const { return fHistogram[T::kType]; } |
private: |
- int* fHistogram; |
+ int fHistogram[kRecordTypes]; |
}; |
DEF_TEST(Recorder, r) { |
@@ -27,10 +29,8 @@ DEF_TEST(Recorder, r) { |
recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); |
- int histogram[kRecordTypes]; |
- sk_bzero(&histogram, sizeof(histogram)); |
- |
- record.visit(Tally(histogram)); |
+ Tally tally; |
+ record.visit(tally); |
- REPORTER_ASSERT(r, 1 == histogram[SkRecords::DrawRect::kType]); |
+ REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); |
} |