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/sessions/tab_restore_service_factory.h" |
10 #include "chrome/browser/tabs/tab_strip_model.h" | 10 #include "chrome/browser/tabs/tab_strip_model.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 static_cast<TabRestoreService::Window*>(service->entries().front()); | 151 static_cast<TabRestoreService::Window*>(service->entries().front()); |
152 EXPECT_EQ(3U, window->tabs.size()); | 152 EXPECT_EQ(3U, window->tabs.size()); |
153 | 153 |
154 // Find the SessionID for entry2. Since the session service was destroyed, | 154 // Find the SessionID for entry2. Since the session service was destroyed, |
155 // there is no guarantee that the SessionID for the tab has remained the same. | 155 // there is no guarantee that the SessionID for the tab has remained the same. |
156 std::vector<TabRestoreService::Tab>::const_iterator it = window->tabs.begin(); | 156 std::vector<TabRestoreService::Tab>::const_iterator it = window->tabs.begin(); |
157 for ( ; it != window->tabs.end(); ++it) { | 157 for ( ; it != window->tabs.end(); ++it) { |
158 const TabRestoreService::Tab& tab = *it; | 158 const TabRestoreService::Tab& tab = *it; |
159 // If this tab held url2, then restore this single tab. | 159 // If this tab held url2, then restore this single tab. |
160 if (tab.navigations[0].virtual_url() == url2) { | 160 if (tab.navigations[0].virtual_url() == url2) { |
161 service->RestoreEntryById(NULL, tab.id, false); | 161 service->RestoreEntryById(NULL, tab.id, UNKNOWN); |
162 break; | 162 break; |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 // Make sure that the Window got updated. | 166 // Make sure that the Window got updated. |
167 EXPECT_EQ(1U, service->entries().size()); | 167 EXPECT_EQ(1U, service->entries().size()); |
168 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type); | 168 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type); |
169 window = static_cast<TabRestoreService::Window*>(service->entries().front()); | 169 window = static_cast<TabRestoreService::Window*>(service->entries().front()); |
170 EXPECT_EQ(2U, window->tabs.size()); | 170 EXPECT_EQ(2U, window->tabs.size()); |
171 } | 171 } |
(...skipping 14 matching lines...) Expand all Loading... |
186 // Close the window. | 186 // Close the window. |
187 browser()->window()->Close(); | 187 browser()->window()->Close(); |
188 | 188 |
189 // Expect the window to be converted to a tab by the TRS. | 189 // Expect the window to be converted to a tab by the TRS. |
190 EXPECT_EQ(1U, service->entries().size()); | 190 EXPECT_EQ(1U, service->entries().size()); |
191 ASSERT_EQ(TabRestoreService::TAB, service->entries().front()->type); | 191 ASSERT_EQ(TabRestoreService::TAB, service->entries().front()->type); |
192 const TabRestoreService::Tab* tab = | 192 const TabRestoreService::Tab* tab = |
193 static_cast<TabRestoreService::Tab*>(service->entries().front()); | 193 static_cast<TabRestoreService::Tab*>(service->entries().front()); |
194 | 194 |
195 // Restore the tab. | 195 // Restore the tab. |
196 service->RestoreEntryById(NULL, tab->id, false); | 196 service->RestoreEntryById(NULL, tab->id, UNKNOWN); |
197 | 197 |
198 // Make sure the restore was successful. | 198 // Make sure the restore was successful. |
199 EXPECT_EQ(0U, service->entries().size()); | 199 EXPECT_EQ(0U, service->entries().size()); |
200 } | 200 } |
201 | 201 |
202 // Verifies we remember the last browser window when closing the last | 202 // Verifies we remember the last browser window when closing the last |
203 // non-incognito window while an incognito window is open. | 203 // non-incognito window while an incognito window is open. |
204 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, IncognitotoNonIncognito) { | 204 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, IncognitotoNonIncognito) { |
205 // Turn on session restore. | 205 // Turn on session restore. |
206 SessionStartupPref pref(SessionStartupPref::LAST); | 206 SessionStartupPref pref(SessionStartupPref::LAST); |
(...skipping 20 matching lines...) Expand all Loading... |
227 } | 227 } |
228 | 228 |
229 // Create a new window, which should trigger session restore. | 229 // Create a new window, which should trigger session restore. |
230 incognito_browser->NewWindow(); | 230 incognito_browser->NewWindow(); |
231 | 231 |
232 // The first tab should have 'url' as its url. | 232 // The first tab should have 'url' as its url. |
233 Browser* new_browser = ui_test_utils::WaitForNewBrowser(); | 233 Browser* new_browser = ui_test_utils::WaitForNewBrowser(); |
234 ASSERT_TRUE(new_browser); | 234 ASSERT_TRUE(new_browser); |
235 EXPECT_EQ(url, new_browser->GetTabContentsAt(0)->GetURL()); | 235 EXPECT_EQ(url, new_browser->GetTabContentsAt(0)->GetURL()); |
236 } | 236 } |
OLD | NEW |