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