blob: ad0c3fb4f3d8cf3fbf0e45cf896f4f9ce55d604b [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
mtklein406654b2014-09-03 15:34:37 -07006DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +00007
8namespace DM {
9
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000010bool TestReporter::allowExtendedTest() const { return FLAGS_pathOpsExtended; }
halcanary59598b02014-08-13 10:30:57 -070011bool TestReporter::verbose() const { return FLAGS_veryVerbose; }
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000012
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +000013static SkString test_name(const char* name) {
14 SkString result("test ");
15 result.append(name);
16 return result;
17}
18
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000019CpuTestTask::CpuTestTask(Reporter* reporter,
20 TaskRunner* taskRunner,
21 skiatest::TestRegistry::Factory factory)
22 : CpuTask(reporter, taskRunner)
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000023 , fTest(factory(NULL))
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +000024 , fName(test_name(fTest->getName())) {}
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000025
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000026GpuTestTask::GpuTestTask(Reporter* reporter,
27 TaskRunner* taskRunner,
28 skiatest::TestRegistry::Factory factory)
29 : GpuTask(reporter, taskRunner)
30 , fTest(factory(NULL))
31 , fName(test_name(fTest->getName())) {}
32
33
34void CpuTestTask::draw() {
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000035 fTest->setReporter(&fTestReporter);
36 fTest->run();
37 if (!fTest->passed()) {
38 this->fail(fTestReporter.failure());
39 }
40}
41
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000042void GpuTestTask::draw(GrContextFactory* grFactory) {
43 fTest->setGrContextFactory(grFactory);
44 fTest->setReporter(&fTestReporter);
45 fTest->run();
46 if (!fTest->passed()) {
47 this->fail(fTestReporter.failure());
48 }
49}
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000050
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000051bool GpuTestTask::shouldSkip() const {
52 return kGPUDisabled;
53}
54
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000055} // namespace DM