Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: content/public/test/test_renderer_host.cc

Issue 2079623002: Create only one ContextFactory in content unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add dcheck Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "build/build_config.h" 10 #include "build/build_config.h"
11 #include "content/browser/compositor/test/no_transport_image_transport_factory.h "
11 #include "content/browser/frame_host/navigation_entry_impl.h" 12 #include "content/browser/frame_host/navigation_entry_impl.h"
12 #include "content/browser/renderer_host/render_view_host_factory.h" 13 #include "content/browser/renderer_host/render_view_host_factory.h"
13 #include "content/browser/renderer_host/render_widget_host_impl.h" 14 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "content/browser/site_instance_impl.h" 15 #include "content/browser/site_instance_impl.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/browser_side_navigation_policy.h" 18 #include "content/public/common/browser_side_navigation_policy.h"
18 #include "content/public/test/mock_render_process_host.h" 19 #include "content/public/test/mock_render_process_host.h"
19 #include "content/public/test/test_browser_context.h" 20 #include "content/public/test/test_browser_context.h"
20 #include "content/test/browser_side_navigation_test_utils.h" 21 #include "content/test/browser_side_navigation_test_utils.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void RenderViewHostTestHarness::SetUp() { 184 void RenderViewHostTestHarness::SetUp() {
184 // ContentTestSuiteBase might have already initialized 185 // ContentTestSuiteBase might have already initialized
185 // MaterialDesignController in unit_tests suite. 186 // MaterialDesignController in unit_tests suite.
186 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); 187 ui::test::MaterialDesignControllerTestAPI::Uninitialize();
187 ui::MaterialDesignController::Initialize(); 188 ui::MaterialDesignController::Initialize();
188 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_)); 189 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_));
189 190
190 #if defined(OS_WIN) 191 #if defined(OS_WIN)
191 ole_initializer_.reset(new ui::ScopedOleInitializer()); 192 ole_initializer_.reset(new ui::ScopedOleInitializer());
192 #endif 193 #endif
194 #if !defined(OS_ANDROID)
195 ImageTransportFactory::InitializeForUnitTests(
196 base::WrapUnique(new NoTransportImageTransportFactory));
197 #endif
193 #if defined(USE_AURA) 198 #if defined(USE_AURA)
194 // The ContextFactory must exist before any Compositors are created.
195 bool enable_pixel_output = false;
196 ui::ContextFactory* context_factory = 199 ui::ContextFactory* context_factory =
197 ui::InitializeContextFactoryForTests(enable_pixel_output); 200 ImageTransportFactory::GetInstance()->GetContextFactory();
198 201
199 aura_test_helper_.reset( 202 aura_test_helper_.reset(
200 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); 203 new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
201 aura_test_helper_->SetUp(context_factory); 204 aura_test_helper_->SetUp(context_factory);
202 new wm::DefaultActivationClient(aura_test_helper_->root_window()); 205 new wm::DefaultActivationClient(aura_test_helper_->root_window());
203 #endif 206 #endif
204 207
205 sanity_checker_.reset(new ContentBrowserSanityChecker()); 208 sanity_checker_.reset(new ContentBrowserSanityChecker());
206 209
207 DCHECK(!browser_context_); 210 DCHECK(!browser_context_);
(...skipping 27 matching lines...) Expand all
235 rvh_test_enabler_.rph_factory_.reset(); 238 rvh_test_enabler_.rph_factory_.reset();
236 239
237 // Release the browser context by posting itself on the end of the task 240 // Release the browser context by posting itself on the end of the task
238 // queue. This is preferable to immediate deletion because it will behave 241 // queue. This is preferable to immediate deletion because it will behave
239 // properly if the |rph_factory_| reset above enqueued any tasks which 242 // properly if the |rph_factory_| reset above enqueued any tasks which
240 // depend on |browser_context_|. 243 // depend on |browser_context_|.
241 BrowserThread::DeleteSoon(content::BrowserThread::UI, 244 BrowserThread::DeleteSoon(content::BrowserThread::UI,
242 FROM_HERE, 245 FROM_HERE,
243 browser_context_.release()); 246 browser_context_.release());
244 thread_bundle_.reset(); 247 thread_bundle_.reset();
248
249 #if !defined(OS_ANDROID)
250 // RenderWidgetHostView holds on to a reference to SurfaceManager, so it
251 // must be shut down before the ImageTransportFactory.
252 ImageTransportFactory::Terminate();
253 #endif
245 } 254 }
246 255
247 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { 256 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() {
248 return new TestBrowserContext(); 257 return new TestBrowserContext();
249 } 258 }
250 259
251 void RenderViewHostTestHarness::SetRenderProcessHostFactory( 260 void RenderViewHostTestHarness::SetRenderProcessHostFactory(
252 RenderProcessHostFactory* factory) { 261 RenderProcessHostFactory* factory) {
253 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); 262 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory);
254 } 263 }
255 264
256 } // namespace content 265 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac_unittest.mm ('k') | content/test/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698