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

Side by Side Diff: content/public/test/browser_test_base.cc

Issue 803813003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « content/public/common/url_utils.cc ('k') | content/public/test/content_browser_test.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser_test_base.h" 5 #include "content/public/test/browser_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/stack_trace.h" 9 #include "base/debug/stack_trace.h"
10 #include "base/i18n/icu_util.h" 10 #include "base/i18n/icu_util.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 BrowserTestBase::~BrowserTestBase() { 162 BrowserTestBase::~BrowserTestBase() {
163 #if defined(OS_ANDROID) 163 #if defined(OS_ANDROID)
164 // RemoteTestServer can cause wait on the UI thread. 164 // RemoteTestServer can cause wait on the UI thread.
165 base::ThreadRestrictions::ScopedAllowWait allow_wait; 165 base::ThreadRestrictions::ScopedAllowWait allow_wait;
166 test_server_.reset(NULL); 166 test_server_.reset(NULL);
167 #endif 167 #endif
168 } 168 }
169 169
170 void BrowserTestBase::SetUp() { 170 void BrowserTestBase::SetUp() {
171 CommandLine* command_line = CommandLine::ForCurrentProcess(); 171 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
172 172
173 // Override the child process connection timeout since tests can exceed that 173 // Override the child process connection timeout since tests can exceed that
174 // when sharded. 174 // when sharded.
175 command_line->AppendSwitchASCII( 175 command_line->AppendSwitchASCII(
176 switches::kIPCConnectionTimeout, 176 switches::kIPCConnectionTimeout,
177 base::IntToString(TestTimeouts::action_max_timeout().InSeconds())); 177 base::IntToString(TestTimeouts::action_max_timeout().InSeconds()));
178 178
179 // The tests assume that file:// URIs can freely access other file:// URIs. 179 // The tests assume that file:// URIs can freely access other file:// URIs.
180 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); 180 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);
181 181
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 271
272 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { 272 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() {
273 #if defined(OS_POSIX) 273 #if defined(OS_POSIX)
274 if (handle_sigterm_) { 274 if (handle_sigterm_) {
275 g_browser_process_pid = base::GetCurrentProcId(); 275 g_browser_process_pid = base::GetCurrentProcId();
276 signal(SIGTERM, DumpStackTraceSignalHandler); 276 signal(SIGTERM, DumpStackTraceSignalHandler);
277 } 277 }
278 #endif // defined(OS_POSIX) 278 #endif // defined(OS_POSIX)
279 279
280 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTracing)) { 280 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
281 switches::kEnableTracing)) {
281 base::debug::CategoryFilter category_filter( 282 base::debug::CategoryFilter category_filter(
282 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 283 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
283 switches::kEnableTracing)); 284 switches::kEnableTracing));
284 TracingController::GetInstance()->EnableRecording( 285 TracingController::GetInstance()->EnableRecording(
285 category_filter, 286 category_filter,
286 base::debug::TraceOptions(base::debug::RECORD_CONTINUOUSLY), 287 base::debug::TraceOptions(base::debug::RECORD_CONTINUOUSLY),
287 TracingController::EnableRecordingDoneCallback()); 288 TracingController::EnableRecordingDoneCallback());
288 } 289 }
289 290
290 RunTestOnMainThreadLoop(); 291 RunTestOnMainThreadLoop();
291 292
292 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTracing)) { 293 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
294 switches::kEnableTracing)) {
293 base::FilePath trace_file = 295 base::FilePath trace_file =
294 CommandLine::ForCurrentProcess()->GetSwitchValuePath( 296 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
295 switches::kEnableTracingOutput); 297 switches::kEnableTracingOutput);
296 // If there was no file specified, put a hardcoded one in the current 298 // If there was no file specified, put a hardcoded one in the current
297 // working directory. 299 // working directory.
298 if (trace_file.empty()) 300 if (trace_file.empty())
299 trace_file = base::FilePath().AppendASCII("trace.json"); 301 trace_file = base::FilePath().AppendASCII("trace.json");
300 302
301 // Wait for tracing to collect results from the renderers. 303 // Wait for tracing to collect results from the renderers.
302 base::RunLoop run_loop; 304 base::RunLoop run_loop;
303 TracingController::GetInstance()->DisableRecording( 305 TracingController::GetInstance()->DisableRecording(
304 TracingControllerImpl::CreateFileSink( 306 TracingControllerImpl::CreateFileSink(
305 trace_file, 307 trace_file,
306 base::Bind(&TraceDisableRecordingComplete, 308 base::Bind(&TraceDisableRecordingComplete,
307 run_loop.QuitClosure(), 309 run_loop.QuitClosure(),
308 trace_file))); 310 trace_file)));
309 run_loop.Run(); 311 run_loop.Run();
310 } 312 }
311 } 313 }
312 314
313 void BrowserTestBase::CreateTestServer(const base::FilePath& test_server_base) { 315 void BrowserTestBase::CreateTestServer(const base::FilePath& test_server_base) {
314 CHECK(!test_server_.get()); 316 CHECK(!test_server_.get());
315 test_server_.reset(new net::SpawnedTestServer( 317 test_server_.reset(new net::SpawnedTestServer(
316 net::SpawnedTestServer::TYPE_HTTP, 318 net::SpawnedTestServer::TYPE_HTTP,
317 net::SpawnedTestServer::kLocalhost, 319 net::SpawnedTestServer::kLocalhost,
318 test_server_base)); 320 test_server_base));
319 } 321 }
320 322
321 void BrowserTestBase::PostTaskToInProcessRendererAndWait( 323 void BrowserTestBase::PostTaskToInProcessRendererAndWait(
322 const base::Closure& task) { 324 const base::Closure& task) {
323 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); 325 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
326 switches::kSingleProcess));
324 327
325 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; 328 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner;
326 329
327 base::MessageLoop* renderer_loop = 330 base::MessageLoop* renderer_loop =
328 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); 331 RenderProcessHostImpl::GetInProcessRendererThreadForTesting();
329 CHECK(renderer_loop); 332 CHECK(renderer_loop);
330 333
331 renderer_loop->PostTask( 334 renderer_loop->PostTask(
332 FROM_HERE, 335 FROM_HERE,
333 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); 336 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure()));
334 runner->Run(); 337 runner->Run();
335 } 338 }
336 339
337 void BrowserTestBase::EnablePixelOutput() { enable_pixel_output_ = true; } 340 void BrowserTestBase::EnablePixelOutput() { enable_pixel_output_ = true; }
338 341
339 void BrowserTestBase::UseSoftwareCompositing() { 342 void BrowserTestBase::UseSoftwareCompositing() {
340 use_software_compositing_ = true; 343 use_software_compositing_ = true;
341 } 344 }
342 345
343 bool BrowserTestBase::UsingOSMesa() const { 346 bool BrowserTestBase::UsingOSMesa() const {
344 CommandLine* cmd = CommandLine::ForCurrentProcess(); 347 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
345 return cmd->GetSwitchValueASCII(switches::kUseGL) == 348 return cmd->GetSwitchValueASCII(switches::kUseGL) ==
346 gfx::kGLImplementationOSMesaName; 349 gfx::kGLImplementationOSMesaName;
347 } 350 }
348 351
349 } // namespace content 352 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/url_utils.cc ('k') | content/public/test/content_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698