blob: f99abd0053ebca53059054daa07c0f9d3639a2fc [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
commit-bot@chromium.org125c6cd2014-04-30 14:56:29 +00005// When PathOps threaded tests get going, they're briefly a big consumer of lots of RAM.
6// We disable the internal threading there by default on 32-bit builds.
7static const bool is32Bit = sizeof(void*) == 4;
8
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +00009DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
commit-bot@chromium.org125c6cd2014-04-30 14:56:29 +000010DEFINE_bool2(pathOpsSingleThread, z, is32Bit, "Disallow pathOps tests from using threads.");
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000011DEFINE_bool2(pathOpsVerbose, V, false, "Tell pathOps tests to be verbose.");
12
13namespace DM {
14
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000015bool TestReporter::allowExtendedTest() const { return FLAGS_pathOpsExtended; }
16bool TestReporter::allowThreaded() const { return !FLAGS_pathOpsSingleThread; }
17bool TestReporter::verbose() const { return FLAGS_pathOpsVerbose; }
18
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +000019static SkString test_name(const char* name) {
20 SkString result("test ");
21 result.append(name);
22 return result;
23}
24
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000025CpuTestTask::CpuTestTask(Reporter* reporter,
26 TaskRunner* taskRunner,
27 skiatest::TestRegistry::Factory factory)
28 : CpuTask(reporter, taskRunner)
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000029 , fTest(factory(NULL))
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +000030 , fName(test_name(fTest->getName())) {}
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000031
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000032GpuTestTask::GpuTestTask(Reporter* reporter,
33 TaskRunner* taskRunner,
34 skiatest::TestRegistry::Factory factory)
35 : GpuTask(reporter, taskRunner)
36 , fTest(factory(NULL))
37 , fName(test_name(fTest->getName())) {}
38
39
40void CpuTestTask::draw() {
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000041 fTest->setReporter(&fTestReporter);
42 fTest->run();
43 if (!fTest->passed()) {
44 this->fail(fTestReporter.failure());
45 }
46}
47
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000048void GpuTestTask::draw(GrContextFactory* grFactory) {
49 fTest->setGrContextFactory(grFactory);
50 fTest->setReporter(&fTestReporter);
51 fTest->run();
52 if (!fTest->passed()) {
53 this->fail(fTestReporter.failure());
54 }
55}
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000056
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000057bool GpuTestTask::shouldSkip() const {
58 return kGPUDisabled;
59}
60
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000061} // namespace DM