| 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" |
| 11 #include "SkTArray.h" | 11 #include "SkTArray.h" |
| 12 #include "SkTime.h" | 12 #include "SkTime.h" |
| 13 #include "SkError.h" |
| 13 | 14 |
| 14 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
| 15 #include "GrContext.h" | 16 #include "GrContext.h" |
| 16 #include "gl/SkNativeGLContext.h" | 17 #include "gl/SkNativeGLContext.h" |
| 17 #else | 18 #else |
| 18 class GrContext; | 19 class GrContext; |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 SK_DEFINE_INST_COUNT(skiatest::Reporter) | 22 SK_DEFINE_INST_COUNT(skiatest::Reporter) |
| 22 | 23 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 fReporter->bumpTestCount(); | 86 fReporter->bumpTestCount(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 private: | 89 private: |
| 89 Reporter* fReporter; // Unowned. | 90 Reporter* fReporter; // Unowned. |
| 90 SkTArray<SkString> fFailures; | 91 SkTArray<SkString> fFailures; |
| 91 }; | 92 }; |
| 92 } // namespace | 93 } // namespace |
| 93 | 94 |
| 94 void Test::run() { | 95 void Test::run() { |
| 96 // Clear the Skia error callback before running any test, to ensure that tes
ts |
| 97 // don't have unintended side effects when running more than one. |
| 98 SkSetErrorCallback( NULL, NULL ); |
| 99 |
| 95 // Tell (likely shared) fReporter that this test has started. | 100 // Tell (likely shared) fReporter that this test has started. |
| 96 fReporter->startTest(this); | 101 fReporter->startTest(this); |
| 97 | 102 |
| 98 const SkMSec start = SkTime::GetMSecs(); | 103 const SkMSec start = SkTime::GetMSecs(); |
| 99 // 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 |
| 100 // from other tests that might share fReporter. | 105 // from other tests that might share fReporter. |
| 101 LocalReporter local(fReporter); | 106 LocalReporter local(fReporter); |
| 102 this->onRun(&local); | 107 this->onRun(&local); |
| 103 fPassed = local.failure_size() == 0; | 108 fPassed = local.failure_size() == 0; |
| 104 fElapsed = SkTime::GetMSecs() - start; | 109 fElapsed = SkTime::GetMSecs() - start; |
| 105 | 110 |
| 106 // Now tell fReporter about any failures and wrap up. | 111 // Now tell fReporter about any failures and wrap up. |
| 107 for (int i = 0; i < local.failure_size(); i++) { | 112 for (int i = 0; i < local.failure_size(); i++) { |
| 108 fReporter->report(local.failure(i), Reporter::kFailed); | 113 fReporter->report(local.failure(i), Reporter::kFailed); |
| 109 } | 114 } |
| 110 fReporter->endTest(this); | 115 fReporter->endTest(this); |
| 116 |
| 111 } | 117 } |
| 112 | 118 |
| 113 /////////////////////////////////////////////////////////////////////////////// | 119 /////////////////////////////////////////////////////////////////////////////// |
| 114 | 120 |
| 115 #if SK_SUPPORT_GPU | 121 #if SK_SUPPORT_GPU |
| 116 #include "GrContextFactory.h" | 122 #include "GrContextFactory.h" |
| 117 GrContextFactory gGrContextFactory; | 123 GrContextFactory gGrContextFactory; |
| 118 #endif | 124 #endif |
| 119 | 125 |
| 120 GrContextFactory* GpuTest::GetGrContextFactory() { | 126 GrContextFactory* GpuTest::GetGrContextFactory() { |
| 121 #if SK_SUPPORT_GPU | 127 #if SK_SUPPORT_GPU |
| 122 return &gGrContextFactory; | 128 return &gGrContextFactory; |
| 123 #else | 129 #else |
| 124 return NULL; | 130 return NULL; |
| 125 #endif | 131 #endif |
| 126 } | 132 } |
| 127 | 133 |
| 128 void GpuTest::DestroyContexts() { | 134 void GpuTest::DestroyContexts() { |
| 129 #if SK_SUPPORT_GPU | 135 #if SK_SUPPORT_GPU |
| 130 gGrContextFactory.destroyContexts(); | 136 gGrContextFactory.destroyContexts(); |
| 131 #endif | 137 #endif |
| 132 } | 138 } |
| OLD | NEW |