Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 | 9 |
| 10 #include "SkCommandLineFlags.h" | |
| 10 #include "SkError.h" | 11 #include "SkError.h" |
| 11 #include "SkString.h" | 12 #include "SkString.h" |
| 12 #include "SkTArray.h" | 13 #include "SkTArray.h" |
| 14 #include "SkTLS.h" | |
| 13 #include "SkTime.h" | 15 #include "SkTime.h" |
| 14 | 16 |
| 15 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU |
| 16 #include "GrContext.h" | 18 #include "GrContext.h" |
| 17 #include "gl/SkNativeGLContext.h" | 19 #include "gl/SkNativeGLContext.h" |
| 18 #else | 20 #else |
| 19 class GrContext; | 21 class GrContext; |
| 20 #endif | 22 #endif |
| 21 | 23 |
| 24 DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use."); | |
| 25 DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); | |
|
bsalomon
2014/02/24 20:23:14
Does this mean the same flag is used for test and
mtklein
2014/02/24 20:36:12
Sort of. Right now one is --resources and the oth
| |
| 26 | |
| 22 using namespace skiatest; | 27 using namespace skiatest; |
| 23 | 28 |
| 24 Reporter::Reporter() : fTestCount(0) { | 29 Reporter::Reporter() : fTestCount(0) { |
| 25 } | 30 } |
| 26 | 31 |
| 27 void Reporter::startTest(Test* test) { | 32 void Reporter::startTest(Test* test) { |
| 28 this->bumpTestCount(); | 33 this->bumpTestCount(); |
| 29 this->onStart(test); | 34 this->onStart(test); |
| 30 } | 35 } |
| 31 | 36 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 fElapsed = SkTime::GetMSecs() - start; | 112 fElapsed = SkTime::GetMSecs() - start; |
| 108 | 113 |
| 109 // Now tell fReporter about any failures and wrap up. | 114 // Now tell fReporter about any failures and wrap up. |
| 110 for (int i = 0; i < local.numFailures(); i++) { | 115 for (int i = 0; i < local.numFailures(); i++) { |
| 111 fReporter->reportFailed(local.failure(i)); | 116 fReporter->reportFailed(local.failure(i)); |
| 112 } | 117 } |
| 113 fReporter->endTest(this); | 118 fReporter->endTest(this); |
| 114 | 119 |
| 115 } | 120 } |
| 116 | 121 |
| 122 SkString Test::GetTmpDir() { | |
| 123 const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0]; | |
| 124 return SkString(tmpDir); | |
| 125 } | |
| 126 | |
| 127 SkString Test::GetResourcePath() { | |
| 128 const char* resourcePath = FLAGS_resourcePath.isEmpty() ? NULL : FLAGS_resou rcePath[0]; | |
| 129 return SkString(resourcePath); | |
| 130 } | |
| 131 | |
| 132 | |
| 117 /////////////////////////////////////////////////////////////////////////////// | 133 /////////////////////////////////////////////////////////////////////////////// |
| 118 | 134 |
| 119 #if SK_SUPPORT_GPU | 135 #if SK_SUPPORT_GPU |
| 120 #include "GrContextFactory.h" | 136 # include "GrContextFactory.h" |
| 121 GrContextFactory gGrContextFactory; | |
| 122 #endif | |
| 123 | 137 |
| 124 GrContextFactory* GpuTest::GetGrContextFactory() { | 138 static void* new_gr_context_factory() { |
| 125 #if SK_SUPPORT_GPU | 139 return SkNEW(GrContextFactory); |
| 126 return &gGrContextFactory; | |
| 127 #else | |
| 128 return NULL; | |
| 129 #endif | |
| 130 } | 140 } |
| 131 | 141 |
| 132 void GpuTest::DestroyContexts() { | 142 static void delete_gr_context_factory(void* factory) { |
| 133 #if SK_SUPPORT_GPU | 143 SkDELETE((GrContextFactory*) factory); |
| 134 gGrContextFactory.destroyContexts(); | 144 } |
| 145 GrContextFactory* GpuTest::GetGrContextFactory() { | |
| 146 return reinterpret_cast<GrContextFactory*>(SkTLS::Get(&new_gr_context_factor y, | |
| 147 &delete_gr_context_fac tory)); | |
| 148 } | |
| 149 #else // SK_GPU_SUPPORT | |
| 150 GrContextFactory* GpuTest::GetGrContextFactory() { return NULL; } | |
| 135 #endif | 151 #endif |
| 136 } | |
| OLD | NEW |