OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/test_launcher.h" | 5 #include "content/test/test_launcher.h" |
6 | 6 |
| 7 #include "base/base_paths.h" |
7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" |
9 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
10 #include "content/test/content_test_suite.h" | 12 #include "base/test/test_suite.h" |
| 13 #include "content/app/content_main.h" |
| 14 #include "content/common/content_switches.h" |
| 15 #include "content/shell/shell_main_delegate.h" |
| 16 |
| 17 #if defined(OS_WIN) |
| 18 #include "content/app/startup_helper_win.h" |
| 19 #include "sandbox/src/sandbox_types.h" |
| 20 #endif // defined(OS_WIN) |
11 | 21 |
12 class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate { | 22 class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate { |
13 public: | 23 public: |
14 ContentTestLauncherDelegate() { | 24 ContentTestLauncherDelegate() { |
15 } | 25 } |
16 | 26 |
17 virtual ~ContentTestLauncherDelegate() { | 27 virtual ~ContentTestLauncherDelegate() { |
18 } | 28 } |
19 | 29 |
20 virtual void EarlyInitialize() OVERRIDE { | 30 virtual void EarlyInitialize() OVERRIDE { |
21 } | 31 } |
22 | 32 |
23 virtual bool Run(int argc, char** argv, int* return_code) OVERRIDE { | 33 virtual bool Run(int argc, char** argv, int* return_code) OVERRIDE { |
| 34 #if defined(OS_WIN) |
24 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 35 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
25 | 36 if (command_line->HasSwitch(switches::kProcessType)) { |
26 // TODO(pkasting): This "single_process vs. single-process" design is | 37 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
27 // terrible UI. Instead, there should be some sort of signal flag on the | 38 content::InitializeSandboxInfo(&sandbox_info); |
28 // command line, with all subsequent arguments passed through to the | 39 ShellMainDelegate delegate; |
29 // underlying browser. | 40 *return_code = |
30 if (command_line->HasSwitch(test_launcher::kSingleProcessTestsFlag) || | 41 content::ContentMain(GetModuleHandle(NULL), &sandbox_info, &delegate); |
31 command_line->HasSwitch( | |
32 test_launcher::kSingleProcessTestsAndChromeFlag) || | |
33 command_line->HasSwitch(test_launcher::kGTestListTestsFlag) || | |
34 command_line->HasSwitch(test_launcher::kGTestHelpFlag)) { | |
35 *return_code = ContentTestSuite(argc, argv).Run(); | |
36 return true; | 42 return true; |
37 } | 43 } |
| 44 #endif // defined(OS_WIN) |
38 | 45 |
39 return false; | 46 return false; |
40 } | 47 } |
41 | 48 |
| 49 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { |
| 50 return base::TestSuite(argc, argv).Run(); |
| 51 } |
| 52 |
42 virtual bool AdjustChildProcessCommandLine( | 53 virtual bool AdjustChildProcessCommandLine( |
43 CommandLine* command_line) OVERRIDE { | 54 CommandLine* command_line) OVERRIDE { |
| 55 FilePath file_exe; |
| 56 if (!PathService::Get(base::FILE_EXE, &file_exe)) |
| 57 return false; |
| 58 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, file_exe); |
44 return true; | 59 return true; |
45 } | 60 } |
46 | 61 |
47 private: | 62 private: |
48 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); | 63 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); |
49 }; | 64 }; |
50 | 65 |
51 int main(int argc, char** argv) { | 66 int main(int argc, char** argv) { |
52 ContentTestLauncherDelegate launcher_delegate; | 67 ContentTestLauncherDelegate launcher_delegate; |
53 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); | 68 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); |
54 } | 69 } |
OLD | NEW |