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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const char* Test::getName() { | 52 const char* Test::getName() { |
53 if (fName.size() == 0) { | 53 if (fName.size() == 0) { |
54 this->onGetName(&fName); | 54 this->onGetName(&fName); |
55 } | 55 } |
56 return fName.c_str(); | 56 return fName.c_str(); |
57 } | 57 } |
58 | 58 |
59 namespace { | 59 namespace { |
60 class LocalReporter : public Reporter { | 60 class LocalReporter : public Reporter { |
61 public: | 61 public: |
62 LocalReporter() {} | 62 explicit LocalReporter(const Reporter& reporterToMimic) : fReporter(repo
rterToMimic) {} |
63 | 63 |
64 int failure_size() const { return fFailures.count(); } | 64 int failure_size() const { return fFailures.count(); } |
65 const char* failure(int i) const { return fFailures[i].c_str(); } | 65 const char* failure(int i) const { return fFailures[i].c_str(); } |
66 | 66 |
67 protected: | 67 protected: |
68 void onReport(const char desc[], Result result) SK_OVERRIDE { | 68 void onReport(const char desc[], Result result) SK_OVERRIDE { |
69 if (kFailed == result) { | 69 if (kFailed == result) { |
70 fFailures.push_back().set(desc); | 70 fFailures.push_back().set(desc); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
| 74 virtual bool allowExtendedTest() const SK_OVERRIDE { |
| 75 return fReporter.allowExtendedTest(); |
| 76 } |
| 77 |
| 78 virtual bool allowThreaded() const SK_OVERRIDE { |
| 79 return fReporter.allowThreaded(); |
| 80 } |
| 81 |
74 private: | 82 private: |
| 83 const Reporter& fReporter; |
75 SkTArray<SkString> fFailures; | 84 SkTArray<SkString> fFailures; |
76 }; | 85 }; |
77 } // namespace | 86 } // namespace |
78 | 87 |
79 void Test::run() { | 88 void Test::run() { |
80 // Tell (likely shared) fReporter that this test has started. | 89 // Tell (likely shared) fReporter that this test has started. |
81 fReporter->startTest(this); | 90 fReporter->startTest(this); |
82 | 91 |
83 // Run the test into a LocalReporter so we know if it's passed or failed wit
hout interference | 92 // Run the test into a LocalReporter so we know if it's passed or failed wit
hout interference |
84 // from other tests that might share fReporter. | 93 // from other tests that might share fReporter. |
85 LocalReporter local; | 94 LocalReporter local(*fReporter); |
86 this->onRun(&local); | 95 this->onRun(&local); |
87 fPassed = local.failure_size() == 0; | 96 fPassed = local.failure_size() == 0; |
88 | 97 |
89 // Now tell fReporter about any failures and wrap up. | 98 // Now tell fReporter about any failures and wrap up. |
90 for (int i = 0; i < local.failure_size(); i++) { | 99 for (int i = 0; i < local.failure_size(); i++) { |
91 fReporter->report(local.failure(i), Reporter::kFailed); | 100 fReporter->report(local.failure(i), Reporter::kFailed); |
92 } | 101 } |
93 fReporter->endTest(this); | 102 fReporter->endTest(this); |
94 } | 103 } |
95 | 104 |
(...skipping 10 matching lines...) Expand all Loading... |
106 #else | 115 #else |
107 return NULL; | 116 return NULL; |
108 #endif | 117 #endif |
109 } | 118 } |
110 | 119 |
111 void GpuTest::DestroyContexts() { | 120 void GpuTest::DestroyContexts() { |
112 #if SK_SUPPORT_GPU | 121 #if SK_SUPPORT_GPU |
113 gGrContextFactory.destroyContexts(); | 122 gGrContextFactory.destroyContexts(); |
114 #endif | 123 #endif |
115 } | 124 } |
OLD | NEW |