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 74dd068c1dd43b01cfcce3538f835e2c79115855..7d4341686b80b5052a404f2e39b800ae45c787b3 100644 |
--- a/chrome/browser/tab_contents/navigation_controller_unittest.cc |
+++ b/chrome/browser/tab_contents/navigation_controller_unittest.cc |
@@ -1865,6 +1865,69 @@ TEST_F(NavigationControllerTest, HistoryNavigate) { |
EXPECT_TRUE(message == NULL); |
} |
+// Test call to PruneAllButActive for the only entry. |
+TEST_F(NavigationControllerTest, PruneAllButActiveForSingle) { |
+ const GURL url1("http://foo1"); |
+ NavigateAndCommit(url1); |
+ controller().PruneAllButActive(); |
+ |
+ EXPECT_EQ(-1, controller().pending_entry_index()); |
+ EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url1); |
+} |
+ |
+// Test call to PruneAllButActive for last entry. |
+TEST_F(NavigationControllerTest, PruneAllButActiveForLast) { |
+ const GURL url1("http://foo1"); |
+ const GURL url2("http://foo2"); |
+ const GURL url3("http://foo3"); |
+ |
+ NavigateAndCommit(url1); |
+ NavigateAndCommit(url2); |
+ NavigateAndCommit(url3); |
+ controller().GoBack(); |
+ controller().GoBack(); |
+ contents()->CommitPendingNavigation(); |
+ |
+ controller().PruneAllButActive(); |
+ |
+ EXPECT_EQ(-1, controller().pending_entry_index()); |
+ EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url1); |
+} |
+ |
+// Test call to PruneAllButActive for intermediate entry. |
+TEST_F(NavigationControllerTest, PruneAllButActiveForIntermediate) { |
+ const GURL url1("http://foo1"); |
+ const GURL url2("http://foo2"); |
+ const GURL url3("http://foo3"); |
+ |
+ NavigateAndCommit(url1); |
+ NavigateAndCommit(url2); |
+ NavigateAndCommit(url3); |
+ controller().GoBack(); |
+ contents()->CommitPendingNavigation(); |
+ |
+ controller().PruneAllButActive(); |
+ |
+ EXPECT_EQ(-1, controller().pending_entry_index()); |
+ EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url2); |
+} |
+ |
+// Test call to PruneAllButActive for intermediate entry. |
+TEST_F(NavigationControllerTest, PruneAllButActiveForPending) { |
+ const GURL url1("http://foo1"); |
+ const GURL url2("http://foo2"); |
+ const GURL url3("http://foo3"); |
+ |
+ NavigateAndCommit(url1); |
+ NavigateAndCommit(url2); |
+ NavigateAndCommit(url3); |
+ controller().GoBack(); |
+ |
+ controller().PruneAllButActive(); |
+ |
+ EXPECT_EQ(0, controller().pending_entry_index()); |
+} |
+ |
/* TODO(brettw) These test pass on my local machine but fail on the XP buildbot |
(but not Vista) cleaning up the directory after they run. |
This should be fixed. |