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

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

Issue 9359022: Aura: Support hovering restore & close buttons for full screen apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser_test Created 8 years, 10 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
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 30 matching lines...) Expand all
41 std::string b = base::Int64ToString(base::Time::Now().ToInternalValue()); 41 std::string b = base::Int64ToString(base::Time::Now().ToInternalValue());
42 42
43 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 43 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
44 path_ = temp_dir_.path().Append(FILE_PATH_LITERAL("SessionTestDirs")); 44 path_ = temp_dir_.path().Append(FILE_PATH_LITERAL("SessionTestDirs"));
45 ASSERT_TRUE(file_util::CreateDirectory(path_)); 45 ASSERT_TRUE(file_util::CreateDirectory(path_));
46 path_ = path_.AppendASCII(b); 46 path_ = path_.AppendASCII(b);
47 47
48 SessionService* session_service = new SessionService(path_); 48 SessionService* session_service = new SessionService(path_);
49 helper_.set_service(session_service); 49 helper_.set_service(session_service);
50 50
51 service()->SetWindowType(window_id, Browser::TYPE_TABBED); 51 service()->SetWindowType(
52 window_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL);
52 service()->SetWindowBounds(window_id, 53 service()->SetWindowBounds(window_id,
53 window_bounds, 54 window_bounds,
54 ui::SHOW_STATE_NORMAL); 55 ui::SHOW_STATE_NORMAL);
55 } 56 }
56 57
57 // Upon notification, increment the sync_save_count variable 58 // Upon notification, increment the sync_save_count variable
58 void Observe(int type, 59 void Observe(int type,
59 const content::NotificationSource& source, 60 const content::NotificationSource& source,
60 const content::NotificationDetails& details) { 61 const content::NotificationDetails& details) {
61 ASSERT_EQ(type, chrome::NOTIFICATION_SESSION_SERVICE_SAVED); 62 ASSERT_EQ(type, chrome::NOTIFICATION_SESSION_SERVICE_SAVED);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 ASCIIToUTF16("abc"), "def", 269 ASCIIToUTF16("abc"), "def",
269 content::PAGE_TRANSITION_QUALIFIER_MASK); 270 content::PAGE_TRANSITION_QUALIFIER_MASK);
270 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), 271 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(),
271 ASCIIToUTF16("abcd"), "defg", 272 ASCIIToUTF16("abcd"), "defg",
272 content::PAGE_TRANSITION_AUTO_BOOKMARK); 273 content::PAGE_TRANSITION_AUTO_BOOKMARK);
273 274
274 helper_.PrepareTabInWindow(window_id, tab1_id, 0, true); 275 helper_.PrepareTabInWindow(window_id, tab1_id, 0, true);
275 UpdateNavigation(window_id, tab1_id, nav1, 0, true); 276 UpdateNavigation(window_id, tab1_id, nav1, 0, true);
276 277
277 const gfx::Rect window2_bounds(3, 4, 5, 6); 278 const gfx::Rect window2_bounds(3, 4, 5, 6);
278 service()->SetWindowType(window2_id, Browser::TYPE_TABBED); 279 service()->SetWindowType(
280 window2_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL);
279 service()->SetWindowBounds(window2_id, 281 service()->SetWindowBounds(window2_id,
280 window2_bounds, 282 window2_bounds,
281 ui::SHOW_STATE_MAXIMIZED); 283 ui::SHOW_STATE_MAXIMIZED);
282 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true); 284 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true);
283 UpdateNavigation(window2_id, tab2_id, nav2, 0, true); 285 UpdateNavigation(window2_id, tab2_id, nav2, 0, true);
284 286
285 ScopedVector<SessionWindow> windows; 287 ScopedVector<SessionWindow> windows;
286 ReadWindows(&(windows.get())); 288 ReadWindows(&(windows.get()));
287 289
288 ASSERT_EQ(2U, windows->size()); 290 ASSERT_EQ(2U, windows->size());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 SessionID tab2_id; 324 SessionID tab2_id;
323 325
324 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), 326 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(),
325 ASCIIToUTF16("abc"), "def", 327 ASCIIToUTF16("abc"), "def",
326 content::PAGE_TRANSITION_QUALIFIER_MASK); 328 content::PAGE_TRANSITION_QUALIFIER_MASK);
327 329
328 helper_.PrepareTabInWindow(window_id, tab1_id, 0, true); 330 helper_.PrepareTabInWindow(window_id, tab1_id, 0, true);
329 UpdateNavigation(window_id, tab1_id, nav1, 0, true); 331 UpdateNavigation(window_id, tab1_id, nav1, 0, true);
330 332
331 const gfx::Rect window2_bounds(3, 4, 5, 6); 333 const gfx::Rect window2_bounds(3, 4, 5, 6);
332 service()->SetWindowType(window2_id, Browser::TYPE_TABBED); 334 service()->SetWindowType(
335 window2_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL);
333 service()->SetWindowBounds(window2_id, 336 service()->SetWindowBounds(window2_id,
334 window2_bounds, 337 window2_bounds,
335 ui::SHOW_STATE_NORMAL); 338 ui::SHOW_STATE_NORMAL);
336 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true); 339 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true);
337 340
338 ScopedVector<SessionWindow> windows; 341 ScopedVector<SessionWindow> windows;
339 ReadWindows(&(windows.get())); 342 ReadWindows(&(windows.get()));
340 343
341 ASSERT_EQ(1U, windows->size()); 344 ASSERT_EQ(1U, windows->size());
342 ASSERT_EQ(0, windows[0]->selected_tab_index); 345 ASSERT_EQ(0, windows[0]->selected_tab_index);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 helper_.AssertTabEquals(window_id, tab2_id, 1, 0, 1, *tab); 387 helper_.AssertTabEquals(window_id, tab2_id, 1, 0, 1, *tab);
385 helper_.AssertNavigationEquals(nav2, tab->navigations[0]); 388 helper_.AssertNavigationEquals(nav2, tab->navigations[0]);
386 } 389 }
387 390
388 TEST_F(SessionServiceTest, WindowCloseCommittedAfterNavigate) { 391 TEST_F(SessionServiceTest, WindowCloseCommittedAfterNavigate) {
389 SessionID window2_id; 392 SessionID window2_id;
390 SessionID tab_id; 393 SessionID tab_id;
391 SessionID tab2_id; 394 SessionID tab2_id;
392 ASSERT_NE(window2_id.id(), window_id.id()); 395 ASSERT_NE(window2_id.id(), window_id.id());
393 396
394 service()->SetWindowType(window2_id, Browser::TYPE_TABBED); 397 service()->SetWindowType(
398 window2_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL);
395 service()->SetWindowBounds(window2_id, 399 service()->SetWindowBounds(window2_id,
396 window_bounds, 400 window_bounds,
397 ui::SHOW_STATE_NORMAL); 401 ui::SHOW_STATE_NORMAL);
398 402
399 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), 403 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(),
400 ASCIIToUTF16("abc"), "def", 404 ASCIIToUTF16("abc"), "def",
401 content::PAGE_TRANSITION_QUALIFIER_MASK); 405 content::PAGE_TRANSITION_QUALIFIER_MASK);
402 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), 406 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(),
403 ASCIIToUTF16("abcd"), "defg", 407 ASCIIToUTF16("abcd"), "defg",
404 content::PAGE_TRANSITION_AUTO_BOOKMARK); 408 content::PAGE_TRANSITION_AUTO_BOOKMARK);
(...skipping 24 matching lines...) Expand all
429 // Makes sure we don't track popups. 433 // Makes sure we don't track popups.
430 TEST_F(SessionServiceTest, IgnorePopups) { 434 TEST_F(SessionServiceTest, IgnorePopups) {
431 if (browser_defaults::kRestorePopups) 435 if (browser_defaults::kRestorePopups)
432 return; // This test is only applicable if popups aren't restored. 436 return; // This test is only applicable if popups aren't restored.
433 437
434 SessionID window2_id; 438 SessionID window2_id;
435 SessionID tab_id; 439 SessionID tab_id;
436 SessionID tab2_id; 440 SessionID tab2_id;
437 ASSERT_NE(window2_id.id(), window_id.id()); 441 ASSERT_NE(window2_id.id(), window_id.id());
438 442
439 service()->SetWindowType(window2_id, Browser::TYPE_POPUP); 443 service()->SetWindowType(
444 window2_id, Browser::TYPE_POPUP, SessionService::TYPE_NORMAL);
440 service()->SetWindowBounds(window2_id, 445 service()->SetWindowBounds(window2_id,
441 window_bounds, 446 window_bounds,
442 ui::SHOW_STATE_NORMAL); 447 ui::SHOW_STATE_NORMAL);
443 448
444 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), 449 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(),
445 ASCIIToUTF16("abc"), "def", 450 ASCIIToUTF16("abc"), "def",
446 content::PAGE_TRANSITION_QUALIFIER_MASK); 451 content::PAGE_TRANSITION_QUALIFIER_MASK);
447 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), 452 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(),
448 ASCIIToUTF16("abcd"), "defg", 453 ASCIIToUTF16("abcd"), "defg",
449 content::PAGE_TRANSITION_AUTO_BOOKMARK); 454 content::PAGE_TRANSITION_AUTO_BOOKMARK);
(...skipping 20 matching lines...) Expand all
470 // Makes sure we track popups. 475 // Makes sure we track popups.
471 TEST_F(SessionServiceTest, RestorePopup) { 476 TEST_F(SessionServiceTest, RestorePopup) {
472 if (!browser_defaults::kRestorePopups) 477 if (!browser_defaults::kRestorePopups)
473 return; // This test is only applicable if popups are restored. 478 return; // This test is only applicable if popups are restored.
474 479
475 SessionID window2_id; 480 SessionID window2_id;
476 SessionID tab_id; 481 SessionID tab_id;
477 SessionID tab2_id; 482 SessionID tab2_id;
478 ASSERT_NE(window2_id.id(), window_id.id()); 483 ASSERT_NE(window2_id.id(), window_id.id());
479 484
480 service()->SetWindowType(window2_id, Browser::TYPE_POPUP); 485 service()->SetWindowType(
486 window2_id, Browser::TYPE_POPUP, SessionService::TYPE_NORMAL);
481 service()->SetWindowBounds(window2_id, 487 service()->SetWindowBounds(window2_id,
482 window_bounds, 488 window_bounds,
483 ui::SHOW_STATE_NORMAL); 489 ui::SHOW_STATE_NORMAL);
484 490
485 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), 491 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(),
486 ASCIIToUTF16("abc"), "def", 492 ASCIIToUTF16("abc"), "def",
487 content::PAGE_TRANSITION_QUALIFIER_MASK); 493 content::PAGE_TRANSITION_QUALIFIER_MASK);
488 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(), 494 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(),
489 ASCIIToUTF16("abcd"), "defg", 495 ASCIIToUTF16("abcd"), "defg",
490 content::PAGE_TRANSITION_AUTO_BOOKMARK); 496 content::PAGE_TRANSITION_AUTO_BOOKMARK);
(...skipping 21 matching lines...) Expand all
512 518
513 ASSERT_EQ(0, windows[popup_index]->selected_tab_index); 519 ASSERT_EQ(0, windows[popup_index]->selected_tab_index);
514 ASSERT_EQ(window2_id.id(), windows[popup_index]->window_id.id()); 520 ASSERT_EQ(window2_id.id(), windows[popup_index]->window_id.id());
515 ASSERT_EQ(1U, windows[popup_index]->tabs.size()); 521 ASSERT_EQ(1U, windows[popup_index]->tabs.size());
516 522
517 tab = windows[popup_index]->tabs[0]; 523 tab = windows[popup_index]->tabs[0];
518 helper_.AssertTabEquals(window2_id, tab2_id, 0, 0, 1, *tab); 524 helper_.AssertTabEquals(window2_id, tab2_id, 0, 0, 1, *tab);
519 helper_.AssertNavigationEquals(nav2, tab->navigations[0]); 525 helper_.AssertNavigationEquals(nav2, tab->navigations[0]);
520 } 526 }
521 527
528 #if defined (USE_AURA)
529 // Makes sure we track apps. Only applicable on aura.
530 TEST_F(SessionServiceTest, RestoreApp) {
531 SessionID window2_id;
532 SessionID tab_id;
533 SessionID tab2_id;
534 ASSERT_NE(window2_id.id(), window_id.id());
535
536 service()->SetWindowType(
537 window2_id, Browser::TYPE_POPUP, SessionService::TYPE_APP);
538 service()->SetWindowBounds(window2_id,
539 window_bounds,
540 ui::SHOW_STATE_NORMAL);
541 service()->SetWindowAppName(window2_id, "TestApp");
542
543 TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(),
544 ASCIIToUTF16("abc"), "def",
545 content::PAGE_TRANSITION_QUALIFIER_MASK);
546 TabNavigation nav2(0, GURL("http://google2.com"), content::Referrer(),
547 ASCIIToUTF16("abcd"), "defg",
548 content::PAGE_TRANSITION_AUTO_BOOKMARK);
549
550 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
551 UpdateNavigation(window_id, tab_id, nav1, 0, true);
552
553 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, false);
554 UpdateNavigation(window2_id, tab2_id, nav2, 0, true);
555
556 ScopedVector<SessionWindow> windows;
557 ReadWindows(&(windows.get()));
558
559 ASSERT_EQ(2U, windows->size());
560 int tabbed_index = windows[0]->type == Browser::TYPE_TABBED ?
561 0 : 1;
562 int app_index = tabbed_index == 0 ? 1 : 0;
563 ASSERT_EQ(0, windows[tabbed_index]->selected_tab_index);
564 ASSERT_EQ(window_id.id(), windows[tabbed_index]->window_id.id());
565 ASSERT_EQ(1U, windows[tabbed_index]->tabs.size());
566
567 SessionTab* tab = windows[tabbed_index]->tabs[0];
568 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
569 helper_.AssertNavigationEquals(nav1, tab->navigations[0]);
570
571 ASSERT_EQ(0, windows[app_index]->selected_tab_index);
572 ASSERT_EQ(window2_id.id(), windows[app_index]->window_id.id());
573 ASSERT_EQ(1U, windows[app_index]->tabs.size());
574 ASSERT_EQ(1U, windows[app_index]->type == Browser::TYPE_POPUP);
575 ASSERT_EQ("TestApp", windows[app_index]->app_name);
576
577 tab = windows[app_index]->tabs[0];
578 helper_.AssertTabEquals(window2_id, tab2_id, 0, 0, 1, *tab);
579 helper_.AssertNavigationEquals(nav2, tab->navigations[0]);
580 }
581 #endif
582
522 // Tests pruning from the front. 583 // Tests pruning from the front.
523 TEST_F(SessionServiceTest, PruneFromFront) { 584 TEST_F(SessionServiceTest, PruneFromFront) {
524 const std::string base_url("http://google.com/"); 585 const std::string base_url("http://google.com/");
525 SessionID tab_id; 586 SessionID tab_id;
526 587
527 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 588 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
528 589
529 // Add 5 navigations, with the 4th selected. 590 // Add 5 navigations, with the 4th selected.
530 for (int i = 0; i < 5; ++i) { 591 for (int i = 0; i < 5; ++i) {
531 TabNavigation nav(0, GURL(base_url + base::IntToString(i)), 592 TabNavigation nav(0, GURL(base_url + base::IntToString(i)),
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 797
737 ScopedVector<SessionWindow> windows; 798 ScopedVector<SessionWindow> windows;
738 ReadWindows(&(windows.get())); 799 ReadWindows(&(windows.get()));
739 800
740 helper_.AssertSingleWindowWithSingleTab(windows.get(), 2); 801 helper_.AssertSingleWindowWithSingleTab(windows.get(), 2);
741 802
742 // Expected: the content state of both navigations was saved and restored. 803 // Expected: the content state of both navigations was saved and restored.
743 helper_.AssertNavigationEquals(nav1, windows[0]->tabs[0]->navigations[0]); 804 helper_.AssertNavigationEquals(nav1, windows[0]->tabs[0]->navigations[0]);
744 helper_.AssertNavigationEquals(nav2, windows[0]->tabs[0]->navigations[1]); 805 helper_.AssertNavigationEquals(nav2, windows[0]->tabs[0]->navigations[1]);
745 } 806 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698