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

Side by Side Diff: content/browser/frame_host/navigator_impl_unittest.cc

Issue 1010243002: PlzNavigate: Properly set the pending entry in the NavigatorImpl unit test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simpler Created 5 years, 9 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/browser/frame_host/navigation_controller_impl.h" 8 #include "content/browser/frame_host/navigation_controller_impl.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/frame_host/navigation_request.h" 10 #include "content/browser/frame_host/navigation_request.h"
(...skipping 30 matching lines...) Expand all
41 RenderViewHostImplTestHarness::SetUp(); 41 RenderViewHostImplTestHarness::SetUp();
42 } 42 }
43 43
44 TestNavigationURLLoader* GetLoaderForNavigationRequest( 44 TestNavigationURLLoader* GetLoaderForNavigationRequest(
45 NavigationRequest* request) const { 45 NavigationRequest* request) const {
46 return static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); 46 return static_cast<TestNavigationURLLoader*>(request->loader_for_testing());
47 } 47 }
48 48
49 void RequestNavigation(FrameTreeNode* node, const GURL& url) { 49 void RequestNavigation(FrameTreeNode* node, const GURL& url) {
50 RequestNavigationWithParameters(node, url, Referrer(), 50 RequestNavigationWithParameters(node, url, Referrer(),
51 ui::PAGE_TRANSITION_LINK, 51 ui::PAGE_TRANSITION_LINK);
52 NavigationController::NO_RELOAD);
53 } 52 }
54 53
55 void RequestNavigationWithParameters( 54 void RequestNavigationWithParameters(
56 FrameTreeNode* node, 55 FrameTreeNode* node,
57 const GURL& url, 56 const GURL& url,
58 const Referrer& referrer, 57 const Referrer& referrer,
59 ui::PageTransition transition_type, 58 ui::PageTransition transition_type) {
60 NavigationController::ReloadType reload_type) { 59 NavigationController::LoadURLParams load_params(url);
61 scoped_ptr<NavigationEntryImpl> entry( 60 load_params.frame_tree_node_id = node->frame_tree_node_id();
62 NavigationEntryImpl::FromNavigationEntry( 61 load_params.referrer = referrer;
63 NavigationController::CreateNavigationEntry( 62 load_params.transition_type = transition_type;
64 url, 63
65 referrer, 64 controller().LoadURLWithParams(load_params);
66 transition_type,
67 false,
68 std::string(),
69 controller().GetBrowserContext())));
70 static_cast<NavigatorImpl*>(node->navigator())->RequestNavigation(
71 node, *entry, reload_type, base::TimeTicks::Now());
72 } 65 }
73 66
74 NavigationRequest* GetNavigationRequestForFrameTreeNode( 67 NavigationRequest* GetNavigationRequestForFrameTreeNode(
75 FrameTreeNode* frame_tree_node) { 68 FrameTreeNode* frame_tree_node) {
76 return static_cast<NavigatorImpl*>(frame_tree_node->navigator()) 69 return static_cast<NavigatorImpl*>(frame_tree_node->navigator())
77 ->GetNavigationRequestForNodeForTesting(frame_tree_node); 70 ->GetNavigationRequestForNodeForTesting(frame_tree_node);
78 } 71 }
79 72
80 TestRenderFrameHost* GetSpeculativeRenderFrameHost(FrameTreeNode* node) { 73 TestRenderFrameHost* GetSpeculativeRenderFrameHost(FrameTreeNode* node) {
81 return static_cast<TestRenderFrameHost*>( 74 return static_cast<TestRenderFrameHost*>(
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 758 }
766 759
767 // PlzNavigate: Test that a reload navigation is properly signaled to the 760 // PlzNavigate: Test that a reload navigation is properly signaled to the
768 // RenderFrame when the navigation can commit. A speculative RenderFrameHost 761 // RenderFrame when the navigation can commit. A speculative RenderFrameHost
769 // should not be created at any step. 762 // should not be created at any step.
770 TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) { 763 TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) {
771 const GURL kUrl("http://www.google.com/"); 764 const GURL kUrl("http://www.google.com/");
772 contents()->NavigateAndCommit(kUrl); 765 contents()->NavigateAndCommit(kUrl);
773 766
774 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); 767 FrameTreeNode* node = main_test_rfh()->frame_tree_node();
775 RequestNavigationWithParameters(node, kUrl, Referrer(), 768 controller().Reload(false);
776 ui::PAGE_TRANSITION_LINK,
777 NavigationController::RELOAD);
778 // A NavigationRequest should have been generated. 769 // A NavigationRequest should have been generated.
779 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node); 770 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node);
780 ASSERT_TRUE(main_request != NULL); 771 ASSERT_TRUE(main_request != NULL);
781 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD, 772 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD,
782 main_request->common_params().navigation_type); 773 main_request->common_params().navigation_type);
783 main_test_rfh()->PrepareForCommit(); 774 main_test_rfh()->PrepareForCommit();
784 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); 775 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
785 776
786 main_test_rfh()->SendNavigate(0, kUrl); 777 main_test_rfh()->SendNavigate(0, kUrl);
787 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); 778 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
788 779
789 // Now do a shift+reload. 780 // Now do a shift+reload.
790 RequestNavigationWithParameters(node, kUrl, Referrer(), 781 controller().ReloadIgnoringCache(false);
Avi (use Gerrit) 2015/03/19 14:51:16 Note that ReloadType isn't a part of LoadURLParams
clamy 2015/03/19 16:34:52 Acknowledged.
791 ui::PAGE_TRANSITION_LINK,
792 NavigationController::RELOAD_IGNORING_CACHE);
793 // A NavigationRequest should have been generated. 782 // A NavigationRequest should have been generated.
794 main_request = GetNavigationRequestForFrameTreeNode(node); 783 main_request = GetNavigationRequestForFrameTreeNode(node);
795 ASSERT_TRUE(main_request != NULL); 784 ASSERT_TRUE(main_request != NULL);
796 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, 785 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE,
797 main_request->common_params().navigation_type); 786 main_request->common_params().navigation_type);
798 main_test_rfh()->PrepareForCommit(); 787 main_test_rfh()->PrepareForCommit();
799 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); 788 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
800 } 789 }
801 790
802 // PlzNavigate: Confirm that a speculative RenderFrameHost is used when 791 // PlzNavigate: Confirm that a speculative RenderFrameHost is used when
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 main_rfh->SendRendererInitiatedNavigationRequest(kUrl2, true); 991 main_rfh->SendRendererInitiatedNavigationRequest(kUrl2, true);
1003 navigation_request = GetNavigationRequestForFrameTreeNode(node); 992 navigation_request = GetNavigationRequestForFrameTreeNode(node);
1004 ASSERT_TRUE(navigation_request); 993 ASSERT_TRUE(navigation_request);
1005 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, 994 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED,
1006 navigation_request->state()); 995 navigation_request->state());
1007 EXPECT_FALSE(navigation_request->loader_for_testing()); 996 EXPECT_FALSE(navigation_request->loader_for_testing());
1008 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); 997 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
1009 } 998 }
1010 999
1011 } // namespace content 1000 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698