| 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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 virtual ~LocalHostResolverProc() {} | 109 virtual ~LocalHostResolverProc() {} |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace | 112 } // namespace |
| 113 | 113 |
| 114 extern int BrowserMain(const MainFunctionParams&); | 114 extern int BrowserMain(const MainFunctionParams&); |
| 115 | 115 |
| 116 BrowserTestBase::BrowserTestBase() | 116 BrowserTestBase::BrowserTestBase() |
| 117 : embedded_test_server_io_thread_("EmbeddedTestServer io thread"), | 117 : allow_test_contexts_(true), |
| 118 allow_test_contexts_(true), | |
| 119 allow_osmesa_(true) { | 118 allow_osmesa_(true) { |
| 120 #if defined(OS_MACOSX) | 119 #if defined(OS_MACOSX) |
| 121 base::mac::SetOverrideAmIBundled(true); | 120 base::mac::SetOverrideAmIBundled(true); |
| 122 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); | 121 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); |
| 123 #endif | 122 #endif |
| 124 | 123 |
| 125 #if defined(OS_POSIX) | 124 #if defined(OS_POSIX) |
| 126 handle_sigterm_ = true; | 125 handle_sigterm_ = true; |
| 127 #endif | 126 #endif |
| 128 | 127 |
| 129 // Create a separate thread for the test server to run on. It's tempting to | 128 embedded_test_server_.reset(new net::test_server::EmbeddedTestServer); |
| 130 // use actual browser threads, but that doesn't work for cases where the test | |
| 131 // server needs to be started before the browser, for example when the server | |
| 132 // URL should be passed in command-line parameters. | |
| 133 base::Thread::Options thread_options; | |
| 134 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | |
| 135 CHECK(embedded_test_server_io_thread_.StartWithOptions(thread_options)); | |
| 136 embedded_test_server_.reset(new net::test_server::EmbeddedTestServer( | |
| 137 embedded_test_server_io_thread_.message_loop_proxy())); | |
| 138 } | 129 } |
| 139 | 130 |
| 140 BrowserTestBase::~BrowserTestBase() { | 131 BrowserTestBase::~BrowserTestBase() { |
| 141 #if defined(OS_ANDROID) | 132 #if defined(OS_ANDROID) |
| 142 // RemoteTestServer can cause wait on the UI thread. | 133 // RemoteTestServer can cause wait on the UI thread. |
| 143 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 134 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 144 test_server_.reset(NULL); | 135 test_server_.reset(NULL); |
| 145 #endif | 136 #endif |
| 146 } | 137 } |
| 147 | 138 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); | 253 RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); |
| 263 CHECK(renderer_loop); | 254 CHECK(renderer_loop); |
| 264 | 255 |
| 265 renderer_loop->PostTask( | 256 renderer_loop->PostTask( |
| 266 FROM_HERE, | 257 FROM_HERE, |
| 267 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); | 258 base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); |
| 268 runner->Run(); | 259 runner->Run(); |
| 269 } | 260 } |
| 270 | 261 |
| 271 } // namespace content | 262 } // namespace content |
| OLD | NEW |