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