OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "chrome/browser/sessions/session_backend.h" | 9 #include "chrome/browser/sessions/session_backend.h" |
10 #include "chrome/browser/sessions/session_service.h" | 10 #include "chrome/browser/sessions/session_service.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); | 103 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); |
104 ASSERT_EQ(1U, windows[0]->tabs.size()); | 104 ASSERT_EQ(1U, windows[0]->tabs.size()); |
105 ASSERT_EQ(Browser::TYPE_NORMAL, windows[0]->type); | 105 ASSERT_EQ(Browser::TYPE_NORMAL, windows[0]->type); |
106 | 106 |
107 SessionTab* tab = windows[0]->tabs[0]; | 107 SessionTab* tab = windows[0]->tabs[0]; |
108 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); | 108 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); |
109 | 109 |
110 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); | 110 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); |
111 } | 111 } |
112 | 112 |
113 // Creates a navigation entry with post data, saves it, and makes sure it does | 113 // Make sure we persist post entries. |
114 // not get restored. | 114 TEST_F(SessionServiceTest, PersistPostData) { |
115 TEST_F(SessionServiceTest, PrunePostData1) { | |
116 SessionID tab_id; | 115 SessionID tab_id; |
117 ASSERT_NE(window_id.id(), tab_id.id()); | 116 ASSERT_NE(window_id.id(), tab_id.id()); |
118 | 117 |
119 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 118 TabNavigation nav1(0, GURL("http://google.com"), GURL(), |
120 ASCIIToUTF16("abc"), "def", | 119 ASCIIToUTF16("abc"), std::string(), |
121 PageTransition::QUALIFIER_MASK); | 120 PageTransition::QUALIFIER_MASK); |
122 nav1.set_type_mask(TabNavigation::HAS_POST_DATA); | 121 nav1.set_type_mask(TabNavigation::HAS_POST_DATA); |
123 | 122 |
124 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 123 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
125 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 124 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
126 | 125 |
127 ScopedVector<SessionWindow> windows; | 126 ScopedVector<SessionWindow> windows; |
128 ReadWindows(&(windows.get())); | 127 ReadWindows(&(windows.get())); |
129 | 128 |
130 ASSERT_EQ(0U, windows->size()); | 129 helper_.AssertSingleWindowWithSingleTab(windows.get(), 1); |
131 } | |
132 | |
133 // Creates two navigation entries, one with post data one without. Restores | |
134 // and verifies we get back only the entry with no post data. | |
135 TEST_F(SessionServiceTest, PrunePostData2) { | |
136 SessionID tab_id; | |
137 ASSERT_NE(window_id.id(), tab_id.id()); | |
138 | |
139 TabNavigation nav1(0, GURL("http://google.com"), | |
140 GURL("http://www.referrer.com"), | |
141 ASCIIToUTF16("abc"), "def", | |
142 PageTransition::QUALIFIER_MASK); | |
143 nav1.set_type_mask(TabNavigation::HAS_POST_DATA); | |
144 TabNavigation nav2(0, GURL("http://google2.com"), GURL(), | |
145 ASCIIToUTF16("abc"), "def", | |
146 PageTransition::QUALIFIER_MASK); | |
147 | |
148 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | |
149 UpdateNavigation(window_id, tab_id, nav1, 0, true); | |
150 UpdateNavigation(window_id, tab_id, nav2, 1, false); | |
151 | |
152 ScopedVector<SessionWindow> windows; | |
153 ReadWindows(&(windows.get())); | |
154 | |
155 ASSERT_EQ(1U, windows->size()); | |
156 ASSERT_EQ(0, windows[0]->selected_tab_index); | |
157 | |
158 SessionTab* tab = windows[0]->tabs[0]; | |
159 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); | |
160 | |
161 helper_.AssertNavigationEquals(nav2, tab->navigations[0]); | |
162 } | 130 } |
163 | 131 |
164 TEST_F(SessionServiceTest, ClosingTabStaysClosed) { | 132 TEST_F(SessionServiceTest, ClosingTabStaysClosed) { |
165 SessionID tab_id; | 133 SessionID tab_id; |
166 SessionID tab2_id; | 134 SessionID tab2_id; |
167 ASSERT_NE(tab_id.id(), tab2_id.id()); | 135 ASSERT_NE(tab_id.id(), tab2_id.id()); |
168 | 136 |
169 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 137 TabNavigation nav1(0, GURL("http://google.com"), GURL(), |
170 ASCIIToUTF16("abc"), "def", | 138 ASCIIToUTF16("abc"), "def", |
171 PageTransition::QUALIFIER_MASK); | 139 PageTransition::QUALIFIER_MASK); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 444 |
477 // Prune the first two navigations from the front. | 445 // Prune the first two navigations from the front. |
478 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 5); | 446 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 5); |
479 | 447 |
480 // Read back in. | 448 // Read back in. |
481 ScopedVector<SessionWindow> windows; | 449 ScopedVector<SessionWindow> windows; |
482 ReadWindows(&(windows.get())); | 450 ReadWindows(&(windows.get())); |
483 | 451 |
484 ASSERT_EQ(0U, windows->size()); | 452 ASSERT_EQ(0U, windows->size()); |
485 } | 453 } |
OLD | NEW |