commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 1 | #ifndef DMTestTask_DEFINED |
| 2 | #define DMTestTask_DEFINED |
| 3 | |
| 4 | #include "DMReporter.h" |
| 5 | #include "DMTask.h" |
| 6 | #include "DMTaskRunner.h" |
| 7 | #include "SkString.h" |
| 8 | #include "SkTemplates.h" |
| 9 | #include "Test.h" |
| 10 | |
| 11 | // Runs a unit test. |
| 12 | namespace DM { |
| 13 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 14 | class TestReporter : public skiatest::Reporter { |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 15 | public: |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 16 | TestReporter() {} |
| 17 | |
| 18 | const char* failure() const { return fFailure.c_str(); } |
| 19 | |
| 20 | private: |
| 21 | virtual bool allowExtendedTest() const SK_OVERRIDE; |
| 22 | virtual bool allowThreaded() const SK_OVERRIDE; |
| 23 | virtual bool verbose() const SK_OVERRIDE; |
| 24 | |
| 25 | virtual void onReportFailed(const SkString& desc) SK_OVERRIDE { |
| 26 | fFailure = desc; |
| 27 | } |
| 28 | |
| 29 | SkString fFailure; |
| 30 | }; |
| 31 | |
| 32 | class CpuTestTask : public CpuTask { |
| 33 | public: |
| 34 | CpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 35 | |
| 36 | virtual void draw() SK_OVERRIDE; |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 37 | virtual bool shouldSkip() const SK_OVERRIDE { return false; } |
| 38 | virtual SkString name() const SK_OVERRIDE { return fName; } |
| 39 | |
| 40 | private: |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 41 | TestReporter fTestReporter; |
| 42 | SkAutoTDelete<skiatest::Test> fTest; |
| 43 | const SkString fName; |
| 44 | }; |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 45 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 46 | class GpuTestTask : public GpuTask { |
| 47 | public: |
| 48 | GpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 49 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 50 | virtual void draw(GrContextFactory*) SK_OVERRIDE; |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 51 | virtual bool shouldSkip() const SK_OVERRIDE; |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 52 | virtual SkString name() const SK_OVERRIDE { return fName; } |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 53 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 54 | private: |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 55 | TestReporter fTestReporter; |
| 56 | SkAutoTDelete<skiatest::Test> fTest; |
| 57 | const SkString fName; |
| 58 | }; |
| 59 | |
| 60 | } // namespace DM |
| 61 | |
| 62 | #endif // DMTestTask_DEFINED |