blob: 32a698c6738cbfd9bb28ed5decfc106ea2e6d896 [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.org38aeb0f2014-02-26 23:01:57 +000011static SkString test_name(const char* name) {
12 SkString result("test ");
13 result.append(name);
14 return result;
15}
16
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000017TestTask::TestTask(Reporter* reporter,
18 TaskRunner* taskRunner,
19 skiatest::TestRegistry::Factory factory)
20 : Task(reporter, taskRunner)
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000021 , fTest(factory(NULL))
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +000022 , fName(test_name(fTest->getName())) {}
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000023
24void TestTask::draw() {
25 if (this->usesGpu()) {
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +000026 fTest->setGrContextFactory(this->getGrContextFactory());
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000027 }
28 fTest->setReporter(&fTestReporter);
29 fTest->run();
30 if (!fTest->passed()) {
31 this->fail(fTestReporter.failure());
32 }
33}
34
35bool TestTask::TestReporter::allowExtendedTest() const { return FLAGS_pathOpsExtended; }
36bool TestTask::TestReporter::allowThreaded() const { return !FLAGS_pathOpsSingleThread; }
37bool TestTask::TestReporter::verbose() const { return FLAGS_pathOpsVerbose; }
38
39} // namespace DM