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

Side by Side Diff: content/browser/web_contents/navigation_controller_impl_unittest.cc

Issue 10704048: [RDS] Reloads a page using the original request URL (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding unit test & removing public function Created 8 years, 5 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
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 // Now the reload is committed. 621 // Now the reload is committed.
622 EXPECT_EQ(controller.GetEntryCount(), 2); 622 EXPECT_EQ(controller.GetEntryCount(), 2);
623 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); 623 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1);
624 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); 624 EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
625 EXPECT_TRUE(controller.GetLastCommittedEntry()); 625 EXPECT_TRUE(controller.GetLastCommittedEntry());
626 EXPECT_FALSE(controller.GetPendingEntry()); 626 EXPECT_FALSE(controller.GetPendingEntry());
627 EXPECT_TRUE(controller.CanGoBack()); 627 EXPECT_TRUE(controller.CanGoBack());
628 EXPECT_FALSE(controller.CanGoForward()); 628 EXPECT_FALSE(controller.CanGoForward());
629 } 629 }
630 630
631 TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
632 NavigationControllerImpl& controller = controller_impl();
633 TestNotificationTracker notifications;
634 RegisterForAllNavNotifications(&notifications, &controller);
635
636 const GURL original_url("http://foo1");
637 const GURL final_url("http://foo2");
638
639 // Load up the original URL, but get redirected. The NavigationEntry should
640 // save both the original URL and the final redirected URL.
Charlie Reis 2012/07/03 17:22:26 Can you check this using GetURL() and GetOriginalR
gone 2012/07/03 18:24:39 Done.
641 controller.LoadURL(original_url, content::Referrer(),
642 content::PAGE_TRANSITION_TYPED, std::string());
643 EXPECT_EQ(0U, notifications.size());
644 test_rvh()->SendNavigateWithOriginalRequestURL(0, final_url, original_url);
645 EXPECT_TRUE(notifications.Check1AndReset(
646 content::NOTIFICATION_NAV_ENTRY_COMMITTED));
647
648 // Reload using the original URL.
649 controller.GetActiveEntry()->SetTitle(ASCIIToUTF16("Title"));
650 controller.ReloadOriginalRequestURL(false);
651 EXPECT_EQ(0U, notifications.size());
652
653 // The reload is pending. The request should point to the original URL.
654 EXPECT_EQ(original_url, test_rvh()->last_params()->url);
655 EXPECT_EQ(controller.GetEntryCount(), 1);
656 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
657 EXPECT_EQ(controller.GetPendingEntryIndex(), 0);
658 EXPECT_TRUE(controller.GetLastCommittedEntry());
659 EXPECT_TRUE(controller.GetPendingEntry());
Charlie Reis 2012/07/03 17:22:26 Why not check that the pending entry's URL is the
gone 2012/07/03 18:24:39 We need to know where the NavigationController is
660 EXPECT_FALSE(controller.CanGoBack());
661 EXPECT_FALSE(controller.CanGoForward());
662
663 // Make sure the title has been cleared (will be redrawn just after reload).
664 // Avoids a stale cached title when the new page being reloaded has no title.
665 // See http://crbug.com/96041.
666 EXPECT_TRUE(controller.GetActiveEntry()->GetTitle().empty());
667
668 // Send that the navigation has proceeded; say it got redirected again.
669 test_rvh()->SendNavigate(0, final_url);
670 EXPECT_TRUE(notifications.Check1AndReset(
671 content::NOTIFICATION_NAV_ENTRY_COMMITTED));
672
673 // Now the reload is committed.
674 EXPECT_EQ(controller.GetEntryCount(), 1);
675 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
676 EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
677 EXPECT_TRUE(controller.GetLastCommittedEntry());
678 EXPECT_FALSE(controller.GetPendingEntry());
679 EXPECT_FALSE(controller.CanGoBack());
680 EXPECT_FALSE(controller.CanGoForward());
681 }
682
631 // Tests what happens when we navigate back successfully 683 // Tests what happens when we navigate back successfully
632 TEST_F(NavigationControllerTest, Back) { 684 TEST_F(NavigationControllerTest, Back) {
633 NavigationControllerImpl& controller = controller_impl(); 685 NavigationControllerImpl& controller = controller_impl();
634 TestNotificationTracker notifications; 686 TestNotificationTracker notifications;
635 RegisterForAllNavNotifications(&notifications, &controller); 687 RegisterForAllNavNotifications(&notifications, &controller);
636 688
637 const GURL url1("http://foo1"); 689 const GURL url1("http://foo1");
638 test_rvh()->SendNavigate(0, url1); 690 test_rvh()->SendNavigate(0, url1);
639 EXPECT_TRUE(notifications.Check1AndReset( 691 EXPECT_TRUE(notifications.Check1AndReset(
640 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); 692 content::NOTIFICATION_NAV_ENTRY_COMMITTED));
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 TabNavigation nav(0, url0, GURL(), string16(), 2671 TabNavigation nav(0, url0, GURL(), string16(),
2620 webkit_glue::CreateHistoryStateForURL(url0), 2672 webkit_glue::CreateHistoryStateForURL(url0),
2621 content::PAGE_TRANSITION_LINK); 2673 content::PAGE_TRANSITION_LINK);
2622 session_helper_.AssertNavigationEquals(nav, 2674 session_helper_.AssertNavigationEquals(nav,
2623 windows_[0]->tabs[0]->navigations[0]); 2675 windows_[0]->tabs[0]->navigations[0]);
2624 nav.set_url(url2); 2676 nav.set_url(url2);
2625 session_helper_.AssertNavigationEquals(nav, 2677 session_helper_.AssertNavigationEquals(nav,
2626 windows_[0]->tabs[0]->navigations[1]); 2678 windows_[0]->tabs[0]->navigations[1]);
2627 } 2679 }
2628 */ 2680 */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698