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

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

Issue 636673002: Remove navigation from TestRenderViewHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a TODO Created 6 years, 2 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
« no previous file with comments | « content/public/test/test_renderer_host.h ('k') | content/test/test_render_frame_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "content/browser/frame_host/navigation_entry_impl.h" 8 #include "content/browser/frame_host/navigation_entry_impl.h"
9 #include "content/browser/renderer_host/render_view_host_factory.h" 9 #include "content/browser/renderer_host/render_view_host_factory.h"
10 #include "content/browser/renderer_host/render_widget_host_impl.h" 10 #include "content/browser/renderer_host/render_widget_host_impl.h"
(...skipping 20 matching lines...) Expand all
31 31
32 namespace content { 32 namespace content {
33 33
34 // RenderFrameHostTester ------------------------------------------------------ 34 // RenderFrameHostTester ------------------------------------------------------
35 35
36 // static 36 // static
37 RenderFrameHostTester* RenderFrameHostTester::For(RenderFrameHost* host) { 37 RenderFrameHostTester* RenderFrameHostTester::For(RenderFrameHost* host) {
38 return static_cast<TestRenderFrameHost*>(host); 38 return static_cast<TestRenderFrameHost*>(host);
39 } 39 }
40 40
41 // static
42 RenderFrameHost* RenderFrameHostTester::GetPendingForController(
43 NavigationController* controller) {
44 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
45 controller->GetWebContents());
46 return web_contents->GetRenderManagerForTesting()->pending_frame_host();
47 }
48
41 // RenderViewHostTester ------------------------------------------------------- 49 // RenderViewHostTester -------------------------------------------------------
42 50
43 // static 51 // static
44 RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) { 52 RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) {
45 return static_cast<TestRenderViewHost*>(host); 53 return static_cast<TestRenderViewHost*>(host);
46 } 54 }
47 55
48 // static 56 // static
49 RenderViewHost* RenderViewHostTester::GetPendingForController(
50 NavigationController* controller) {
51 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
52 controller->GetWebContents());
53 return web_contents->GetRenderManagerForTesting()->pending_render_view_host();
54 }
55
56 // static
57 bool RenderViewHostTester::IsRenderViewHostSwappedOut(RenderViewHost* rvh) { 57 bool RenderViewHostTester::IsRenderViewHostSwappedOut(RenderViewHost* rvh) {
58 return static_cast<RenderFrameHostImpl*>(rvh->GetMainFrame())->rfh_state() == 58 return static_cast<RenderFrameHostImpl*>(rvh->GetMainFrame())->rfh_state() ==
59 RenderFrameHostImpl::STATE_SWAPPED_OUT; 59 RenderFrameHostImpl::STATE_SWAPPED_OUT;
60 } 60 }
61 61
62 // static 62 // static
63 bool RenderViewHostTester::TestOnMessageReceived(RenderViewHost* rvh, 63 bool RenderViewHostTester::TestOnMessageReceived(RenderViewHost* rvh,
64 const IPC::Message& msg) { 64 const IPC::Message& msg) {
65 return static_cast<RenderViewHostImpl*>(rvh)->OnMessageReceived(msg); 65 return static_cast<RenderViewHostImpl*>(rvh)->OnMessageReceived(msg);
66 } 66 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 154
155 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { 155 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) {
156 static_cast<TestWebContents*>(web_contents())->NavigateAndCommit(url); 156 static_cast<TestWebContents*>(web_contents())->NavigateAndCommit(url);
157 } 157 }
158 158
159 void RenderViewHostTestHarness::Reload() { 159 void RenderViewHostTestHarness::Reload() {
160 NavigationEntry* entry = controller().GetLastCommittedEntry(); 160 NavigationEntry* entry = controller().GetLastCommittedEntry();
161 DCHECK(entry); 161 DCHECK(entry);
162 controller().Reload(false); 162 controller().Reload(false);
163 static_cast<TestRenderViewHost*>( 163 RenderFrameHostTester::For(main_rfh())->SendNavigateWithTransition(
164 rvh())->SendNavigateWithTransition( 164 entry->GetPageID(), entry->GetURL(), ui::PAGE_TRANSITION_RELOAD);
165 entry->GetPageID(), entry->GetURL(), ui::PAGE_TRANSITION_RELOAD);
166 } 165 }
167 166
168 void RenderViewHostTestHarness::FailedReload() { 167 void RenderViewHostTestHarness::FailedReload() {
169 NavigationEntry* entry = controller().GetLastCommittedEntry(); 168 NavigationEntry* entry = controller().GetLastCommittedEntry();
170 DCHECK(entry); 169 DCHECK(entry);
171 controller().Reload(false); 170 controller().Reload(false);
172 static_cast<TestRenderViewHost*>( 171 RenderFrameHostTester::For(main_rfh())->SendFailedNavigate(entry->GetPageID(),
173 rvh())->SendFailedNavigate(entry->GetPageID(), entry->GetURL()); 172 entry->GetURL());
174 } 173 }
175 174
176 void RenderViewHostTestHarness::SetUp() { 175 void RenderViewHostTestHarness::SetUp() {
177 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_)); 176 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_));
178 177
179 #if defined(OS_WIN) 178 #if defined(OS_WIN)
180 ole_initializer_.reset(new ui::ScopedOleInitializer()); 179 ole_initializer_.reset(new ui::ScopedOleInitializer());
181 #endif 180 #endif
182 #if defined(USE_AURA) 181 #if defined(USE_AURA)
183 // The ContextFactory must exist before any Compositors are created. 182 // The ContextFactory must exist before any Compositors are created.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { 227 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() {
229 return new TestBrowserContext(); 228 return new TestBrowserContext();
230 } 229 }
231 230
232 void RenderViewHostTestHarness::SetRenderProcessHostFactory( 231 void RenderViewHostTestHarness::SetRenderProcessHostFactory(
233 RenderProcessHostFactory* factory) { 232 RenderProcessHostFactory* factory) {
234 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); 233 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory);
235 } 234 }
236 235
237 } // namespace content 236 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_renderer_host.h ('k') | content/test/test_render_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698