aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tests/DataRefTest.cpp2
-rw-r--r--tests/EmptyPathTest.cpp2
-rw-r--r--tests/StreamTest.cpp2
-rw-r--r--tests/Test.cpp14
-rw-r--r--tests/Test.h20
-rw-r--r--tests/skia_test.cpp8
6 files changed, 13 insertions, 35 deletions
diff --git a/tests/DataRefTest.cpp b/tests/DataRefTest.cpp
index b6daaf9569..313a61066d 100644
--- a/tests/DataRefTest.cpp
+++ b/tests/DataRefTest.cpp
@@ -273,7 +273,7 @@ static void test_files(skiatest::Reporter* reporter) {
if (!writer.isValid()) {
SkString msg;
msg.printf("Failed to create tmp file %s\n", path.c_str());
- reporter->reportFailed(msg.c_str());
+ reporter->reportFailed(msg);
return;
}
writer.write(s, 26);
diff --git a/tests/EmptyPathTest.cpp b/tests/EmptyPathTest.cpp
index 5c054ec16b..153af1f50a 100644
--- a/tests/EmptyPathTest.cpp
+++ b/tests/EmptyPathTest.cpp
@@ -59,7 +59,7 @@ static void drawAndTest(skiatest::Reporter* reporter, const SkPath& path,
}
appendStr(&str, paint);
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
// canvas.drawPath(path, p);
diff --git a/tests/StreamTest.cpp b/tests/StreamTest.cpp
index 00c079abc0..cf828430a9 100644
--- a/tests/StreamTest.cpp
+++ b/tests/StreamTest.cpp
@@ -44,7 +44,7 @@ static void test_filestreams(skiatest::Reporter* reporter, const char* tmpDir) {
if (!writer.isValid()) {
SkString msg;
msg.printf("Failed to create tmp file %s\n", path.c_str());
- reporter->reportFailed(msg.c_str());
+ reporter->reportFailed(msg);
return;
}
diff --git a/tests/Test.cpp b/tests/Test.cpp
index f8f2e62610..32c293e40f 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -31,8 +31,8 @@ void Reporter::startTest(Test* test) {
this->onStart(test);
}
-void Reporter::report(const char desc[], Result result) {
- this->onReport(desc ? desc : "<no description>", result);
+void Reporter::reportFailed(const SkString& desc) {
+ this->onReportFailed(desc);
}
void Reporter::endTest(Test* test) {
@@ -64,13 +64,11 @@ namespace {
explicit LocalReporter(Reporter* reporterToMimic) : fReporter(reporterToMimic) {}
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:
- void onReport(const char desc[], Result result) SK_OVERRIDE {
- if (kFailed == result) {
- fFailures.push_back().set(desc);
- }
+ void onReportFailed(const SkString& desc) SK_OVERRIDE {
+ fFailures.push_back(desc);
}
// 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.
for (int i = 0; i < local.failure_size(); i++) {
- fReporter->report(local.failure(i), Reporter::kFailed);
+ fReporter->reportFailed(local.failure(i));
}
fReporter->endTest(this);
diff --git a/tests/Test.h b/tests/Test.h
index 8cb23c1b48..fa62afeab3 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -25,35 +25,19 @@ namespace skiatest {
SK_DECLARE_INST_COUNT(Reporter)
Reporter();
- enum Result {
- kPassed, // must begin with 0
- kFailed,
- /////
- kLastResult = kFailed
- };
-
int countTests() const { return fTestCount; }
void startTest(Test*);
- void report(const char testDesc[], Result);
+ void reportFailed(const SkString& desc);
void endTest(Test*);
virtual bool allowExtendedTest() const { return false; }
virtual bool allowThreaded() const { return false; }
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:
virtual void onStart(Test*) {}
- virtual void onReport(const char desc[], Result) {}
+ virtual void onReportFailed(const SkString& desc) {}
virtual void onEnd(Test*) {}
private:
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 8cae656089..98168c55dd 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -55,10 +55,6 @@ private:
const TestRegistry* fReg;
};
-static const char* result2string(Reporter::Result result) {
- return result == Reporter::kPassed ? "passed" : "FAILED";
-}
-
class DebugfReporter : public Reporter {
public:
DebugfReporter(bool allowExtendedTest, bool allowThreaded)
@@ -87,8 +83,8 @@ protected:
sk_atomic_inc(&fPending);
SkDebugf("[%3d/%3d] (%d) %s\n", index+1, fTotal, fPending, test->getName());
}
- virtual void onReport(const char desc[], Reporter::Result result) {
- SkDebugf("\t%s: %s\n", result2string(result), desc);
+ virtual void onReportFailed(const SkString& desc) {
+ SkDebugf("\tFAILED: %s\n", desc.c_str());
}
virtual void onEnd(Test* test) {