diff --git a/Makefile b/Makefile index 715f7e171a..ddfecfc326 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,8 @@ C_INCLUDES += -Isrc/core TESTS_SRCS := GeometryTest.cpp MathTest.cpp MatrixTest.cpp PackBitsTest.cpp \ Sk64Test.cpp StringTest.cpp Test.cpp UtilsTest.cpp PathTest.cpp \ ClipCubicTest.cpp SrcOverTest.cpp StreamTest.cpp SortTest.cpp \ - PathMeasureTest.cpp TriangulationTest.cpp main.cpp + PathMeasureTest.cpp TriangulationTest.cpp \ + testmain.cpp TESTS_SRCS := $(addprefix tests/, $(TESTS_SRCS)) diff --git a/include/core/SkTRegistry.h b/include/core/SkTRegistry.h index f0f427cb0f..78c5a0734e 100644 --- a/include/core/SkTRegistry.h +++ b/include/core/SkTRegistry.h @@ -28,6 +28,18 @@ public: typedef T (*Factory)(P); SkTRegistry(Factory fact) { +#ifdef ANDROID + // work-around for double-initialization bug + { + SkTRegistry* reg = gHead; + while (reg) { + if (reg == this) { + return; + } + reg = reg->fChain; + } + } +#endif fFact = fact; fChain = gHead; gHead = this; diff --git a/tests/main.cpp b/tests/testmain.cpp similarity index 74% rename from tests/main.cpp rename to tests/testmain.cpp index 13f8817b70..57d7c041a2 100644 --- a/tests/main.cpp +++ b/tests/testmain.cpp @@ -28,6 +28,16 @@ public: return NULL; } + static int Count() { + const TestRegistry* reg = TestRegistry::Head(); + int count = 0; + while (reg) { + count += 1; + reg = reg->next(); + } + return count; + } + private: Reporter* fReporter; const TestRegistry* fReg; @@ -38,14 +48,21 @@ static const char* result2string(Reporter::Result result) { } class DebugfReporter : public Reporter { +public: + void setIndexOfTotal(int index, int total) { + fIndex = index; + fTotal = total; + } protected: virtual void onStart(Test* test) { - SkDebugf("Running %s...\n", test->getName()); + SkDebugf("Running [%d/%d] %s...\n", fIndex+1, fTotal, test->getName()); } virtual void onReport(const char desc[], Reporter::Result result) { SkDebugf("\t%s: %s\n", result2string(result), desc); } virtual void onEnd(Test* test) {} +private: + int fIndex, fTotal; }; class SkAutoGraphics { @@ -65,17 +82,23 @@ int main (int argc, char * const argv[]) { Iter iter(&reporter); Test* test; + const int count = Iter::Count(); + int index = 0; while ((test = iter.next()) != NULL) { + reporter.setIndexOfTotal(index, count); 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 return 0; }