OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 | 9 |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 using namespace skiatest; | 24 using namespace skiatest; |
25 | 25 |
26 Reporter::Reporter() : fTestCount(0) { | 26 Reporter::Reporter() : fTestCount(0) { |
27 } | 27 } |
28 | 28 |
29 void Reporter::startTest(Test* test) { | 29 void Reporter::startTest(Test* test) { |
30 this->bumpTestCount(); | 30 this->bumpTestCount(); |
31 this->onStart(test); | 31 this->onStart(test); |
32 } | 32 } |
33 | 33 |
34 void Reporter::report(const char desc[], Result result) { | 34 void Reporter::reportFailed(const SkString& desc) { |
35 this->onReport(desc ? desc : "<no description>", result); | 35 this->onReportFailed(desc); |
36 } | 36 } |
37 | 37 |
38 void Reporter::endTest(Test* test) { | 38 void Reporter::endTest(Test* test) { |
39 this->onEnd(test); | 39 this->onEnd(test); |
40 } | 40 } |
41 | 41 |
42 /////////////////////////////////////////////////////////////////////////////// | 42 /////////////////////////////////////////////////////////////////////////////// |
43 | 43 |
44 Test::Test() : fReporter(NULL), fPassed(true) {} | 44 Test::Test() : fReporter(NULL), fPassed(true) {} |
45 | 45 |
(...skipping 11 matching lines...) Expand all Loading... |
57 } | 57 } |
58 return fName.c_str(); | 58 return fName.c_str(); |
59 } | 59 } |
60 | 60 |
61 namespace { | 61 namespace { |
62 class LocalReporter : public Reporter { | 62 class LocalReporter : public Reporter { |
63 public: | 63 public: |
64 explicit LocalReporter(Reporter* reporterToMimic) : fReporter(reporterTo
Mimic) {} | 64 explicit LocalReporter(Reporter* reporterToMimic) : fReporter(reporterTo
Mimic) {} |
65 | 65 |
66 int failure_size() const { return fFailures.count(); } | 66 int failure_size() const { return fFailures.count(); } |
67 const char* failure(int i) const { return fFailures[i].c_str(); } | 67 const SkString& failure(int i) const { return fFailures[i]; } |
68 | 68 |
69 protected: | 69 protected: |
70 void onReport(const char desc[], Result result) SK_OVERRIDE { | 70 void onReportFailed(const SkString& desc) SK_OVERRIDE { |
71 if (kFailed == result) { | 71 fFailures.push_back(desc); |
72 fFailures.push_back().set(desc); | |
73 } | |
74 } | 72 } |
75 | 73 |
76 // Proxy down to fReporter. We assume these calls are threadsafe. | 74 // Proxy down to fReporter. We assume these calls are threadsafe. |
77 virtual bool allowExtendedTest() const SK_OVERRIDE { | 75 virtual bool allowExtendedTest() const SK_OVERRIDE { |
78 return fReporter->allowExtendedTest(); | 76 return fReporter->allowExtendedTest(); |
79 } | 77 } |
80 | 78 |
81 virtual bool allowThreaded() const SK_OVERRIDE { | 79 virtual bool allowThreaded() const SK_OVERRIDE { |
82 return fReporter->allowThreaded(); | 80 return fReporter->allowThreaded(); |
83 } | 81 } |
(...skipping 19 matching lines...) Expand all Loading... |
103 const SkMSec start = SkTime::GetMSecs(); | 101 const SkMSec start = SkTime::GetMSecs(); |
104 // Run the test into a LocalReporter so we know if it's passed or failed wit
hout interference | 102 // Run the test into a LocalReporter so we know if it's passed or failed wit
hout interference |
105 // from other tests that might share fReporter. | 103 // from other tests that might share fReporter. |
106 LocalReporter local(fReporter); | 104 LocalReporter local(fReporter); |
107 this->onRun(&local); | 105 this->onRun(&local); |
108 fPassed = local.failure_size() == 0; | 106 fPassed = local.failure_size() == 0; |
109 fElapsed = SkTime::GetMSecs() - start; | 107 fElapsed = SkTime::GetMSecs() - start; |
110 | 108 |
111 // Now tell fReporter about any failures and wrap up. | 109 // Now tell fReporter about any failures and wrap up. |
112 for (int i = 0; i < local.failure_size(); i++) { | 110 for (int i = 0; i < local.failure_size(); i++) { |
113 fReporter->report(local.failure(i), Reporter::kFailed); | 111 fReporter->reportFailed(local.failure(i)); |
114 } | 112 } |
115 fReporter->endTest(this); | 113 fReporter->endTest(this); |
116 | 114 |
117 } | 115 } |
118 | 116 |
119 /////////////////////////////////////////////////////////////////////////////// | 117 /////////////////////////////////////////////////////////////////////////////// |
120 | 118 |
121 #if SK_SUPPORT_GPU | 119 #if SK_SUPPORT_GPU |
122 #include "GrContextFactory.h" | 120 #include "GrContextFactory.h" |
123 GrContextFactory gGrContextFactory; | 121 GrContextFactory gGrContextFactory; |
124 #endif | 122 #endif |
125 | 123 |
126 GrContextFactory* GpuTest::GetGrContextFactory() { | 124 GrContextFactory* GpuTest::GetGrContextFactory() { |
127 #if SK_SUPPORT_GPU | 125 #if SK_SUPPORT_GPU |
128 return &gGrContextFactory; | 126 return &gGrContextFactory; |
129 #else | 127 #else |
130 return NULL; | 128 return NULL; |
131 #endif | 129 #endif |
132 } | 130 } |
133 | 131 |
134 void GpuTest::DestroyContexts() { | 132 void GpuTest::DestroyContexts() { |
135 #if SK_SUPPORT_GPU | 133 #if SK_SUPPORT_GPU |
136 gGrContextFactory.destroyContexts(); | 134 gGrContextFactory.destroyContexts(); |
137 #endif | 135 #endif |
138 } | 136 } |
OLD | NEW |