Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: tests/Test.cpp

Issue 13983011: Also proxy bumpTestCount. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/Test.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const char* Test::getName() { 53 const char* Test::getName() {
54 if (fName.size() == 0) { 54 if (fName.size() == 0) {
55 this->onGetName(&fName); 55 this->onGetName(&fName);
56 } 56 }
57 return fName.c_str(); 57 return fName.c_str();
58 } 58 }
59 59
60 namespace { 60 namespace {
61 class LocalReporter : public Reporter { 61 class LocalReporter : public Reporter {
62 public: 62 public:
63 explicit LocalReporter(const Reporter& reporterToMimic) : fReporter(repo rterToMimic) {} 63 explicit LocalReporter(Reporter* reporterToMimic) : fReporter(reporterTo Mimic) {}
64 64
65 int failure_size() const { return fFailures.count(); } 65 int failure_size() const { return fFailures.count(); }
66 const char* failure(int i) const { return fFailures[i].c_str(); } 66 const char* failure(int i) const { return fFailures[i].c_str(); }
67 67
68 protected: 68 protected:
69 void onReport(const char desc[], Result result) SK_OVERRIDE { 69 void onReport(const char desc[], Result result) SK_OVERRIDE {
70 if (kFailed == result) { 70 if (kFailed == result) {
71 fFailures.push_back().set(desc); 71 fFailures.push_back().set(desc);
72 } 72 }
73 } 73 }
74 74
75 // Proxy down to fReporter. We assume these calls are threadsafe.
75 virtual bool allowExtendedTest() const SK_OVERRIDE { 76 virtual bool allowExtendedTest() const SK_OVERRIDE {
76 return fReporter.allowExtendedTest(); 77 return fReporter->allowExtendedTest();
77 } 78 }
78 79
79 virtual bool allowThreaded() const SK_OVERRIDE { 80 virtual bool allowThreaded() const SK_OVERRIDE {
80 return fReporter.allowThreaded(); 81 return fReporter->allowThreaded();
82 }
83
84 virtual void bumpTestCount() SK_OVERRIDE {
85 fReporter->bumpTestCount();
81 } 86 }
82 87
83 private: 88 private:
84 const Reporter& fReporter; 89 Reporter* fReporter; // Unowned.
85 SkTArray<SkString> fFailures; 90 SkTArray<SkString> fFailures;
86 }; 91 };
87 } // namespace 92 } // namespace
88 93
89 void Test::run() { 94 void Test::run() {
90 // Tell (likely shared) fReporter that this test has started. 95 // Tell (likely shared) fReporter that this test has started.
91 fReporter->startTest(this); 96 fReporter->startTest(this);
92 97
93 const SkMSec start = SkTime::GetMSecs(); 98 const SkMSec start = SkTime::GetMSecs();
94 // Run the test into a LocalReporter so we know if it's passed or failed wit hout interference 99 // Run the test into a LocalReporter so we know if it's passed or failed wit hout interference
95 // from other tests that might share fReporter. 100 // from other tests that might share fReporter.
96 LocalReporter local(*fReporter); 101 LocalReporter local(fReporter);
97 this->onRun(&local); 102 this->onRun(&local);
98 fPassed = local.failure_size() == 0; 103 fPassed = local.failure_size() == 0;
99 fElapsed = SkTime::GetMSecs() - start; 104 fElapsed = SkTime::GetMSecs() - start;
100 105
101 // Now tell fReporter about any failures and wrap up. 106 // Now tell fReporter about any failures and wrap up.
102 for (int i = 0; i < local.failure_size(); i++) { 107 for (int i = 0; i < local.failure_size(); i++) {
103 fReporter->report(local.failure(i), Reporter::kFailed); 108 fReporter->report(local.failure(i), Reporter::kFailed);
104 } 109 }
105 fReporter->endTest(this); 110 fReporter->endTest(this);
106 } 111 }
(...skipping 11 matching lines...) Expand all
118 #else 123 #else
119 return NULL; 124 return NULL;
120 #endif 125 #endif
121 } 126 }
122 127
123 void GpuTest::DestroyContexts() { 128 void GpuTest::DestroyContexts() {
124 #if SK_SUPPORT_GPU 129 #if SK_SUPPORT_GPU
125 gGrContextFactory.destroyContexts(); 130 gGrContextFactory.destroyContexts();
126 #endif 131 #endif
127 } 132 }
OLDNEW
« no previous file with comments | « tests/Test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698