2009-02-27 16:24:51 +00:00
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
using namespace skiatest;
|
|
|
|
|
|
|
|
Reporter::Reporter() {
|
|
|
|
this->resetReporting();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reporter::resetReporting() {
|
|
|
|
fCurrTest = NULL;
|
|
|
|
fTestCount = 0;
|
2009-06-29 16:25:36 +00:00
|
|
|
sk_bzero(fResultCount, sizeof(fResultCount));
|
2009-02-27 16:24:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reporter::startTest(Test* test) {
|
|
|
|
SkASSERT(NULL == fCurrTest);
|
|
|
|
fCurrTest = test;
|
|
|
|
this->onStart(test);
|
|
|
|
fTestCount += 1;
|
2009-04-09 04:06:54 +00:00
|
|
|
fCurrTestSuccess = true; // we're optimistic
|
2009-02-27 16:24:51 +00: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 04:06:54 +00:00
|
|
|
if (kFailed == result) {
|
|
|
|
fCurrTestSuccess = false;
|
|
|
|
}
|
2009-02-27 16:24:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reporter::endTest(Test* test) {
|
|
|
|
SkASSERT(test == fCurrTest);
|
|
|
|
this->onEnd(test);
|
|
|
|
fCurrTest = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
Test::Test() : fReporter(NULL) {}
|
|
|
|
|
|
|
|
Test::~Test() {
|
|
|
|
fReporter->safeUnref();
|
|
|
|
}
|
|
|
|
|
|
|
|
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 04:06:54 +00:00
|
|
|
bool Test::run() {
|
2009-02-27 16:24:51 +00:00
|
|
|
fReporter->startTest(this);
|
|
|
|
this->onRun(fReporter);
|
|
|
|
fReporter->endTest(this);
|
2009-04-09 04:06:54 +00:00
|
|
|
return fReporter->getCurrSuccess();
|
2009-02-27 16:24:51 +00:00
|
|
|
}
|
|
|
|
|