OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "OverwriteLine.h" | 9 #include "OverwriteLine.h" |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } reporter; | 97 } reporter; |
98 | 98 |
99 const SkMSec start = SkTime::GetMSecs(); | 99 const SkMSec start = SkTime::GetMSecs(); |
100 fTest.proc(&reporter, fGrContextFactory); | 100 fTest.proc(&reporter, fGrContextFactory); |
101 SkMSec elapsed = SkTime::GetMSecs() - start; | 101 SkMSec elapsed = SkTime::GetMSecs() - start; |
102 if (reporter.fError) { | 102 if (reporter.fError) { |
103 fStatus->reportFailure(); | 103 fStatus->reportFailure(); |
104 } | 104 } |
105 fStatus->endTest(fTest.name, !reporter.fError, elapsed, | 105 fStatus->endTest(fTest.name, !reporter.fError, elapsed, |
106 reporter.fTestCount); | 106 reporter.fTestCount); |
107 SkDELETE(this); | 107 delete this; |
108 } | 108 } |
109 | 109 |
110 private: | 110 private: |
111 Test fTest; | 111 Test fTest; |
112 Status* fStatus; | 112 Status* fStatus; |
113 GrContextFactory* fGrContextFactory; | 113 GrContextFactory* fGrContextFactory; |
114 }; | 114 }; |
115 | 115 |
116 static bool should_run(const char* testName, bool isGPUTest) { | 116 static bool should_run(const char* testName, bool isGPUTest) { |
117 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, testName)) { | 117 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, testName)) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 Status status(toRun); | 183 Status status(toRun); |
184 for (const TestRegistry* iter = TestRegistry::Head(); iter; | 184 for (const TestRegistry* iter = TestRegistry::Head(); iter; |
185 iter = iter->next()) { | 185 iter = iter->next()) { |
186 const Test& test = iter->factory(); | 186 const Test& test = iter->factory(); |
187 if (!should_run(test.name, test.needsGpu)) { | 187 if (!should_run(test.name, test.needsGpu)) { |
188 ++skipCount; | 188 ++skipCount; |
189 } else if (test.needsGpu) { | 189 } else if (test.needsGpu) { |
190 gpuTests.push_back(&test); | 190 gpuTests.push_back(&test); |
191 } else { | 191 } else { |
192 cpuTests.add(SkNEW_ARGS(SkTestRunnable, (test, &status))); | 192 cpuTests.add(new SkTestRunnable(test, &status)); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 GrContextFactory* grContextFactoryPtr = NULL; | 196 GrContextFactory* grContextFactoryPtr = NULL; |
197 #if SK_SUPPORT_GPU | 197 #if SK_SUPPORT_GPU |
198 // Give GPU tests a context factory if that makes sense on this machine. | 198 // Give GPU tests a context factory if that makes sense on this machine. |
199 GrContextFactory grContextFactory; | 199 GrContextFactory grContextFactory; |
200 grContextFactoryPtr = &grContextFactory; | 200 grContextFactoryPtr = &grContextFactory; |
201 | 201 |
202 #endif | 202 #endif |
203 | 203 |
204 // Run GPU tests on this thread. | 204 // Run GPU tests on this thread. |
205 for (int i = 0; i < gpuTests.count(); i++) { | 205 for (int i = 0; i < gpuTests.count(); i++) { |
206 SkNEW_ARGS(SkTestRunnable, (*gpuTests[i], &status, grContextFactoryPtr)) | 206 (new SkTestRunnable(*gpuTests[i], &status, grContextFactoryPtr))->run(); |
207 ->run(); | |
208 } | 207 } |
209 | 208 |
210 // Block until threaded tests finish. | 209 // Block until threaded tests finish. |
211 cpuTests.wait(); | 210 cpuTests.wait(); |
212 | 211 |
213 if (FLAGS_verbose) { | 212 if (FLAGS_verbose) { |
214 SkDebugf( | 213 SkDebugf( |
215 "\nFinished %d tests, %d failures, %d skipped. " | 214 "\nFinished %d tests, %d failures, %d skipped. " |
216 "(%d internal tests)", | 215 "(%d internal tests)", |
217 toRun, status.failCount(), skipCount, status.testCount()); | 216 toRun, status.failCount(), skipCount, status.testCount()); |
218 } | 217 } |
219 | 218 |
220 SkDebugf("\n"); | 219 SkDebugf("\n"); |
221 return (status.failCount() == 0) ? 0 : 1; | 220 return (status.failCount() == 0) ? 0 : 1; |
222 } | 221 } |
223 | 222 |
224 #if !defined(SK_BUILD_FOR_IOS) | 223 #if !defined(SK_BUILD_FOR_IOS) |
225 int main(int argc, char** argv) { | 224 int main(int argc, char** argv) { |
226 SkCommandLineFlags::Parse(argc, argv); | 225 SkCommandLineFlags::Parse(argc, argv); |
227 return test_main(); | 226 return test_main(); |
228 } | 227 } |
229 #endif | 228 #endif |
OLD | NEW |