Home | History | Annotate | Download | only in dm
      1 #ifndef DMTestTask_DEFINED
      2 #define DMTestTask_DEFINED
      3 
      4 #include "DMReporter.h"
      5 #include "DMTask.h"
      6 #include "DMTaskRunner.h"
      7 #include "SkString.h"
      8 #include "SkTemplates.h"
      9 #include "Test.h"
     10 
     11 // Runs a unit test.
     12 namespace DM {
     13 
     14 class TestReporter : public skiatest::Reporter {
     15 public:
     16   TestReporter() {}
     17 
     18   const char* failure() const { return fFailure.c_str(); }
     19 
     20 private:
     21   virtual bool allowExtendedTest() const SK_OVERRIDE;
     22   virtual bool verbose()           const SK_OVERRIDE;
     23 
     24   virtual void onReportFailed(const SkString& desc) SK_OVERRIDE {
     25       fFailure = desc;
     26   }
     27 
     28   SkString fFailure;
     29 };
     30 
     31 class CpuTestTask : public CpuTask {
     32 public:
     33     CpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory);
     34 
     35     virtual void draw() SK_OVERRIDE;
     36     virtual bool shouldSkip() const SK_OVERRIDE { return false; }
     37     virtual SkString name() const SK_OVERRIDE { return fName; }
     38 
     39 private:
     40     TestReporter fTestReporter;
     41     SkAutoTDelete<skiatest::Test> fTest;
     42     const SkString fName;
     43 };
     44 
     45 class GpuTestTask : public GpuTask {
     46 public:
     47     GpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory);
     48 
     49     virtual void draw(GrContextFactory*) SK_OVERRIDE;
     50     virtual bool shouldSkip() const SK_OVERRIDE;
     51     virtual SkString name() const SK_OVERRIDE { return fName; }
     52 
     53 private:
     54     TestReporter fTestReporter;
     55     SkAutoTDelete<skiatest::Test> fTest;
     56     const SkString fName;
     57 };
     58 
     59 }  // namespace DM
     60 
     61 #endif // DMTestTask_DEFINED
     62