blob: e16df98d756e37e04fac567ba678a57e048e8ded [file] [log] [blame]
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +00001#include "DMTestTask.h"
2#include "DMUtil.h"
3#include "SkCommandLineFlags.h"
4
5DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
6DEFINE_bool2(pathOpsSingleThread, z, false, "Disallow pathOps tests from using threads.");
7DEFINE_bool2(pathOpsVerbose, V, false, "Tell pathOps tests to be verbose.");
8
9namespace DM {
10
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000011bool TestReporter::allowExtendedTest() const { return FLAGS_pathOpsExtended; }
12bool TestReporter::allowThreaded() const { return !FLAGS_pathOpsSingleThread; }
13bool TestReporter::verbose() const { return FLAGS_pathOpsVerbose; }
14
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +000015static SkString test_name(const char* name) {
16 SkString result("test ");
17 result.append(name);
18 return result;
19}
20
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000021CpuTestTask::CpuTestTask(Reporter* reporter,
22 TaskRunner* taskRunner,
23 skiatest::TestRegistry::Factory factory)
24 : CpuTask(reporter, taskRunner)
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000025 , fTest(factory(NULL))
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +000026 , fName(test_name(fTest->getName())) {}
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000027
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000028GpuTestTask::GpuTestTask(Reporter* reporter,
29 TaskRunner* taskRunner,
30 skiatest::TestRegistry::Factory factory)
31 : GpuTask(reporter, taskRunner)
32 , fTest(factory(NULL))
33 , fName(test_name(fTest->getName())) {}
34
35
36void CpuTestTask::draw() {
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000037 fTest->setReporter(&fTestReporter);
38 fTest->run();
39 if (!fTest->passed()) {
40 this->fail(fTestReporter.failure());
41 }
42}
43
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000044void GpuTestTask::draw(GrContextFactory* grFactory) {
45 fTest->setGrContextFactory(grFactory);
46 fTest->setReporter(&fTestReporter);
47 fTest->run();
48 if (!fTest->passed()) {
49 this->fail(fTestReporter.failure());
50 }
51}
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000052
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000053bool GpuTestTask::shouldSkip() const {
54 return kGPUDisabled;
55}
56
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000057} // namespace DM