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