diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-14 20:20:09 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-14 20:20:09 +0000 |
commit | 5c0e648d6f4ea988be36e74cae045ba5f041e5cb (patch) | |
tree | f0fb62cf06be0ef7afa2b74babb0fe0ee7c1bc02 /chrome/browser/sessions/session_service_unittest.cc | |
parent | 2e7054c0c76fe1c9a12de5925b7ad1a7aff94e45 (diff) | |
download | chromium_src-5c0e648d6f4ea988be36e74cae045ba5f041e5cb.zip chromium_src-5c0e648d6f4ea988be36e74cae045ba5f041e5cb.tar.gz chromium_src-5c0e648d6f4ea988be36e74cae045ba5f041e5cb.tar.bz2 |
Wires up restoring pinned tabs for session and tab restore
services. And turns on pinned tabs by default on linux.
BUG=16634
TEST=Currently this linux only. Try tab pinning and make sure it works.
Review URL: http://codereview.chromium.org/149621
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sessions/session_service_unittest.cc')
-rw-r--r-- | chrome/browser/sessions/session_service_unittest.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/chrome/browser/sessions/session_service_unittest.cc b/chrome/browser/sessions/session_service_unittest.cc index baafd90..19997e7 100644 --- a/chrome/browser/sessions/session_service_unittest.cc +++ b/chrome/browser/sessions/session_service_unittest.cc @@ -71,6 +71,40 @@ class SessionServiceTest : public testing::Test { helper_.ReadWindows(windows); } + // Configures the session service with one window with one tab and a single + // navigation. If |pinned_state| is true or |write_always| is true, the + // pinned state of the tab is updated. The session service is then recreated + // and the pinned state of the read back tab is returned. + bool CreateAndWriteSessionWithOneTab(bool pinned_state, bool write_always) { + SessionID tab_id; + + TabNavigation nav1(0, GURL("http://google.com"), + GURL("http://www.referrer.com"), + ASCIIToUTF16("abc"), "def", + PageTransition::QUALIFIER_MASK); + + helper_.PrepareTabInWindow(window_id, tab_id, 0, true); + UpdateNavigation(window_id, tab_id, nav1, 0, true); + + if (pinned_state || write_always) + helper_.service()->SetPinnedState(window_id, tab_id, pinned_state); + + ScopedVector<SessionWindow> windows; + ReadWindows(&(windows.get())); + + EXPECT_EQ(1U, windows->size()); + if (HasFatalFailure()) + return false; + EXPECT_EQ(1U, windows[0]->tabs.size()); + if (HasFatalFailure()) + return false; + + SessionTab* tab = windows[0]->tabs[0]; + helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); + + return tab->pinned; + } + SessionService* service() { return helper_.service(); } SessionBackend* backend() { return helper_.backend(); } @@ -455,3 +489,18 @@ TEST_F(SessionServiceTest, PruneToEmpty) { ASSERT_EQ(0U, windows->size()); } + +// Don't set the pinned state and make sure the pinned value is false. +TEST_F(SessionServiceTest, PinnedDefaultsToFalse) { + EXPECT_FALSE(CreateAndWriteSessionWithOneTab(false, false)); +} + +// Explicitly set the pinned state to false and make sure we get back false. +TEST_F(SessionServiceTest, PinnedFalseWhenSetToFalse) { + EXPECT_FALSE(CreateAndWriteSessionWithOneTab(false, true)); +} + +// Explicitly set the pinned state to false and make sure we get back true. +TEST_F(SessionServiceTest, PinnedTrue) { + EXPECT_TRUE(CreateAndWriteSessionWithOneTab(true, true)); +} |