2009-02-27 19:24:51 +03:00
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
using namespace skiatest;
|
|
|
|
|
|
|
|
Reporter::Reporter() {
|
|
|
|
this->resetReporting();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reporter::resetReporting() {
|
|
|
|
fCurrTest = NULL;
|
|
|
|
fTestCount = 0;
|
2009-06-29 20:25:36 +04:00
|
|
|
sk_bzero(fResultCount, sizeof(fResultCount));
|
2009-02-27 19:24:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reporter::startTest(Test* test) {
|
|
|
|
SkASSERT(NULL == fCurrTest);
|
|
|
|
fCurrTest = test;
|
|
|
|
this->onStart(test);
|
|
|
|
fTestCount += 1;
|
2009-04-09 08:06:54 +04:00
|
|
|
fCurrTestSuccess = true; // we're optimistic
|
2009-02-27 19:24:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reporter::report(const char desc[], Result result) {
|
|
|
|
if (NULL == desc) {
|
|
|
|
desc = "<no description>";
|
|
|
|
}
|
|
|
|
this->onReport(desc, result);
|
|
|
|
fResultCount[result] += 1;
|
2009-04-09 08:06:54 +04:00
|
|
|
if (kFailed == result) {
|
|
|
|
fCurrTestSuccess = false;
|
|
|
|
}
|
2009-02-27 19:24:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reporter::endTest(Test* test) {
|
|
|
|
SkASSERT(test == fCurrTest);
|
|
|
|
this->onEnd(test);
|
|
|
|
fCurrTest = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Test::Test() : fReporter(NULL) {}
|
|
|
|
|
|
|
|
Test::~Test() {
|
2011-02-07 18:30:46 +03:00
|
|
|
SkSafeUnref(fReporter);
|
2009-02-27 19:24:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Test::setReporter(Reporter* r) {
|
|
|
|
SkRefCnt_SafeAssign(fReporter, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* Test::getName() {
|
|
|
|
if (fName.size() == 0) {
|
|
|
|
this->onGetName(&fName);
|
|
|
|
}
|
|
|
|
return fName.c_str();
|
|
|
|
}
|
|
|
|
|
2009-04-09 08:06:54 +04:00
|
|
|
bool Test::run() {
|
2009-02-27 19:24:51 +03:00
|
|
|
fReporter->startTest(this);
|
|
|
|
this->onRun(fReporter);
|
|
|
|
fReporter->endTest(this);
|
2009-04-09 08:06:54 +04:00
|
|
|
return fReporter->getCurrSuccess();
|
2009-02-27 19:24:51 +03:00
|
|
|
}
|
|
|
|
|