| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 helper_.ReadWindows(windows); | 91 helper_.ReadWindows(windows); |
| 92 } | 92 } |
| 93 | 93 |
| 94 // Configures the session service with one window with one tab and a single | 94 // Configures the session service with one window with one tab and a single |
| 95 // navigation. If |pinned_state| is true or |write_always| is true, the | 95 // navigation. If |pinned_state| is true or |write_always| is true, the |
| 96 // pinned state of the tab is updated. The session service is then recreated | 96 // pinned state of the tab is updated. The session service is then recreated |
| 97 // and the pinned state of the read back tab is returned. | 97 // and the pinned state of the read back tab is returned. |
| 98 bool CreateAndWriteSessionWithOneTab(bool pinned_state, bool write_always) { | 98 bool CreateAndWriteSessionWithOneTab(bool pinned_state, bool write_always) { |
| 99 SessionID tab_id; | 99 SessionID tab_id; |
| 100 TabNavigation nav1(0, GURL("http://google.com"), | 100 TabNavigation nav1(0, GURL("http://google.com"), |
| 101 GURL("http://www.referrer.com"), | 101 content::Referrer(GURL("http://www.referrer.com"), |
| 102 WebKit::WebReferrerPolicyDefault), |
| 102 ASCIIToUTF16("abc"), "def", | 103 ASCIIToUTF16("abc"), "def", |
| 103 content::PAGE_TRANSITION_QUALIFIER_MASK); | 104 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 104 | 105 |
| 105 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 106 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 106 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 107 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 107 | 108 |
| 108 if (pinned_state || write_always) | 109 if (pinned_state || write_always) |
| 109 helper_.service()->SetPinnedState(window_id, tab_id, pinned_state); | 110 helper_.service()->SetPinnedState(window_id, tab_id, pinned_state); |
| 110 | 111 |
| 111 ScopedVector<SessionWindow> windows; | 112 ScopedVector<SessionWindow> windows; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 139 FilePath path_; | 140 FilePath path_; |
| 140 | 141 |
| 141 SessionServiceTestHelper helper_; | 142 SessionServiceTestHelper helper_; |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 TEST_F(SessionServiceTest, Basic) { | 145 TEST_F(SessionServiceTest, Basic) { |
| 145 SessionID tab_id; | 146 SessionID tab_id; |
| 146 ASSERT_NE(window_id.id(), tab_id.id()); | 147 ASSERT_NE(window_id.id(), tab_id.id()); |
| 147 | 148 |
| 148 TabNavigation nav1(0, GURL("http://google.com"), | 149 TabNavigation nav1(0, GURL("http://google.com"), |
| 149 GURL("http://www.referrer.com"), | 150 content::Referrer(GURL("http://www.referrer.com"), |
| 151 WebKit::WebReferrerPolicyDefault), |
| 150 ASCIIToUTF16("abc"), "def", | 152 ASCIIToUTF16("abc"), "def", |
| 151 content::PAGE_TRANSITION_QUALIFIER_MASK); | 153 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 152 | 154 |
| 153 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 155 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 154 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 156 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 155 | 157 |
| 156 ScopedVector<SessionWindow> windows; | 158 ScopedVector<SessionWindow> windows; |
| 157 ReadWindows(&(windows.get())); | 159 ReadWindows(&(windows.get())); |
| 158 | 160 |
| 159 ASSERT_EQ(1U, windows->size()); | 161 ASSERT_EQ(1U, windows->size()); |
| 160 ASSERT_TRUE(window_bounds == windows[0]->bounds); | 162 ASSERT_TRUE(window_bounds == windows[0]->bounds); |
| 161 ASSERT_EQ(0, windows[0]->selected_tab_index); | 163 ASSERT_EQ(0, windows[0]->selected_tab_index); |
| 162 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); | 164 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); |
| 163 ASSERT_EQ(1U, windows[0]->tabs.size()); | 165 ASSERT_EQ(1U, windows[0]->tabs.size()); |
| 164 ASSERT_EQ(Browser::TYPE_TABBED, windows[0]->type); | 166 ASSERT_EQ(Browser::TYPE_TABBED, windows[0]->type); |
| 165 | 167 |
| 166 SessionTab* tab = windows[0]->tabs[0]; | 168 SessionTab* tab = windows[0]->tabs[0]; |
| 167 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); | 169 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); |
| 168 | 170 |
| 169 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); | 171 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); |
| 170 } | 172 } |
| 171 | 173 |
| 172 // Make sure we persist post entries. | 174 // Make sure we persist post entries. |
| 173 TEST_F(SessionServiceTest, PersistPostData) { | 175 TEST_F(SessionServiceTest, PersistPostData) { |
| 174 SessionID tab_id; | 176 SessionID tab_id; |
| 175 ASSERT_NE(window_id.id(), tab_id.id()); | 177 ASSERT_NE(window_id.id(), tab_id.id()); |
| 176 | 178 |
| 177 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 179 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 178 ASCIIToUTF16("abc"), std::string(), | 180 ASCIIToUTF16("abc"), std::string(), |
| 179 content::PAGE_TRANSITION_QUALIFIER_MASK); | 181 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 180 nav1.set_type_mask(TabNavigation::HAS_POST_DATA); | 182 nav1.set_type_mask(TabNavigation::HAS_POST_DATA); |
| 181 | 183 |
| 182 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 184 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 183 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 185 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 184 | 186 |
| 185 ScopedVector<SessionWindow> windows; | 187 ScopedVector<SessionWindow> windows; |
| 186 ReadWindows(&(windows.get())); | 188 ReadWindows(&(windows.get())); |
| 187 | 189 |
| 188 helper_.AssertSingleWindowWithSingleTab(windows.get(), 1); | 190 helper_.AssertSingleWindowWithSingleTab(windows.get(), 1); |
| 189 } | 191 } |
| 190 | 192 |
| 191 TEST_F(SessionServiceTest, ClosingTabStaysClosed) { | 193 TEST_F(SessionServiceTest, ClosingTabStaysClosed) { |
| 192 SessionID tab_id; | 194 SessionID tab_id; |
| 193 SessionID tab2_id; | 195 SessionID tab2_id; |
| 194 ASSERT_NE(tab_id.id(), tab2_id.id()); | 196 ASSERT_NE(tab_id.id(), tab2_id.id()); |
| 195 | 197 |
| 196 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 198 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 197 ASCIIToUTF16("abc"), "def", | 199 ASCIIToUTF16("abc"), "def", |
| 198 content::PAGE_TRANSITION_QUALIFIER_MASK); | 200 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 199 TabNavigation nav2(0, GURL("http://google2.com"), GURL(), | 201 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), |
| 200 ASCIIToUTF16("abcd"), "defg", | 202 ASCIIToUTF16("abcd"), "defg", |
| 201 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 203 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 202 | 204 |
| 203 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 205 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 204 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 206 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 205 | 207 |
| 206 helper_.PrepareTabInWindow(window_id, tab2_id, 1, false); | 208 helper_.PrepareTabInWindow(window_id, tab2_id, 1, false); |
| 207 UpdateNavigation(window_id, tab2_id, nav2, 0, true); | 209 UpdateNavigation(window_id, tab2_id, nav2, 0, true); |
| 208 service()->TabClosed(window_id, tab2_id, false); | 210 service()->TabClosed(window_id, tab2_id, false); |
| 209 | 211 |
| 210 ScopedVector<SessionWindow> windows; | 212 ScopedVector<SessionWindow> windows; |
| 211 ReadWindows(&(windows.get())); | 213 ReadWindows(&(windows.get())); |
| 212 | 214 |
| 213 ASSERT_EQ(1U, windows->size()); | 215 ASSERT_EQ(1U, windows->size()); |
| 214 ASSERT_EQ(0, windows[0]->selected_tab_index); | 216 ASSERT_EQ(0, windows[0]->selected_tab_index); |
| 215 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); | 217 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); |
| 216 ASSERT_EQ(1U, windows[0]->tabs.size()); | 218 ASSERT_EQ(1U, windows[0]->tabs.size()); |
| 217 | 219 |
| 218 SessionTab* tab = windows[0]->tabs[0]; | 220 SessionTab* tab = windows[0]->tabs[0]; |
| 219 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); | 221 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); |
| 220 | 222 |
| 221 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); | 223 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); |
| 222 } | 224 } |
| 223 | 225 |
| 224 TEST_F(SessionServiceTest, Pruning) { | 226 TEST_F(SessionServiceTest, Pruning) { |
| 225 SessionID tab_id; | 227 SessionID tab_id; |
| 226 | 228 |
| 227 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 229 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 228 ASCIIToUTF16("abc"), "def", | 230 ASCIIToUTF16("abc"), "def", |
| 229 content::PAGE_TRANSITION_QUALIFIER_MASK); | 231 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 230 TabNavigation nav2(0, GURL("http://google2.com"), GURL(), | 232 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), |
| 231 ASCIIToUTF16("abcd"), "defg", | 233 ASCIIToUTF16("abcd"), "defg", |
| 232 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 234 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 233 | 235 |
| 234 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 236 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 235 for (int i = 0; i < 6; ++i) { | 237 for (int i = 0; i < 6; ++i) { |
| 236 TabNavigation& nav = (i % 2) == 0 ? nav1 : nav2; | 238 TabNavigation& nav = (i % 2) == 0 ? nav1 : nav2; |
| 237 UpdateNavigation(window_id, tab_id, nav, i, true); | 239 UpdateNavigation(window_id, tab_id, nav, i, true); |
| 238 } | 240 } |
| 239 service()->TabNavigationPathPrunedFromBack(window_id, tab_id, 3); | 241 service()->TabNavigationPathPrunedFromBack(window_id, tab_id, 3); |
| 240 | 242 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 253 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); | 255 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); |
| 254 helper_.AssertNavigationEquals(nav2, tab->navigations[1]); | 256 helper_.AssertNavigationEquals(nav2, tab->navigations[1]); |
| 255 helper_.AssertNavigationEquals(nav1, tab->navigations[2]); | 257 helper_.AssertNavigationEquals(nav1, tab->navigations[2]); |
| 256 } | 258 } |
| 257 | 259 |
| 258 TEST_F(SessionServiceTest, TwoWindows) { | 260 TEST_F(SessionServiceTest, TwoWindows) { |
| 259 SessionID window2_id; | 261 SessionID window2_id; |
| 260 SessionID tab1_id; | 262 SessionID tab1_id; |
| 261 SessionID tab2_id; | 263 SessionID tab2_id; |
| 262 | 264 |
| 263 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 265 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 264 ASCIIToUTF16("abc"), "def", | 266 ASCIIToUTF16("abc"), "def", |
| 265 content::PAGE_TRANSITION_QUALIFIER_MASK); | 267 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 266 TabNavigation nav2(0, GURL("http://google2.com"), GURL(), | 268 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), |
| 267 ASCIIToUTF16("abcd"), "defg", | 269 ASCIIToUTF16("abcd"), "defg", |
| 268 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 270 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 269 | 271 |
| 270 helper_.PrepareTabInWindow(window_id, tab1_id, 0, true); | 272 helper_.PrepareTabInWindow(window_id, tab1_id, 0, true); |
| 271 UpdateNavigation(window_id, tab1_id, nav1, 0, true); | 273 UpdateNavigation(window_id, tab1_id, nav1, 0, true); |
| 272 | 274 |
| 273 const gfx::Rect window2_bounds(3, 4, 5, 6); | 275 const gfx::Rect window2_bounds(3, 4, 5, 6); |
| 274 service()->SetWindowType(window2_id, Browser::TYPE_TABBED); | 276 service()->SetWindowType(window2_id, Browser::TYPE_TABBED); |
| 275 service()->SetWindowBounds(window2_id, | 277 service()->SetWindowBounds(window2_id, |
| 276 window2_bounds, | 278 window2_bounds, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 tab = rt2; | 312 tab = rt2; |
| 311 helper_.AssertTabEquals(window2_id, tab2_id, 0, 0, 1, *tab); | 313 helper_.AssertTabEquals(window2_id, tab2_id, 0, 0, 1, *tab); |
| 312 helper_.AssertNavigationEquals(nav2, tab->navigations[0]); | 314 helper_.AssertNavigationEquals(nav2, tab->navigations[0]); |
| 313 } | 315 } |
| 314 | 316 |
| 315 TEST_F(SessionServiceTest, WindowWithNoTabsGetsPruned) { | 317 TEST_F(SessionServiceTest, WindowWithNoTabsGetsPruned) { |
| 316 SessionID window2_id; | 318 SessionID window2_id; |
| 317 SessionID tab1_id; | 319 SessionID tab1_id; |
| 318 SessionID tab2_id; | 320 SessionID tab2_id; |
| 319 | 321 |
| 320 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 322 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 321 ASCIIToUTF16("abc"), "def", | 323 ASCIIToUTF16("abc"), "def", |
| 322 content::PAGE_TRANSITION_QUALIFIER_MASK); | 324 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 323 | 325 |
| 324 helper_.PrepareTabInWindow(window_id, tab1_id, 0, true); | 326 helper_.PrepareTabInWindow(window_id, tab1_id, 0, true); |
| 325 UpdateNavigation(window_id, tab1_id, nav1, 0, true); | 327 UpdateNavigation(window_id, tab1_id, nav1, 0, true); |
| 326 | 328 |
| 327 const gfx::Rect window2_bounds(3, 4, 5, 6); | 329 const gfx::Rect window2_bounds(3, 4, 5, 6); |
| 328 service()->SetWindowType(window2_id, Browser::TYPE_TABBED); | 330 service()->SetWindowType(window2_id, Browser::TYPE_TABBED); |
| 329 service()->SetWindowBounds(window2_id, | 331 service()->SetWindowBounds(window2_id, |
| 330 window2_bounds, | 332 window2_bounds, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 342 SessionTab* tab = windows[0]->tabs[0]; | 344 SessionTab* tab = windows[0]->tabs[0]; |
| 343 helper_.AssertTabEquals(window_id, tab1_id, 0, 0, 1, *tab); | 345 helper_.AssertTabEquals(window_id, tab1_id, 0, 0, 1, *tab); |
| 344 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); | 346 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); |
| 345 } | 347 } |
| 346 | 348 |
| 347 TEST_F(SessionServiceTest, ClosingWindowDoesntCloseTabs) { | 349 TEST_F(SessionServiceTest, ClosingWindowDoesntCloseTabs) { |
| 348 SessionID tab_id; | 350 SessionID tab_id; |
| 349 SessionID tab2_id; | 351 SessionID tab2_id; |
| 350 ASSERT_NE(tab_id.id(), tab2_id.id()); | 352 ASSERT_NE(tab_id.id(), tab2_id.id()); |
| 351 | 353 |
| 352 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 354 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 353 ASCIIToUTF16("abc"), "def", | 355 ASCIIToUTF16("abc"), "def", |
| 354 content::PAGE_TRANSITION_QUALIFIER_MASK); | 356 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 355 TabNavigation nav2(0, GURL("http://google2.com"), GURL(), | 357 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), |
| 356 ASCIIToUTF16("abcd"), "defg", | 358 ASCIIToUTF16("abcd"), "defg", |
| 357 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 359 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 358 | 360 |
| 359 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 361 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 360 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 362 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 361 | 363 |
| 362 helper_.PrepareTabInWindow(window_id, tab2_id, 1, false); | 364 helper_.PrepareTabInWindow(window_id, tab2_id, 1, false); |
| 363 UpdateNavigation(window_id, tab2_id, nav2, 0, true); | 365 UpdateNavigation(window_id, tab2_id, nav2, 0, true); |
| 364 | 366 |
| 365 service()->WindowClosing(window_id); | 367 service()->WindowClosing(window_id); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 385 SessionID window2_id; | 387 SessionID window2_id; |
| 386 SessionID tab_id; | 388 SessionID tab_id; |
| 387 SessionID tab2_id; | 389 SessionID tab2_id; |
| 388 ASSERT_NE(window2_id.id(), window_id.id()); | 390 ASSERT_NE(window2_id.id(), window_id.id()); |
| 389 | 391 |
| 390 service()->SetWindowType(window2_id, Browser::TYPE_TABBED); | 392 service()->SetWindowType(window2_id, Browser::TYPE_TABBED); |
| 391 service()->SetWindowBounds(window2_id, | 393 service()->SetWindowBounds(window2_id, |
| 392 window_bounds, | 394 window_bounds, |
| 393 ui::SHOW_STATE_NORMAL); | 395 ui::SHOW_STATE_NORMAL); |
| 394 | 396 |
| 395 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 397 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 396 ASCIIToUTF16("abc"), "def", | 398 ASCIIToUTF16("abc"), "def", |
| 397 content::PAGE_TRANSITION_QUALIFIER_MASK); | 399 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 398 TabNavigation nav2(0, GURL("http://google2.com"), GURL(), | 400 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), |
| 399 ASCIIToUTF16("abcd"), "defg", | 401 ASCIIToUTF16("abcd"), "defg", |
| 400 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 402 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 401 | 403 |
| 402 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 404 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 403 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 405 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 404 | 406 |
| 405 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); | 407 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); |
| 406 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); | 408 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); |
| 407 | 409 |
| 408 service()->WindowClosing(window2_id); | 410 service()->WindowClosing(window2_id); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 430 SessionID window2_id; | 432 SessionID window2_id; |
| 431 SessionID tab_id; | 433 SessionID tab_id; |
| 432 SessionID tab2_id; | 434 SessionID tab2_id; |
| 433 ASSERT_NE(window2_id.id(), window_id.id()); | 435 ASSERT_NE(window2_id.id(), window_id.id()); |
| 434 | 436 |
| 435 service()->SetWindowType(window2_id, Browser::TYPE_POPUP); | 437 service()->SetWindowType(window2_id, Browser::TYPE_POPUP); |
| 436 service()->SetWindowBounds(window2_id, | 438 service()->SetWindowBounds(window2_id, |
| 437 window_bounds, | 439 window_bounds, |
| 438 ui::SHOW_STATE_NORMAL); | 440 ui::SHOW_STATE_NORMAL); |
| 439 | 441 |
| 440 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 442 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 441 ASCIIToUTF16("abc"), "def", | 443 ASCIIToUTF16("abc"), "def", |
| 442 content::PAGE_TRANSITION_QUALIFIER_MASK); | 444 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 443 TabNavigation nav2(0, GURL("http://google2.com"), GURL(), | 445 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), |
| 444 ASCIIToUTF16("abcd"), "defg", | 446 ASCIIToUTF16("abcd"), "defg", |
| 445 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 447 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 446 | 448 |
| 447 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 449 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 448 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 450 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 449 | 451 |
| 450 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); | 452 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); |
| 451 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); | 453 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); |
| 452 | 454 |
| 453 ScopedVector<SessionWindow> windows; | 455 ScopedVector<SessionWindow> windows; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 471 SessionID window2_id; | 473 SessionID window2_id; |
| 472 SessionID tab_id; | 474 SessionID tab_id; |
| 473 SessionID tab2_id; | 475 SessionID tab2_id; |
| 474 ASSERT_NE(window2_id.id(), window_id.id()); | 476 ASSERT_NE(window2_id.id(), window_id.id()); |
| 475 | 477 |
| 476 service()->SetWindowType(window2_id, Browser::TYPE_POPUP); | 478 service()->SetWindowType(window2_id, Browser::TYPE_POPUP); |
| 477 service()->SetWindowBounds(window2_id, | 479 service()->SetWindowBounds(window2_id, |
| 478 window_bounds, | 480 window_bounds, |
| 479 ui::SHOW_STATE_NORMAL); | 481 ui::SHOW_STATE_NORMAL); |
| 480 | 482 |
| 481 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 483 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 482 ASCIIToUTF16("abc"), "def", | 484 ASCIIToUTF16("abc"), "def", |
| 483 content::PAGE_TRANSITION_QUALIFIER_MASK); | 485 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 484 TabNavigation nav2(0, GURL("http://google2.com"), GURL(), | 486 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), |
| 485 ASCIIToUTF16("abcd"), "defg", | 487 ASCIIToUTF16("abcd"), "defg", |
| 486 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 488 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 487 | 489 |
| 488 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 490 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 489 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 491 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 490 | 492 |
| 491 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); | 493 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); |
| 492 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); | 494 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); |
| 493 | 495 |
| 494 ScopedVector<SessionWindow> windows; | 496 ScopedVector<SessionWindow> windows; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 517 | 519 |
| 518 // Tests pruning from the front. | 520 // Tests pruning from the front. |
| 519 TEST_F(SessionServiceTest, PruneFromFront) { | 521 TEST_F(SessionServiceTest, PruneFromFront) { |
| 520 const std::string base_url("http://google.com/"); | 522 const std::string base_url("http://google.com/"); |
| 521 SessionID tab_id; | 523 SessionID tab_id; |
| 522 | 524 |
| 523 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 525 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 524 | 526 |
| 525 // Add 5 navigations, with the 4th selected. | 527 // Add 5 navigations, with the 4th selected. |
| 526 for (int i = 0; i < 5; ++i) { | 528 for (int i = 0; i < 5; ++i) { |
| 527 TabNavigation nav(0, GURL(base_url + base::IntToString(i)), GURL(), | 529 TabNavigation nav(0, GURL(base_url + base::IntToString(i)), |
| 530 content::Referrer(), |
| 528 ASCIIToUTF16("a"), "b", | 531 ASCIIToUTF16("a"), "b", |
| 529 content::PAGE_TRANSITION_QUALIFIER_MASK); | 532 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 530 UpdateNavigation(window_id, tab_id, nav, i, (i == 3)); | 533 UpdateNavigation(window_id, tab_id, nav, i, (i == 3)); |
| 531 } | 534 } |
| 532 | 535 |
| 533 // Prune the first two navigations from the front. | 536 // Prune the first two navigations from the front. |
| 534 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 2); | 537 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 2); |
| 535 | 538 |
| 536 // Read back in. | 539 // Read back in. |
| 537 ScopedVector<SessionWindow> windows; | 540 ScopedVector<SessionWindow> windows; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 559 | 562 |
| 560 // Prunes from front so that we have no entries. | 563 // Prunes from front so that we have no entries. |
| 561 TEST_F(SessionServiceTest, PruneToEmpty) { | 564 TEST_F(SessionServiceTest, PruneToEmpty) { |
| 562 const std::string base_url("http://google.com/"); | 565 const std::string base_url("http://google.com/"); |
| 563 SessionID tab_id; | 566 SessionID tab_id; |
| 564 | 567 |
| 565 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 568 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 566 | 569 |
| 567 // Add 5 navigations, with the 4th selected. | 570 // Add 5 navigations, with the 4th selected. |
| 568 for (int i = 0; i < 5; ++i) { | 571 for (int i = 0; i < 5; ++i) { |
| 569 TabNavigation nav(0, GURL(base_url + base::IntToString(i)), GURL(), | 572 TabNavigation nav(0, GURL(base_url + base::IntToString(i)), |
| 573 content::Referrer(), |
| 570 ASCIIToUTF16("a"), "b", | 574 ASCIIToUTF16("a"), "b", |
| 571 content::PAGE_TRANSITION_QUALIFIER_MASK); | 575 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 572 UpdateNavigation(window_id, tab_id, nav, i, (i == 3)); | 576 UpdateNavigation(window_id, tab_id, nav, i, (i == 3)); |
| 573 } | 577 } |
| 574 | 578 |
| 575 // Prune the first two navigations from the front. | 579 // Prune the first two navigations from the front. |
| 576 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 5); | 580 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 5); |
| 577 | 581 |
| 578 // Read back in. | 582 // Read back in. |
| 579 ScopedVector<SessionWindow> windows; | 583 ScopedVector<SessionWindow> windows; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 591 TEST_F(SessionServiceTest, PinnedFalseWhenSetToFalse) { | 595 TEST_F(SessionServiceTest, PinnedFalseWhenSetToFalse) { |
| 592 EXPECT_FALSE(CreateAndWriteSessionWithOneTab(false, true)); | 596 EXPECT_FALSE(CreateAndWriteSessionWithOneTab(false, true)); |
| 593 } | 597 } |
| 594 | 598 |
| 595 // Make sure application extension ids are persisted. | 599 // Make sure application extension ids are persisted. |
| 596 TEST_F(SessionServiceTest, PersistApplicationExtensionID) { | 600 TEST_F(SessionServiceTest, PersistApplicationExtensionID) { |
| 597 SessionID tab_id; | 601 SessionID tab_id; |
| 598 ASSERT_NE(window_id.id(), tab_id.id()); | 602 ASSERT_NE(window_id.id(), tab_id.id()); |
| 599 std::string app_id("foo"); | 603 std::string app_id("foo"); |
| 600 | 604 |
| 601 TabNavigation nav1(0, GURL("http://google.com"), GURL(), | 605 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), |
| 602 ASCIIToUTF16("abc"), std::string(), | 606 ASCIIToUTF16("abc"), std::string(), |
| 603 content::PAGE_TRANSITION_QUALIFIER_MASK); | 607 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 604 | 608 |
| 605 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 609 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 606 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 610 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 607 helper_.SetTabExtensionAppID(window_id, tab_id, app_id); | 611 helper_.SetTabExtensionAppID(window_id, tab_id, app_id); |
| 608 | 612 |
| 609 ScopedVector<SessionWindow> windows; | 613 ScopedVector<SessionWindow> windows; |
| 610 ReadWindows(&(windows.get())); | 614 ReadWindows(&(windows.get())); |
| 611 | 615 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 service()->Save(); | 662 service()->Save(); |
| 659 EXPECT_EQ(sync_save_count_, 1); | 663 EXPECT_EQ(sync_save_count_, 1); |
| 660 } | 664 } |
| 661 | 665 |
| 662 // Makes sure a tab closed by a user gesture is not restored. | 666 // Makes sure a tab closed by a user gesture is not restored. |
| 663 TEST_F(SessionServiceTest, CloseTabUserGesture) { | 667 TEST_F(SessionServiceTest, CloseTabUserGesture) { |
| 664 SessionID tab_id; | 668 SessionID tab_id; |
| 665 ASSERT_NE(window_id.id(), tab_id.id()); | 669 ASSERT_NE(window_id.id(), tab_id.id()); |
| 666 | 670 |
| 667 TabNavigation nav1(0, GURL("http://google.com"), | 671 TabNavigation nav1(0, GURL("http://google.com"), |
| 668 GURL("http://www.referrer.com"), | 672 content::Referrer(GURL("http://www.referrer.com"), |
| 673 WebKit::WebReferrerPolicyDefault), |
| 669 ASCIIToUTF16("abc"), "def", | 674 ASCIIToUTF16("abc"), "def", |
| 670 content::PAGE_TRANSITION_QUALIFIER_MASK); | 675 content::PAGE_TRANSITION_QUALIFIER_MASK); |
| 671 | 676 |
| 672 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 677 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 673 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 678 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
| 674 service()->TabClosed(window_id, tab_id, true); | 679 service()->TabClosed(window_id, tab_id, true); |
| 675 | 680 |
| 676 ScopedVector<SessionWindow> windows; | 681 ScopedVector<SessionWindow> windows; |
| 677 ReadWindows(&(windows.get())); | 682 ReadWindows(&(windows.get())); |
| 678 | 683 |
| 679 ASSERT_TRUE(windows->empty()); | 684 ASSERT_TRUE(windows->empty()); |
| 680 } | 685 } |
| OLD | NEW |