OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/public/test/test_launcher.h" | 5 #include "content/public/test/test_launcher.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 explicit WrapperTestLauncherDelegate( | 223 explicit WrapperTestLauncherDelegate( |
224 content::TestLauncherDelegate* launcher_delegate) | 224 content::TestLauncherDelegate* launcher_delegate) |
225 : launcher_delegate_(launcher_delegate), | 225 : launcher_delegate_(launcher_delegate), |
226 timeout_count_(0), | 226 timeout_count_(0), |
227 printed_timeout_message_(false) { | 227 printed_timeout_message_(false) { |
228 } | 228 } |
229 | 229 |
230 // base::TestLauncherDelegate: | 230 // base::TestLauncherDelegate: |
231 virtual bool ShouldRunTest(const testing::TestCase* test_case, | 231 virtual bool ShouldRunTest(const testing::TestCase* test_case, |
232 const testing::TestInfo* test_info) OVERRIDE; | 232 const testing::TestInfo* test_info) OVERRIDE; |
233 virtual bool RunTest(const testing::TestCase* test_case, | 233 virtual void RunTest( |
234 const testing::TestInfo* test_info) OVERRIDE; | 234 const testing::TestCase* test_case, |
| 235 const testing::TestInfo* test_info, |
| 236 const base::TestLauncherDelegate::TestResultCallback& callback) OVERRIDE; |
| 237 virtual void RunRemainingTests() OVERRIDE; |
235 | 238 |
236 private: | 239 private: |
237 content::TestLauncherDelegate* launcher_delegate_; | 240 content::TestLauncherDelegate* launcher_delegate_; |
238 | 241 |
239 // Number of times a test timeout occurred. | 242 // Number of times a test timeout occurred. |
240 size_t timeout_count_; | 243 size_t timeout_count_; |
241 | 244 |
242 // True after a message about too many timeouts has been printed, | 245 // True after a message about too many timeouts has been printed, |
243 // to avoid doing it more than once. | 246 // to avoid doing it more than once. |
244 bool printed_timeout_message_; | 247 bool printed_timeout_message_; |
(...skipping 20 matching lines...) Expand all Loading... |
265 if (!printed_timeout_message_) { | 268 if (!printed_timeout_message_) { |
266 printed_timeout_message_ = true; | 269 printed_timeout_message_ = true; |
267 printf("Too many timeouts, aborting test\n"); | 270 printf("Too many timeouts, aborting test\n"); |
268 } | 271 } |
269 return false; | 272 return false; |
270 } | 273 } |
271 | 274 |
272 return true; | 275 return true; |
273 } | 276 } |
274 | 277 |
275 bool WrapperTestLauncherDelegate::RunTest(const testing::TestCase* test_case, | 278 void WrapperTestLauncherDelegate::RunTest( |
276 const testing::TestInfo* test_info) { | 279 const testing::TestCase* test_case, |
| 280 const testing::TestInfo* test_info, |
| 281 const base::TestLauncherDelegate::TestResultCallback& callback) { |
| 282 base::TimeTicks start_time = base::TimeTicks::Now(); |
277 bool was_timeout = false; | 283 bool was_timeout = false; |
278 std::string test_name = | 284 std::string test_name = |
279 std::string(test_case->name()) + "." + test_info->name(); | 285 std::string(test_case->name()) + "." + test_info->name(); |
280 int exit_code = DoRunTest(launcher_delegate_, | 286 int exit_code = DoRunTest(launcher_delegate_, |
281 test_case, | 287 test_case, |
282 test_name, | 288 test_name, |
283 TestTimeouts::action_max_timeout(), | 289 TestTimeouts::action_max_timeout(), |
284 &was_timeout); | 290 &was_timeout); |
285 if (was_timeout) | 291 if (was_timeout) |
286 timeout_count_++; | 292 timeout_count_++; |
287 return exit_code == 0; | 293 |
| 294 base::TestResult result; |
| 295 result.test_case_name = test_case->name(); |
| 296 result.test_name = test_info->name(); |
| 297 result.success = (exit_code == 0); |
| 298 result.elapsed_time = (base::TimeTicks::Now() - start_time); |
| 299 |
| 300 callback.Run(result); |
| 301 } |
| 302 |
| 303 void WrapperTestLauncherDelegate::RunRemainingTests() { |
| 304 // No need to do anything here, we launch tests synchronously. |
288 } | 305 } |
289 | 306 |
290 } // namespace | 307 } // namespace |
291 | 308 |
292 // The following is kept for historical reasons (so people that are used to | 309 // The following is kept for historical reasons (so people that are used to |
293 // using it don't get surprised). | 310 // using it don't get surprised). |
294 const char kChildProcessFlag[] = "child"; | 311 const char kChildProcessFlag[] = "child"; |
295 | 312 |
296 const char kGTestHelpFlag[] = "gtest_help"; | 313 const char kGTestHelpFlag[] = "gtest_help"; |
297 | 314 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 402 |
386 WrapperTestLauncherDelegate delegate(launcher_delegate); | 403 WrapperTestLauncherDelegate delegate(launcher_delegate); |
387 return base::LaunchTests(&delegate, argc, argv); | 404 return base::LaunchTests(&delegate, argc, argv); |
388 } | 405 } |
389 | 406 |
390 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { | 407 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { |
391 return g_launcher_delegate; | 408 return g_launcher_delegate; |
392 } | 409 } |
393 | 410 |
394 } // namespace content | 411 } // namespace content |
OLD | NEW |