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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigator_impl_unittest.cc
diff --git a/content/browser/frame_host/navigator_impl_unittest.cc b/content/browser/frame_host/navigator_impl_unittest.cc
index d5b9da663184bb623d161a1f03a422a56ba09fd9..d5828875aff2c5d2604ced62ec3a1bbac79b6653 100644
--- a/content/browser/frame_host/navigator_impl_unittest.cc
+++ b/content/browser/frame_host/navigator_impl_unittest.cc
@@ -47,26 +47,42 @@ class NavigatorTestWithBrowserSideNavigation
}
void RequestNavigation(FrameTreeNode* node, const GURL& url) {
- RequestNavigationWithParameters(node, url, Referrer(),
- ui::PAGE_TRANSITION_LINK,
+ NavigationEntryImpl* entry =
+ NavigationEntryImpl::FromNavigationEntry(
+ NavigationController::CreateNavigationEntry(
+ url,
+ Referrer(),
+ ui::PAGE_TRANSITION_LINK,
+ false,
+ std::string(),
+ controller().GetBrowserContext()));
+ NavigationControllerImpl& navigation_controller_impl =
+ static_cast<NavigationControllerImpl&>(controller());
+ navigation_controller_impl.SetPendingEntry(entry);
+
+ RequestNavigationWithParameters(entry, node, url,
NavigationController::NO_RELOAD);
}
+ void RequestReloadNavigation(
+ FrameTreeNode* node,
+ const GURL& url,
+ NavigationController::ReloadType reload_type) {
+ NavigationControllerImpl& navigation_controller_impl =
+ static_cast<NavigationControllerImpl&>(controller());
+ navigation_controller_impl.SetPendingEntryAndIndexForTesting(
+ navigation_controller_impl.GetLastCommittedEntryIndex());
+ NavigationEntryImpl* entry =
+ navigation_controller_impl.GetPendingEntry();
+
+ RequestNavigationWithParameters(entry, node, url, reload_type);
+ }
+
void RequestNavigationWithParameters(
+ NavigationEntryImpl* entry,
FrameTreeNode* node,
const GURL& url,
- const Referrer& referrer,
- ui::PageTransition transition_type,
NavigationController::ReloadType reload_type) {
- scoped_ptr<NavigationEntryImpl> entry(
- NavigationEntryImpl::FromNavigationEntry(
- NavigationController::CreateNavigationEntry(
- url,
- referrer,
- transition_type,
- false,
- std::string(),
- controller().GetBrowserContext())));
static_cast<NavigatorImpl*>(node->navigator())->RequestNavigation(
Charlie Reis 2015/03/17 22:20:22 The goal of this change is to make sure that |entr
Avi (use Gerrit) 2015/03/17 23:28:16 Done.
node, *entry, reload_type, base::TimeTicks::Now());
}
@@ -184,7 +200,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, request->state());
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl2);
+ main_test_rfh()->SendNavigate(1, kUrl2);
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state());
EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl2),
main_test_rfh()->GetSiteInstance()->GetSiteURL());
@@ -229,7 +245,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, request->state());
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl2);
+ main_test_rfh()->SendNavigate(1, kUrl2);
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state());
EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL());
EXPECT_FALSE(GetNavigationRequestForFrameTreeNode(node));
@@ -613,7 +629,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh()));
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl2);
+ main_test_rfh()->SendNavigate(1, kUrl2);
// Confirm that the commit corresponds to the new request.
ASSERT_TRUE(main_test_rfh());
@@ -661,7 +677,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh()));
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl1);
+ main_test_rfh()->SendNavigate(1, kUrl1);
EXPECT_EQ(kUrl1, contents()->GetLastCommittedURL());
}
@@ -757,7 +773,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh()));
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl2);
+ main_test_rfh()->SendNavigate(1, kUrl2);
EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL());
// The SiteInstance did not change.
@@ -772,9 +788,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) {
contents()->NavigateAndCommit(kUrl);
FrameTreeNode* node = main_test_rfh()->frame_tree_node();
- RequestNavigationWithParameters(node, kUrl, Referrer(),
- ui::PAGE_TRANSITION_LINK,
- NavigationController::RELOAD);
+ RequestReloadNavigation(node, kUrl, NavigationController::RELOAD);
// A NavigationRequest should have been generated.
NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(main_request != NULL);
@@ -787,9 +801,8 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) {
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
// Now do a shift+reload.
- RequestNavigationWithParameters(node, kUrl, Referrer(),
- ui::PAGE_TRANSITION_LINK,
- NavigationController::RELOAD_IGNORING_CACHE);
+ RequestReloadNavigation(
+ node, kUrl, NavigationController::RELOAD_IGNORING_CACHE);
// A NavigationRequest should have been generated.
main_request = GetNavigationRequestForFrameTreeNode(node);
ASSERT_TRUE(main_request != NULL);
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698