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

Unified Diff: chrome/browser/tab_contents/navigation_controller_unittest.cc

Issue 220002: Initialize user_gesture_observed_ in NavigationController constructor. (Closed)
Patch Set: Created 11 years, 3 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 | « chrome/browser/tab_contents/navigation_controller.cc ('k') | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/navigation_controller_unittest.cc
diff --git a/chrome/browser/tab_contents/navigation_controller_unittest.cc b/chrome/browser/tab_contents/navigation_controller_unittest.cc
index 3f3e20355d20d369ccba49d16e7ced7f437577cc..24e2d7b75995d33352b6546413ad174f418faac9 100644
--- a/chrome/browser/tab_contents/navigation_controller_unittest.cc
+++ b/chrome/browser/tab_contents/navigation_controller_unittest.cc
@@ -767,6 +767,50 @@ TEST_F(NavigationControllerTest, Redirect) {
EXPECT_FALSE(controller().CanGoForward());
}
+// A redirect right off the bat should be a NEW_PAGE.
+TEST_F(NavigationControllerTest, ImmediateRedirect) {
+ TestNotificationTracker notifications;
+ RegisterForAllNavNotifications(&notifications, &controller());
+
+ const GURL url1("http://foo1");
+ const GURL url2("http://foo2"); // Redirection target
+
+ // First request
+ controller().LoadURL(url1, GURL(), PageTransition::TYPED);
+
+ EXPECT_TRUE(controller().pending_entry());
+ EXPECT_EQ(controller().pending_entry_index(), -1);
+ EXPECT_EQ(url1, controller().GetActiveEntry()->url());
+
+ ViewHostMsg_FrameNavigate_Params params = {0};
+ params.page_id = 0;
+ params.url = url2;
+ params.transition = PageTransition::SERVER_REDIRECT;
+ params.redirects.push_back(GURL("http://foo1"));
+ params.redirects.push_back(GURL("http://foo2"));
+ params.should_update_history = false;
+ params.gesture = NavigationGestureAuto;
+ params.is_post = false;
+
+ NavigationController::LoadCommittedDetails details;
+
+ EXPECT_EQ(0U, notifications.size());
+ EXPECT_TRUE(controller().RendererDidNavigate(params, &details));
+ EXPECT_TRUE(notifications.Check1AndReset(
+ NotificationType::NAV_ENTRY_COMMITTED));
+
+ EXPECT_TRUE(details.type == NavigationType::NEW_PAGE);
+ EXPECT_EQ(controller().entry_count(), 1);
+ EXPECT_EQ(controller().last_committed_entry_index(), 0);
+ EXPECT_TRUE(controller().GetLastCommittedEntry());
+ EXPECT_EQ(controller().pending_entry_index(), -1);
+ EXPECT_FALSE(controller().pending_entry());
+ EXPECT_EQ(url2, controller().GetActiveEntry()->url());
+
+ EXPECT_FALSE(controller().CanGoBack());
+ EXPECT_FALSE(controller().CanGoForward());
+}
+
// Tests navigation via link click within a subframe. A new navigation entry
// should be created.
TEST_F(NavigationControllerTest, NewSubframe) {
« no previous file with comments | « chrome/browser/tab_contents/navigation_controller.cc ('k') | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698