| 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 <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // that span browser restarts. | 53 // that span browser restarts. |
| 54 const char kPreTestPrefix[] = "PRE_"; | 54 const char kPreTestPrefix[] = "PRE_"; |
| 55 | 55 |
| 56 // Manual tests only run when --run-manual is specified. This allows writing | 56 // Manual tests only run when --run-manual is specified. This allows writing |
| 57 // tests that don't run automatically but are still in the same test binary. | 57 // tests that don't run automatically but are still in the same test binary. |
| 58 // This is useful so that a team that wants to run a few tests doesn't have to | 58 // This is useful so that a team that wants to run a few tests doesn't have to |
| 59 // add a new binary that must be compiled on all builds. | 59 // add a new binary that must be compiled on all builds. |
| 60 const char kManualTestPrefix[] = "MANUAL_"; | 60 const char kManualTestPrefix[] = "MANUAL_"; |
| 61 | 61 |
| 62 TestLauncherDelegate* g_launcher_delegate; | 62 TestLauncherDelegate* g_launcher_delegate; |
| 63 ContentMainParams* g_params; |
| 63 | 64 |
| 64 std::string RemoveAnyPrePrefixes(const std::string& test_name) { | 65 std::string RemoveAnyPrePrefixes(const std::string& test_name) { |
| 65 std::string result(test_name); | 66 std::string result(test_name); |
| 66 ReplaceSubstringsAfterOffset(&result, 0, kPreTestPrefix, std::string()); | 67 ReplaceSubstringsAfterOffset(&result, 0, kPreTestPrefix, std::string()); |
| 67 return result; | 68 return result; |
| 68 } | 69 } |
| 69 | 70 |
| 70 void PrintUsage() { | 71 void PrintUsage() { |
| 71 fprintf(stdout, | 72 fprintf(stdout, |
| 72 "Runs tests using the gtest framework, each batch of tests being\n" | 73 "Runs tests using the gtest framework, each batch of tests being\n" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 if (command_line->HasSwitch(kHelpFlag)) { | 470 if (command_line->HasSwitch(kHelpFlag)) { |
| 470 PrintUsage(); | 471 PrintUsage(); |
| 471 return 0; | 472 return 0; |
| 472 } | 473 } |
| 473 | 474 |
| 474 if (command_line->HasSwitch(kSingleProcessTestsFlag) || | 475 if (command_line->HasSwitch(kSingleProcessTestsFlag) || |
| 475 (command_line->HasSwitch(switches::kSingleProcess) && | 476 (command_line->HasSwitch(switches::kSingleProcess) && |
| 476 command_line->HasSwitch(base::kGTestFilterFlag)) || | 477 command_line->HasSwitch(base::kGTestFilterFlag)) || |
| 477 command_line->HasSwitch(base::kGTestListTestsFlag) || | 478 command_line->HasSwitch(base::kGTestListTestsFlag) || |
| 478 command_line->HasSwitch(base::kGTestHelpFlag)) { | 479 command_line->HasSwitch(base::kGTestHelpFlag)) { |
| 479 #if defined(OS_WIN) | 480 |
| 480 if (command_line->HasSwitch(kSingleProcessTestsFlag)) { | 481 // COPY OF RUNCONTENTMAIN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 481 sandbox::SandboxInterfaceInfo sandbox_info; | 482 scoped_ptr<ContentMainDelegate> chrome_main_delegate( |
| 482 InitializeSandboxInfo(&sandbox_info); | 483 launcher_delegate->CreateContentMainDelegate()); |
| 483 InitializeSandbox(&sandbox_info); | 484 ContentMainParams params(chrome_main_delegate.get()); |
| 484 } | 485 |
| 485 #endif | 486 #if defined(OS_WIN) |
| 487 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
| 488 InitializeSandboxInfo(&sandbox_info); |
| 489 |
| 490 params.instance = GetModuleHandle(NULL); |
| 491 params.sandbox_info = &sandbox_info; |
| 492 #elif defined(OS_LINUX) |
| 493 params.argc = argc; |
| 494 params.argv = const_cast<const char**>(argv); |
| 495 #endif // defined(OS_WIN) |
| 496 // END COPY!!!!!!!!!!!!!!!!! |
| 497 |
| 498 g_params = ¶ms; |
| 499 |
| 500 |
| 486 return launcher_delegate->RunTestSuite(argc, argv); | 501 return launcher_delegate->RunTestSuite(argc, argv); |
| 487 } | 502 } |
| 488 | 503 |
| 489 #if defined(OS_WIN) || defined(OS_LINUX) | 504 #if defined(OS_WIN) || defined(OS_LINUX) |
| 490 if (ShouldRunContentMain()) | 505 if (ShouldRunContentMain()) |
| 491 return RunContentMain(argc, argv, launcher_delegate); | 506 return RunContentMain(argc, argv, launcher_delegate); |
| 492 #endif | 507 #endif |
| 493 | 508 |
| 494 base::AtExitManager at_exit; | 509 base::AtExitManager at_exit; |
| 495 testing::InitGoogleTest(&argc, argv); | 510 testing::InitGoogleTest(&argc, argv); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 511 WrapperTestLauncherDelegate delegate(launcher_delegate); | 526 WrapperTestLauncherDelegate delegate(launcher_delegate); |
| 512 base::TestLauncher launcher(&delegate, default_jobs); | 527 base::TestLauncher launcher(&delegate, default_jobs); |
| 513 bool success = launcher.Run(argc, argv); | 528 bool success = launcher.Run(argc, argv); |
| 514 return (success ? 0 : 1); | 529 return (success ? 0 : 1); |
| 515 } | 530 } |
| 516 | 531 |
| 517 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { | 532 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { |
| 518 return g_launcher_delegate; | 533 return g_launcher_delegate; |
| 519 } | 534 } |
| 520 | 535 |
| 536 ContentMainParams* GetContentMainParams() { |
| 537 return g_params; |
| 538 } |
| 539 |
| 521 } // namespace content | 540 } // namespace content |
| OLD | NEW |