| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/memory_pressure_listener.h" | 9 #include "base/memory/memory_pressure_listener.h" |
| 10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/ui/browser_list.h" | 27 #include "chrome/browser/ui/browser_list.h" |
| 28 #include "chrome/browser/ui/browser_tabstrip.h" | 28 #include "chrome/browser/ui/browser_tabstrip.h" |
| 29 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
| 30 #include "chrome/browser/ui/host_desktop.h" | 30 #include "chrome/browser/ui/host_desktop.h" |
| 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/test/base/in_process_browser_test.h" | 34 #include "chrome/test/base/in_process_browser_test.h" |
| 35 #include "chrome/test/base/test_switches.h" | 35 #include "chrome/test/base/test_switches.h" |
| 36 #include "chrome/test/base/ui_test_utils.h" | 36 #include "chrome/test/base/ui_test_utils.h" |
| 37 #include "components/sessions/content/content_live_tab.h" |
| 37 #include "components/sessions/serialized_navigation_entry_test_helper.h" | 38 #include "components/sessions/serialized_navigation_entry_test_helper.h" |
| 38 #include "components/sessions/session_types.h" | 39 #include "components/sessions/session_types.h" |
| 39 #include "content/public/browser/navigation_controller.h" | 40 #include "content/public/browser/navigation_controller.h" |
| 40 #include "content/public/browser/navigation_entry.h" | 41 #include "content/public/browser/navigation_entry.h" |
| 41 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
| 42 #include "content/public/browser/notification_types.h" | 43 #include "content/public/browser/notification_types.h" |
| 43 #include "content/public/browser/render_process_host.h" | 44 #include "content/public/browser/render_process_host.h" |
| 44 #include "content/public/browser/render_view_host.h" | 45 #include "content/public/browser/render_view_host.h" |
| 45 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 46 #include "content/public/common/bindings_policy.h" | 47 #include "content/public/common/bindings_policy.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 // there is no guarantee that the SessionID for the tab has remained the same. | 524 // there is no guarantee that the SessionID for the tab has remained the same. |
| 524 base::Time timestamp; | 525 base::Time timestamp; |
| 525 int http_status_code = 0; | 526 int http_status_code = 0; |
| 526 for (std::vector<TabRestoreService::Tab>::const_iterator it = | 527 for (std::vector<TabRestoreService::Tab>::const_iterator it = |
| 527 window->tabs.begin(); it != window->tabs.end(); ++it) { | 528 window->tabs.begin(); it != window->tabs.end(); ++it) { |
| 528 const TabRestoreService::Tab& tab = *it; | 529 const TabRestoreService::Tab& tab = *it; |
| 529 // If this tab held url2, then restore this single tab. | 530 // If this tab held url2, then restore this single tab. |
| 530 if (tab.navigations[0].virtual_url() == url2) { | 531 if (tab.navigations[0].virtual_url() == url2) { |
| 531 timestamp = tab.navigations[0].timestamp(); | 532 timestamp = tab.navigations[0].timestamp(); |
| 532 http_status_code = tab.navigations[0].http_status_code(); | 533 http_status_code = tab.navigations[0].http_status_code(); |
| 533 std::vector<content::WebContents*> content = | 534 std::vector<sessions::LiveTab*> content = |
| 534 service->RestoreEntryById(NULL, tab.id, host_desktop_type, UNKNOWN); | 535 service->RestoreEntryById(NULL, tab.id, host_desktop_type, UNKNOWN); |
| 535 ASSERT_EQ(1U, content.size()); | 536 ASSERT_EQ(1U, content.size()); |
| 536 ASSERT_TRUE(content[0]); | 537 ASSERT_TRUE(content[0]); |
| 537 EXPECT_EQ(url2, content[0]->GetURL()); | 538 EXPECT_EQ(url2, static_cast<sessions::ContentLiveTab*>(content[0]) |
| 539 ->web_contents() |
| 540 ->GetURL()); |
| 538 break; | 541 break; |
| 539 } | 542 } |
| 540 } | 543 } |
| 541 EXPECT_FALSE(timestamp.is_null()); | 544 EXPECT_FALSE(timestamp.is_null()); |
| 542 EXPECT_EQ(200, http_status_code); | 545 EXPECT_EQ(200, http_status_code); |
| 543 | 546 |
| 544 // Make sure that the restored tab is removed from the service. | 547 // Make sure that the restored tab is removed from the service. |
| 545 ASSERT_EQ(1U, service->entries().size()); | 548 ASSERT_EQ(1U, service->entries().size()); |
| 546 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type); | 549 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type); |
| 547 window = static_cast<TabRestoreService::Window*>(service->entries().front()); | 550 window = static_cast<TabRestoreService::Window*>(service->entries().front()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 577 // Close the window. | 580 // Close the window. |
| 578 browser()->window()->Close(); | 581 browser()->window()->Close(); |
| 579 | 582 |
| 580 // Expect the window to be converted to a tab by the TRS. | 583 // Expect the window to be converted to a tab by the TRS. |
| 581 EXPECT_EQ(1U, service->entries().size()); | 584 EXPECT_EQ(1U, service->entries().size()); |
| 582 ASSERT_EQ(TabRestoreService::TAB, service->entries().front()->type); | 585 ASSERT_EQ(TabRestoreService::TAB, service->entries().front()->type); |
| 583 const TabRestoreService::Tab* tab = | 586 const TabRestoreService::Tab* tab = |
| 584 static_cast<TabRestoreService::Tab*>(service->entries().front()); | 587 static_cast<TabRestoreService::Tab*>(service->entries().front()); |
| 585 | 588 |
| 586 // Restore the tab. | 589 // Restore the tab. |
| 587 std::vector<content::WebContents*> content = | 590 std::vector<sessions::LiveTab*> content = |
| 588 service->RestoreEntryById(NULL, tab->id, host_desktop_type, UNKNOWN); | 591 service->RestoreEntryById(NULL, tab->id, host_desktop_type, UNKNOWN); |
| 589 ASSERT_EQ(1U, content.size()); | 592 ASSERT_EQ(1U, content.size()); |
| 590 ASSERT_TRUE(content[0]); | 593 ASSERT_TRUE(content[0]); |
| 591 EXPECT_EQ(url, content[0]->GetURL()); | 594 EXPECT_EQ(url, static_cast<sessions::ContentLiveTab*>(content[0]) |
| 595 ->web_contents() |
| 596 ->GetURL()); |
| 592 | 597 |
| 593 // Make sure the restore was successful. | 598 // Make sure the restore was successful. |
| 594 EXPECT_EQ(0U, service->entries().size()); | 599 EXPECT_EQ(0U, service->entries().size()); |
| 595 } | 600 } |
| 596 | 601 |
| 597 #if !defined(OS_CHROMEOS) | 602 #if !defined(OS_CHROMEOS) |
| 598 // This test does not apply to ChromeOS as ChromeOS does not do session | 603 // This test does not apply to ChromeOS as ChromeOS does not do session |
| 599 // restore when a new window is open. | 604 // restore when a new window is open. |
| 600 | 605 |
| 601 // Verifies we remember the last browser window when closing the last | 606 // Verifies we remember the last browser window when closing the last |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 // automatically at the start of the test. | 1509 // automatically at the start of the test. |
| 1505 for (size_t i = 1; i < web_contents().size(); i++) { | 1510 for (size_t i = 1; i < web_contents().size(); i++) { |
| 1506 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); | 1511 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); |
| 1507 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); | 1512 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); |
| 1508 if (i > 0) { | 1513 if (i > 0) { |
| 1509 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), | 1514 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), |
| 1510 web_contents()[i]->GetLastActiveTime()); | 1515 web_contents()[i]->GetLastActiveTime()); |
| 1511 } | 1516 } |
| 1512 } | 1517 } |
| 1513 } | 1518 } |
| OLD | NEW |