• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "Test.h"
2 
3 using namespace skiatest;
4 
Reporter()5 Reporter::Reporter() {
6     this->resetReporting();
7 }
8 
resetReporting()9 void Reporter::resetReporting() {
10     fCurrTest = NULL;
11     fTestCount = 0;
12     sk_bzero(fResultCount, sizeof(fResultCount));
13 }
14 
startTest(Test * test)15 void Reporter::startTest(Test* test) {
16     SkASSERT(NULL == fCurrTest);
17     fCurrTest = test;
18     this->onStart(test);
19     fTestCount += 1;
20     fCurrTestSuccess = true;    // we're optimistic
21 }
22 
report(const char desc[],Result result)23 void Reporter::report(const char desc[], Result result) {
24     if (NULL == desc) {
25         desc = "<no description>";
26     }
27     this->onReport(desc, result);
28     fResultCount[result] += 1;
29     if (kFailed == result) {
30         fCurrTestSuccess = false;
31     }
32 }
33 
endTest(Test * test)34 void Reporter::endTest(Test* test) {
35     SkASSERT(test == fCurrTest);
36     this->onEnd(test);
37     fCurrTest = NULL;
38 }
39 
40 ///////////////////////////////////////////////////////////////////////////////
41 
Test()42 Test::Test() : fReporter(NULL) {}
43 
~Test()44 Test::~Test() {
45     SkSafeUnref(fReporter);
46 }
47 
setReporter(Reporter * r)48 void Test::setReporter(Reporter* r) {
49     SkRefCnt_SafeAssign(fReporter, r);
50 }
51 
getName()52 const char* Test::getName() {
53     if (fName.size() == 0) {
54         this->onGetName(&fName);
55     }
56     return fName.c_str();
57 }
58 
run()59 bool Test::run() {
60     fReporter->startTest(this);
61     this->onRun(fReporter);
62     fReporter->endTest(this);
63     return fReporter->getCurrSuccess();
64 }
65 
66