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

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

Issue 2832153003: Move calling of shared browser test methods like SetUpOnMainThread/TearDownOnMainThread/RunTestOn... (Closed)
Patch Set: sync Created 3 years, 8 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
« no previous file with comments | « content/public/test/browser_test_base.h ('k') | content/public/test/content_browser_test.h » ('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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/stack_trace.h" 11 #include "base/debug/stack_trace.h"
12 #include "base/feature_list.h" 12 #include "base/feature_list.h"
13 #include "base/i18n/icu_util.h" 13 #include "base/i18n/icu_util.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/sys_info.h" 18 #include "base/sys_info.h"
19 #include "base/test/test_timeouts.h" 19 #include "base/test/test_timeouts.h"
20 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/threading/sequenced_worker_pool.h"
21 #include "base/threading/thread_restrictions.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "content/browser/renderer_host/render_process_host_impl.h" 23 #include "content/browser/renderer_host/render_process_host_impl.h"
23 #include "content/browser/tracing/tracing_controller_impl.h" 24 #include "content/browser/tracing/tracing_controller_impl.h"
24 #include "content/public/app/content_main.h" 25 #include "content/public/app/content_main.h"
25 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
26 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
27 #include "content/public/common/main_function_params.h" 28 #include "content/public/common/main_function_params.h"
28 #include "content/public/test/test_launcher.h" 29 #include "content/public/test/test_launcher.h"
29 #include "content/public/test/test_utils.h" 30 #include "content/public/test/test_utils.h"
30 #include "content/test/content_browser_sanity_checker.h" 31 #include "content/test/content_browser_sanity_checker.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 139 }
139 140
140 } // namespace 141 } // namespace
141 142
142 extern int BrowserMain(const MainFunctionParams&); 143 extern int BrowserMain(const MainFunctionParams&);
143 144
144 BrowserTestBase::BrowserTestBase() 145 BrowserTestBase::BrowserTestBase()
145 : expected_exit_code_(0), 146 : expected_exit_code_(0),
146 enable_pixel_output_(false), 147 enable_pixel_output_(false),
147 use_software_compositing_(false), 148 use_software_compositing_(false),
148 set_up_called_(false) { 149 set_up_called_(false),
150 disable_io_checks_(false) {
149 #if defined(OS_MACOSX) 151 #if defined(OS_MACOSX)
150 base::mac::SetOverrideAmIBundled(true); 152 base::mac::SetOverrideAmIBundled(true);
151 #endif 153 #endif
152 154
153 ui::test::EnableTestConfigForPlatformWindows(); 155 ui::test::EnableTestConfigForPlatformWindows();
154 156
155 #if defined(OS_POSIX) 157 #if defined(OS_POSIX)
156 handle_sigterm_ = true; 158 handle_sigterm_ = true;
157 #endif 159 #endif
158 160
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 trace_config, 338 trace_config,
337 TracingController::StartTracingDoneCallback()); 339 TracingController::StartTracingDoneCallback());
338 } 340 }
339 341
340 { 342 {
341 // This can be called from a posted task. Allow nested tasks here, because 343 // This can be called from a posted task. Allow nested tasks here, because
342 // otherwise the test body will have to do it in order to use RunLoop for 344 // otherwise the test body will have to do it in order to use RunLoop for
343 // waiting. 345 // waiting.
344 base::MessageLoop::ScopedNestableTaskAllower allow( 346 base::MessageLoop::ScopedNestableTaskAllower allow(
345 base::MessageLoop::current()); 347 base::MessageLoop::current());
346 RunTestOnMainThreadLoop(); 348 PreRunTestOnMainThread();
349 SetUpOnMainThread();
350 bool old_io_allowed_value = false;
351 if (!disable_io_checks_)
352 base::ThreadRestrictions::SetIOAllowed(false);
353 RunTestOnMainThread();
354 if (!disable_io_checks_)
355 base::ThreadRestrictions::SetIOAllowed(old_io_allowed_value);
356 TearDownOnMainThread();
357 PostRunTestOnMainThread();
347 } 358 }
348 359
349 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 360 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
350 switches::kEnableTracing)) { 361 switches::kEnableTracing)) {
351 base::FilePath trace_file = 362 base::FilePath trace_file =
352 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( 363 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
353 switches::kEnableTracingOutput); 364 switches::kEnableTracingOutput);
354 // If there was no file specified, put a hardcoded one in the current 365 // If there was no file specified, put a hardcoded one in the current
355 // working directory. 366 // working directory.
356 if (trace_file.empty()) 367 if (trace_file.empty())
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 use_software_compositing_ = true; 410 use_software_compositing_ = true;
400 } 411 }
401 412
402 bool BrowserTestBase::UsingSoftwareGL() const { 413 bool BrowserTestBase::UsingSoftwareGL() const {
403 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 414 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
404 return cmd->GetSwitchValueASCII(switches::kUseGL) == 415 return cmd->GetSwitchValueASCII(switches::kUseGL) ==
405 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation()); 416 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation());
406 } 417 }
407 418
408 } // namespace content 419 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_base.h ('k') | content/public/test/content_browser_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698