| 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" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "content/browser/tab_contents/tab_contents.h" | 16 #include "content/browser/tab_contents/tab_contents.h" |
| 17 #include "content/common/page_transition_types.h" | 17 #include "content/public/common/page_transition_types.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // BrowserList::Observer implementation that waits for a browser to be | 21 // BrowserList::Observer implementation that waits for a browser to be |
| 22 // removed. | 22 // removed. |
| 23 class BrowserListObserverImpl : public BrowserList::Observer { | 23 class BrowserListObserverImpl : public BrowserList::Observer { |
| 24 public: | 24 public: |
| 25 BrowserListObserverImpl() : did_remove_(false), running_(false) { | 25 BrowserListObserverImpl() : did_remove_(false), running_(false) { |
| 26 BrowserList::AddObserver(this); | 26 BrowserList::AddObserver(this); |
| 27 } | 27 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 FilePath(FILE_PATH_LITERAL("title2.html")))); | 117 FilePath(FILE_PATH_LITERAL("title2.html")))); |
| 118 GURL url3(ui_test_utils::GetTestUrl( | 118 GURL url3(ui_test_utils::GetTestUrl( |
| 119 FilePath(FilePath::kCurrentDirectory), | 119 FilePath(FilePath::kCurrentDirectory), |
| 120 FilePath(FILE_PATH_LITERAL("title3.html")))); | 120 FilePath(FILE_PATH_LITERAL("title3.html")))); |
| 121 | 121 |
| 122 // Add and navigate three tabs. | 122 // Add and navigate three tabs. |
| 123 ui_test_utils::NavigateToURL(browser(), url1); | 123 ui_test_utils::NavigateToURL(browser(), url1); |
| 124 { | 124 { |
| 125 ui_test_utils::WindowedNotificationObserver observer( | 125 ui_test_utils::WindowedNotificationObserver observer( |
| 126 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 126 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 127 browser()->AddSelectedTabWithURL(url2, PageTransition::LINK); | 127 browser()->AddSelectedTabWithURL(url2, content::PAGE_TRANSITION_LINK); |
| 128 observer.Wait(); | 128 observer.Wait(); |
| 129 } | 129 } |
| 130 { | 130 { |
| 131 ui_test_utils::WindowedNotificationObserver observer( | 131 ui_test_utils::WindowedNotificationObserver observer( |
| 132 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 132 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 133 browser()->AddSelectedTabWithURL(url3, PageTransition::LINK); | 133 browser()->AddSelectedTabWithURL(url3, content::PAGE_TRANSITION_LINK); |
| 134 observer.Wait(); | 134 observer.Wait(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 TabRestoreService* service = | 137 TabRestoreService* service = |
| 138 TabRestoreServiceFactory::GetForProfile(browser()->profile()); | 138 TabRestoreServiceFactory::GetForProfile(browser()->profile()); |
| 139 service->ClearEntries(); | 139 service->ClearEntries(); |
| 140 | 140 |
| 141 browser()->window()->Close(); | 141 browser()->window()->Close(); |
| 142 | 142 |
| 143 // Expect a window with three tabs. | 143 // Expect a window with three tabs. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 223 } |
| 224 | 224 |
| 225 // Create a new window, which should trigger session restore. | 225 // Create a new window, which should trigger session restore. |
| 226 incognito_browser->NewWindow(); | 226 incognito_browser->NewWindow(); |
| 227 | 227 |
| 228 // The first tab should have 'url' as its url. | 228 // The first tab should have 'url' as its url. |
| 229 Browser* new_browser = ui_test_utils::WaitForNewBrowser(); | 229 Browser* new_browser = ui_test_utils::WaitForNewBrowser(); |
| 230 ASSERT_TRUE(new_browser); | 230 ASSERT_TRUE(new_browser); |
| 231 EXPECT_EQ(url, new_browser->GetTabContentsAt(0)->GetURL()); | 231 EXPECT_EQ(url, new_browser->GetTabContentsAt(0)->GetURL()); |
| 232 } | 232 } |
| OLD | NEW |