| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/process/launch.h" | 9 #include "base/process/launch.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "chrome/test/base/ui_test_utils.h" | 36 #include "chrome/test/base/ui_test_utils.h" |
| 37 #include "components/sessions/serialized_navigation_entry_test_helper.h" | 37 #include "components/sessions/serialized_navigation_entry_test_helper.h" |
| 38 #include "content/public/browser/navigation_controller.h" | 38 #include "content/public/browser/navigation_controller.h" |
| 39 #include "content/public/browser/navigation_entry.h" | 39 #include "content/public/browser/navigation_entry.h" |
| 40 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 41 #include "content/public/browser/notification_types.h" | 41 #include "content/public/browser/notification_types.h" |
| 42 #include "content/public/browser/render_process_host.h" | 42 #include "content/public/browser/render_process_host.h" |
| 43 #include "content/public/browser/render_view_host.h" | 43 #include "content/public/browser/render_view_host.h" |
| 44 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
| 45 #include "content/public/common/bindings_policy.h" | 45 #include "content/public/common/bindings_policy.h" |
| 46 #include "content/public/common/page_transition_types.h" | |
| 47 #include "content/public/test/browser_test_utils.h" | 46 #include "content/public/test/browser_test_utils.h" |
| 48 #include "content/public/test/test_navigation_observer.h" | 47 #include "content/public/test/test_navigation_observer.h" |
| 49 #include "sync/protocol/session_specifics.pb.h" | 48 #include "sync/protocol/session_specifics.pb.h" |
| 49 #include "ui/base/page_transition_types.h" |
| 50 | 50 |
| 51 using sessions::SerializedNavigationEntry; | 51 using sessions::SerializedNavigationEntry; |
| 52 using sessions::SerializedNavigationEntryTestHelper; | 52 using sessions::SerializedNavigationEntryTestHelper; |
| 53 | 53 |
| 54 #if defined(OS_MACOSX) | 54 #if defined(OS_MACOSX) |
| 55 #include "base/mac/scoped_nsautorelease_pool.h" | 55 #include "base/mac/scoped_nsautorelease_pool.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 #if defined(USE_AURA) | 58 #if defined(USE_AURA) |
| 59 #include "ui/aura/window.h" | 59 #include "ui/aura/window.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // Create a new window, which should trigger session restore. | 137 // Create a new window, which should trigger session restore. |
| 138 ui_test_utils::BrowserAddedObserver window_observer; | 138 ui_test_utils::BrowserAddedObserver window_observer; |
| 139 content::WindowedNotificationObserver restore_observer( | 139 content::WindowedNotificationObserver restore_observer( |
| 140 chrome::NOTIFICATION_SESSION_RESTORE_DONE, | 140 chrome::NOTIFICATION_SESSION_RESTORE_DONE, |
| 141 content::NotificationService::AllSources()); | 141 content::NotificationService::AllSources()); |
| 142 if (url.is_empty()) { | 142 if (url.is_empty()) { |
| 143 chrome::NewEmptyWindow(profile, chrome::HOST_DESKTOP_TYPE_NATIVE); | 143 chrome::NewEmptyWindow(profile, chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 144 } else { | 144 } else { |
| 145 chrome::NavigateParams params(profile, | 145 chrome::NavigateParams params(profile, |
| 146 url, | 146 url, |
| 147 content::PAGE_TRANSITION_LINK); | 147 ui::PAGE_TRANSITION_LINK); |
| 148 chrome::Navigate(¶ms); | 148 chrome::Navigate(¶ms); |
| 149 } | 149 } |
| 150 Browser* new_browser = window_observer.WaitForSingleNewBrowser(); | 150 Browser* new_browser = window_observer.WaitForSingleNewBrowser(); |
| 151 restore_observer.Wait(); | 151 restore_observer.Wait(); |
| 152 g_browser_process->ReleaseModule(); | 152 g_browser_process->ReleaseModule(); |
| 153 | 153 |
| 154 return new_browser; | 154 return new_browser; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void GoBack(Browser* browser) { | 157 void GoBack(Browser* browser) { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 base::FilePath(base::FilePath::kCurrentDirectory), | 394 base::FilePath(base::FilePath::kCurrentDirectory), |
| 395 base::FilePath(FILE_PATH_LITERAL("title3.html")))); | 395 base::FilePath(FILE_PATH_LITERAL("title3.html")))); |
| 396 | 396 |
| 397 // Add and navigate three tabs. | 397 // Add and navigate three tabs. |
| 398 ui_test_utils::NavigateToURL(browser(), url1); | 398 ui_test_utils::NavigateToURL(browser(), url1); |
| 399 { | 399 { |
| 400 content::WindowedNotificationObserver observer( | 400 content::WindowedNotificationObserver observer( |
| 401 content::NOTIFICATION_LOAD_STOP, | 401 content::NOTIFICATION_LOAD_STOP, |
| 402 content::NotificationService::AllSources()); | 402 content::NotificationService::AllSources()); |
| 403 chrome::AddSelectedTabWithURL(browser(), url2, | 403 chrome::AddSelectedTabWithURL(browser(), url2, |
| 404 content::PAGE_TRANSITION_LINK); | 404 ui::PAGE_TRANSITION_LINK); |
| 405 observer.Wait(); | 405 observer.Wait(); |
| 406 } | 406 } |
| 407 { | 407 { |
| 408 content::WindowedNotificationObserver observer( | 408 content::WindowedNotificationObserver observer( |
| 409 content::NOTIFICATION_LOAD_STOP, | 409 content::NOTIFICATION_LOAD_STOP, |
| 410 content::NotificationService::AllSources()); | 410 content::NotificationService::AllSources()); |
| 411 chrome::AddSelectedTabWithURL(browser(), url3, | 411 chrome::AddSelectedTabWithURL(browser(), url3, |
| 412 content::PAGE_TRANSITION_LINK); | 412 ui::PAGE_TRANSITION_LINK); |
| 413 observer.Wait(); | 413 observer.Wait(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 TabRestoreService* service = | 416 TabRestoreService* service = |
| 417 TabRestoreServiceFactory::GetForProfile(browser()->profile()); | 417 TabRestoreServiceFactory::GetForProfile(browser()->profile()); |
| 418 service->ClearEntries(); | 418 service->ClearEntries(); |
| 419 | 419 |
| 420 chrome::HostDesktopType host_desktop_type = browser()->host_desktop_type(); | 420 chrome::HostDesktopType host_desktop_type = browser()->host_desktop_type(); |
| 421 | 421 |
| 422 browser()->window()->Close(); | 422 browser()->window()->Close(); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 } | 886 } |
| 887 | 887 |
| 888 // Ensures active tab properly restored when tabs are inserted before it . | 888 // Ensures active tab properly restored when tabs are inserted before it . |
| 889 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ActiveIndexUpdatedAtInsert) { | 889 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ActiveIndexUpdatedAtInsert) { |
| 890 ui_test_utils::NavigateToURL(browser(), url1_); | 890 ui_test_utils::NavigateToURL(browser(), url1_); |
| 891 ui_test_utils::NavigateToURLWithDisposition( | 891 ui_test_utils::NavigateToURLWithDisposition( |
| 892 browser(), url2_, NEW_BACKGROUND_TAB, | 892 browser(), url2_, NEW_BACKGROUND_TAB, |
| 893 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 893 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 894 | 894 |
| 895 chrome::NavigateParams navigate_params(browser(), url3_, | 895 chrome::NavigateParams navigate_params(browser(), url3_, |
| 896 content::PAGE_TRANSITION_TYPED); | 896 ui::PAGE_TRANSITION_TYPED); |
| 897 navigate_params.tabstrip_index = 0; | 897 navigate_params.tabstrip_index = 0; |
| 898 navigate_params.disposition = NEW_BACKGROUND_TAB; | 898 navigate_params.disposition = NEW_BACKGROUND_TAB; |
| 899 ui_test_utils::NavigateToURL(&navigate_params); | 899 ui_test_utils::NavigateToURL(&navigate_params); |
| 900 | 900 |
| 901 Browser* new_browser = QuitBrowserAndRestore(browser(), 3); | 901 Browser* new_browser = QuitBrowserAndRestore(browser(), 3); |
| 902 | 902 |
| 903 ASSERT_EQ(url1_, | 903 ASSERT_EQ(url1_, |
| 904 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); | 904 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 905 ASSERT_EQ(new_browser->tab_strip_model()->active_index(), 1); | 905 ASSERT_EQ(new_browser->tab_strip_model()->active_index(), 1); |
| 906 } | 906 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 content::NavigationController* controller = | 1194 content::NavigationController* controller = |
| 1195 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); | 1195 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); |
| 1196 EXPECT_TRUE( | 1196 EXPECT_TRUE( |
| 1197 controller->GetDefaultSessionStorageNamespace()->should_persist()); | 1197 controller->GetDefaultSessionStorageNamespace()->should_persist()); |
| 1198 | 1198 |
| 1199 // Quit and restore. Check that no extra tabs were created. | 1199 // Quit and restore. Check that no extra tabs were created. |
| 1200 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 1200 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
| 1201 ASSERT_EQ(1u, active_browser_list_->size()); | 1201 ASSERT_EQ(1u, active_browser_list_->size()); |
| 1202 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); | 1202 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); |
| 1203 } | 1203 } |
| OLD | NEW |