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" |
scroggo | 0ee2627 | 2014-11-07 06:07:32 -0800 | [diff] [blame] | 5 | #include "DMJsonWriter.h" |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 6 | #include "DMTask.h" |
| 7 | #include "DMTaskRunner.h" |
| 8 | #include "SkString.h" |
| 9 | #include "SkTemplates.h" |
| 10 | #include "Test.h" |
| 11 | |
| 12 | // Runs a unit test. |
| 13 | namespace DM { |
| 14 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 15 | class TestReporter : public skiatest::Reporter { |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 16 | public: |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 17 | TestReporter() {} |
| 18 | |
mtklein | 008f1ea | 2014-11-19 13:36:19 -0800 | [diff] [blame] | 19 | const SkTArray<SkString>& failures() const { return fFailures; } |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 20 | |
| 21 | private: |
| 22 | virtual bool allowExtendedTest() const SK_OVERRIDE; |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 23 | virtual bool verbose() const SK_OVERRIDE; |
| 24 | |
scroggo | 0ee2627 | 2014-11-07 06:07:32 -0800 | [diff] [blame] | 25 | virtual void onReportFailed(const skiatest::Failure& failure) SK_OVERRIDE { |
| 26 | JsonWriter::AddTestFailure(failure); |
| 27 | |
| 28 | SkString newFailure; |
| 29 | failure.getFailureString(&newFailure); |
mtklein | 008f1ea | 2014-11-19 13:36:19 -0800 | [diff] [blame] | 30 | fFailures.push_back(newFailure); |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 31 | } |
| 32 | |
mtklein | 008f1ea | 2014-11-19 13:36:19 -0800 | [diff] [blame] | 33 | SkTArray<SkString> fFailures; |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | class CpuTestTask : public CpuTask { |
| 37 | public: |
| 38 | CpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 39 | |
| 40 | virtual void draw() SK_OVERRIDE; |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 41 | virtual bool shouldSkip() const SK_OVERRIDE { return false; } |
| 42 | virtual SkString name() const SK_OVERRIDE { return fName; } |
| 43 | |
| 44 | private: |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 45 | TestReporter fTestReporter; |
| 46 | SkAutoTDelete<skiatest::Test> fTest; |
| 47 | const SkString fName; |
| 48 | }; |
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 | class GpuTestTask : public GpuTask { |
| 51 | public: |
| 52 | GpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory); |
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 | virtual void draw(GrContextFactory*) SK_OVERRIDE; |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 55 | virtual bool shouldSkip() const SK_OVERRIDE; |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 56 | virtual SkString name() const SK_OVERRIDE { return fName; } |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 57 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 58 | private: |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 59 | TestReporter fTestReporter; |
| 60 | SkAutoTDelete<skiatest::Test> fTest; |
| 61 | const SkString fName; |
| 62 | }; |
| 63 | |
| 64 | } // namespace DM |
| 65 | |
| 66 | #endif // DMTestTask_DEFINED |