| 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 #ifndef skiatest_Test_DEFINED | 8 #ifndef skiatest_Test_DEFINED |
| 9 #define skiatest_Test_DEFINED | 9 #define skiatest_Test_DEFINED |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 Reporter(); | 24 Reporter(); |
| 25 | 25 |
| 26 enum Result { | 26 enum Result { |
| 27 kPassed, // must begin with 0 | 27 kPassed, // must begin with 0 |
| 28 kFailed, | 28 kFailed, |
| 29 ///// | 29 ///// |
| 30 kLastResult = kFailed | 30 kLastResult = kFailed |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 void resetReporting(); | 33 void resetReporting(); |
| 34 void bumpTestCount() { ++fTestCount; } |
| 34 int countTests() const { return fTestCount; } | 35 int countTests() const { return fTestCount; } |
| 35 int countResults(Result r) { | 36 int countResults(Result r) { |
| 36 SkASSERT((unsigned)r <= kLastResult); | 37 SkASSERT((unsigned)r <= kLastResult); |
| 37 return fResultCount[r]; | 38 return fResultCount[r]; |
| 38 } | 39 } |
| 39 | 40 |
| 40 void startTest(Test*); | 41 void startTest(Test*); |
| 41 void report(const char testDesc[], Result); | 42 void report(const char testDesc[], Result); |
| 42 void endTest(Test*); | 43 void endTest(Test*); |
| 44 virtual bool allowExtendedTest() const { return false; } |
| 43 | 45 |
| 44 // helpers for tests | 46 // helpers for tests |
| 45 void assertTrue(bool cond, const char desc[]) { | 47 void assertTrue(bool cond, const char desc[]) { |
| 46 if (!cond) { | 48 if (!cond) { |
| 47 this->report(desc, kFailed); | 49 this->report(desc, kFailed); |
| 48 } | 50 } |
| 49 } | 51 } |
| 50 void assertFalse(bool cond, const char desc[]) { | 52 void assertFalse(bool cond, const char desc[]) { |
| 51 if (cond) { | 53 if (cond) { |
| 52 this->report(desc, kFailed); | 54 this->report(desc, kFailed); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 do { \ | 127 do { \ |
| 126 if (!(cond)) { \ | 128 if (!(cond)) { \ |
| 127 SkString desc; \ | 129 SkString desc; \ |
| 128 desc.printf("%s %s:%d: %s", message, __FILE__, __LINE__, #cond); \ | 130 desc.printf("%s %s:%d: %s", message, __FILE__, __LINE__, #cond); \ |
| 129 r->reportFailed(desc); \ | 131 r->reportFailed(desc); \ |
| 130 } \ | 132 } \ |
| 131 } while(0) | 133 } while(0) |
| 132 | 134 |
| 133 | 135 |
| 134 #endif | 136 #endif |
| OLD | NEW |