blob: 2ca31e38b5be650af623b2abe8cc1994f1fe2c7c [file] [log] [blame]
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +00001#ifndef DMTestTask_DEFINED
2#define DMTestTask_DEFINED
3
4#include "DMReporter.h"
scroggo0ee26272014-11-07 06:07:32 -08005#include "DMJsonWriter.h"
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +00006#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.
13namespace DM {
14
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000015class TestReporter : public skiatest::Reporter {
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000016public:
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000017 TestReporter() {}
18
mtklein008f1ea2014-11-19 13:36:19 -080019 const SkTArray<SkString>& failures() const { return fFailures; }
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000020
21private:
22 virtual bool allowExtendedTest() const SK_OVERRIDE;
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000023 virtual bool verbose() const SK_OVERRIDE;
24
scroggo0ee26272014-11-07 06:07:32 -080025 virtual void onReportFailed(const skiatest::Failure& failure) SK_OVERRIDE {
26 JsonWriter::AddTestFailure(failure);
27
28 SkString newFailure;
29 failure.getFailureString(&newFailure);
mtklein008f1ea2014-11-19 13:36:19 -080030 fFailures.push_back(newFailure);
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000031 }
32
mtklein008f1ea2014-11-19 13:36:19 -080033 SkTArray<SkString> fFailures;
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000034};
35
36class CpuTestTask : public CpuTask {
37public:
38 CpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory);
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000039
40 virtual void draw() SK_OVERRIDE;
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000041 virtual bool shouldSkip() const SK_OVERRIDE { return false; }
42 virtual SkString name() const SK_OVERRIDE { return fName; }
43
44private:
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000045 TestReporter fTestReporter;
46 SkAutoTDelete<skiatest::Test> fTest;
47 const SkString fName;
48};
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000049
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000050class GpuTestTask : public GpuTask {
51public:
52 GpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory);
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000053
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000054 virtual void draw(GrContextFactory*) SK_OVERRIDE;
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000055 virtual bool shouldSkip() const SK_OVERRIDE;
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000056 virtual SkString name() const SK_OVERRIDE { return fName; }
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000057
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000058private:
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000059 TestReporter fTestReporter;
60 SkAutoTDelete<skiatest::Test> fTest;
61 const SkString fName;
62};
63
64} // namespace DM
65
66#endif // DMTestTask_DEFINED