OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/test_renderer_host.h" | 5 #include "content/public/test/test_renderer_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 RenderWidgetHostImpl::From(rvh->GetWidget()); | 120 RenderWidgetHostImpl::From(rvh->GetWidget()); |
121 return host_impl->has_touch_handler(); | 121 return host_impl->has_touch_handler(); |
122 } | 122 } |
123 | 123 |
124 | 124 |
125 // RenderViewHostTestEnabler -------------------------------------------------- | 125 // RenderViewHostTestEnabler -------------------------------------------------- |
126 | 126 |
127 RenderViewHostTestEnabler::RenderViewHostTestEnabler() | 127 RenderViewHostTestEnabler::RenderViewHostTestEnabler() |
128 : rph_factory_(new MockRenderProcessHostFactory()), | 128 : rph_factory_(new MockRenderProcessHostFactory()), |
129 rvh_factory_(new TestRenderViewHostFactory(rph_factory_.get())), | 129 rvh_factory_(new TestRenderViewHostFactory(rph_factory_.get())), |
130 rfh_factory_(new TestRenderFrameHostFactory()) {} | 130 rfh_factory_(new TestRenderFrameHostFactory()) { |
| 131 #if !defined(OS_ANDROID) |
| 132 ImageTransportFactory::InitializeForUnitTests( |
| 133 base::WrapUnique(new NoTransportImageTransportFactory)); |
| 134 #else |
| 135 gpu_channel_factory_ = base::MakeUnique<MockGpuChannelEstablishFactory>(); |
| 136 ContextProviderFactoryImpl::Initialize(gpu_channel_factory_.get()); |
| 137 ui::ContextProviderFactory::SetInstance( |
| 138 ContextProviderFactoryImpl::GetInstance()); |
| 139 #endif |
| 140 } |
131 | 141 |
132 RenderViewHostTestEnabler::~RenderViewHostTestEnabler() { | 142 RenderViewHostTestEnabler::~RenderViewHostTestEnabler() { |
| 143 #if !defined(OS_ANDROID) |
| 144 // RenderWidgetHostView holds on to a reference to SurfaceManager, so it |
| 145 // must be shut down before the ImageTransportFactory. |
| 146 ImageTransportFactory::Terminate(); |
| 147 #else |
| 148 ui::ContextProviderFactory::SetInstance(nullptr); |
| 149 ContextProviderFactoryImpl::Terminate(); |
| 150 gpu_channel_factory_.reset(); |
| 151 #endif |
133 } | 152 } |
134 | 153 |
135 | 154 |
136 // RenderViewHostTestHarness -------------------------------------------------- | 155 // RenderViewHostTestHarness -------------------------------------------------- |
137 | 156 |
138 RenderViewHostTestHarness::RenderViewHostTestHarness() | 157 RenderViewHostTestHarness::RenderViewHostTestHarness() |
139 : thread_bundle_options_(TestBrowserThreadBundle::DEFAULT) {} | 158 : thread_bundle_options_(TestBrowserThreadBundle::DEFAULT) {} |
140 | 159 |
141 RenderViewHostTestHarness::~RenderViewHostTestHarness() { | 160 RenderViewHostTestHarness::~RenderViewHostTestHarness() { |
142 } | 161 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 void RenderViewHostTestHarness::SetUp() { | 247 void RenderViewHostTestHarness::SetUp() { |
229 // ContentTestSuiteBase might have already initialized | 248 // ContentTestSuiteBase might have already initialized |
230 // MaterialDesignController in unit_tests suite. | 249 // MaterialDesignController in unit_tests suite. |
231 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); | 250 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); |
232 ui::MaterialDesignController::Initialize(); | 251 ui::MaterialDesignController::Initialize(); |
233 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_)); | 252 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_)); |
234 | 253 |
235 #if defined(OS_WIN) | 254 #if defined(OS_WIN) |
236 ole_initializer_.reset(new ui::ScopedOleInitializer()); | 255 ole_initializer_.reset(new ui::ScopedOleInitializer()); |
237 #endif | 256 #endif |
238 #if !defined(OS_ANDROID) | |
239 ImageTransportFactory::InitializeForUnitTests( | |
240 base::WrapUnique(new NoTransportImageTransportFactory)); | |
241 #else | |
242 gpu_channel_factory_ = base::MakeUnique<MockGpuChannelEstablishFactory>(); | |
243 ContextProviderFactoryImpl::Initialize(gpu_channel_factory_.get()); | |
244 ui::ContextProviderFactory::SetInstance( | |
245 ContextProviderFactoryImpl::GetInstance()); | |
246 #endif | |
247 #if defined(USE_AURA) | 257 #if defined(USE_AURA) |
248 ui::ContextFactory* context_factory = | 258 ui::ContextFactory* context_factory = |
249 ImageTransportFactory::GetInstance()->GetContextFactory(); | 259 ImageTransportFactory::GetInstance()->GetContextFactory(); |
250 | 260 |
251 aura_test_helper_.reset( | 261 aura_test_helper_.reset( |
252 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); | 262 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
253 aura_test_helper_->SetUp(context_factory); | 263 aura_test_helper_->SetUp(context_factory); |
254 new wm::DefaultActivationClient(aura_test_helper_->root_window()); | 264 new wm::DefaultActivationClient(aura_test_helper_->root_window()); |
255 #endif | 265 #endif |
256 | 266 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 rvh_test_enabler_.rph_factory_.reset(); | 305 rvh_test_enabler_.rph_factory_.reset(); |
296 | 306 |
297 // Release the browser context by posting itself on the end of the task | 307 // Release the browser context by posting itself on the end of the task |
298 // queue. This is preferable to immediate deletion because it will behave | 308 // queue. This is preferable to immediate deletion because it will behave |
299 // properly if the |rph_factory_| reset above enqueued any tasks which | 309 // properly if the |rph_factory_| reset above enqueued any tasks which |
300 // depend on |browser_context_|. | 310 // depend on |browser_context_|. |
301 BrowserThread::DeleteSoon(content::BrowserThread::UI, | 311 BrowserThread::DeleteSoon(content::BrowserThread::UI, |
302 FROM_HERE, | 312 FROM_HERE, |
303 browser_context_.release()); | 313 browser_context_.release()); |
304 thread_bundle_.reset(); | 314 thread_bundle_.reset(); |
305 | |
306 #if !defined(OS_ANDROID) | |
307 // RenderWidgetHostView holds on to a reference to SurfaceManager, so it | |
308 // must be shut down before the ImageTransportFactory. | |
309 ImageTransportFactory::Terminate(); | |
310 #else | |
311 ui::ContextProviderFactory::SetInstance(nullptr); | |
312 ContextProviderFactoryImpl::Terminate(); | |
313 gpu_channel_factory_.reset(); | |
314 #endif | |
315 } | 315 } |
316 | 316 |
317 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { | 317 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { |
318 return new TestBrowserContext(); | 318 return new TestBrowserContext(); |
319 } | 319 } |
320 | 320 |
321 void RenderViewHostTestHarness::SetRenderProcessHostFactory( | 321 void RenderViewHostTestHarness::SetRenderProcessHostFactory( |
322 RenderProcessHostFactory* factory) { | 322 RenderProcessHostFactory* factory) { |
323 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); | 323 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); |
324 } | 324 } |
325 | 325 |
326 } // namespace content | 326 } // namespace content |
OLD | NEW |