| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 153 | 153 | 
| 154 #if defined(OS_POSIX) | 154 #if defined(OS_POSIX) | 
| 155   handle_sigterm_ = true; | 155   handle_sigterm_ = true; | 
| 156 #endif | 156 #endif | 
| 157 | 157 | 
| 158   // This is called through base::TestSuite initially. It'll also be called | 158   // This is called through base::TestSuite initially. It'll also be called | 
| 159   // inside BrowserMain, so tell the code to ignore the check that it's being | 159   // inside BrowserMain, so tell the code to ignore the check that it's being | 
| 160   // called more than once | 160   // called more than once | 
| 161   base::i18n::AllowMultipleInitializeCallsForTesting(); | 161   base::i18n::AllowMultipleInitializeCallsForTesting(); | 
| 162 | 162 | 
| 163   embedded_test_server_.reset(new net::test_server::EmbeddedTestServer); | 163   embedded_test_server_.reset(new net::EmbeddedTestServer); | 
| 164 } | 164 } | 
| 165 | 165 | 
| 166 BrowserTestBase::~BrowserTestBase() { | 166 BrowserTestBase::~BrowserTestBase() { | 
| 167 #if defined(OS_ANDROID) | 167 #if defined(OS_ANDROID) | 
| 168   // RemoteTestServer can cause wait on the UI thread. | 168   // RemoteTestServer can cause wait on the UI thread. | 
| 169   base::ThreadRestrictions::ScopedAllowWait allow_wait; | 169   base::ThreadRestrictions::ScopedAllowWait allow_wait; | 
| 170   test_server_.reset(NULL); | 170   spawned_test_server_.reset(NULL); | 
| 171 #endif | 171 #endif | 
| 172 | 172 | 
| 173   CHECK(set_up_called_) << "SetUp was not called. This probably means that the " | 173   CHECK(set_up_called_) << "SetUp was not called. This probably means that the " | 
| 174                            "developer has overridden the method and not called " | 174                            "developer has overridden the method and not called " | 
| 175                            "the superclass version. In this case, the test " | 175                            "the superclass version. In this case, the test " | 
| 176                            "does not run and reports a false positive result."; | 176                            "does not run and reports a false positive result."; | 
| 177 } | 177 } | 
| 178 | 178 | 
| 179 void BrowserTestBase::SetUp() { | 179 void BrowserTestBase::SetUp() { | 
| 180   set_up_called_ = true; | 180   set_up_called_ = true; | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 316         TracingControllerImpl::CreateFileSink( | 316         TracingControllerImpl::CreateFileSink( | 
| 317             trace_file, | 317             trace_file, | 
| 318             base::Bind(&TraceDisableRecordingComplete, | 318             base::Bind(&TraceDisableRecordingComplete, | 
| 319                        run_loop.QuitClosure(), | 319                        run_loop.QuitClosure(), | 
| 320                        trace_file))); | 320                        trace_file))); | 
| 321     run_loop.Run(); | 321     run_loop.Run(); | 
| 322   } | 322   } | 
| 323 } | 323 } | 
| 324 | 324 | 
| 325 void BrowserTestBase::CreateTestServer(const base::FilePath& test_server_base) { | 325 void BrowserTestBase::CreateTestServer(const base::FilePath& test_server_base) { | 
| 326   CHECK(!test_server_.get()); | 326   CHECK(!spawned_test_server_.get()); | 
| 327   test_server_.reset(new net::SpawnedTestServer( | 327   spawned_test_server_.reset(new net::SpawnedTestServer( | 
| 328       net::SpawnedTestServer::TYPE_HTTP, | 328       net::SpawnedTestServer::TYPE_HTTP, net::SpawnedTestServer::kLocalhost, | 
| 329       net::SpawnedTestServer::kLocalhost, |  | 
| 330       test_server_base)); | 329       test_server_base)); | 
|  | 330   embedded_test_server()->AddDefaultHandlers(test_server_base); | 
| 331 } | 331 } | 
| 332 | 332 | 
| 333 void BrowserTestBase::PostTaskToInProcessRendererAndWait( | 333 void BrowserTestBase::PostTaskToInProcessRendererAndWait( | 
| 334     const base::Closure& task) { | 334     const base::Closure& task) { | 
| 335   CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 335   CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 
| 336       switches::kSingleProcess)); | 336       switches::kSingleProcess)); | 
| 337 | 337 | 
| 338   scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; | 338   scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; | 
| 339 | 339 | 
| 340   base::MessageLoop* renderer_loop = | 340   base::MessageLoop* renderer_loop = | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 353   use_software_compositing_ = true; | 353   use_software_compositing_ = true; | 
| 354 } | 354 } | 
| 355 | 355 | 
| 356 bool BrowserTestBase::UsingOSMesa() const { | 356 bool BrowserTestBase::UsingOSMesa() const { | 
| 357   base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 357   base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 
| 358   return cmd->GetSwitchValueASCII(switches::kUseGL) == | 358   return cmd->GetSwitchValueASCII(switches::kUseGL) == | 
| 359          gfx::kGLImplementationOSMesaName; | 359          gfx::kGLImplementationOSMesaName; | 
| 360 } | 360 } | 
| 361 | 361 | 
| 362 }  // namespace content | 362 }  // namespace content | 
| OLD | NEW | 
|---|