blob: 5b8d439e2faa1a42acf4ce8198f27a65747cd15d [file] [log] [blame]
reed@android.comed673312009-02-27 16:24:51 +00001#include "Test.h"
2
3using namespace skiatest;
4
5Reporter::Reporter() {
6 this->resetReporting();
7}
8
9void Reporter::resetReporting() {
10 fCurrTest = NULL;
11 fTestCount = 0;
12 bzero(fResultCount, sizeof(fResultCount));
13}
14
15void Reporter::startTest(Test* test) {
16 SkASSERT(NULL == fCurrTest);
17 fCurrTest = test;
18 this->onStart(test);
19 fTestCount += 1;
20}
21
22void Reporter::report(const char desc[], Result result) {
23 if (NULL == desc) {
24 desc = "<no description>";
25 }
26 this->onReport(desc, result);
27 fResultCount[result] += 1;
28}
29
30void Reporter::endTest(Test* test) {
31 SkASSERT(test == fCurrTest);
32 this->onEnd(test);
33 fCurrTest = NULL;
34}
35
36///////////////////////////////////////////////////////////////////////////////
37
38Test::Test() : fReporter(NULL) {}
39
40Test::~Test() {
41 fReporter->safeUnref();
42}
43
44void Test::setReporter(Reporter* r) {
45 SkRefCnt_SafeAssign(fReporter, r);
46}
47
48const char* Test::getName() {
49 if (fName.size() == 0) {
50 this->onGetName(&fName);
51 }
52 return fName.c_str();
53}
54
55void Test::run() {
56 fReporter->startTest(this);
57 this->onRun(fReporter);
58 fReporter->endTest(this);
59}
60