Chromium Code Reviews| 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..1a327227c933006123f3867c0394e404f8bd216c 100644 |
| --- a/chrome/browser/tab_contents/navigation_controller_unittest.cc |
| +++ b/chrome/browser/tab_contents/navigation_controller_unittest.cc |
| @@ -1865,6 +1865,92 @@ 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()); |
| +} |
| + |
| +// Test call to PruneAllButActive for transient entry. |
| +TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) { |
| + const GURL url0("http://foo0"); |
| + const GURL url1("http://foo1"); |
| + const GURL transient_url("http://transient"); |
| + |
| + controller().LoadURL(url0, GURL(), PageTransition::TYPED); |
| + rvh()->SendNavigate(0, url0); |
| + controller().LoadURL(url1, GURL(), PageTransition::TYPED); |
| + rvh()->SendNavigate(1, url1); |
| + |
| + // Adding a transient with no pending entry. |
| + NavigationEntry* transient_entry = new NavigationEntry; |
| + transient_entry->set_url(transient_url); |
| + controller().AddTransientEntry(transient_entry); |
| + |
| + controller().PruneAllButActive(); |
| + |
| + EXPECT_EQ(-1, controller().pending_entry_index()); |
| + EXPECT_EQ(-1, controller().pending_entry_index()); |
| + EXPECT_EQ(controller().GetTransientEntry()->url(), transient_url); |
| +} |
| + |
| /* TODO(brettw) These test pass on my local machine but fail on the XP buildbot |
|
Paweł Hajdan Jr.
2010/12/15 08:26:22
Could you DISABLE the tests below instead of havin
pfeldman1
2010/12/15 11:29:59
I don't see how it relates to the change I am appl
|
| (but not Vista) cleaning up the directory after they run. |
| This should be fixed. |