Refactor: clean up some unused or mostly-unused API I saw here.
BUG= R=bungeman@google.com, reed@google.com Author: mtklein@google.com Review URL: https://chromiumcodereview.appspot.com/17414003 git-svn-id: http://skia.googlecode.com/svn/trunk@9668 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
7a11591e5e
commit
1f7928663f
@ -273,7 +273,7 @@ static void test_files(skiatest::Reporter* reporter) {
|
|||||||
if (!writer.isValid()) {
|
if (!writer.isValid()) {
|
||||||
SkString msg;
|
SkString msg;
|
||||||
msg.printf("Failed to create tmp file %s\n", path.c_str());
|
msg.printf("Failed to create tmp file %s\n", path.c_str());
|
||||||
reporter->reportFailed(msg.c_str());
|
reporter->reportFailed(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
writer.write(s, 26);
|
writer.write(s, 26);
|
||||||
|
@ -59,7 +59,7 @@ static void drawAndTest(skiatest::Reporter* reporter, const SkPath& path,
|
|||||||
}
|
}
|
||||||
appendStr(&str, paint);
|
appendStr(&str, paint);
|
||||||
appendStr(&str, path);
|
appendStr(&str, path);
|
||||||
reporter->report(str.c_str(), skiatest::Reporter::kFailed);
|
reporter->reportFailed(str);
|
||||||
|
|
||||||
// uncomment this if you want to step in to see the failure
|
// uncomment this if you want to step in to see the failure
|
||||||
// canvas.drawPath(path, p);
|
// canvas.drawPath(path, p);
|
||||||
|
@ -44,7 +44,7 @@ static void test_filestreams(skiatest::Reporter* reporter, const char* tmpDir) {
|
|||||||
if (!writer.isValid()) {
|
if (!writer.isValid()) {
|
||||||
SkString msg;
|
SkString msg;
|
||||||
msg.printf("Failed to create tmp file %s\n", path.c_str());
|
msg.printf("Failed to create tmp file %s\n", path.c_str());
|
||||||
reporter->reportFailed(msg.c_str());
|
reporter->reportFailed(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ void Reporter::startTest(Test* test) {
|
|||||||
this->onStart(test);
|
this->onStart(test);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reporter::report(const char desc[], Result result) {
|
void Reporter::reportFailed(const SkString& desc) {
|
||||||
this->onReport(desc ? desc : "<no description>", result);
|
this->onReportFailed(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reporter::endTest(Test* test) {
|
void Reporter::endTest(Test* test) {
|
||||||
@ -64,13 +64,11 @@ namespace {
|
|||||||
explicit LocalReporter(Reporter* reporterToMimic) : fReporter(reporterToMimic) {}
|
explicit LocalReporter(Reporter* reporterToMimic) : fReporter(reporterToMimic) {}
|
||||||
|
|
||||||
int failure_size() const { return fFailures.count(); }
|
int failure_size() const { return fFailures.count(); }
|
||||||
const char* failure(int i) const { return fFailures[i].c_str(); }
|
const SkString& failure(int i) const { return fFailures[i]; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onReport(const char desc[], Result result) SK_OVERRIDE {
|
void onReportFailed(const SkString& desc) SK_OVERRIDE {
|
||||||
if (kFailed == result) {
|
fFailures.push_back(desc);
|
||||||
fFailures.push_back().set(desc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proxy down to fReporter. We assume these calls are threadsafe.
|
// Proxy down to fReporter. We assume these calls are threadsafe.
|
||||||
@ -110,7 +108,7 @@ void Test::run() {
|
|||||||
|
|
||||||
// Now tell fReporter about any failures and wrap up.
|
// Now tell fReporter about any failures and wrap up.
|
||||||
for (int i = 0; i < local.failure_size(); i++) {
|
for (int i = 0; i < local.failure_size(); i++) {
|
||||||
fReporter->report(local.failure(i), Reporter::kFailed);
|
fReporter->reportFailed(local.failure(i));
|
||||||
}
|
}
|
||||||
fReporter->endTest(this);
|
fReporter->endTest(this);
|
||||||
|
|
||||||
|
20
tests/Test.h
20
tests/Test.h
@ -25,35 +25,19 @@ namespace skiatest {
|
|||||||
SK_DECLARE_INST_COUNT(Reporter)
|
SK_DECLARE_INST_COUNT(Reporter)
|
||||||
Reporter();
|
Reporter();
|
||||||
|
|
||||||
enum Result {
|
|
||||||
kPassed, // must begin with 0
|
|
||||||
kFailed,
|
|
||||||
/////
|
|
||||||
kLastResult = kFailed
|
|
||||||
};
|
|
||||||
|
|
||||||
int countTests() const { return fTestCount; }
|
int countTests() const { return fTestCount; }
|
||||||
|
|
||||||
void startTest(Test*);
|
void startTest(Test*);
|
||||||
void report(const char testDesc[], Result);
|
void reportFailed(const SkString& desc);
|
||||||
void endTest(Test*);
|
void endTest(Test*);
|
||||||
|
|
||||||
virtual bool allowExtendedTest() const { return false; }
|
virtual bool allowExtendedTest() const { return false; }
|
||||||
virtual bool allowThreaded() const { return false; }
|
virtual bool allowThreaded() const { return false; }
|
||||||
virtual void bumpTestCount() { sk_atomic_inc(&fTestCount); }
|
virtual void bumpTestCount() { sk_atomic_inc(&fTestCount); }
|
||||||
|
|
||||||
// helpers for tests
|
|
||||||
void reportFailed(const char desc[]) {
|
|
||||||
this->report(desc, kFailed);
|
|
||||||
}
|
|
||||||
void reportFailed(const SkString& desc) {
|
|
||||||
this->report(desc.c_str(), kFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onStart(Test*) {}
|
virtual void onStart(Test*) {}
|
||||||
virtual void onReport(const char desc[], Result) {}
|
virtual void onReportFailed(const SkString& desc) {}
|
||||||
virtual void onEnd(Test*) {}
|
virtual void onEnd(Test*) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -55,10 +55,6 @@ private:
|
|||||||
const TestRegistry* fReg;
|
const TestRegistry* fReg;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* result2string(Reporter::Result result) {
|
|
||||||
return result == Reporter::kPassed ? "passed" : "FAILED";
|
|
||||||
}
|
|
||||||
|
|
||||||
class DebugfReporter : public Reporter {
|
class DebugfReporter : public Reporter {
|
||||||
public:
|
public:
|
||||||
DebugfReporter(bool allowExtendedTest, bool allowThreaded)
|
DebugfReporter(bool allowExtendedTest, bool allowThreaded)
|
||||||
@ -87,8 +83,8 @@ protected:
|
|||||||
sk_atomic_inc(&fPending);
|
sk_atomic_inc(&fPending);
|
||||||
SkDebugf("[%3d/%3d] (%d) %s\n", index+1, fTotal, fPending, test->getName());
|
SkDebugf("[%3d/%3d] (%d) %s\n", index+1, fTotal, fPending, test->getName());
|
||||||
}
|
}
|
||||||
virtual void onReport(const char desc[], Reporter::Result result) {
|
virtual void onReportFailed(const SkString& desc) {
|
||||||
SkDebugf("\t%s: %s\n", result2string(result), desc);
|
SkDebugf("\tFAILED: %s\n", desc.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void onEnd(Test* test) {
|
virtual void onEnd(Test* test) {
|
||||||
|
Loading…
Reference in New Issue
Block a user