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

Side by Side Diff: content/test/test_render_frame_host.cc

Issue 761013003: PlzNavigate: add support in several navigation controller unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Nasko's comments Created 6 years 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/test/test_render_frame_host.h ('k') | content/test/test_web_contents.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/test_render_frame_host.h" 5 #include "content/test/test_render_frame_host.h"
6 6
7 #include "base/command_line.h"
7 #include "content/browser/frame_host/frame_tree.h" 8 #include "content/browser/frame_host/frame_tree.h"
9 #include "content/browser/frame_host/navigation_request.h"
10 #include "content/browser/frame_host/navigator.h"
11 #include "content/browser/frame_host/navigator_impl.h"
8 #include "content/browser/frame_host/render_frame_host_delegate.h" 12 #include "content/browser/frame_host/render_frame_host_delegate.h"
9 #include "content/common/frame_messages.h" 13 #include "content/public/browser/stream_handle.h"
14 #include "content/public/common/content_switches.h"
15 #include "content/test/browser_side_navigation_test_utils.h"
16 #include "content/test/test_navigation_url_loader.h"
10 #include "content/test/test_render_view_host.h" 17 #include "content/test/test_render_view_host.h"
11 #include "net/base/load_flags.h" 18 #include "net/base/load_flags.h"
12 #include "third_party/WebKit/public/web/WebPageVisibilityState.h" 19 #include "third_party/WebKit/public/web/WebPageVisibilityState.h"
13 #include "ui/base/page_transition_types.h" 20 #include "ui/base/page_transition_types.h"
14 21
15 namespace content { 22 namespace content {
16 23
17 TestRenderFrameHostCreationObserver::TestRenderFrameHostCreationObserver( 24 TestRenderFrameHostCreationObserver::TestRenderFrameHostCreationObserver(
18 WebContents* web_contents) 25 WebContents* web_contents)
19 : WebContentsObserver(web_contents), last_created_frame_(NULL) { 26 : WebContentsObserver(web_contents), last_created_frame_(NULL) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 common_params.url = url; 190 common_params.url = url;
184 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); 191 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault);
185 common_params.transition = ui::PAGE_TRANSITION_LINK; 192 common_params.transition = ui::PAGE_TRANSITION_LINK;
186 OnBeginNavigation(begin_params, common_params); 193 OnBeginNavigation(begin_params, common_params);
187 } 194 }
188 195
189 void TestRenderFrameHost::DidDisownOpener() { 196 void TestRenderFrameHost::DidDisownOpener() {
190 OnDidDisownOpener(); 197 OnDidDisownOpener();
191 } 198 }
192 199
200 void TestRenderFrameHost::PrepareForCommit(const GURL& url) {
201 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
202 switches::kEnableBrowserSideNavigation)) {
203 SendBeforeUnloadACK(true);
204 return;
205 }
206
207 // PlzNavigate
208 // Simulate the network stack commit without any redirects.
209 NavigationRequest* request =
210 static_cast<NavigatorImpl*>(frame_tree_node_->navigator())
211 ->GetNavigationRequestForNodeForTesting(frame_tree_node_);
212
213 // We are simulating a renderer-initiated navigation.
214 if (!request) {
215 SendBeginNavigationWithURL(url);
216 request = static_cast<NavigatorImpl*>(frame_tree_node_->navigator())
217 ->GetNavigationRequestForNodeForTesting(frame_tree_node_);
218 }
219 ASSERT_TRUE(request);
220
221 // We may not have simulated the renderer response to the navigation request.
222 // Do that now.
223 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE)
224 SendBeginNavigationWithURL(url);
225
226 // We have already simulated the IO thread commit. Only the
227 // DidCommitProvisionalLoad from the renderer is missing.
228 if (request->state() == NavigationRequest::RESPONSE_STARTED)
229 return;
230
231 ASSERT_TRUE(request->state() == NavigationRequest::STARTED);
232 TestNavigationURLLoader* url_loader =
233 static_cast<TestNavigationURLLoader*>(request->loader_for_testing());
234 ASSERT_TRUE(url_loader);
235 scoped_refptr<ResourceResponse> response(new ResourceResponse);
236 url_loader->CallOnResponseStarted(response, MakeEmptyStream());
237 }
238
193 } // namespace content 239 } // namespace content
OLDNEW
« no previous file with comments | « content/test/test_render_frame_host.h ('k') | content/test/test_web_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698