| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "chrome/test/base/ui_test_utils.h" | 45 #include "chrome/test/base/ui_test_utils.h" |
| 46 #include "components/sessions/content/content_live_tab.h" | 46 #include "components/sessions/content/content_live_tab.h" |
| 47 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" | 47 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" |
| 48 #include "components/sessions/core/session_types.h" | 48 #include "components/sessions/core/session_types.h" |
| 49 #include "components/sessions/core/tab_restore_service.h" | 49 #include "components/sessions/core/tab_restore_service.h" |
| 50 #include "components/sync/protocol/session_specifics.pb.h" | 50 #include "components/sync/protocol/session_specifics.pb.h" |
| 51 #include "content/public/browser/navigation_controller.h" | 51 #include "content/public/browser/navigation_controller.h" |
| 52 #include "content/public/browser/navigation_entry.h" | 52 #include "content/public/browser/navigation_entry.h" |
| 53 #include "content/public/browser/notification_service.h" | 53 #include "content/public/browser/notification_service.h" |
| 54 #include "content/public/browser/notification_types.h" | 54 #include "content/public/browser/notification_types.h" |
| 55 #include "content/public/browser/render_frame_host.h" |
| 55 #include "content/public/browser/render_process_host.h" | 56 #include "content/public/browser/render_process_host.h" |
| 56 #include "content/public/browser/render_view_host.h" | 57 #include "content/public/browser/render_view_host.h" |
| 57 #include "content/public/browser/web_contents.h" | 58 #include "content/public/browser/web_contents.h" |
| 58 #include "content/public/common/bindings_policy.h" | 59 #include "content/public/common/bindings_policy.h" |
| 59 #include "content/public/test/browser_test_utils.h" | 60 #include "content/public/test/browser_test_utils.h" |
| 60 #include "content/public/test/download_test_observer.h" | 61 #include "content/public/test/download_test_observer.h" |
| 61 #include "content/public/test/test_navigation_observer.h" | 62 #include "content/public/test/test_navigation_observer.h" |
| 62 #include "net/test/embedded_test_server/embedded_test_server.h" | 63 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 63 #include "ui/base/page_transition_types.h" | 64 #include "ui/base/page_transition_types.h" |
| 64 | 65 |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 // At least one of the render widgets should not be initialized yet. | 940 // At least one of the render widgets should not be initialized yet. |
| 940 ASSERT_FALSE( | 941 ASSERT_FALSE( |
| 941 tab_strip_model->GetWebContentsAt(0)->GetRenderWidgetHostView() && | 942 tab_strip_model->GetWebContentsAt(0)->GetRenderWidgetHostView() && |
| 942 tab_strip_model->GetWebContentsAt(1)->GetRenderWidgetHostView() && | 943 tab_strip_model->GetWebContentsAt(1)->GetRenderWidgetHostView() && |
| 943 tab_strip_model->GetWebContentsAt(2)->GetRenderWidgetHostView()); | 944 tab_strip_model->GetWebContentsAt(2)->GetRenderWidgetHostView()); |
| 944 } | 945 } |
| 945 | 946 |
| 946 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUI) { | 947 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUI) { |
| 947 const GURL webui_url("chrome://omnibox"); | 948 const GURL webui_url("chrome://omnibox"); |
| 948 ui_test_utils::NavigateToURL(browser(), webui_url); | 949 ui_test_utils::NavigateToURL(browser(), webui_url); |
| 949 const content::WebContents* old_tab = | 950 content::WebContents* old_tab = |
| 950 browser()->tab_strip_model()->GetActiveWebContents(); | 951 browser()->tab_strip_model()->GetActiveWebContents(); |
| 951 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, | 952 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
| 952 old_tab->GetRenderViewHost()->GetEnabledBindings()); | 953 old_tab->GetMainFrame()->GetEnabledBindings()); |
| 953 | 954 |
| 954 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 955 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
| 955 ASSERT_EQ(1u, active_browser_list_->size()); | 956 ASSERT_EQ(1u, active_browser_list_->size()); |
| 956 const content::WebContents* new_tab = | 957 content::WebContents* new_tab = |
| 957 new_browser->tab_strip_model()->GetActiveWebContents(); | 958 new_browser->tab_strip_model()->GetActiveWebContents(); |
| 958 EXPECT_EQ(webui_url, new_tab->GetURL()); | 959 EXPECT_EQ(webui_url, new_tab->GetURL()); |
| 959 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, | 960 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
| 960 new_tab->GetRenderViewHost()->GetEnabledBindings()); | 961 new_tab->GetMainFrame()->GetEnabledBindings()); |
| 961 } | 962 } |
| 962 | 963 |
| 963 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUISettings) { | 964 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUISettings) { |
| 964 const GURL webui_url("chrome://settings"); | 965 const GURL webui_url("chrome://settings"); |
| 965 ui_test_utils::NavigateToURL(browser(), webui_url); | 966 ui_test_utils::NavigateToURL(browser(), webui_url); |
| 966 const content::WebContents* old_tab = | 967 content::WebContents* old_tab = |
| 967 browser()->tab_strip_model()->GetActiveWebContents(); | 968 browser()->tab_strip_model()->GetActiveWebContents(); |
| 968 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, | 969 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
| 969 old_tab->GetRenderViewHost()->GetEnabledBindings()); | 970 old_tab->GetMainFrame()->GetEnabledBindings()); |
| 970 | 971 |
| 971 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 972 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
| 972 ASSERT_EQ(1u, active_browser_list_->size()); | 973 ASSERT_EQ(1u, active_browser_list_->size()); |
| 973 const content::WebContents* new_tab = | 974 content::WebContents* new_tab = |
| 974 new_browser->tab_strip_model()->GetActiveWebContents(); | 975 new_browser->tab_strip_model()->GetActiveWebContents(); |
| 975 EXPECT_EQ(webui_url, new_tab->GetURL()); | 976 EXPECT_EQ(webui_url, new_tab->GetURL()); |
| 976 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, | 977 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
| 977 new_tab->GetRenderViewHost()->GetEnabledBindings()); | 978 new_tab->GetMainFrame()->GetEnabledBindings()); |
| 978 } | 979 } |
| 979 | 980 |
| 980 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) { | 981 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) { |
| 981 ui_test_utils::NavigateToURL(browser(), url1_); | 982 ui_test_utils::NavigateToURL(browser(), url1_); |
| 982 ui_test_utils::NavigateToURL(browser(), url2_); | 983 ui_test_utils::NavigateToURL(browser(), url2_); |
| 983 ui_test_utils::NavigateToURL(browser(), url3_); | 984 ui_test_utils::NavigateToURL(browser(), url3_); |
| 984 | 985 |
| 985 GoBack(browser()); | 986 GoBack(browser()); |
| 986 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 987 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
| 987 ASSERT_EQ(1u, active_browser_list_->size()); | 988 ASSERT_EQ(1u, active_browser_list_->size()); |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1610 // automatically at the start of the test. | 1611 // automatically at the start of the test. |
| 1611 for (size_t i = 1; i < web_contents().size(); i++) { | 1612 for (size_t i = 1; i < web_contents().size(); i++) { |
| 1612 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); | 1613 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); |
| 1613 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); | 1614 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); |
| 1614 if (i > 0) { | 1615 if (i > 0) { |
| 1615 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), | 1616 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), |
| 1616 web_contents()[i]->GetLastActiveTime()); | 1617 web_contents()[i]->GetLastActiveTime()); |
| 1617 } | 1618 } |
| 1618 } | 1619 } |
| 1619 } | 1620 } |
| OLD | NEW |