summaryrefslogtreecommitdiffstats
path: root/chrome/browser/session_service_unittest.cc
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-17 16:28:49 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-17 16:28:49 +0000
commitc12bf1a1aa1a24d7f516b7e76428518c594d7da5 (patch)
treea8417e738ef3f6017f93972cba7eea0ca8a2f8e3 /chrome/browser/session_service_unittest.cc
parent5753fae33db5da0f5ca75490ea0eff8c91084392 (diff)
downloadchromium_src-c12bf1a1aa1a24d7f516b7e76428518c594d7da5.zip
chromium_src-c12bf1a1aa1a24d7f516b7e76428518c594d7da5.tar.gz
chromium_src-c12bf1a1aa1a24d7f516b7e76428518c594d7da5.tar.bz2
Wires up session restore so that it correctly deals with the
navigation controller removing entries from the front of its list. BUG=1324021 TEST=covered by unit tests, but make sure you don't see problems with session restore. Review URL: http://codereview.chromium.org/2906 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/session_service_unittest.cc')
-rw-r--r--chrome/browser/session_service_unittest.cc60
1 files changed, 59 insertions, 1 deletions
diff --git a/chrome/browser/session_service_unittest.cc b/chrome/browser/session_service_unittest.cc
index 59379a3..4ff7a21b 100644
--- a/chrome/browser/session_service_unittest.cc
+++ b/chrome/browser/session_service_unittest.cc
@@ -196,7 +196,7 @@ TEST_F(SessionServiceTest, Pruning) {
TabNavigation& nav = (i % 2) == 0 ? nav1 : nav2;
UpdateNavigation(window_id, tab_id, nav, i, true);
}
- service()->TabNavigationPathPruned(window_id, tab_id, 3);
+ service()->TabNavigationPathPrunedFromBack(window_id, tab_id, 3);
ScopedVector<SessionWindow> windows;
ReadWindows(&(windows.get()));
@@ -403,3 +403,61 @@ TEST_F(SessionServiceTest, IgnorePopups) {
helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
}
+// Tests pruning from the front.
+TEST_F(SessionServiceTest, PruneFromFront) {
+ const std::string base_url("http://google.com/");
+ SessionID tab_id;
+
+ helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
+
+ // Add 5 navigations, with the 4th selected.
+ for (int i = 0; i < 5; ++i) {
+ TabNavigation nav(0, GURL(base_url + IntToString(i)),
+ L"a", "b", PageTransition::QUALIFIER_MASK);
+ UpdateNavigation(window_id, tab_id, nav, i, (i == 3));
+ }
+
+ // Prune the first two navigations from the front.
+ helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 2);
+
+ // Read back in.
+ ScopedVector<SessionWindow> windows;
+ ReadWindows(&(windows.get()));
+
+ ASSERT_EQ(1, windows->size());
+ ASSERT_EQ(0, windows[0]->selected_tab_index);
+ ASSERT_EQ(window_id.id(), windows[0]->window_id.id());
+ ASSERT_EQ(1, windows[0]->tabs.size());
+
+ // We should be left with three navigations, the 2nd selected.
+ SessionTab* tab = windows[0]->tabs[0];
+ ASSERT_EQ(1, tab->current_navigation_index);
+ EXPECT_EQ(3U, tab->navigations.size());
+ EXPECT_TRUE(GURL(base_url + IntToString(2)) == tab->navigations[0].url);
+ EXPECT_TRUE(GURL(base_url + IntToString(3)) == tab->navigations[1].url);
+ EXPECT_TRUE(GURL(base_url + IntToString(4)) == tab->navigations[2].url);
+}
+
+// Prunes from front so that we have no entries.
+TEST_F(SessionServiceTest, PruneToEmpty) {
+ const std::string base_url("http://google.com/");
+ SessionID tab_id;
+
+ helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
+
+ // Add 5 navigations, with the 4th selected.
+ for (int i = 0; i < 5; ++i) {
+ TabNavigation nav(0, GURL(base_url + IntToString(i)),
+ L"a", "b", PageTransition::QUALIFIER_MASK);
+ UpdateNavigation(window_id, tab_id, nav, i, (i == 3));
+ }
+
+ // Prune the first two navigations from the front.
+ helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 5);
+
+ // Read back in.
+ ScopedVector<SessionWindow> windows;
+ ReadWindows(&(windows.get()));
+
+ ASSERT_EQ(0, windows->size());
+}