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/browser/renderer_host/media/media_stream_manager.h" | 12 #include "content/browser/renderer_host/media/media_stream_manager.h" |
13 #include "content/public/app/content_main.h" | |
14 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
15 #include "content/public/test/content_test_suite_base.h" | 14 #include "content/public/test/content_test_suite_base.h" |
16 #include "content/shell/shell_content_browser_client.h" | 15 #include "content/shell/shell_content_browser_client.h" |
17 #include "content/shell/shell_content_client.h" | 16 #include "content/shell/shell_content_client.h" |
18 #include "content/shell/shell_main_delegate.h" | 17 #include "content/shell/shell_main_delegate.h" |
19 #include "content/shell/shell_switches.h" | 18 #include "content/shell/shell_switches.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
21 | 20 |
22 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
23 #include "content/public/app/startup_helper_win.h" | 22 #include "content/public/app/startup_helper_win.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 87 |
89 class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate { | 88 class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate { |
90 public: | 89 public: |
91 ContentTestLauncherDelegate() {} | 90 ContentTestLauncherDelegate() {} |
92 virtual ~ContentTestLauncherDelegate() {} | 91 virtual ~ContentTestLauncherDelegate() {} |
93 | 92 |
94 virtual std::string GetEmptyTestName() OVERRIDE { | 93 virtual std::string GetEmptyTestName() OVERRIDE { |
95 return std::string(); | 94 return std::string(); |
96 } | 95 } |
97 | 96 |
98 virtual bool Run(int argc, char** argv, int* return_code) OVERRIDE { | |
99 #if defined(OS_WIN) || defined(OS_LINUX) | |
100 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
101 if (command_line->HasSwitch(switches::kProcessType)) { | |
102 ShellMainDelegate delegate; | |
103 #if defined(OS_WIN) | |
104 sandbox::SandboxInterfaceInfo sandbox_info = {0}; | |
105 InitializeSandboxInfo(&sandbox_info); | |
106 *return_code = | |
107 ContentMain(GetModuleHandle(NULL), &sandbox_info, &delegate); | |
108 #elif defined(OS_LINUX) | |
109 *return_code = ContentMain(argc, | |
110 const_cast<const char**>(argv), | |
111 &delegate); | |
112 #endif // defined(OS_WIN) | |
113 return true; | |
114 } | |
115 #endif // defined(OS_WIN) || defined(OS_LINUX) | |
116 | |
117 return false; | |
118 } | |
119 | |
120 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { | 97 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { |
121 return ContentBrowserTestSuite(argc, argv).Run(); | 98 return ContentBrowserTestSuite(argc, argv).Run(); |
122 } | 99 } |
123 | 100 |
124 virtual bool AdjustChildProcessCommandLine( | 101 virtual bool AdjustChildProcessCommandLine( |
125 CommandLine* command_line, const FilePath& temp_data_dir) OVERRIDE { | 102 CommandLine* command_line, const FilePath& temp_data_dir) OVERRIDE { |
126 command_line->AppendSwitchPath(switches::kContentShellDataPath, | 103 command_line->AppendSwitchPath(switches::kContentShellDataPath, |
127 temp_data_dir); | 104 temp_data_dir); |
128 return true; | 105 return true; |
129 } | 106 } |
130 | 107 |
| 108 protected: |
| 109 virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE { |
| 110 return new ShellMainDelegate(); |
| 111 } |
| 112 |
131 private: | 113 private: |
132 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); | 114 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); |
133 }; | 115 }; |
134 | 116 |
135 } // namespace content | 117 } // namespace content |
136 | 118 |
137 int main(int argc, char** argv) { | 119 int main(int argc, char** argv) { |
138 // Always use fake WebRTC devices in this binary since we want to be able | 120 // Always use fake WebRTC devices in this binary since we want to be able |
139 // to test WebRTC even if we don't have any devices on the system. | 121 // to test WebRTC even if we don't have any devices on the system. |
140 media_stream::MediaStreamManager::AlwaysUseFakeDevice(); | 122 media_stream::MediaStreamManager::AlwaysUseFakeDevice(); |
141 | 123 |
142 content::ContentTestLauncherDelegate launcher_delegate; | 124 content::ContentTestLauncherDelegate launcher_delegate; |
143 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); | 125 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); |
144 } | 126 } |
OLD | NEW |