OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 content::NotificationService::AllSources()); | 530 content::NotificationService::AllSources()); |
531 chrome::AddSelectedTabWithURL(browser(), url3, | 531 chrome::AddSelectedTabWithURL(browser(), url3, |
532 ui::PAGE_TRANSITION_LINK); | 532 ui::PAGE_TRANSITION_LINK); |
533 observer.Wait(); | 533 observer.Wait(); |
534 } | 534 } |
535 | 535 |
536 sessions::TabRestoreService* service = | 536 sessions::TabRestoreService* service = |
537 TabRestoreServiceFactory::GetForProfile(browser()->profile()); | 537 TabRestoreServiceFactory::GetForProfile(browser()->profile()); |
538 service->ClearEntries(); | 538 service->ClearEntries(); |
539 | 539 |
540 chrome::HostDesktopType host_desktop_type = browser()->host_desktop_type(); | |
541 | |
542 browser()->window()->Close(); | 540 browser()->window()->Close(); |
543 | 541 |
544 // Expect a window with three tabs. | 542 // Expect a window with three tabs. |
545 ASSERT_EQ(1U, service->entries().size()); | 543 ASSERT_EQ(1U, service->entries().size()); |
546 ASSERT_EQ(sessions::TabRestoreService::WINDOW, | 544 ASSERT_EQ(sessions::TabRestoreService::WINDOW, |
547 service->entries().front()->type); | 545 service->entries().front()->type); |
548 const sessions::TabRestoreService::Window* window = | 546 const sessions::TabRestoreService::Window* window = |
549 static_cast<sessions::TabRestoreService::Window*>( | 547 static_cast<sessions::TabRestoreService::Window*>( |
550 service->entries().front()); | 548 service->entries().front()); |
551 EXPECT_EQ(3U, window->tabs.size()); | 549 EXPECT_EQ(3U, window->tabs.size()); |
552 | 550 |
553 // Find the SessionID for entry2. Since the session service was destroyed, | 551 // Find the SessionID for entry2. Since the session service was destroyed, |
554 // there is no guarantee that the SessionID for the tab has remained the same. | 552 // there is no guarantee that the SessionID for the tab has remained the same. |
555 base::Time timestamp; | 553 base::Time timestamp; |
556 int http_status_code = 0; | 554 int http_status_code = 0; |
557 for (const sessions::TabRestoreService::Tab& tab : window->tabs) { | 555 for (const sessions::TabRestoreService::Tab& tab : window->tabs) { |
558 // If this tab held url2, then restore this single tab. | 556 // If this tab held url2, then restore this single tab. |
559 if (tab.navigations[0].virtual_url() == url2) { | 557 if (tab.navigations[0].virtual_url() == url2) { |
560 timestamp = tab.navigations[0].timestamp(); | 558 timestamp = tab.navigations[0].timestamp(); |
561 http_status_code = tab.navigations[0].http_status_code(); | 559 http_status_code = tab.navigations[0].http_status_code(); |
562 std::vector<sessions::LiveTab*> content = | 560 std::vector<sessions::LiveTab*> content = |
563 service->RestoreEntryById(NULL, tab.id, host_desktop_type, UNKNOWN); | 561 service->RestoreEntryById(NULL, tab.id, UNKNOWN); |
564 ASSERT_EQ(1U, content.size()); | 562 ASSERT_EQ(1U, content.size()); |
565 sessions::ContentLiveTab* live_tab = | 563 sessions::ContentLiveTab* live_tab = |
566 static_cast<sessions::ContentLiveTab*>(content[0]); | 564 static_cast<sessions::ContentLiveTab*>(content[0]); |
567 ASSERT_TRUE(live_tab); | 565 ASSERT_TRUE(live_tab); |
568 EXPECT_EQ(url2, live_tab->web_contents()->GetURL()); | 566 EXPECT_EQ(url2, live_tab->web_contents()->GetURL()); |
569 break; | 567 break; |
570 } | 568 } |
571 } | 569 } |
572 EXPECT_FALSE(timestamp.is_null()); | 570 EXPECT_FALSE(timestamp.is_null()); |
573 EXPECT_EQ(200, http_status_code); | 571 EXPECT_EQ(200, http_status_code); |
(...skipping 30 matching lines...) Expand all Loading... |
604 base::FilePath(FILE_PATH_LITERAL("title1.html")))); | 602 base::FilePath(FILE_PATH_LITERAL("title1.html")))); |
605 | 603 |
606 // Add a single tab. | 604 // Add a single tab. |
607 ui_test_utils::NavigateToURL(browser(), url); | 605 ui_test_utils::NavigateToURL(browser(), url); |
608 | 606 |
609 sessions::TabRestoreService* service = | 607 sessions::TabRestoreService* service = |
610 TabRestoreServiceFactory::GetForProfile(browser()->profile()); | 608 TabRestoreServiceFactory::GetForProfile(browser()->profile()); |
611 service->ClearEntries(); | 609 service->ClearEntries(); |
612 EXPECT_EQ(0U, service->entries().size()); | 610 EXPECT_EQ(0U, service->entries().size()); |
613 | 611 |
614 chrome::HostDesktopType host_desktop_type = browser()->host_desktop_type(); | |
615 | |
616 // Close the window. | 612 // Close the window. |
617 browser()->window()->Close(); | 613 browser()->window()->Close(); |
618 | 614 |
619 // Expect the window to be converted to a tab by the TRS. | 615 // Expect the window to be converted to a tab by the TRS. |
620 EXPECT_EQ(1U, service->entries().size()); | 616 EXPECT_EQ(1U, service->entries().size()); |
621 ASSERT_EQ(sessions::TabRestoreService::TAB, service->entries().front()->type); | 617 ASSERT_EQ(sessions::TabRestoreService::TAB, service->entries().front()->type); |
622 const sessions::TabRestoreService::Tab* tab = | 618 const sessions::TabRestoreService::Tab* tab = |
623 static_cast<sessions::TabRestoreService::Tab*>( | 619 static_cast<sessions::TabRestoreService::Tab*>( |
624 service->entries().front()); | 620 service->entries().front()); |
625 | 621 |
626 // Restore the tab. | 622 // Restore the tab. |
627 std::vector<sessions::LiveTab*> content = | 623 std::vector<sessions::LiveTab*> content = |
628 service->RestoreEntryById(NULL, tab->id, host_desktop_type, UNKNOWN); | 624 service->RestoreEntryById(NULL, tab->id, UNKNOWN); |
629 ASSERT_EQ(1U, content.size()); | 625 ASSERT_EQ(1U, content.size()); |
630 ASSERT_TRUE(content[0]); | 626 ASSERT_TRUE(content[0]); |
631 EXPECT_EQ(url, static_cast<sessions::ContentLiveTab*>(content[0]) | 627 EXPECT_EQ(url, static_cast<sessions::ContentLiveTab*>(content[0]) |
632 ->web_contents() | 628 ->web_contents() |
633 ->GetURL()); | 629 ->GetURL()); |
634 | 630 |
635 // Make sure the restore was successful. | 631 // Make sure the restore was successful. |
636 EXPECT_EQ(0U, service->entries().size()); | 632 EXPECT_EQ(0U, service->entries().size()); |
637 } | 633 } |
638 | 634 |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 // automatically at the start of the test. | 1474 // automatically at the start of the test. |
1479 for (size_t i = 1; i < web_contents().size(); i++) { | 1475 for (size_t i = 1; i < web_contents().size(); i++) { |
1480 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); | 1476 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); |
1481 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); | 1477 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); |
1482 if (i > 0) { | 1478 if (i > 0) { |
1483 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), | 1479 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), |
1484 web_contents()[i]->GetLastActiveTime()); | 1480 web_contents()[i]->GetLastActiveTime()); |
1485 } | 1481 } |
1486 } | 1482 } |
1487 } | 1483 } |
OLD | NEW |