OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if (!command_line->HasSwitch(kUnitTestShowWindows) && !show_window_) | 128 if (!command_line->HasSwitch(kUnitTestShowWindows) && !show_window_) |
129 BrowserView::SetShowState(SW_HIDE); | 129 BrowserView::SetShowState(SW_HIDE); |
130 #endif | 130 #endif |
131 | 131 |
132 if (dom_automation_enabled_) | 132 if (dom_automation_enabled_) |
133 command_line->AppendSwitch(switches::kDomAutomationController); | 133 command_line->AppendSwitch(switches::kDomAutomationController); |
134 | 134 |
135 // Turn off tip loading for tests; see http://crbug.com/17725 | 135 // Turn off tip loading for tests; see http://crbug.com/17725 |
136 command_line->AppendSwitch(switches::kDisableWebResources); | 136 command_line->AppendSwitch(switches::kDisableWebResources); |
137 | 137 |
138 command_line->AppendSwitchWithValue(switches::kUserDataDir, | 138 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
139 user_data_dir.ToWStringHack()); | |
140 | 139 |
141 // Don't show the first run ui. | 140 // Don't show the first run ui. |
142 command_line->AppendSwitch(switches::kNoFirstRun); | 141 command_line->AppendSwitch(switches::kNoFirstRun); |
143 | 142 |
144 // This is a Browser test. | 143 // This is a Browser test. |
145 command_line->AppendSwitchWithValue(switches::kTestType, | 144 command_line->AppendSwitchWithValue(switches::kTestType, kBrowserTestType); |
146 ASCIIToWide(kBrowserTestType)); | |
147 | 145 |
148 // Single-process mode is not set in BrowserMain so it needs to be processed | 146 // Single-process mode is not set in BrowserMain so it needs to be processed |
149 // explicitly. | 147 // explicitly. |
150 original_single_process_ = RenderProcessHost::run_renderer_in_process(); | 148 original_single_process_ = RenderProcessHost::run_renderer_in_process(); |
151 if (command_line->HasSwitch(switches::kSingleProcess)) | 149 if (command_line->HasSwitch(switches::kSingleProcess)) |
152 RenderProcessHost::set_run_renderer_in_process(true); | 150 RenderProcessHost::set_run_renderer_in_process(true); |
153 | 151 |
154 #if defined(OS_WIN) | 152 #if defined(OS_WIN) |
155 // The Windows sandbox requires that the browser and child processes are the | 153 // The Windows sandbox requires that the browser and child processes are the |
156 // same binary. So we launch browser_process.exe which loads chrome.dll | 154 // same binary. So we launch browser_process.exe which loads chrome.dll |
157 command_line->AppendSwitchWithValue(switches::kBrowserSubprocessPath, | 155 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, |
158 command_line->GetProgram().value()); | 156 command_line->GetProgram()); |
159 #else | 157 #else |
160 // Explicitly set the path of the binary used for child processes, otherwise | 158 // Explicitly set the path of the binary used for child processes, otherwise |
161 // they'll try to use browser_tests which doesn't contain ChromeMain. | 159 // they'll try to use browser_tests which doesn't contain ChromeMain. |
162 FilePath subprocess_path; | 160 FilePath subprocess_path; |
163 PathService::Get(base::FILE_EXE, &subprocess_path); | 161 PathService::Get(base::FILE_EXE, &subprocess_path); |
164 subprocess_path = subprocess_path.DirName(); | 162 subprocess_path = subprocess_path.DirName(); |
165 subprocess_path = subprocess_path.AppendASCII(WideToASCII( | 163 subprocess_path = subprocess_path.AppendASCII(WideToASCII( |
166 chrome::kBrowserProcessExecutablePath)); | 164 chrome::kBrowserProcessExecutablePath)); |
167 command_line->AppendSwitchWithValue(switches::kBrowserSubprocessPath, | 165 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, |
168 subprocess_path.ToWStringHack()); | 166 subprocess_path); |
169 #endif | 167 #endif |
170 | 168 |
171 // Enable warning level logging so that we can see when bad stuff happens. | 169 // Enable warning level logging so that we can see when bad stuff happens. |
172 command_line->AppendSwitch(switches::kEnableLogging); | 170 command_line->AppendSwitch(switches::kEnableLogging); |
173 command_line->AppendSwitchWithValue(switches::kLoggingLevel, | 171 command_line->AppendSwitchWithValue(switches::kLoggingLevel, |
174 IntToWString(1)); // warning | 172 IntToWString(1)); // warning |
175 | 173 |
176 // If ncecessary, disable TabCloseableStateWatcher. | 174 // If ncecessary, disable TabCloseableStateWatcher. |
177 if (!tab_closeable_state_watcher_enabled_) | 175 if (!tab_closeable_state_watcher_enabled_) |
178 command_line->AppendSwitch(switches::kDisableTabCloseableStateWatcher); | 176 command_line->AppendSwitch(switches::kDisableTabCloseableStateWatcher); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 335 |
338 GTEST_NONFATAL_FAILURE_(error_message.c_str()); | 336 GTEST_NONFATAL_FAILURE_(error_message.c_str()); |
339 | 337 |
340 MessageLoopForUI::current()->Quit(); | 338 MessageLoopForUI::current()->Quit(); |
341 } | 339 } |
342 | 340 |
343 void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) { | 341 void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) { |
344 DCHECK_GT(timeout_value, 0); | 342 DCHECK_GT(timeout_value, 0); |
345 initial_timeout_ = timeout_value; | 343 initial_timeout_ = timeout_value; |
346 } | 344 } |
OLD | NEW |