| 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 "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/test/test_suite.h" | 11 #include "base/test/test_suite.h" |
| 12 #include "content/public/app/content_main.h" | |
| 13 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/test/content_test_suite_base.h" | 13 #include "content/public/test/content_test_suite_base.h" |
| 15 #include "content/shell/shell_content_browser_client.h" | 14 #include "content/shell/shell_content_browser_client.h" |
| 16 #include "content/shell/shell_content_client.h" | 15 #include "content/shell/shell_content_client.h" |
| 17 #include "content/shell/shell_main_delegate.h" | 16 #include "content/shell/shell_main_delegate.h" |
| 18 #include "content/shell/shell_switches.h" | 17 #include "content/shell/shell_switches.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 19 |
| 21 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 22 #include "content/public/app/startup_helper_win.h" | 21 #include "content/public/app/startup_helper_win.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 86 |
| 88 class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate { | 87 class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate { |
| 89 public: | 88 public: |
| 90 ContentTestLauncherDelegate() {} | 89 ContentTestLauncherDelegate() {} |
| 91 virtual ~ContentTestLauncherDelegate() {} | 90 virtual ~ContentTestLauncherDelegate() {} |
| 92 | 91 |
| 93 virtual std::string GetEmptyTestName() OVERRIDE { | 92 virtual std::string GetEmptyTestName() OVERRIDE { |
| 94 return std::string(); | 93 return std::string(); |
| 95 } | 94 } |
| 96 | 95 |
| 97 virtual bool Run(int argc, char** argv, int* return_code) OVERRIDE { | |
| 98 #if defined(OS_WIN) || defined(OS_LINUX) | |
| 99 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 100 if (command_line->HasSwitch(switches::kProcessType)) { | |
| 101 ShellMainDelegate delegate; | |
| 102 #if defined(OS_WIN) | |
| 103 sandbox::SandboxInterfaceInfo sandbox_info = {0}; | |
| 104 InitializeSandboxInfo(&sandbox_info); | |
| 105 *return_code = | |
| 106 ContentMain(GetModuleHandle(NULL), &sandbox_info, &delegate); | |
| 107 #elif defined(OS_LINUX) | |
| 108 *return_code = ContentMain(argc, | |
| 109 const_cast<const char**>(argv), | |
| 110 &delegate); | |
| 111 #endif // defined(OS_WIN) | |
| 112 return true; | |
| 113 } | |
| 114 #endif // defined(OS_WIN) || defined(OS_LINUX) | |
| 115 | |
| 116 return false; | |
| 117 } | |
| 118 | |
| 119 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { | 96 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { |
| 120 return ContentBrowserTestSuite(argc, argv).Run(); | 97 return ContentBrowserTestSuite(argc, argv).Run(); |
| 121 } | 98 } |
| 122 | 99 |
| 123 virtual bool AdjustChildProcessCommandLine( | 100 virtual bool AdjustChildProcessCommandLine( |
| 124 CommandLine* command_line, const FilePath& temp_data_dir) OVERRIDE { | 101 CommandLine* command_line, const FilePath& temp_data_dir) OVERRIDE { |
| 125 command_line->AppendSwitchPath(switches::kContentShellDataPath, | 102 command_line->AppendSwitchPath(switches::kContentShellDataPath, |
| 126 temp_data_dir); | 103 temp_data_dir); |
| 127 return true; | 104 return true; |
| 128 } | 105 } |
| 129 | 106 |
| 107 protected: |
| 108 virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE { |
| 109 return new ShellMainDelegate(); |
| 110 } |
| 111 |
| 130 private: | 112 private: |
| 131 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); | 113 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); |
| 132 }; | 114 }; |
| 133 | 115 |
| 134 } // namespace content | 116 } // namespace content |
| 135 | 117 |
| 136 int main(int argc, char** argv) { | 118 int main(int argc, char** argv) { |
| 137 content::ContentTestLauncherDelegate launcher_delegate; | 119 content::ContentTestLauncherDelegate launcher_delegate; |
| 138 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); | 120 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); |
| 139 } | 121 } |
| OLD | NEW |