| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 35 #include "base/base_switches.h" | 35 #include "base/base_switches.h" |
| 36 #include "content/common/sandbox_policy.h" | 36 #include "content/common/sandbox_policy.h" |
| 37 #include "sandbox/win/src/sandbox_factory.h" | 37 #include "sandbox/win/src/sandbox_factory.h" |
| 38 #include "sandbox/win/src/sandbox_types.h" | 38 #include "sandbox/win/src/sandbox_types.h" |
| 39 #elif defined(OS_MACOSX) | 39 #elif defined(OS_MACOSX) |
| 40 #include "base/mac/scoped_nsautorelease_pool.h" | 40 #include "base/mac/scoped_nsautorelease_pool.h" |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 namespace test_launcher { | 43 namespace content { |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 // A multiplier for slow tests. We generally avoid multiplying | 47 // A multiplier for slow tests. We generally avoid multiplying |
| 48 // test timeouts by any constants. Here it is used as last resort | 48 // test timeouts by any constants. Here it is used as last resort |
| 49 // to implement the SLOW_ test prefix. | 49 // to implement the SLOW_ test prefix. |
| 50 const int kSlowTestTimeoutMultiplier = 5; | 50 const int kSlowTestTimeoutMultiplier = 5; |
| 51 | 51 |
| 52 // Tests with this prefix have a longer timeout, see above. | 52 // Tests with this prefix have a longer timeout, see above. |
| 53 const char kSlowTestPrefix[] = "SLOW_"; | 53 const char kSlowTestPrefix[] = "SLOW_"; |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 command_line->HasSwitch(kLaunchAsBrowser); | 658 command_line->HasSwitch(kLaunchAsBrowser); |
| 659 #else | 659 #else |
| 660 return false; | 660 return false; |
| 661 #endif // defined(OS_WIN) || defined(OS_LINUX) | 661 #endif // defined(OS_WIN) || defined(OS_LINUX) |
| 662 } | 662 } |
| 663 | 663 |
| 664 int RunContentMain(int argc, char** argv, | 664 int RunContentMain(int argc, char** argv, |
| 665 TestLauncherDelegate* launcher_delegate) { | 665 TestLauncherDelegate* launcher_delegate) { |
| 666 #if defined(OS_WIN) | 666 #if defined(OS_WIN) |
| 667 sandbox::SandboxInterfaceInfo sandbox_info = {0}; | 667 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
| 668 content::InitializeSandboxInfo(&sandbox_info); | 668 InitializeSandboxInfo(&sandbox_info); |
| 669 scoped_ptr<content::ContentMainDelegate> chrome_main_delegate( | 669 scoped_ptr<ContentMainDelegate> chrome_main_delegate( |
| 670 launcher_delegate->CreateContentMainDelegate()); | 670 launcher_delegate->CreateContentMainDelegate()); |
| 671 return content::ContentMain(GetModuleHandle(NULL), | 671 return ContentMain(GetModuleHandle(NULL), |
| 672 &sandbox_info, | 672 &sandbox_info, |
| 673 chrome_main_delegate.get()); | 673 chrome_main_delegate.get()); |
| 674 #elif defined(OS_LINUX) | 674 #elif defined(OS_LINUX) |
| 675 scoped_ptr<content::ContentMainDelegate> chrome_main_delegate( | 675 scoped_ptr<ContentMainDelegate> chrome_main_delegate( |
| 676 launcher_delegate->CreateContentMainDelegate()); | 676 launcher_delegate->CreateContentMainDelegate()); |
| 677 return content::ContentMain(argc, | 677 return ContentMain(argc, const_cast<const char**>(argv), |
| 678 const_cast<const char**>(argv), | 678 chrome_main_delegate.get()); |
| 679 chrome_main_delegate.get()); | |
| 680 #endif // defined(OS_WIN) | 679 #endif // defined(OS_WIN) |
| 681 NOTREACHED(); | 680 NOTREACHED(); |
| 682 return 0; | 681 return 0; |
| 683 } | 682 } |
| 684 | 683 |
| 685 int LaunchTests(TestLauncherDelegate* launcher_delegate, | 684 int LaunchTests(TestLauncherDelegate* launcher_delegate, |
| 686 int argc, | 685 int argc, |
| 687 char** argv) { | 686 char** argv) { |
| 688 DCHECK(!g_launcher_delegate); | 687 DCHECK(!g_launcher_delegate); |
| 689 g_launcher_delegate = launcher_delegate; | 688 g_launcher_delegate = launcher_delegate; |
| 690 | 689 |
| 691 CommandLine::Init(argc, argv); | 690 CommandLine::Init(argc, argv); |
| 692 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 691 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 693 | 692 |
| 694 if (command_line->HasSwitch(kHelpFlag)) { | 693 if (command_line->HasSwitch(kHelpFlag)) { |
| 695 PrintUsage(); | 694 PrintUsage(); |
| 696 return 0; | 695 return 0; |
| 697 } | 696 } |
| 698 | 697 |
| 699 if (command_line->HasSwitch(kSingleProcessTestsFlag) || | 698 if (command_line->HasSwitch(kSingleProcessTestsFlag) || |
| 700 (command_line->HasSwitch(kSingleProcessTestsAndChromeFlag) && | 699 (command_line->HasSwitch(kSingleProcessTestsAndChromeFlag) && |
| 701 command_line->HasSwitch(kGTestFilterFlag)) || | 700 command_line->HasSwitch(kGTestFilterFlag)) || |
| 702 command_line->HasSwitch(kGTestListTestsFlag) || | 701 command_line->HasSwitch(kGTestListTestsFlag) || |
| 703 command_line->HasSwitch(kGTestHelpFlag)) { | 702 command_line->HasSwitch(kGTestHelpFlag)) { |
| 704 #if defined(OS_WIN) | 703 #if defined(OS_WIN) |
| 705 if (command_line->HasSwitch(kSingleProcessTestsFlag)) { | 704 if (command_line->HasSwitch(kSingleProcessTestsFlag)) { |
| 706 sandbox::SandboxInterfaceInfo sandbox_info; | 705 sandbox::SandboxInterfaceInfo sandbox_info; |
| 707 content::InitializeSandboxInfo(&sandbox_info); | 706 InitializeSandboxInfo(&sandbox_info); |
| 708 content::InitializeSandbox(&sandbox_info); | 707 InitializeSandbox(&sandbox_info); |
| 709 } | 708 } |
| 710 #endif | 709 #endif |
| 711 return launcher_delegate->RunTestSuite(argc, argv); | 710 return launcher_delegate->RunTestSuite(argc, argv); |
| 712 } | 711 } |
| 713 | 712 |
| 714 if (ShouldRunContentMain()) | 713 if (ShouldRunContentMain()) |
| 715 return RunContentMain(argc, argv, launcher_delegate); | 714 return RunContentMain(argc, argv, launcher_delegate); |
| 716 | 715 |
| 717 base::AtExitManager at_exit; | 716 base::AtExitManager at_exit; |
| 718 | 717 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 if (cycles != -1) | 773 if (cycles != -1) |
| 775 cycles--; | 774 cycles--; |
| 776 } | 775 } |
| 777 return exit_code; | 776 return exit_code; |
| 778 } | 777 } |
| 779 | 778 |
| 780 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { | 779 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { |
| 781 return g_launcher_delegate; | 780 return g_launcher_delegate; |
| 782 } | 781 } |
| 783 | 782 |
| 784 } // namespace test_launcher | 783 } // namespace content |
| OLD | NEW |