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

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

Issue 468493003: Admixtures in BrowserTestBase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed teardown fixes Created 6 years, 4 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') | no next file » | 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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/sys_info.h" 13 #include "base/sys_info.h"
14 #include "base/test/test_timeouts.h" 14 #include "base/test/test_timeouts.h"
15 #include "content/browser/renderer_host/render_process_host_impl.h"
15 #include "content/public/app/content_main.h" 16 #include "content/public/app/content_main.h"
16 #include "content/browser/renderer_host/render_process_host_impl.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
19 #include "content/public/common/main_function_params.h" 19 #include "content/public/common/main_function_params.h"
20 #include "content/public/test/test_launcher.h" 20 #include "content/public/test/test_launcher.h"
21 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
22 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
23 #include "net/dns/mock_host_resolver.h" 23 #include "net/dns/mock_host_resolver.h"
24 #include "net/test/embedded_test_server/embedded_test_server.h" 24 #include "net/test/embedded_test_server/embedded_test_server.h"
25 #include "ui/compositor/compositor_switches.h" 25 #include "ui/compositor/compositor_switches.h"
26 #include "ui/gl/gl_implementation.h" 26 #include "ui/gl/gl_implementation.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 BrowserTestBase::~BrowserTestBase() { 151 BrowserTestBase::~BrowserTestBase() {
152 #if defined(OS_ANDROID) 152 #if defined(OS_ANDROID)
153 // RemoteTestServer can cause wait on the UI thread. 153 // RemoteTestServer can cause wait on the UI thread.
154 base::ThreadRestrictions::ScopedAllowWait allow_wait; 154 base::ThreadRestrictions::ScopedAllowWait allow_wait;
155 test_server_.reset(NULL); 155 test_server_.reset(NULL);
156 #endif 156 #endif
157 } 157 }
158 158
159 void BrowserTestBase::SetUp() { 159 void BrowserTestBase::SetUp() {
160 CommandLine* command_line = CommandLine::ForCurrentProcess(); 160 CommandLine* command_line = CommandLine::ForCurrentProcess();
161
162 // Override the child process connection timeout since tests can exceed that 161 // Override the child process connection timeout since tests can exceed that
163 // when sharded. 162 // when sharded.
164 command_line->AppendSwitchASCII( 163 command_line->AppendSwitchASCII(
165 switches::kIPCConnectionTimeout, 164 switches::kIPCConnectionTimeout,
166 base::IntToString(TestTimeouts::action_max_timeout().InSeconds())); 165 base::IntToString(TestTimeouts::action_max_timeout().InSeconds()));
167 166
168 // The tests assume that file:// URIs can freely access other file:// URIs. 167 // The tests assume that file:// URIs can freely access other file:// URIs.
169 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); 168 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);
170 169
171 command_line->AppendSwitch(switches::kDomAutomationController); 170 command_line->AppendSwitch(switches::kDomAutomationController);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (use_osmesa && !use_software_compositing_) 229 if (use_osmesa && !use_software_compositing_)
231 command_line->AppendSwitch(switches::kOverrideUseGLWithOSMesaForTests); 230 command_line->AppendSwitch(switches::kOverrideUseGLWithOSMesaForTests);
232 231
233 scoped_refptr<net::HostResolverProc> local_resolver = 232 scoped_refptr<net::HostResolverProc> local_resolver =
234 new LocalHostResolverProc(); 233 new LocalHostResolverProc();
235 rule_based_resolver_ = 234 rule_based_resolver_ =
236 new net::RuleBasedHostResolverProc(local_resolver.get()); 235 new net::RuleBasedHostResolverProc(local_resolver.get());
237 rule_based_resolver_->AddSimulatedFailure("wpad"); 236 rule_based_resolver_->AddSimulatedFailure("wpad");
238 net::ScopedDefaultHostResolverProc scoped_local_host_resolver_proc( 237 net::ScopedDefaultHostResolverProc scoped_local_host_resolver_proc(
239 rule_based_resolver_.get()); 238 rule_based_resolver_.get());
239 for (ScopedVector<Admixture>::iterator it = admixtures_.begin();
240 it != admixtures_.end();
241 ++it) {
242 (*it)->SetUpInProcessBrowserTestFixture();
243 }
240 SetUpInProcessBrowserTestFixture(); 244 SetUpInProcessBrowserTestFixture();
241
242 base::Closure* ui_task = 245 base::Closure* ui_task =
243 new base::Closure( 246 new base::Closure(
244 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); 247 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this));
245 248
246 #if defined(OS_ANDROID) 249 #if defined(OS_ANDROID)
247 MainFunctionParams params(*command_line); 250 MainFunctionParams params(*command_line);
248 params.ui_task = ui_task; 251 params.ui_task = ui_task;
249 // TODO(phajdan.jr): Check return code, http://crbug.com/374738 . 252 // TODO(phajdan.jr): Check return code, http://crbug.com/374738 .
250 BrowserMain(params); 253 BrowserMain(params);
251 #else 254 #else
252 GetContentMainParams()->ui_task = ui_task; 255 GetContentMainParams()->ui_task = ui_task;
253 EXPECT_EQ(expected_exit_code_, ContentMain(*GetContentMainParams())); 256 EXPECT_EQ(expected_exit_code_, ContentMain(*GetContentMainParams()));
254 #endif 257 #endif
255 TearDownInProcessBrowserTestFixture(); 258 TearDownInProcessBrowserTestFixture();
259 for (ScopedVector<Admixture>::reverse_iterator it = admixtures_.rbegin();
260 it != admixtures_.rend();
261 ++it) {
262 (*it)->TearDownInProcessBrowserTestFixture();
263 }
256 } 264 }
257 265
258 void BrowserTestBase::TearDown() { 266 void BrowserTestBase::TearDown() {
259 } 267 }
260 268
261 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { 269 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() {
262 #if defined(OS_POSIX) 270 #if defined(OS_POSIX)
263 if (handle_sigterm_) { 271 if (handle_sigterm_) {
264 g_browser_process_pid = base::GetCurrentProcId(); 272 g_browser_process_pid = base::GetCurrentProcId();
265 signal(SIGTERM, DumpStackTraceSignalHandler); 273 signal(SIGTERM, DumpStackTraceSignalHandler);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 void BrowserTestBase::UseSoftwareCompositing() { 305 void BrowserTestBase::UseSoftwareCompositing() {
298 use_software_compositing_ = true; 306 use_software_compositing_ = true;
299 } 307 }
300 308
301 bool BrowserTestBase::UsingOSMesa() const { 309 bool BrowserTestBase::UsingOSMesa() const {
302 CommandLine* cmd = CommandLine::ForCurrentProcess(); 310 CommandLine* cmd = CommandLine::ForCurrentProcess();
303 return cmd->GetSwitchValueASCII(switches::kUseGL) == 311 return cmd->GetSwitchValueASCII(switches::kUseGL) ==
304 gfx::kGLImplementationOSMesaName; 312 gfx::kGLImplementationOSMesaName;
305 } 313 }
306 314
315 void BrowserTestBase::AddAdmixture(BrowserTestBase::Admixture* admixture) {
316 admixtures_.push_back(admixture);
317 }
318
319 std::vector<BrowserTestBase::Admixture*> BrowserTestBase::GetAdmixtures() {
320 return admixtures_.get();
321 }
322
307 } // namespace content 323 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698