summaryrefslogtreecommitdiffstats
path: root/chrome/browser/navigation_controller_unittest.cc
diff options
context:
space:
mode:
authorcreis@google.com <creis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-04 19:36:36 +0000
committercreis@google.com <creis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-04 19:36:36 +0000
commitb33452302702b3915e1110dae72fc8a746b3358c (patch)
tree0cbb07b8aa30ee443def321cedcb395ef8db77c1 /chrome/browser/navigation_controller_unittest.cc
parent113736ca60dff0d00fe7ae03eeb095ac50af48c5 (diff)
downloadchromium_src-b33452302702b3915e1110dae72fc8a746b3358c.zip
chromium_src-b33452302702b3915e1110dae72fc8a746b3358c.tar.gz
chromium_src-b33452302702b3915e1110dae72fc8a746b3358c.tar.bz2
Ensures that we clean up TabContents with other types after a navigation commits, even if their NavigationEntries aren't adjacent to the current entry.
Also makes NavigationController::Destroy compatible with NavigationControllerTest, which adds more tab types than TAB_CONTENTS_NUM_TYPES. Also re-enables the SwitchTypes tests and adds another to prevent regression of this bug. BUG=1296773 TEST=NavigationControllerTest.SwitchTypesCleanup git-svn-id: svn://svn.chromium.org/chrome/trunk/src@332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/navigation_controller_unittest.cc')
-rw-r--r--chrome/browser/navigation_controller_unittest.cc47
1 files changed, 45 insertions, 2 deletions
diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc
index 6b8de0d..5986b31 100644
--- a/chrome/browser/navigation_controller_unittest.cc
+++ b/chrome/browser/navigation_controller_unittest.cc
@@ -626,7 +626,7 @@ TEST_F(NavigationControllerTest, LinkClick) {
EXPECT_FALSE(contents->controller()->CanGoForward());
}
-TEST_F(NavigationControllerTest, DISABLED_SwitchTypes) {
+TEST_F(NavigationControllerTest, SwitchTypes) {
const GURL url1("test1:foo");
const GURL url2("test2:foo");
@@ -664,11 +664,15 @@ TEST_F(NavigationControllerTest, DISABLED_SwitchTypes) {
EXPECT_FALSE(contents->controller()->GetPendingEntry());
EXPECT_FALSE(contents->controller()->CanGoBack());
EXPECT_TRUE(contents->controller()->CanGoForward());
+
+ // There may be TabContentsCollector tasks pending, so flush them from queue.
+ MessageLoop::current()->Quit();
+ MessageLoop::current()->Run();
}
// Tests what happens when we begin to navigate to a new contents type, but
// then that navigation gets discarded instead.
-TEST_F(NavigationControllerTest, DISABLED_SwitchTypes_Discard) {
+TEST_F(NavigationControllerTest, SwitchTypes_Discard) {
const GURL url1("test1:foo");
const GURL url2("test2:foo");
@@ -694,6 +698,45 @@ TEST_F(NavigationControllerTest, DISABLED_SwitchTypes_Discard) {
EXPECT_FALSE(contents->controller()->GetPendingEntry());
EXPECT_FALSE(contents->controller()->CanGoBack());
EXPECT_FALSE(contents->controller()->CanGoForward());
+
+ // There may be TabContentsCollector tasks pending, so flush them from queue.
+ MessageLoop::current()->Quit();
+ MessageLoop::current()->Run();
+}
+
+// Tests that TabContentsTypes that are not in use are deleted (via a
+// TabContentsCollector task). Prevents regression of bug 1296773.
+TEST_F(NavigationControllerTest, SwitchTypesCleanup) {
+ const GURL url1("test1:foo");
+ const GURL url2("test2:foo");
+ const GURL url3("test2:bar");
+
+ contents->controller()->LoadURL(url1, PageTransition::TYPED);
+ contents->CompleteNavigation(0);
+
+ contents->controller()->LoadURL(url2, PageTransition::TYPED);
+ contents->CompleteNavigation(0);
+
+ contents->controller()->LoadURL(url3, PageTransition::TYPED);
+ contents->CompleteNavigation(1);
+
+ // Navigate back to the start
+ contents->controller()->GoToIndex(0);
+ contents->CompleteNavigation(0);
+
+ // Now jump to the end
+ contents->controller()->GoToIndex(2);
+ contents->CompleteNavigation(1);
+
+ // There may be TabContentsCollector tasks pending, so flush them from queue.
+ MessageLoop::current()->Quit();
+ MessageLoop::current()->Run();
+
+ // Now that the tasks have been flushed, the first tab type should be gone.
+ ASSERT_TRUE(
+ contents->controller()->GetTabContents(kTestContentsType1) == NULL);
+ ASSERT_EQ(contents,
+ contents->controller()->GetTabContents(kTestContentsType2));
}
// Tests that we limit the number of navigation entries created correctly.