blob: 9e7f41e7d0991d39159d9e4ce104491319727c48 [file] [log] [blame]
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +00001#include "DMTestTask.h"
2#include "DMUtil.h"
3#include "SkCommandLineFlags.h"
halcanary59598b02014-08-13 10:30:57 -07004#include "SkCommonFlags.h"
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +00005
commit-bot@chromium.org125c6cd2014-04-30 14:56:29 +00006// When PathOps threaded tests get going, they're briefly a big consumer of lots of RAM.
7// We disable the internal threading there by default on 32-bit builds.
8static const bool is32Bit = sizeof(void*) == 4;
9
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000010DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
commit-bot@chromium.org125c6cd2014-04-30 14:56:29 +000011DEFINE_bool2(pathOpsSingleThread, z, is32Bit, "Disallow pathOps tests from using threads.");
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000012
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; }
halcanary59598b02014-08-13 10:30:57 -070017bool TestReporter::verbose() const { return FLAGS_veryVerbose; }
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000018
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