| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 Reporter* getReporter() const { return fReporter; } | 55 Reporter* getReporter() const { return fReporter; } |
| 56 void setReporter(Reporter*); | 56 void setReporter(Reporter*); |
| 57 | 57 |
| 58 const char* getName(); | 58 const char* getName(); |
| 59 void run(); | 59 void run(); |
| 60 bool passed() const { return fPassed; } | 60 bool passed() const { return fPassed; } |
| 61 SkMSec elapsedMs() const { return fElapsed; } | 61 SkMSec elapsedMs() const { return fElapsed; } |
| 62 | 62 |
| 63 static SkString GetTmpDir(); | 63 static SkString GetTmpDir(); |
| 64 | 64 |
| 65 static void SetResourcePath(const char*); |
| 65 static SkString GetResourcePath(); | 66 static SkString GetResourcePath(); |
| 66 | 67 |
| 67 virtual bool isGPUTest() const { return false; } | 68 virtual bool isGPUTest() const { return false; } |
| 69 virtual void setGrContextFactory(GrContextFactory* factory) {} |
| 68 | 70 |
| 69 protected: | 71 protected: |
| 70 virtual void onGetName(SkString*) = 0; | 72 virtual void onGetName(SkString*) = 0; |
| 71 virtual void onRun(Reporter*) = 0; | 73 virtual void onRun(Reporter*) = 0; |
| 72 | 74 |
| 73 private: | 75 private: |
| 74 Reporter* fReporter; | 76 Reporter* fReporter; |
| 75 SkString fName; | 77 SkString fName; |
| 76 bool fPassed; | 78 bool fPassed; |
| 77 SkMSec fElapsed; | 79 SkMSec fElapsed; |
| 78 }; | 80 }; |
| 79 | 81 |
| 80 class GpuTest : public Test{ | 82 class GpuTest : public Test{ |
| 81 public: | 83 public: |
| 82 GpuTest() : Test() {} | 84 GpuTest() : Test(), fGrContextFactory(NULL) {} |
| 83 static GrContextFactory* GetGrContextFactory(); | 85 |
| 84 static void DestroyContexts(); | |
| 85 virtual bool isGPUTest() const { return true; } | 86 virtual bool isGPUTest() const { return true; } |
| 86 private: | 87 virtual void setGrContextFactory(GrContextFactory* factory) { |
| 88 fGrContextFactory = factory; |
| 89 } |
| 90 |
| 91 protected: |
| 92 GrContextFactory* fGrContextFactory; // Unowned. |
| 87 }; | 93 }; |
| 88 | 94 |
| 89 typedef SkTRegistry<Test*(*)(void*)> TestRegistry; | 95 typedef SkTRegistry<Test*(*)(void*)> TestRegistry; |
| 90 } // namespace skiatest | 96 } // namespace skiatest |
| 91 | 97 |
| 92 /* | 98 /* |
| 93 Use the following macros to make use of the skiatest classes, e.g. | 99 Use the following macros to make use of the skiatest classes, e.g. |
| 94 | 100 |
| 95 #include "Test.h" | 101 #include "Test.h" |
| 96 | 102 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 static void name(skiatest::Reporter*, GrContextFactory*); \ | 161 static void name(skiatest::Reporter*, GrContextFactory*); \ |
| 156 namespace skiatest { \ | 162 namespace skiatest { \ |
| 157 class name##Class : public GpuTest { \ | 163 class name##Class : public GpuTest { \ |
| 158 public: \ | 164 public: \ |
| 159 static Test* Factory(void*) { return SkNEW(name##Class); } \ | 165 static Test* Factory(void*) { return SkNEW(name##Class); } \ |
| 160 protected: \ | 166 protected: \ |
| 161 virtual void onGetName(SkString* name) SK_OVERRIDE { \ | 167 virtual void onGetName(SkString* name) SK_OVERRIDE { \ |
| 162 name->set(#name); \ | 168 name->set(#name); \ |
| 163 } \ | 169 } \ |
| 164 virtual void onRun(Reporter* r) SK_OVERRIDE { \ | 170 virtual void onRun(Reporter* r) SK_OVERRIDE { \ |
| 165 name(r, GetGrContextFactory()); \ | 171 name(r, fGrContextFactory); \ |
| 166 } \ | 172 } \ |
| 167 }; \ | 173 }; \ |
| 168 static TestRegistry gReg_##name##Class(name##Class::Factory); \ | 174 static TestRegistry gReg_##name##Class(name##Class::Factory); \ |
| 169 } \ | 175 } \ |
| 170 static void name(skiatest::Reporter* reporter, GrContextFactory* factory) | 176 static void name(skiatest::Reporter* reporter, GrContextFactory* factory) |
| 171 | 177 |
| 172 #endif | 178 #endif |
| OLD | NEW |