| 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_path.h" | 5 #include "base/file_path.h" |
| 6 #include "chrome/browser/defaults.h" | 6 #include "chrome/browser/defaults.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/sessions/tab_restore_service.h" | 8 #include "chrome/browser/sessions/tab_restore_service.h" |
| 9 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 9 #include "chrome/browser/tabs/tab_strip_model.h" | 10 #include "chrome/browser/tabs/tab_strip_model.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/test/in_process_browser_test.h" | 14 #include "chrome/test/in_process_browser_test.h" |
| 14 #include "chrome/test/ui_test_utils.h" | 15 #include "chrome/test/ui_test_utils.h" |
| 15 #include "content/browser/tab_contents/tab_contents.h" | 16 #include "content/browser/tab_contents/tab_contents.h" |
| 16 #include "content/common/page_transition_types.h" | 17 #include "content/common/page_transition_types.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 FilePath(FILE_PATH_LITERAL("title3.html")))); | 120 FilePath(FILE_PATH_LITERAL("title3.html")))); |
| 120 | 121 |
| 121 // Add and navigate three tabs. | 122 // Add and navigate three tabs. |
| 122 ui_test_utils::NavigateToURL(browser(), url1); | 123 ui_test_utils::NavigateToURL(browser(), url1); |
| 123 browser()->AddSelectedTabWithURL(url2, PageTransition::LINK); | 124 browser()->AddSelectedTabWithURL(url2, PageTransition::LINK); |
| 124 ui_test_utils::WaitForNavigationInCurrentTab(browser()); | 125 ui_test_utils::WaitForNavigationInCurrentTab(browser()); |
| 125 | 126 |
| 126 browser()->AddSelectedTabWithURL(url3, PageTransition::LINK); | 127 browser()->AddSelectedTabWithURL(url3, PageTransition::LINK); |
| 127 ui_test_utils::WaitForNavigationInCurrentTab(browser()); | 128 ui_test_utils::WaitForNavigationInCurrentTab(browser()); |
| 128 | 129 |
| 129 TabRestoreService* service = browser()->profile()->GetTabRestoreService(); | 130 TabRestoreService* service = |
| 131 TabRestoreServiceFactory::GetForProfile(browser()->profile()); |
| 130 service->ClearEntries(); | 132 service->ClearEntries(); |
| 131 | 133 |
| 132 browser()->window()->Close(); | 134 browser()->window()->Close(); |
| 133 | 135 |
| 134 // Expect a window with three tabs. | 136 // Expect a window with three tabs. |
| 135 EXPECT_EQ(1U, service->entries().size()); | 137 EXPECT_EQ(1U, service->entries().size()); |
| 136 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type); | 138 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type); |
| 137 const TabRestoreService::Window* window = | 139 const TabRestoreService::Window* window = |
| 138 static_cast<TabRestoreService::Window*>(service->entries().front()); | 140 static_cast<TabRestoreService::Window*>(service->entries().front()); |
| 139 EXPECT_EQ(3U, window->tabs.size()); | 141 EXPECT_EQ(3U, window->tabs.size()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 158 } | 160 } |
| 159 | 161 |
| 160 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, WindowWithOneTab) { | 162 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, WindowWithOneTab) { |
| 161 GURL url(ui_test_utils::GetTestUrl( | 163 GURL url(ui_test_utils::GetTestUrl( |
| 162 FilePath(FilePath::kCurrentDirectory), | 164 FilePath(FilePath::kCurrentDirectory), |
| 163 FilePath(FILE_PATH_LITERAL("title1.html")))); | 165 FilePath(FILE_PATH_LITERAL("title1.html")))); |
| 164 | 166 |
| 165 // Add a single tab. | 167 // Add a single tab. |
| 166 ui_test_utils::NavigateToURL(browser(), url); | 168 ui_test_utils::NavigateToURL(browser(), url); |
| 167 | 169 |
| 168 TabRestoreService* service = browser()->profile()->GetTabRestoreService(); | 170 TabRestoreService* service = |
| 171 TabRestoreServiceFactory::GetForProfile(browser()->profile()); |
| 169 service->ClearEntries(); | 172 service->ClearEntries(); |
| 170 EXPECT_EQ(0U, service->entries().size()); | 173 EXPECT_EQ(0U, service->entries().size()); |
| 171 | 174 |
| 172 // Close the window. | 175 // Close the window. |
| 173 browser()->window()->Close(); | 176 browser()->window()->Close(); |
| 174 | 177 |
| 175 // Expect the window to be converted to a tab by the TRS. | 178 // Expect the window to be converted to a tab by the TRS. |
| 176 EXPECT_EQ(1U, service->entries().size()); | 179 EXPECT_EQ(1U, service->entries().size()); |
| 177 ASSERT_EQ(TabRestoreService::TAB, service->entries().front()->type); | 180 ASSERT_EQ(TabRestoreService::TAB, service->entries().front()->type); |
| 178 const TabRestoreService::Tab* tab = | 181 const TabRestoreService::Tab* tab = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 216 } |
| 214 | 217 |
| 215 // Create a new window, which should trigger session restore. | 218 // Create a new window, which should trigger session restore. |
| 216 incognito_browser->NewWindow(); | 219 incognito_browser->NewWindow(); |
| 217 | 220 |
| 218 // The first tab should have 'url' as its url. | 221 // The first tab should have 'url' as its url. |
| 219 Browser* new_browser = ui_test_utils::WaitForNewBrowser(); | 222 Browser* new_browser = ui_test_utils::WaitForNewBrowser(); |
| 220 ASSERT_TRUE(new_browser); | 223 ASSERT_TRUE(new_browser); |
| 221 EXPECT_EQ(url, new_browser->GetTabContentsAt(0)->GetURL()); | 224 EXPECT_EQ(url, new_browser->GetTabContentsAt(0)->GetURL()); |
| 222 } | 225 } |
| OLD | NEW |