aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2009-04-13 16:39:41 -0400
committerMike Reed <reed@google.com>2009-04-14 10:52:38 -0400
commitf95abb54afa5469c53d3ac899ecbce8a386471c1 (patch)
treeb60a28f58b44679c3c5d71b114ad5cb812670539 /tests
parenta9235d9e57f42da3cd6b6cdc34ef4c68940cb771 (diff)
downloadexternal_skia-f95abb54afa5469c53d3ac899ecbce8a386471c1.zip
external_skia-f95abb54afa5469c53d3ac899ecbce8a386471c1.tar.gz
external_skia-f95abb54afa5469c53d3ac899ecbce8a386471c1.tar.bz2
Pull latest changes from skia/trunk:
SkColorPriv.h - change alpha macro to favor keep opaque destinations opaque SkFontHost.h - new apis for accessing font tables SkPostConfig.h - more #ifdef protections around windows.h SkFontHost_tables.cpp added Various updates to unit tests
Diffstat (limited to 'tests')
-rw-r--r--tests/SrcOverTest.cpp2
-rw-r--r--tests/Test.cpp7
-rw-r--r--tests/Test.h9
-rw-r--r--tests/testmain.cpp63
4 files changed, 62 insertions, 19 deletions
diff --git a/tests/SrcOverTest.cpp b/tests/SrcOverTest.cpp
index 497b3a8..e95485b 100644
--- a/tests/SrcOverTest.cpp
+++ b/tests/SrcOverTest.cpp
@@ -39,7 +39,7 @@ static void test_srcover_hack(skiatest::Reporter* reporter) {
opaqueCounter0, opaqueCounter1, opaqueCounter2);
#endif
// we acknowledge that technique0 does not always return opaque
- REPORTER_ASSERT(reporter, opaqueCounter0 == 129);
+ REPORTER_ASSERT(reporter, opaqueCounter0 == 256);
REPORTER_ASSERT(reporter, opaqueCounter1 == 256);
REPORTER_ASSERT(reporter, opaqueCounter2 == 256);
diff --git a/tests/Test.cpp b/tests/Test.cpp
index 5b8d439..2de0183 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -17,6 +17,7 @@ void Reporter::startTest(Test* test) {
fCurrTest = test;
this->onStart(test);
fTestCount += 1;
+ fCurrTestSuccess = true; // we're optimistic
}
void Reporter::report(const char desc[], Result result) {
@@ -25,6 +26,9 @@ void Reporter::report(const char desc[], Result result) {
}
this->onReport(desc, result);
fResultCount[result] += 1;
+ if (kFailed == result) {
+ fCurrTestSuccess = false;
+ }
}
void Reporter::endTest(Test* test) {
@@ -52,9 +56,10 @@ const char* Test::getName() {
return fName.c_str();
}
-void Test::run() {
+bool Test::run() {
fReporter->startTest(this);
this->onRun(fReporter);
fReporter->endTest(this);
+ return fReporter->getCurrSuccess();
}
diff --git a/tests/Test.h b/tests/Test.h
index d5dc9e3..de51801 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -48,7 +48,11 @@ namespace skiatest {
void reportFailed(const SkString& desc) {
this->report(desc.c_str(), kFailed);
}
-
+
+ bool getCurrSuccess() const {
+ return fCurrTestSuccess;
+ }
+
protected:
virtual void onStart(Test*) {}
virtual void onReport(const char desc[], Result) {}
@@ -58,6 +62,7 @@ namespace skiatest {
Test* fCurrTest;
int fTestCount;
int fResultCount[kLastResult+1];
+ bool fCurrTestSuccess;
typedef SkRefCnt INHERITED;
};
@@ -71,7 +76,7 @@ namespace skiatest {
void setReporter(Reporter*);
const char* getName();
- void run();
+ bool run(); // returns true on success
protected:
virtual void onGetName(SkString*) = 0;
diff --git a/tests/testmain.cpp b/tests/testmain.cpp
index 2e16de3..f09fded 100644
--- a/tests/testmain.cpp
+++ b/tests/testmain.cpp
@@ -49,20 +49,50 @@ static const char* result2string(Reporter::Result result) {
class DebugfReporter : public Reporter {
public:
+ DebugfReporter(bool androidMode) : fAndroidMode(androidMode) {}
+
void setIndexOfTotal(int index, int total) {
fIndex = index;
fTotal = total;
}
protected:
virtual void onStart(Test* test) {
- SkDebugf("Running [%d/%d] %s...\n", fIndex+1, fTotal, test->getName());
+ this->dumpState(test, kStarting_State);
}
virtual void onReport(const char desc[], Reporter::Result result) {
- SkDebugf("\t%s: %s\n", result2string(result), desc);
+ if (!fAndroidMode) {
+ SkDebugf("\t%s: %s\n", result2string(result), desc);
+ }
+ }
+ virtual void onEnd(Test* test) {
+ this->dumpState(test, this->getCurrSuccess() ?
+ kSucceeded_State : kFailed_State);
}
- virtual void onEnd(Test* test) {}
private:
+ enum State {
+ kStarting_State = 1,
+ kSucceeded_State = 0,
+ kFailed_State = -2
+ };
+
+ void dumpState(Test* test, State state) {
+ if (fAndroidMode) {
+ SkDebugf("INSTRUMENTATION_STATUS: test=%s\n", test->getName());
+ SkDebugf("INSTRUMENTATION_STATUS: class=com.skia\n");
+ SkDebugf("INSTRUMENTATION_STATUS: current=%d\n", fIndex+1);
+ SkDebugf("INSTRUMENTATION_STATUS: numtests=%d\n", fTotal);
+ SkDebugf("INSTRUMENTATION_STATUS_CODE: %d\n", state);
+ } else {
+ if (kStarting_State == state) {
+ SkDebugf("[%d/%d] %s...\n", fIndex+1, fTotal, test->getName());
+ } else if (kFailed_State == state) {
+ SkDebugf("---- FAILED\n");
+ }
+ }
+ }
+
int fIndex, fTotal;
+ bool fAndroidMode;
};
class SkAutoGraphics {
@@ -77,28 +107,31 @@ public:
int main (int argc, char * const argv[]) {
SkAutoGraphics ag;
+
+ bool androidMode = false;
+ for (int i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-android")) {
+ androidMode = true;
+ }
+ }
- DebugfReporter reporter;
+ DebugfReporter reporter(androidMode);
Iter iter(&reporter);
Test* test;
const int count = Iter::Count();
int index = 0;
+ int successCount = 0;
while ((test = iter.next()) != NULL) {
reporter.setIndexOfTotal(index, count);
- test->run();
+ successCount += test->run();
SkDELETE(test);
index += 1;
}
- SkDebugf("Finished %d tests.\n", count);
-
-#if 0
- int total = reporter.countTests();
- int passed = reporter.countResults(Reporter::kPassed);
- int failed = reporter.countResults(Reporter::kFailed);
- SkDebugf("Tests=%d Passed=%d (%g%%) Failed=%d (%g%%)\n", total,
- passed, passed * 100.f / total,
- failed, failed * 100.f / total);
-#endif
+
+ if (!androidMode) {
+ SkDebugf("Finished %d tests, %d failures.\n", count,
+ count - successCount);
+ }
return 0;
}