OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/test/in_process_browser_test.h" | 5 #include "chrome/test/in_process_browser_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/main_function_params.h" | 29 #include "chrome/common/main_function_params.h" |
30 #include "chrome/common/notification_registrar.h" | 30 #include "chrome/common/notification_registrar.h" |
31 #include "chrome/common/notification_type.h" | 31 #include "chrome/common/notification_type.h" |
32 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
33 #include "chrome/test/testing_browser_process.h" | 33 #include "chrome/test/testing_browser_process.h" |
34 #include "chrome/test/ui_test_utils.h" | 34 #include "chrome/test/ui_test_utils.h" |
35 #include "sandbox/src/dep.h" | 35 #include "sandbox/src/dep.h" |
36 | 36 |
| 37 #if defined(OS_LINUX) |
| 38 #include "base/singleton.h" |
| 39 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" |
| 40 #include "chrome/browser/zygote_host_linux.h" |
| 41 |
| 42 namespace { |
| 43 |
| 44 // A helper class to do Linux-only initialization only once per process. |
| 45 class LinuxHostInit { |
| 46 public: |
| 47 LinuxHostInit() { |
| 48 RenderSandboxHostLinux* shost = Singleton<RenderSandboxHostLinux>().get(); |
| 49 shost->Init(""); |
| 50 ZygoteHost* zhost = Singleton<ZygoteHost>().get(); |
| 51 zhost->Init(""); |
| 52 } |
| 53 ~LinuxHostInit() {} |
| 54 }; |
| 55 |
| 56 } // namespace |
| 57 #endif |
| 58 |
37 extern int BrowserMain(const MainFunctionParams&); | 59 extern int BrowserMain(const MainFunctionParams&); |
38 | 60 |
39 const wchar_t kUnitTestShowWindows[] = L"show-windows"; | 61 const wchar_t kUnitTestShowWindows[] = L"show-windows"; |
40 | 62 |
41 // Default delay for the time-out at which we stop the | 63 // Default delay for the time-out at which we stop the |
42 // inner-message loop the first time. | 64 // inner-message loop the first time. |
43 const int kInitialTimeoutInMS = 30000; | 65 const int kInitialTimeoutInMS = 30000; |
44 | 66 |
45 // Delay for sub-sequent time-outs once the initial time-out happened. | 67 // Delay for sub-sequent time-outs once the initial time-out happened. |
46 const int kSubsequentTimeoutInMS = 5000; | 68 const int kSubsequentTimeoutInMS = 5000; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 #elif defined(OS_POSIX) | 240 #elif defined(OS_POSIX) |
219 chrome_path = chrome_path.Append( | 241 chrome_path = chrome_path.Append( |
220 WideToASCII(chrome::kBrowserProcessExecutablePath)); | 242 WideToASCII(chrome::kBrowserProcessExecutablePath)); |
221 #endif | 243 #endif |
222 CHECK(PathService::Override(base::FILE_EXE, chrome_path)); | 244 CHECK(PathService::Override(base::FILE_EXE, chrome_path)); |
223 | 245 |
224 ChromeThread::PostTask( | 246 ChromeThread::PostTask( |
225 ChromeThread::IO, FROM_HERE, | 247 ChromeThread::IO, FROM_HERE, |
226 NewRunnableFunction(chrome_browser_net::SetUrlRequestMocksEnabled, true)); | 248 NewRunnableFunction(chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
227 | 249 |
| 250 #if defined(OS_LINUX) |
| 251 // Initialize the RenderSandbox and Zygote hosts. Apparently they get used |
| 252 // for InProcessBrowserTest, and this is not the normal browser startup path. |
| 253 Singleton<LinuxHostInit>::get(); |
| 254 #endif |
| 255 |
228 browser_ = CreateBrowser(profile); | 256 browser_ = CreateBrowser(profile); |
229 | 257 |
230 // Start the timeout timer to prevent hangs. | 258 // Start the timeout timer to prevent hangs. |
231 MessageLoopForUI::current()->PostDelayedTask(FROM_HERE, | 259 MessageLoopForUI::current()->PostDelayedTask(FROM_HERE, |
232 NewRunnableMethod(this, &InProcessBrowserTest::TimedOut), | 260 NewRunnableMethod(this, &InProcessBrowserTest::TimedOut), |
233 initial_timeout_); | 261 initial_timeout_); |
234 | 262 |
235 RunTestOnMainThread(); | 263 RunTestOnMainThread(); |
236 CleanUpOnMainThread(); | 264 CleanUpOnMainThread(); |
237 | 265 |
(...skipping 22 matching lines...) Expand all Loading... |
260 NewRunnableMethod(this, &InProcessBrowserTest::TimedOut), | 288 NewRunnableMethod(this, &InProcessBrowserTest::TimedOut), |
261 kSubsequentTimeoutInMS); | 289 kSubsequentTimeoutInMS); |
262 | 290 |
263 MessageLoopForUI::current()->Quit(); | 291 MessageLoopForUI::current()->Quit(); |
264 } | 292 } |
265 | 293 |
266 void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) { | 294 void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) { |
267 DCHECK_GT(timeout_value, 0); | 295 DCHECK_GT(timeout_value, 0); |
268 initial_timeout_ = timeout_value; | 296 initial_timeout_ = timeout_value; |
269 } | 297 } |
OLD | NEW |