Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: chrome/test/in_process_browser_test.cc

Issue 2729002: Run in-process browser tests using the sandbox. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/interactive_ui/interactive_ui_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 if (dom_automation_enabled_) 131 if (dom_automation_enabled_)
132 command_line->AppendSwitch(switches::kDomAutomationController); 132 command_line->AppendSwitch(switches::kDomAutomationController);
133 133
134 // Turn off tip loading for tests; see http://crbug.com/17725 134 // Turn off tip loading for tests; see http://crbug.com/17725
135 command_line->AppendSwitch(switches::kDisableWebResources); 135 command_line->AppendSwitch(switches::kDisableWebResources);
136 136
137 command_line->AppendSwitchWithValue(switches::kUserDataDir, 137 command_line->AppendSwitchWithValue(switches::kUserDataDir,
138 user_data_dir.ToWStringHack()); 138 user_data_dir.ToWStringHack());
139 139
140 // For some reason the sandbox wasn't happy running in test mode. These
141 // tests aren't intended to test the sandbox, so we turn it off.
142 command_line->AppendSwitch(switches::kNoSandbox);
143
144 // Don't show the first run ui. 140 // Don't show the first run ui.
145 command_line->AppendSwitch(switches::kNoFirstRun); 141 command_line->AppendSwitch(switches::kNoFirstRun);
146 142
147 // This is a Browser test. 143 // This is a Browser test.
148 command_line->AppendSwitchWithValue(switches::kTestType, 144 command_line->AppendSwitchWithValue(switches::kTestType,
149 ASCIIToWide(kBrowserTestType)); 145 ASCIIToWide(kBrowserTestType));
150 146
151 // Single-process mode is not set in BrowserMain so it needs to be processed 147 // Single-process mode is not set in BrowserMain so it needs to be processed
152 // explicitly. 148 // explicitly.
153 original_single_process_ = RenderProcessHost::run_renderer_in_process(); 149 original_single_process_ = RenderProcessHost::run_renderer_in_process();
154 if (command_line->HasSwitch(switches::kSingleProcess)) 150 if (command_line->HasSwitch(switches::kSingleProcess))
155 RenderProcessHost::set_run_renderer_in_process(true); 151 RenderProcessHost::set_run_renderer_in_process(true);
156 152
157 // Explicitly set the path of the exe used for the renderer and plugin, 153 #if defined(OS_WIN)
158 // otherwise they'll try to use unit_test.exe. 154 // The Windows sandbox requires that the browser and child processes are the
155 // same binary. So we launch browser_process.exe which loads chrome.dll
156 command_line->AppendSwitchWithValue(switches::kBrowserSubprocessPath,
157 command_line->GetProgram().value());
158 #else
159 // Explicitly set the path of the binary used for child processes, otherwise
160 // they'll try to use browser_tests which doesn't contain ChromeMain.
159 FilePath subprocess_path; 161 FilePath subprocess_path;
160 PathService::Get(base::FILE_EXE, &subprocess_path); 162 PathService::Get(base::FILE_EXE, &subprocess_path);
161 subprocess_path = subprocess_path.DirName(); 163 subprocess_path = subprocess_path.DirName();
162 subprocess_path = subprocess_path.AppendASCII(WideToASCII( 164 subprocess_path = subprocess_path.AppendASCII(WideToASCII(
163 chrome::kBrowserProcessExecutablePath)); 165 chrome::kBrowserProcessExecutablePath));
164 command_line->AppendSwitchWithValue(switches::kBrowserSubprocessPath, 166 command_line->AppendSwitchWithValue(switches::kBrowserSubprocessPath,
165 subprocess_path.ToWStringHack()); 167 subprocess_path.ToWStringHack());
168 #endif
166 169
167 // Enable warning level logging so that we can see when bad stuff happens. 170 // Enable warning level logging so that we can see when bad stuff happens.
168 command_line->AppendSwitch(switches::kEnableLogging); 171 command_line->AppendSwitch(switches::kEnableLogging);
169 command_line->AppendSwitchWithValue(switches::kLoggingLevel, 172 command_line->AppendSwitchWithValue(switches::kLoggingLevel,
170 IntToWString(1)); // warning 173 IntToWString(1)); // warning
171 174
172 SandboxInitWrapper sandbox_wrapper; 175 SandboxInitWrapper sandbox_wrapper;
173 MainFunctionParams params(*command_line, sandbox_wrapper, NULL); 176 MainFunctionParams params(*command_line, sandbox_wrapper, NULL);
174 params.ui_task = 177 params.ui_task =
175 NewRunnableMethod(this, &InProcessBrowserTest::RunTestOnMainThreadLoop); 178 NewRunnableMethod(this, &InProcessBrowserTest::RunTestOnMainThreadLoop);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 334
332 GTEST_NONFATAL_FAILURE_(error_message.c_str()); 335 GTEST_NONFATAL_FAILURE_(error_message.c_str());
333 336
334 MessageLoopForUI::current()->Quit(); 337 MessageLoopForUI::current()->Quit();
335 } 338 }
336 339
337 void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) { 340 void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) {
338 DCHECK_GT(timeout_value, 0); 341 DCHECK_GT(timeout_value, 0);
339 initial_timeout_ = timeout_value; 342 initial_timeout_ = timeout_value;
340 } 343 }
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/interactive_ui/interactive_ui_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698