rename tests/main to testmain.cpp
add ANDROID specific work-around for double-cinit bug git-svn-id: http://skia.googlecode.com/svn/trunk@142 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
953ce8dcb7
commit
57b799e951
3
Makefile
3
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))
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user