Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/sessions/session_service_unittest.cc

Issue 10669038: base: Remove dereference structure operator (i.e ->) from ScopedVector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 116 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
117 UpdateNavigation(window_id, tab_id, nav1, 0, true); 117 UpdateNavigation(window_id, tab_id, nav1, 0, true);
118 118
119 if (pinned_state || write_always) 119 if (pinned_state || write_always)
120 helper_.service()->SetPinnedState(window_id, tab_id, pinned_state); 120 helper_.service()->SetPinnedState(window_id, tab_id, pinned_state);
121 121
122 ScopedVector<SessionWindow> windows; 122 ScopedVector<SessionWindow> windows;
123 ReadWindows(&(windows.get())); 123 ReadWindows(&(windows.get()));
124 124
125 EXPECT_EQ(1U, windows->size()); 125 EXPECT_EQ(1U, windows.size());
126 if (HasFatalFailure()) 126 if (HasFatalFailure())
127 return false; 127 return false;
128 EXPECT_EQ(1U, windows[0]->tabs.size()); 128 EXPECT_EQ(1U, windows[0]->tabs.size());
129 if (HasFatalFailure()) 129 if (HasFatalFailure())
130 return false; 130 return false;
131 131
132 SessionTab* tab = windows[0]->tabs[0]; 132 SessionTab* tab = windows[0]->tabs[0];
133 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); 133 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
134 134
135 return tab->pinned; 135 return tab->pinned;
(...skipping 26 matching lines...) Expand all
162 ASCIIToUTF16("abc"), "def", 162 ASCIIToUTF16("abc"), "def",
163 content::PAGE_TRANSITION_QUALIFIER_MASK); 163 content::PAGE_TRANSITION_QUALIFIER_MASK);
164 nav1.set_original_request_url(GURL("http://original.request.com")); 164 nav1.set_original_request_url(GURL("http://original.request.com"));
165 165
166 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 166 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
167 UpdateNavigation(window_id, tab_id, nav1, 0, true); 167 UpdateNavigation(window_id, tab_id, nav1, 0, true);
168 168
169 ScopedVector<SessionWindow> windows; 169 ScopedVector<SessionWindow> windows;
170 ReadWindows(&(windows.get())); 170 ReadWindows(&(windows.get()));
171 171
172 ASSERT_EQ(1U, windows->size()); 172 ASSERT_EQ(1U, windows.size());
173 ASSERT_TRUE(window_bounds == windows[0]->bounds); 173 ASSERT_TRUE(window_bounds == windows[0]->bounds);
174 ASSERT_EQ(0, windows[0]->selected_tab_index); 174 ASSERT_EQ(0, windows[0]->selected_tab_index);
175 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); 175 ASSERT_EQ(window_id.id(), windows[0]->window_id.id());
176 ASSERT_EQ(1U, windows[0]->tabs.size()); 176 ASSERT_EQ(1U, windows[0]->tabs.size());
177 ASSERT_EQ(Browser::TYPE_TABBED, windows[0]->type); 177 ASSERT_EQ(Browser::TYPE_TABBED, windows[0]->type);
178 178
179 SessionTab* tab = windows[0]->tabs[0]; 179 SessionTab* tab = windows[0]->tabs[0];
180 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); 180 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
181 181
182 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); 182 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 216 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
217 UpdateNavigation(window_id, tab_id, nav1, 0, true); 217 UpdateNavigation(window_id, tab_id, nav1, 0, true);
218 218
219 helper_.PrepareTabInWindow(window_id, tab2_id, 1, false); 219 helper_.PrepareTabInWindow(window_id, tab2_id, 1, false);
220 UpdateNavigation(window_id, tab2_id, nav2, 0, true); 220 UpdateNavigation(window_id, tab2_id, nav2, 0, true);
221 service()->TabClosed(window_id, tab2_id, false); 221 service()->TabClosed(window_id, tab2_id, false);
222 222
223 ScopedVector<SessionWindow> windows; 223 ScopedVector<SessionWindow> windows;
224 ReadWindows(&(windows.get())); 224 ReadWindows(&(windows.get()));
225 225
226 ASSERT_EQ(1U, windows->size()); 226 ASSERT_EQ(1U, windows.size());
227 ASSERT_EQ(0, windows[0]->selected_tab_index); 227 ASSERT_EQ(0, windows[0]->selected_tab_index);
228 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); 228 ASSERT_EQ(window_id.id(), windows[0]->window_id.id());
229 ASSERT_EQ(1U, windows[0]->tabs.size()); 229 ASSERT_EQ(1U, windows[0]->tabs.size());
230 230
231 SessionTab* tab = windows[0]->tabs[0]; 231 SessionTab* tab = windows[0]->tabs[0];
232 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); 232 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
233 233
234 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); 234 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
235 } 235 }
236 236
(...skipping 10 matching lines...) Expand all
247 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 247 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
248 for (int i = 0; i < 6; ++i) { 248 for (int i = 0; i < 6; ++i) {
249 TabNavigation& nav = (i % 2) == 0 ? nav1 : nav2; 249 TabNavigation& nav = (i % 2) == 0 ? nav1 : nav2;
250 UpdateNavigation(window_id, tab_id, nav, i, true); 250 UpdateNavigation(window_id, tab_id, nav, i, true);
251 } 251 }
252 service()->TabNavigationPathPrunedFromBack(window_id, tab_id, 3); 252 service()->TabNavigationPathPrunedFromBack(window_id, tab_id, 3);
253 253
254 ScopedVector<SessionWindow> windows; 254 ScopedVector<SessionWindow> windows;
255 ReadWindows(&(windows.get())); 255 ReadWindows(&(windows.get()));
256 256
257 ASSERT_EQ(1U, windows->size()); 257 ASSERT_EQ(1U, windows.size());
258 ASSERT_EQ(0, windows[0]->selected_tab_index); 258 ASSERT_EQ(0, windows[0]->selected_tab_index);
259 ASSERT_EQ(1U, windows[0]->tabs.size()); 259 ASSERT_EQ(1U, windows[0]->tabs.size());
260 260
261 SessionTab* tab = windows[0]->tabs[0]; 261 SessionTab* tab = windows[0]->tabs[0];
262 // We left the selected index at 5, then pruned. When rereading the 262 // We left the selected index at 5, then pruned. When rereading the
263 // index should get reset to last valid navigation, which is 2. 263 // index should get reset to last valid navigation, which is 2.
264 helper_.AssertTabEquals(window_id, tab_id, 0, 2, 3, *tab); 264 helper_.AssertTabEquals(window_id, tab_id, 0, 2, 3, *tab);
265 265
266 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); 266 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
267 helper_.AssertNavigationEquals(nav2, tab->navigations[1]); 267 helper_.AssertNavigationEquals(nav2, tab->navigations[1]);
(...skipping 20 matching lines...) Expand all
288 window2_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL); 288 window2_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL);
289 service()->SetWindowBounds(window2_id, 289 service()->SetWindowBounds(window2_id,
290 window2_bounds, 290 window2_bounds,
291 ui::SHOW_STATE_MAXIMIZED); 291 ui::SHOW_STATE_MAXIMIZED);
292 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true); 292 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true);
293 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); 293 UpdateNavigation(window2_id, tab2_id, nav2, 0, true);
294 294
295 ScopedVector<SessionWindow> windows; 295 ScopedVector<SessionWindow> windows;
296 ReadWindows(&(windows.get())); 296 ReadWindows(&(windows.get()));
297 297
298 ASSERT_EQ(2U, windows->size()); 298 ASSERT_EQ(2U, windows.size());
299 ASSERT_EQ(0, windows[0]->selected_tab_index); 299 ASSERT_EQ(0, windows[0]->selected_tab_index);
300 ASSERT_EQ(0, windows[1]->selected_tab_index); 300 ASSERT_EQ(0, windows[1]->selected_tab_index);
301 ASSERT_EQ(1U, windows[0]->tabs.size()); 301 ASSERT_EQ(1U, windows[0]->tabs.size());
302 ASSERT_EQ(1U, windows[1]->tabs.size()); 302 ASSERT_EQ(1U, windows[1]->tabs.size());
303 303
304 SessionTab* rt1; 304 SessionTab* rt1;
305 SessionTab* rt2; 305 SessionTab* rt2;
306 if (windows[0]->window_id.id() == window_id.id()) { 306 if (windows[0]->window_id.id() == window_id.id()) {
307 ASSERT_EQ(window2_id.id(), windows[1]->window_id.id()); 307 ASSERT_EQ(window2_id.id(), windows[1]->window_id.id());
308 ASSERT_EQ(ui::SHOW_STATE_NORMAL, windows[0]->show_state); 308 ASSERT_EQ(ui::SHOW_STATE_NORMAL, windows[0]->show_state);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 service()->SetWindowType( 342 service()->SetWindowType(
343 window2_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL); 343 window2_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL);
344 service()->SetWindowBounds(window2_id, 344 service()->SetWindowBounds(window2_id,
345 window2_bounds, 345 window2_bounds,
346 ui::SHOW_STATE_NORMAL); 346 ui::SHOW_STATE_NORMAL);
347 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true); 347 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true);
348 348
349 ScopedVector<SessionWindow> windows; 349 ScopedVector<SessionWindow> windows;
350 ReadWindows(&(windows.get())); 350 ReadWindows(&(windows.get()));
351 351
352 ASSERT_EQ(1U, windows->size()); 352 ASSERT_EQ(1U, windows.size());
353 ASSERT_EQ(0, windows[0]->selected_tab_index); 353 ASSERT_EQ(0, windows[0]->selected_tab_index);
354 ASSERT_EQ(1U, windows[0]->tabs.size()); 354 ASSERT_EQ(1U, windows[0]->tabs.size());
355 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); 355 ASSERT_EQ(window_id.id(), windows[0]->window_id.id());
356 356
357 SessionTab* tab = windows[0]->tabs[0]; 357 SessionTab* tab = windows[0]->tabs[0];
358 helper_.AssertTabEquals(window_id, tab1_id, 0, 0, 1, *tab); 358 helper_.AssertTabEquals(window_id, tab1_id, 0, 0, 1, *tab);
359 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); 359 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
360 } 360 }
361 361
362 TEST_F(SessionServiceTest, ClosingWindowDoesntCloseTabs) { 362 TEST_F(SessionServiceTest, ClosingWindowDoesntCloseTabs) {
(...skipping 12 matching lines...) Expand all
375 UpdateNavigation(window_id, tab_id, nav1, 0, true); 375 UpdateNavigation(window_id, tab_id, nav1, 0, true);
376 376
377 helper_.PrepareTabInWindow(window_id, tab2_id, 1, false); 377 helper_.PrepareTabInWindow(window_id, tab2_id, 1, false);
378 UpdateNavigation(window_id, tab2_id, nav2, 0, true); 378 UpdateNavigation(window_id, tab2_id, nav2, 0, true);
379 379
380 service()->WindowClosing(window_id); 380 service()->WindowClosing(window_id);
381 381
382 ScopedVector<SessionWindow> windows; 382 ScopedVector<SessionWindow> windows;
383 ReadWindows(&(windows.get())); 383 ReadWindows(&(windows.get()));
384 384
385 ASSERT_EQ(1U, windows->size()); 385 ASSERT_EQ(1U, windows.size());
386 ASSERT_EQ(0, windows[0]->selected_tab_index); 386 ASSERT_EQ(0, windows[0]->selected_tab_index);
387 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); 387 ASSERT_EQ(window_id.id(), windows[0]->window_id.id());
388 ASSERT_EQ(2U, windows[0]->tabs.size()); 388 ASSERT_EQ(2U, windows[0]->tabs.size());
389 389
390 SessionTab* tab = windows[0]->tabs[0]; 390 SessionTab* tab = windows[0]->tabs[0];
391 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); 391 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
392 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); 392 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
393 393
394 tab = windows[0]->tabs[1]; 394 tab = windows[0]->tabs[1];
395 helper_.AssertTabEquals(window_id, tab2_id, 1, 0, 1, *tab); 395 helper_.AssertTabEquals(window_id, tab2_id, 1, 0, 1, *tab);
(...skipping 25 matching lines...) Expand all
421 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); 421 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false);
422 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); 422 UpdateNavigation(window2_id, tab2_id, nav2, 0, true);
423 423
424 service()->WindowClosing(window2_id); 424 service()->WindowClosing(window2_id);
425 service()->TabClosed(window2_id, tab2_id, false); 425 service()->TabClosed(window2_id, tab2_id, false);
426 service()->WindowClosed(window2_id); 426 service()->WindowClosed(window2_id);
427 427
428 ScopedVector<SessionWindow> windows; 428 ScopedVector<SessionWindow> windows;
429 ReadWindows(&(windows.get())); 429 ReadWindows(&(windows.get()));
430 430
431 ASSERT_EQ(1U, windows->size()); 431 ASSERT_EQ(1U, windows.size());
432 ASSERT_EQ(0, windows[0]->selected_tab_index); 432 ASSERT_EQ(0, windows[0]->selected_tab_index);
433 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); 433 ASSERT_EQ(window_id.id(), windows[0]->window_id.id());
434 ASSERT_EQ(1U, windows[0]->tabs.size()); 434 ASSERT_EQ(1U, windows[0]->tabs.size());
435 435
436 SessionTab* tab = windows[0]->tabs[0]; 436 SessionTab* tab = windows[0]->tabs[0];
437 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); 437 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
438 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); 438 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
439 } 439 }
440 440
441 // Makes sure we don't track popups. 441 // Makes sure we don't track popups.
(...skipping 21 matching lines...) Expand all
463 463
464 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 464 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
465 UpdateNavigation(window_id, tab_id, nav1, 0, true); 465 UpdateNavigation(window_id, tab_id, nav1, 0, true);
466 466
467 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); 467 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false);
468 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); 468 UpdateNavigation(window2_id, tab2_id, nav2, 0, true);
469 469
470 ScopedVector<SessionWindow> windows; 470 ScopedVector<SessionWindow> windows;
471 ReadWindows(&(windows.get())); 471 ReadWindows(&(windows.get()));
472 472
473 ASSERT_EQ(1U, windows->size()); 473 ASSERT_EQ(1U, windows.size());
474 ASSERT_EQ(0, windows[0]->selected_tab_index); 474 ASSERT_EQ(0, windows[0]->selected_tab_index);
475 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); 475 ASSERT_EQ(window_id.id(), windows[0]->window_id.id());
476 ASSERT_EQ(1U, windows[0]->tabs.size()); 476 ASSERT_EQ(1U, windows[0]->tabs.size());
477 477
478 SessionTab* tab = windows[0]->tabs[0]; 478 SessionTab* tab = windows[0]->tabs[0];
479 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); 479 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
480 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); 480 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
481 } 481 }
482 482
483 // Makes sure we track popups. 483 // Makes sure we track popups.
(...skipping 21 matching lines...) Expand all
505 505
506 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 506 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
507 UpdateNavigation(window_id, tab_id, nav1, 0, true); 507 UpdateNavigation(window_id, tab_id, nav1, 0, true);
508 508
509 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); 509 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false);
510 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); 510 UpdateNavigation(window2_id, tab2_id, nav2, 0, true);
511 511
512 ScopedVector<SessionWindow> windows; 512 ScopedVector<SessionWindow> windows;
513 ReadWindows(&(windows.get())); 513 ReadWindows(&(windows.get()));
514 514
515 ASSERT_EQ(2U, windows->size()); 515 ASSERT_EQ(2U, windows.size());
516 int tabbed_index = windows[0]->type == Browser::TYPE_TABBED ? 516 int tabbed_index = windows[0]->type == Browser::TYPE_TABBED ?
517 0 : 1; 517 0 : 1;
518 int popup_index = tabbed_index == 0 ? 1 : 0; 518 int popup_index = tabbed_index == 0 ? 1 : 0;
519 ASSERT_EQ(0, windows[tabbed_index]->selected_tab_index); 519 ASSERT_EQ(0, windows[tabbed_index]->selected_tab_index);
520 ASSERT_EQ(window_id.id(), windows[tabbed_index]->window_id.id()); 520 ASSERT_EQ(window_id.id(), windows[tabbed_index]->window_id.id());
521 ASSERT_EQ(1U, windows[tabbed_index]->tabs.size()); 521 ASSERT_EQ(1U, windows[tabbed_index]->tabs.size());
522 522
523 SessionTab* tab = windows[tabbed_index]->tabs[0]; 523 SessionTab* tab = windows[tabbed_index]->tabs[0];
524 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); 524 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
525 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); 525 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 557
558 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 558 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
559 UpdateNavigation(window_id, tab_id, nav1, 0, true); 559 UpdateNavigation(window_id, tab_id, nav1, 0, true);
560 560
561 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false); 561 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false);
562 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); 562 UpdateNavigation(window2_id, tab2_id, nav2, 0, true);
563 563
564 ScopedVector<SessionWindow> windows; 564 ScopedVector<SessionWindow> windows;
565 ReadWindows(&(windows.get())); 565 ReadWindows(&(windows.get()));
566 566
567 ASSERT_EQ(2U, windows->size()); 567 ASSERT_EQ(2U, windows.size());
568 int tabbed_index = windows[0]->type == Browser::TYPE_TABBED ? 568 int tabbed_index = windows[0]->type == Browser::TYPE_TABBED ?
569 0 : 1; 569 0 : 1;
570 int app_index = tabbed_index == 0 ? 1 : 0; 570 int app_index = tabbed_index == 0 ? 1 : 0;
571 ASSERT_EQ(0, windows[tabbed_index]->selected_tab_index); 571 ASSERT_EQ(0, windows[tabbed_index]->selected_tab_index);
572 ASSERT_EQ(window_id.id(), windows[tabbed_index]->window_id.id()); 572 ASSERT_EQ(window_id.id(), windows[tabbed_index]->window_id.id());
573 ASSERT_EQ(1U, windows[tabbed_index]->tabs.size()); 573 ASSERT_EQ(1U, windows[tabbed_index]->tabs.size());
574 574
575 SessionTab* tab = windows[tabbed_index]->tabs[0]; 575 SessionTab* tab = windows[tabbed_index]->tabs[0];
576 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); 576 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
577 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); 577 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
(...skipping 26 matching lines...) Expand all
604 UpdateNavigation(window_id, tab_id, nav, i, (i == 3)); 604 UpdateNavigation(window_id, tab_id, nav, i, (i == 3));
605 } 605 }
606 606
607 // Prune the first two navigations from the front. 607 // Prune the first two navigations from the front.
608 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 2); 608 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 2);
609 609
610 // Read back in. 610 // Read back in.
611 ScopedVector<SessionWindow> windows; 611 ScopedVector<SessionWindow> windows;
612 ReadWindows(&(windows.get())); 612 ReadWindows(&(windows.get()));
613 613
614 ASSERT_EQ(1U, windows->size()); 614 ASSERT_EQ(1U, windows.size());
615 ASSERT_EQ(0, windows[0]->selected_tab_index); 615 ASSERT_EQ(0, windows[0]->selected_tab_index);
616 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); 616 ASSERT_EQ(window_id.id(), windows[0]->window_id.id());
617 ASSERT_EQ(1U, windows[0]->tabs.size()); 617 ASSERT_EQ(1U, windows[0]->tabs.size());
618 618
619 // There shouldn't be an app id. 619 // There shouldn't be an app id.
620 EXPECT_TRUE(windows[0]->tabs[0]->extension_app_id.empty()); 620 EXPECT_TRUE(windows[0]->tabs[0]->extension_app_id.empty());
621 621
622 // We should be left with three navigations, the 2nd selected. 622 // We should be left with three navigations, the 2nd selected.
623 SessionTab* tab = windows[0]->tabs[0]; 623 SessionTab* tab = windows[0]->tabs[0];
624 ASSERT_EQ(1, tab->current_navigation_index); 624 ASSERT_EQ(1, tab->current_navigation_index);
(...skipping 22 matching lines...) Expand all
647 UpdateNavigation(window_id, tab_id, nav, i, (i == 3)); 647 UpdateNavigation(window_id, tab_id, nav, i, (i == 3));
648 } 648 }
649 649
650 // Prune the first two navigations from the front. 650 // Prune the first two navigations from the front.
651 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 5); 651 helper_.service()->TabNavigationPathPrunedFromFront(window_id, tab_id, 5);
652 652
653 // Read back in. 653 // Read back in.
654 ScopedVector<SessionWindow> windows; 654 ScopedVector<SessionWindow> windows;
655 ReadWindows(&(windows.get())); 655 ReadWindows(&(windows.get()));
656 656
657 ASSERT_EQ(0U, windows->size()); 657 ASSERT_EQ(0U, windows.size());
658 } 658 }
659 659
660 // Don't set the pinned state and make sure the pinned value is false. 660 // Don't set the pinned state and make sure the pinned value is false.
661 TEST_F(SessionServiceTest, PinnedDefaultsToFalse) { 661 TEST_F(SessionServiceTest, PinnedDefaultsToFalse) {
662 EXPECT_FALSE(CreateAndWriteSessionWithOneTab(false, false)); 662 EXPECT_FALSE(CreateAndWriteSessionWithOneTab(false, false));
663 } 663 }
664 664
665 // Explicitly set the pinned state to false and make sure we get back false. 665 // Explicitly set the pinned state to false and make sure we get back false.
666 TEST_F(SessionServiceTest, PinnedFalseWhenSetToFalse) { 666 TEST_F(SessionServiceTest, PinnedFalseWhenSetToFalse) {
667 EXPECT_FALSE(CreateAndWriteSessionWithOneTab(false, true)); 667 EXPECT_FALSE(CreateAndWriteSessionWithOneTab(false, true));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 ASCIIToUTF16("abc"), "def", 738 ASCIIToUTF16("abc"), "def",
739 content::PAGE_TRANSITION_QUALIFIER_MASK); 739 content::PAGE_TRANSITION_QUALIFIER_MASK);
740 740
741 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 741 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
742 UpdateNavigation(window_id, tab_id, nav1, 0, true); 742 UpdateNavigation(window_id, tab_id, nav1, 0, true);
743 service()->TabClosed(window_id, tab_id, true); 743 service()->TabClosed(window_id, tab_id, true);
744 744
745 ScopedVector<SessionWindow> windows; 745 ScopedVector<SessionWindow> windows;
746 ReadWindows(&(windows.get())); 746 ReadWindows(&(windows.get()));
747 747
748 ASSERT_TRUE(windows->empty()); 748 ASSERT_TRUE(windows.empty());
749 } 749 }
750 750
751 // Verifies SetWindowBounds maps SHOW_STATE_DEFAULT to SHOW_STATE_NORMAL. 751 // Verifies SetWindowBounds maps SHOW_STATE_DEFAULT to SHOW_STATE_NORMAL.
752 TEST_F(SessionServiceTest, DontPersistDefault) { 752 TEST_F(SessionServiceTest, DontPersistDefault) {
753 SessionID tab_id; 753 SessionID tab_id;
754 ASSERT_NE(window_id.id(), tab_id.id()); 754 ASSERT_NE(window_id.id(), tab_id.id());
755 TabNavigation nav1(0, GURL("http://google.com"), 755 TabNavigation nav1(0, GURL("http://google.com"),
756 content::Referrer(GURL("http://www.referrer.com"), 756 content::Referrer(GURL("http://www.referrer.com"),
757 WebKit::WebReferrerPolicyDefault), 757 WebKit::WebReferrerPolicyDefault),
758 ASCIIToUTF16("abc"), "def", 758 ASCIIToUTF16("abc"), "def",
759 content::PAGE_TRANSITION_QUALIFIER_MASK); 759 content::PAGE_TRANSITION_QUALIFIER_MASK);
760 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 760 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
761 UpdateNavigation(window_id, tab_id, nav1, 0, true); 761 UpdateNavigation(window_id, tab_id, nav1, 0, true);
762 service()->SetWindowBounds(window_id, 762 service()->SetWindowBounds(window_id,
763 window_bounds, 763 window_bounds,
764 ui::SHOW_STATE_DEFAULT); 764 ui::SHOW_STATE_DEFAULT);
765 765
766 ScopedVector<SessionWindow> windows; 766 ScopedVector<SessionWindow> windows;
767 ReadWindows(&(windows.get())); 767 ReadWindows(&(windows.get()));
768 ASSERT_EQ(1U, windows->size()); 768 ASSERT_EQ(1U, windows.size());
769 EXPECT_EQ(ui::SHOW_STATE_NORMAL, windows[0]->show_state); 769 EXPECT_EQ(ui::SHOW_STATE_NORMAL, windows[0]->show_state);
770 } 770 }
771 771
772 TEST_F(SessionServiceTest, RemovePostData) { 772 TEST_F(SessionServiceTest, RemovePostData) {
773 helper_.service()->save_post_data_ = false; 773 helper_.service()->save_post_data_ = false;
774 774
775 SessionID tab_id; 775 SessionID tab_id;
776 ASSERT_NE(window_id.id(), tab_id.id()); 776 ASSERT_NE(window_id.id(), tab_id.id());
777 777
778 std::string content_state("dummy_content_state"); 778 std::string content_state("dummy_content_state");
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 ASSERT_TRUE(file_util::CopyFile(v1_file_path, dest_file_path)); 903 ASSERT_TRUE(file_util::CopyFile(v1_file_path, dest_file_path));
904 904
905 SessionService* session_service = new SessionService(path_); 905 SessionService* session_service = new SessionService(path_);
906 helper_.set_service(session_service); 906 helper_.set_service(session_service);
907 ScopedVector<SessionWindow> windows; 907 ScopedVector<SessionWindow> windows;
908 helper_.ReadWindows(&(windows.get())); 908 helper_.ReadWindows(&(windows.get()));
909 ASSERT_EQ(1u, windows.size()); 909 ASSERT_EQ(1u, windows.size());
910 EXPECT_EQ(1u, windows[0]->tabs.size()); 910 EXPECT_EQ(1u, windows[0]->tabs.size());
911 } 911 }
912 #endif 912 #endif
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_backend.cc ('k') | chrome/browser/sessions/tab_restore_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698