| 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" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 quit.Run(); | 130 quit.Run(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace | 133 } // namespace |
| 134 | 134 |
| 135 extern int BrowserMain(const MainFunctionParams&); | 135 extern int BrowserMain(const MainFunctionParams&); |
| 136 | 136 |
| 137 BrowserTestBase::BrowserTestBase() | 137 BrowserTestBase::BrowserTestBase() |
| 138 : expected_exit_code_(0), | 138 : expected_exit_code_(0), |
| 139 enable_pixel_output_(false), | 139 enable_pixel_output_(false), |
| 140 use_software_compositing_(false) { | 140 use_software_compositing_(false), |
| 141 set_up_called_(false) { |
| 141 #if defined(OS_MACOSX) | 142 #if defined(OS_MACOSX) |
| 142 base::mac::SetOverrideAmIBundled(true); | 143 base::mac::SetOverrideAmIBundled(true); |
| 143 #endif | 144 #endif |
| 144 | 145 |
| 145 #if defined(USE_AURA) | 146 #if defined(USE_AURA) |
| 146 #if defined(USE_X11) | 147 #if defined(USE_X11) |
| 147 aura::test::SetUseOverrideRedirectWindowByDefault(true); | 148 aura::test::SetUseOverrideRedirectWindowByDefault(true); |
| 148 #endif | 149 #endif |
| 149 aura::test::InitializeAuraEventGeneratorDelegate(); | 150 aura::test::InitializeAuraEventGeneratorDelegate(); |
| 150 #endif | 151 #endif |
| 151 | 152 |
| 152 #if defined(OS_POSIX) | 153 #if defined(OS_POSIX) |
| 153 handle_sigterm_ = true; | 154 handle_sigterm_ = true; |
| 154 #endif | 155 #endif |
| 155 | 156 |
| 156 // This is called through base::TestSuite initially. It'll also be called | 157 // This is called through base::TestSuite initially. It'll also be called |
| 157 // inside BrowserMain, so tell the code to ignore the check that it's being | 158 // inside BrowserMain, so tell the code to ignore the check that it's being |
| 158 // called more than once | 159 // called more than once |
| 159 base::i18n::AllowMultipleInitializeCallsForTesting(); | 160 base::i18n::AllowMultipleInitializeCallsForTesting(); |
| 160 | 161 |
| 161 embedded_test_server_.reset(new net::test_server::EmbeddedTestServer); | 162 embedded_test_server_.reset(new net::test_server::EmbeddedTestServer); |
| 162 } | 163 } |
| 163 | 164 |
| 164 BrowserTestBase::~BrowserTestBase() { | 165 BrowserTestBase::~BrowserTestBase() { |
| 165 #if defined(OS_ANDROID) | 166 #if defined(OS_ANDROID) |
| 166 // RemoteTestServer can cause wait on the UI thread. | 167 // RemoteTestServer can cause wait on the UI thread. |
| 167 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 168 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 168 test_server_.reset(NULL); | 169 test_server_.reset(NULL); |
| 169 #endif | 170 #endif |
| 171 |
| 172 CHECK(set_up_called_) << "SetUp was not called. This probably means that the " |
| 173 "developer has overridden the method and not called " |
| 174 "the superclass version. In this case, the test " |
| 175 "does not run and reports a false positive result."; |
| 170 } | 176 } |
| 171 | 177 |
| 172 void BrowserTestBase::SetUp() { | 178 void BrowserTestBase::SetUp() { |
| 179 set_up_called_ = true; |
| 180 |
| 173 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 181 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 174 | 182 |
| 175 // Override the child process connection timeout since tests can exceed that | 183 // Override the child process connection timeout since tests can exceed that |
| 176 // when sharded. | 184 // when sharded. |
| 177 command_line->AppendSwitchASCII( | 185 command_line->AppendSwitchASCII( |
| 178 switches::kIPCConnectionTimeout, | 186 switches::kIPCConnectionTimeout, |
| 179 base::IntToString(TestTimeouts::action_max_timeout().InSeconds())); | 187 base::IntToString(TestTimeouts::action_max_timeout().InSeconds())); |
| 180 | 188 |
| 181 // The tests assume that file:// URIs can freely access other file:// URIs. | 189 // The tests assume that file:// URIs can freely access other file:// URIs. |
| 182 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); | 190 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 use_software_compositing_ = true; | 356 use_software_compositing_ = true; |
| 349 } | 357 } |
| 350 | 358 |
| 351 bool BrowserTestBase::UsingOSMesa() const { | 359 bool BrowserTestBase::UsingOSMesa() const { |
| 352 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 360 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 353 return cmd->GetSwitchValueASCII(switches::kUseGL) == | 361 return cmd->GetSwitchValueASCII(switches::kUseGL) == |
| 354 gfx::kGLImplementationOSMesaName; | 362 gfx::kGLImplementationOSMesaName; |
| 355 } | 363 } |
| 356 | 364 |
| 357 } // namespace content | 365 } // namespace content |
| OLD | NEW |