| 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->onReport(desc.c_str(), kFailed); |
| 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 onReport(const char desc[], Result result) SK_OVERRIDE { |
| 71 if (kFailed == result) { | 71 if (kFailed == result) { |
| 72 fFailures.push_back().set(desc); | 72 fFailures.push_back().set(desc); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Proxy down to fReporter. We assume these calls are threadsafe. | 76 // Proxy down to fReporter. We assume these calls are threadsafe. |
| 77 virtual bool allowExtendedTest() const SK_OVERRIDE { | 77 virtual bool allowExtendedTest() const SK_OVERRIDE { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 const SkMSec start = SkTime::GetMSecs(); | 103 const SkMSec start = SkTime::GetMSecs(); |
| 104 // Run the test into a LocalReporter so we know if it's passed or failed wit
hout interference | 104 // 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. | 105 // from other tests that might share fReporter. |
| 106 LocalReporter local(fReporter); | 106 LocalReporter local(fReporter); |
| 107 this->onRun(&local); | 107 this->onRun(&local); |
| 108 fPassed = local.failure_size() == 0; | 108 fPassed = local.failure_size() == 0; |
| 109 fElapsed = SkTime::GetMSecs() - start; | 109 fElapsed = SkTime::GetMSecs() - start; |
| 110 | 110 |
| 111 // Now tell fReporter about any failures and wrap up. | 111 // Now tell fReporter about any failures and wrap up. |
| 112 for (int i = 0; i < local.failure_size(); i++) { | 112 for (int i = 0; i < local.failure_size(); i++) { |
| 113 fReporter->report(local.failure(i), Reporter::kFailed); | 113 fReporter->reportFailed(local.failure(i)); |
| 114 } | 114 } |
| 115 fReporter->endTest(this); | 115 fReporter->endTest(this); |
| 116 | 116 |
| 117 } | 117 } |
| 118 | 118 |
| 119 /////////////////////////////////////////////////////////////////////////////// | 119 /////////////////////////////////////////////////////////////////////////////// |
| 120 | 120 |
| 121 #if SK_SUPPORT_GPU | 121 #if SK_SUPPORT_GPU |
| 122 #include "GrContextFactory.h" | 122 #include "GrContextFactory.h" |
| 123 GrContextFactory gGrContextFactory; | 123 GrContextFactory gGrContextFactory; |
| 124 #endif | 124 #endif |
| 125 | 125 |
| 126 GrContextFactory* GpuTest::GetGrContextFactory() { | 126 GrContextFactory* GpuTest::GetGrContextFactory() { |
| 127 #if SK_SUPPORT_GPU | 127 #if SK_SUPPORT_GPU |
| 128 return &gGrContextFactory; | 128 return &gGrContextFactory; |
| 129 #else | 129 #else |
| 130 return NULL; | 130 return NULL; |
| 131 #endif | 131 #endif |
| 132 } | 132 } |
| 133 | 133 |
| 134 void GpuTest::DestroyContexts() { | 134 void GpuTest::DestroyContexts() { |
| 135 #if SK_SUPPORT_GPU | 135 #if SK_SUPPORT_GPU |
| 136 gGrContextFactory.destroyContexts(); | 136 gGrContextFactory.destroyContexts(); |
| 137 #endif | 137 #endif |
| 138 } | 138 } |
| OLD | NEW |