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

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

Issue 2785523002: Reduce/remove usage of BrowserThread in content/browser/loader. (Closed)
Patch Set: Fix test redness Created 3 years, 8 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/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " 13 #include "content/browser/compositor/test/no_transport_image_transport_factory.h "
14 #include "content/browser/frame_host/navigation_entry_impl.h" 14 #include "content/browser/frame_host/navigation_entry_impl.h"
15 #include "content/browser/loader/loader_globals.h"
15 #include "content/browser/renderer_host/render_view_host_factory.h" 16 #include "content/browser/renderer_host/render_view_host_factory.h"
16 #include "content/browser/renderer_host/render_widget_host_impl.h" 17 #include "content/browser/renderer_host/render_widget_host_impl.h"
17 #include "content/browser/site_instance_impl.h" 18 #include "content/browser/site_instance_impl.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/browser_side_navigation_policy.h" 21 #include "content/public/common/browser_side_navigation_policy.h"
21 #include "content/public/test/browser_side_navigation_test_utils.h" 22 #include "content/public/test/browser_side_navigation_test_utils.h"
22 #include "content/public/test/mock_render_process_host.h" 23 #include "content/public/test/mock_render_process_host.h"
23 #include "content/public/test/test_browser_context.h" 24 #include "content/public/test/test_browser_context.h"
24 #include "content/test/content_browser_sanity_checker.h" 25 #include "content/test/content_browser_sanity_checker.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // RenderWidgetHostView holds on to a reference to SurfaceManager, so it 152 // RenderWidgetHostView holds on to a reference to SurfaceManager, so it
152 // must be shut down before the ImageTransportFactory. 153 // must be shut down before the ImageTransportFactory.
153 ImageTransportFactory::Terminate(); 154 ImageTransportFactory::Terminate();
154 #else 155 #else
155 display::Screen::SetScreenInstance(nullptr); 156 display::Screen::SetScreenInstance(nullptr);
156 #endif 157 #endif
157 } 158 }
158 159
159 160
160 // RenderViewHostTestHarness -------------------------------------------------- 161 // RenderViewHostTestHarness --------------------------------------------------
161
162 RenderViewHostTestHarness::RenderViewHostTestHarness() 162 RenderViewHostTestHarness::RenderViewHostTestHarness()
163 : thread_bundle_options_(TestBrowserThreadBundle::DEFAULT) {} 163 : thread_bundle_options_(TestBrowserThreadBundle::DEFAULT) {}
164 164
165 RenderViewHostTestHarness::~RenderViewHostTestHarness() { 165 RenderViewHostTestHarness::~RenderViewHostTestHarness() {
166 } 166 }
167 167
168 NavigationController& RenderViewHostTestHarness::controller() { 168 NavigationController& RenderViewHostTestHarness::controller() {
169 return web_contents()->GetController(); 169 return web_contents()->GetController();
170 } 170 }
171 171
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 277
278 sanity_checker_.reset(new ContentBrowserSanityChecker()); 278 sanity_checker_.reset(new ContentBrowserSanityChecker());
279 279
280 DCHECK(!browser_context_); 280 DCHECK(!browser_context_);
281 browser_context_.reset(CreateBrowserContext()); 281 browser_context_.reset(CreateBrowserContext());
282 282
283 SetContents(CreateTestWebContents()); 283 SetContents(CreateTestWebContents());
284 284
285 if (IsBrowserSideNavigationEnabled()) 285 if (IsBrowserSideNavigationEnabled())
286 BrowserSideNavigationSetUp(); 286 BrowserSideNavigationSetUp();
287
288 // TODO(ananta)
289 // Tests which use the RenderViewHostTestHarness can run
290 // content/browser/loader code which assumes UI thread, IO thread task runner
291 // availability. As a workaround we instantiate the
292 // content/browser/loader/LoaderGlobals class which provides access to these
293 // task runners to the relevant code. This hack will go away when the loader
294 // code becomes part of the network service. We don't want to create the
295 // LoaderGlobals class if it already exists.
296 if (!LoaderGlobals::Get()) {
297 loader_globals_.reset(new content::LoaderGlobals(
298 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
299 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
300 }
287 } 301 }
288 302
289 void RenderViewHostTestHarness::TearDown() { 303 void RenderViewHostTestHarness::TearDown() {
290 if (IsBrowserSideNavigationEnabled()) 304 if (IsBrowserSideNavigationEnabled())
291 BrowserSideNavigationTearDown(); 305 BrowserSideNavigationTearDown();
292 306
293 SetContents(NULL); 307 SetContents(NULL);
294 #if defined(USE_AURA) 308 #if defined(USE_AURA)
295 aura_test_helper_->TearDown(); 309 aura_test_helper_->TearDown();
296 ui::TerminateContextFactoryForTests(); 310 ui::TerminateContextFactoryForTests();
(...skipping 28 matching lines...) Expand all
325 339
326 void RenderViewHostTestHarness::SetRenderProcessHostFactory( 340 void RenderViewHostTestHarness::SetRenderProcessHostFactory(
327 RenderProcessHostFactory* factory) { 341 RenderProcessHostFactory* factory) {
328 if (rvh_test_enabler_) 342 if (rvh_test_enabler_)
329 rvh_test_enabler_->rvh_factory_->set_render_process_host_factory(factory); 343 rvh_test_enabler_->rvh_factory_->set_render_process_host_factory(factory);
330 else 344 else
331 factory_ = factory; 345 factory_ = factory;
332 } 346 }
333 347
334 } // namespace content 348 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698