OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 | 9 |
10 #include "SkCommandLineFlags.h" | 10 #include "SkCommandLineFlags.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 using namespace skiatest; | 25 using namespace skiatest; |
26 | 26 |
27 Reporter::Reporter() : fTestCount(0) { | 27 Reporter::Reporter() : fTestCount(0) { |
28 } | 28 } |
29 | 29 |
30 void Reporter::startTest(Test* test) { | 30 void Reporter::startTest(Test* test) { |
31 this->onStart(test); | 31 this->onStart(test); |
32 } | 32 } |
33 | 33 |
34 void Reporter::reportFailed(const SkString& desc) { | 34 void Reporter::reportFailed(const skiatest::Failure& failure) { |
35 this->onReportFailed(desc); | 35 this->onReportFailed(failure); |
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 10 matching lines...) Expand all Loading... |
56 this->onGetName(&fName); | 56 this->onGetName(&fName); |
57 } | 57 } |
58 return fName.c_str(); | 58 return fName.c_str(); |
59 } | 59 } |
60 | 60 |
61 class LocalReporter : public Reporter { | 61 class LocalReporter : public Reporter { |
62 public: | 62 public: |
63 explicit LocalReporter(Reporter* reporterToMimic) : fReporter(reporterToMimi
c) {} | 63 explicit LocalReporter(Reporter* reporterToMimic) : fReporter(reporterToMimi
c) {} |
64 | 64 |
65 int numFailures() const { return fFailures.count(); } | 65 int numFailures() const { return fFailures.count(); } |
66 const SkString& failure(int i) const { return fFailures[i]; } | 66 const skiatest::Failure& failure(int i) const { return fFailures[i]; } |
67 | 67 |
68 protected: | 68 protected: |
69 virtual void onReportFailed(const SkString& desc) SK_OVERRIDE { | 69 virtual void onReportFailed(const Failure& failure) SK_OVERRIDE { |
70 fFailures.push_back(desc); | 70 fFailures.push_back(failure); |
71 } | 71 } |
72 | 72 |
73 // Proxy down to fReporter. We assume these calls are threadsafe. | 73 // Proxy down to fReporter. We assume these calls are threadsafe. |
74 virtual bool allowExtendedTest() const SK_OVERRIDE { | 74 virtual bool allowExtendedTest() const SK_OVERRIDE { |
75 return fReporter->allowExtendedTest(); | 75 return fReporter->allowExtendedTest(); |
76 } | 76 } |
77 | 77 |
78 virtual void bumpTestCount() SK_OVERRIDE { | 78 virtual void bumpTestCount() SK_OVERRIDE { |
79 fReporter->bumpTestCount(); | 79 fReporter->bumpTestCount(); |
80 } | 80 } |
81 | 81 |
82 virtual bool verbose() const SK_OVERRIDE { | 82 virtual bool verbose() const SK_OVERRIDE { |
83 return fReporter->verbose(); | 83 return fReporter->verbose(); |
84 } | 84 } |
85 | 85 |
86 private: | 86 private: |
87 Reporter* fReporter; // Unowned. | 87 Reporter* fReporter; // Unowned. |
88 SkTArray<SkString> fFailures; | 88 SkTArray<skiatest::Failure> fFailures; |
89 }; | 89 }; |
90 | 90 |
91 void Test::run() { | 91 void Test::run() { |
92 // Clear the Skia error callback before running any test, to ensure that tes
ts | 92 // Clear the Skia error callback before running any test, to ensure that tes
ts |
93 // don't have unintended side effects when running more than one. | 93 // don't have unintended side effects when running more than one. |
94 SkSetErrorCallback( NULL, NULL ); | 94 SkSetErrorCallback( NULL, NULL ); |
95 | 95 |
96 // Tell (likely shared) fReporter that this test has started. | 96 // Tell (likely shared) fReporter that this test has started. |
97 fReporter->startTest(this); | 97 fReporter->startTest(this); |
98 | 98 |
(...skipping 10 matching lines...) Expand all Loading... |
109 fReporter->reportFailed(local.failure(i)); | 109 fReporter->reportFailed(local.failure(i)); |
110 } | 110 } |
111 fReporter->endTest(this); | 111 fReporter->endTest(this); |
112 | 112 |
113 } | 113 } |
114 | 114 |
115 SkString Test::GetTmpDir() { | 115 SkString Test::GetTmpDir() { |
116 const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0]; | 116 const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0]; |
117 return SkString(tmpDir); | 117 return SkString(tmpDir); |
118 } | 118 } |
OLD | NEW |