[email protected] | f573ed6b | 2012-02-10 15:58:52 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 7d855a1 | 2012-06-04 06:08:09 | [diff] [blame] | 5 | #include "content/public/test/test_launcher.h" |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 6 | |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 7 | #include "base/base_paths.h" |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 8 | #include "base/command_line.h" |
| 9 | #include "base/logging.h" |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 10 | #include "base/path_service.h" |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 11 | #include "base/scoped_temp_dir.h" |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 12 | #include "base/test/test_suite.h" |
[email protected] | f573ed6b | 2012-02-10 15:58:52 | [diff] [blame] | 13 | #include "content/public/app/content_main.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 14 | #include "content/public/common/content_switches.h" |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 15 | #include "content/shell/shell_main_delegate.h" |
| 16 | |
| 17 | #if defined(OS_WIN) |
[email protected] | badf5cf | 2011-10-29 03:44:44 | [diff] [blame] | 18 | #include "content/public/app/startup_helper_win.h" |
[email protected] | 18149178 | 2012-07-18 00:59:15 | [diff] [blame^] | 19 | #include "sandbox/win/src/sandbox_types.h" |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 20 | #endif // defined(OS_WIN) |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 21 | |
| 22 | class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate { |
| 23 | public: |
| 24 | ContentTestLauncherDelegate() { |
| 25 | } |
| 26 | |
| 27 | virtual ~ContentTestLauncherDelegate() { |
| 28 | } |
| 29 | |
| 30 | virtual void EarlyInitialize() OVERRIDE { |
| 31 | } |
| 32 | |
| 33 | virtual bool Run(int argc, char** argv, int* return_code) OVERRIDE { |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 34 | #if defined(OS_WIN) |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 35 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 36 | if (command_line->HasSwitch(switches::kProcessType)) { |
| 37 | sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
| 38 | content::InitializeSandboxInfo(&sandbox_info); |
| 39 | ShellMainDelegate delegate; |
| 40 | *return_code = |
| 41 | content::ContentMain(GetModuleHandle(NULL), &sandbox_info, &delegate); |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 42 | return true; |
| 43 | } |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 44 | #endif // defined(OS_WIN) |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 45 | |
| 46 | return false; |
| 47 | } |
| 48 | |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 49 | virtual int RunTestSuite(int argc, char** argv) OVERRIDE { |
| 50 | return base::TestSuite(argc, argv).Run(); |
| 51 | } |
| 52 | |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 53 | virtual bool AdjustChildProcessCommandLine( |
| 54 | CommandLine* command_line) OVERRIDE { |
[email protected] | c1f87b2 | 2011-10-05 21:59:33 | [diff] [blame] | 55 | FilePath file_exe; |
| 56 | if (!PathService::Get(base::FILE_EXE, &file_exe)) |
| 57 | return false; |
| 58 | command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, file_exe); |
[email protected] | bb36d82 | 2011-09-30 20:55:09 | [diff] [blame] | 59 | return true; |
| 60 | } |
| 61 | |
| 62 | private: |
| 63 | DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); |
| 64 | }; |
| 65 | |
| 66 | int main(int argc, char** argv) { |
| 67 | ContentTestLauncherDelegate launcher_delegate; |
| 68 | return test_launcher::LaunchTests(&launcher_delegate, argc, argv); |
[email protected] | 76df8e36 | 2011-09-30 21:23:58 | [diff] [blame] | 69 | } |