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

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

Issue 5716003: View source after POST command isn't what you expected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added navigation controller test. Created 10 years 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
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.

Powered by Google App Engine
This is Rietveld 408576698