OLD | NEW |
---|---|
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 Loading... | |
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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()); |
240 SetUpInProcessBrowserTestFixture(); | 239 SetUpInProcessBrowserTestFixture(); |
240 for (ScopedVector<Admixture>::iterator it = admixtures_.begin(); | |
dzhioev (left Google)
2014/08/18 12:11:46
You call admixtures' SetUp* method after main test
Lisa Ignatyeva
2014/08/18 12:20:41
Done.
| |
241 it != admixtures_.end(); | |
242 ++it) { | |
243 (*it)->SetUpInProcessBrowserTestFixture(); | |
244 } | |
241 | 245 |
242 base::Closure* ui_task = | 246 base::Closure* ui_task = |
243 new base::Closure( | 247 new base::Closure( |
244 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); | 248 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, this)); |
245 | 249 |
246 #if defined(OS_ANDROID) | 250 #if defined(OS_ANDROID) |
247 MainFunctionParams params(*command_line); | 251 MainFunctionParams params(*command_line); |
248 params.ui_task = ui_task; | 252 params.ui_task = ui_task; |
249 // TODO(phajdan.jr): Check return code, http://crbug.com/374738 . | 253 // TODO(phajdan.jr): Check return code, http://crbug.com/374738 . |
250 BrowserMain(params); | 254 BrowserMain(params); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 void BrowserTestBase::UseSoftwareCompositing() { | 301 void BrowserTestBase::UseSoftwareCompositing() { |
298 use_software_compositing_ = true; | 302 use_software_compositing_ = true; |
299 } | 303 } |
300 | 304 |
301 bool BrowserTestBase::UsingOSMesa() const { | 305 bool BrowserTestBase::UsingOSMesa() const { |
302 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 306 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
303 return cmd->GetSwitchValueASCII(switches::kUseGL) == | 307 return cmd->GetSwitchValueASCII(switches::kUseGL) == |
304 gfx::kGLImplementationOSMesaName; | 308 gfx::kGLImplementationOSMesaName; |
305 } | 309 } |
306 | 310 |
311 void BrowserTestBase::AddAdmixture(BrowserTestBase::Admixture* admixture) { | |
312 admixtures_.push_back(admixture); | |
313 } | |
314 | |
315 std::vector<BrowserTestBase::Admixture*> BrowserTestBase::GetAdmixtures() { | |
316 return admixtures_.get(); | |
317 } | |
318 | |
307 } // namespace content | 319 } // namespace content |
OLD | NEW |