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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 g_launcher_delegate = launcher_delegate; | 690 g_launcher_delegate = launcher_delegate; |
691 | 691 |
692 CommandLine::Init(argc, argv); | 692 CommandLine::Init(argc, argv); |
693 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 693 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
694 | 694 |
695 if (command_line->HasSwitch(kHelpFlag)) { | 695 if (command_line->HasSwitch(kHelpFlag)) { |
696 PrintUsage(); | 696 PrintUsage(); |
697 return 0; | 697 return 0; |
698 } | 698 } |
699 | 699 |
700 // TODO(pkasting): This "single_process vs. single-process" design is | |
701 // terrible UI. Instead, there should be some sort of signal flag on the | |
702 // command line, with all subsequent arguments passed through to the | |
703 // underlying browser. | |
704 if (command_line->HasSwitch(kSingleProcessTestsFlag) || | 700 if (command_line->HasSwitch(kSingleProcessTestsFlag) || |
705 command_line->HasSwitch(kSingleProcessTestsAndChromeFlag) || | 701 (command_line->HasSwitch(kSingleProcessTestsAndChromeFlag) && |
| 702 command_line->HasSwitch(kGTestFilterFlag)) || |
706 command_line->HasSwitch(kGTestListTestsFlag) || | 703 command_line->HasSwitch(kGTestListTestsFlag) || |
707 command_line->HasSwitch(kGTestHelpFlag)) { | 704 command_line->HasSwitch(kGTestHelpFlag)) { |
708 #if defined(OS_WIN) | 705 #if defined(OS_WIN) |
709 if (command_line->HasSwitch(kSingleProcessTestsFlag)) { | 706 if (command_line->HasSwitch(kSingleProcessTestsFlag)) { |
710 sandbox::SandboxInterfaceInfo sandbox_info; | 707 sandbox::SandboxInterfaceInfo sandbox_info; |
711 content::InitializeSandboxInfo(&sandbox_info); | 708 content::InitializeSandboxInfo(&sandbox_info); |
712 content::InitializeSandbox(&sandbox_info); | 709 content::InitializeSandbox(&sandbox_info); |
713 } | 710 } |
714 #endif | 711 #endif |
715 return launcher_delegate->RunTestSuite(argc, argv); | 712 return launcher_delegate->RunTestSuite(argc, argv); |
716 } | 713 } |
717 | 714 |
718 if (ShouldRunContentMain()) | 715 if (ShouldRunContentMain()) |
719 return RunContentMain(argc, argv, launcher_delegate); | 716 return RunContentMain(argc, argv, launcher_delegate); |
720 | 717 |
721 base::AtExitManager at_exit; | 718 base::AtExitManager at_exit; |
722 | 719 |
723 int32 total_shards; | 720 int32 total_shards; |
724 int32 shard_index; | 721 int32 shard_index; |
725 bool should_shard = ShouldShard(&total_shards, &shard_index); | 722 bool should_shard = ShouldShard(&total_shards, &shard_index); |
726 | 723 |
727 fprintf(stdout, | 724 fprintf(stdout, |
728 "Starting tests...\n" | 725 "Starting tests...\n" |
729 "IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n" | 726 "IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n" |
730 "For debugging a test inside a debugger, use the\n" | 727 "For debugging a test inside a debugger, use the\n" |
731 "--gtest_filter=<your_test_name> flag along with either\n" | 728 "--gtest_filter=<your_test_name> flag along with either\n" |
732 "--single_process (to run all tests in one launcher/browser process) or\n" | 729 "--single_process (to run the test in one launcher/browser process) or\n" |
733 "--single-process (to do the above, and also run Chrome in single-\n" | 730 "--single-process (to do the above, and also run Chrome in single-" |
734 "process mode).\n"); | 731 "process mode).\n"); |
735 | 732 |
736 testing::InitGoogleTest(&argc, argv); | 733 testing::InitGoogleTest(&argc, argv); |
737 TestTimeouts::Initialize(); | 734 TestTimeouts::Initialize(); |
738 int exit_code = 0; | 735 int exit_code = 0; |
739 | 736 |
740 std::string empty_test = launcher_delegate->GetEmptyTestName(); | 737 std::string empty_test = launcher_delegate->GetEmptyTestName(); |
741 if (!empty_test.empty()) { | 738 if (!empty_test.empty()) { |
742 // Make sure the entire browser code is loaded into memory. Reading it | 739 // Make sure the entire browser code is loaded into memory. Reading it |
743 // from disk may be slow on a busy bot, and can easily exceed the default | 740 // from disk may be slow on a busy bot, and can easily exceed the default |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 cycles--; | 776 cycles--; |
780 } | 777 } |
781 return exit_code; | 778 return exit_code; |
782 } | 779 } |
783 | 780 |
784 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { | 781 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { |
785 return g_launcher_delegate; | 782 return g_launcher_delegate; |
786 } | 783 } |
787 | 784 |
788 } // namespace test_launcher | 785 } // namespace test_launcher |
OLD | NEW |