commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 1 | #include "DMTestTask.h" |
| 2 | #include "DMUtil.h" |
| 3 | #include "SkCommandLineFlags.h" |
| 4 | |
commit-bot@chromium.org | 125c6cd | 2014-04-30 14:56:29 +0000 | [diff] [blame] | 5 | // 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. |
| 7 | static const bool is32Bit = sizeof(void*) == 4; |
| 8 | |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 9 | DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); |
commit-bot@chromium.org | 125c6cd | 2014-04-30 14:56:29 +0000 | [diff] [blame] | 10 | DEFINE_bool2(pathOpsSingleThread, z, is32Bit, "Disallow pathOps tests from using threads."); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 11 | DEFINE_bool2(pathOpsVerbose, V, false, "Tell pathOps tests to be verbose."); |
| 12 | |
| 13 | namespace DM { |
| 14 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 15 | bool TestReporter::allowExtendedTest() const { return FLAGS_pathOpsExtended; } |
| 16 | bool TestReporter::allowThreaded() const { return !FLAGS_pathOpsSingleThread; } |
| 17 | bool TestReporter::verbose() const { return FLAGS_pathOpsVerbose; } |
| 18 | |
commit-bot@chromium.org | 38aeb0f | 2014-02-26 23:01:57 +0000 | [diff] [blame] | 19 | static SkString test_name(const char* name) { |
| 20 | SkString result("test "); |
| 21 | result.append(name); |
| 22 | return result; |
| 23 | } |
| 24 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 25 | CpuTestTask::CpuTestTask(Reporter* reporter, |
| 26 | TaskRunner* taskRunner, |
| 27 | skiatest::TestRegistry::Factory factory) |
| 28 | : CpuTask(reporter, taskRunner) |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 29 | , fTest(factory(NULL)) |
commit-bot@chromium.org | 38aeb0f | 2014-02-26 23:01:57 +0000 | [diff] [blame] | 30 | , fName(test_name(fTest->getName())) {} |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 31 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 32 | GpuTestTask::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 | |
| 40 | void CpuTestTask::draw() { |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 41 | fTest->setReporter(&fTestReporter); |
| 42 | fTest->run(); |
| 43 | if (!fTest->passed()) { |
| 44 | this->fail(fTestReporter.failure()); |
| 45 | } |
| 46 | } |
| 47 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 48 | void 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.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 56 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 57 | bool GpuTestTask::shouldSkip() const { |
| 58 | return kGPUDisabled; |
| 59 | } |
| 60 | |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 61 | } // namespace DM |