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

Unified Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 684173004: Add test for RemoveEntryAtIndex in the pending case. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | content/public/browser/navigation_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigation_controller_impl_unittest.cc
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index 621ab2406df8034bc9100e678b8659bbf37b7884..aafd1ded5b60ebc0a14c0cddd8526408ede0d343 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -2611,6 +2611,45 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
}
+TEST_F(NavigationControllerTest, RemoveEntryWithPending) {
+ NavigationControllerImpl& controller = controller_impl();
+ const GURL url1("http://foo/1");
+ const GURL url2("http://foo/2");
+ const GURL url3("http://foo/3");
+ const GURL default_url("http://foo/default");
+
+ controller.LoadURL(
+ url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ main_test_rfh()->SendNavigate(0, url1);
+ controller.LoadURL(
+ url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ main_test_rfh()->SendNavigate(1, url2);
+ controller.LoadURL(
+ url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ main_test_rfh()->SendNavigate(2, url3);
+
+ // Go back, but don't commit yet. Check that we can't delete the current
+ // and pending entries.
+ controller.GoBack();
+ EXPECT_FALSE(controller.RemoveEntryAtIndex(2));
+ EXPECT_FALSE(controller.RemoveEntryAtIndex(1));
+
+ // Remove the first entry, while there is a pending entry. This is expected
+ // to discard the pending entry.
+ EXPECT_TRUE(controller.RemoveEntryAtIndex(0));
+ EXPECT_FALSE(controller.GetPendingEntry());
+ EXPECT_EQ(-1, controller.GetPendingEntryIndex());
+
+ // We should update the last committed entry index.
+ EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
+
+ // Now commit and ensure we land on the right entry.
+ main_test_rfh()->SendNavigate(1, url2);
+ EXPECT_EQ(2, controller.GetEntryCount());
+ EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
+ EXPECT_FALSE(controller.GetPendingEntry());
+}
+
// Tests the transient entry, making sure it goes away with all navigations.
TEST_F(NavigationControllerTest, TransientEntry) {
NavigationControllerImpl& controller = controller_impl();
« no previous file with comments | « no previous file | content/public/browser/navigation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698