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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 // At least one of the render widgets should not be initialized yet. | 908 // At least one of the render widgets should not be initialized yet. |
908 ASSERT_FALSE( | 909 ASSERT_FALSE( |
909 tab_strip_model->GetWebContentsAt(0)->GetRenderWidgetHostView() && | 910 tab_strip_model->GetWebContentsAt(0)->GetRenderWidgetHostView() && |
910 tab_strip_model->GetWebContentsAt(1)->GetRenderWidgetHostView() && | 911 tab_strip_model->GetWebContentsAt(1)->GetRenderWidgetHostView() && |
911 tab_strip_model->GetWebContentsAt(2)->GetRenderWidgetHostView()); | 912 tab_strip_model->GetWebContentsAt(2)->GetRenderWidgetHostView()); |
912 } | 913 } |
913 | 914 |
914 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUI) { | 915 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUI) { |
915 const GURL webui_url("chrome://omnibox"); | 916 const GURL webui_url("chrome://omnibox"); |
916 ui_test_utils::NavigateToURL(browser(), webui_url); | 917 ui_test_utils::NavigateToURL(browser(), webui_url); |
917 const content::WebContents* old_tab = | 918 content::WebContents* old_tab = |
918 browser()->tab_strip_model()->GetActiveWebContents(); | 919 browser()->tab_strip_model()->GetActiveWebContents(); |
919 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, | 920 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
920 old_tab->GetRenderViewHost()->GetEnabledBindings()); | 921 old_tab->GetMainFrame()->GetEnabledBindings()); |
921 | 922 |
922 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 923 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
923 ASSERT_EQ(1u, active_browser_list_->size()); | 924 ASSERT_EQ(1u, active_browser_list_->size()); |
924 const content::WebContents* new_tab = | 925 content::WebContents* new_tab = |
925 new_browser->tab_strip_model()->GetActiveWebContents(); | 926 new_browser->tab_strip_model()->GetActiveWebContents(); |
926 EXPECT_EQ(webui_url, new_tab->GetURL()); | 927 EXPECT_EQ(webui_url, new_tab->GetURL()); |
927 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, | 928 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
928 new_tab->GetRenderViewHost()->GetEnabledBindings()); | 929 new_tab->GetMainFrame()->GetEnabledBindings()); |
929 } | 930 } |
930 | 931 |
931 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUISettings) { | 932 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUISettings) { |
932 const GURL webui_url("chrome://settings"); | 933 const GURL webui_url("chrome://settings"); |
933 ui_test_utils::NavigateToURL(browser(), webui_url); | 934 ui_test_utils::NavigateToURL(browser(), webui_url); |
934 const content::WebContents* old_tab = | 935 content::WebContents* old_tab = |
935 browser()->tab_strip_model()->GetActiveWebContents(); | 936 browser()->tab_strip_model()->GetActiveWebContents(); |
936 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, | 937 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
937 old_tab->GetRenderViewHost()->GetEnabledBindings()); | 938 old_tab->GetMainFrame()->GetEnabledBindings()); |
938 | 939 |
939 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 940 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
940 ASSERT_EQ(1u, active_browser_list_->size()); | 941 ASSERT_EQ(1u, active_browser_list_->size()); |
941 const content::WebContents* new_tab = | 942 content::WebContents* new_tab = |
942 new_browser->tab_strip_model()->GetActiveWebContents(); | 943 new_browser->tab_strip_model()->GetActiveWebContents(); |
943 EXPECT_EQ(webui_url, new_tab->GetURL()); | 944 EXPECT_EQ(webui_url, new_tab->GetURL()); |
944 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, | 945 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
945 new_tab->GetRenderViewHost()->GetEnabledBindings()); | 946 new_tab->GetMainFrame()->GetEnabledBindings()); |
946 } | 947 } |
947 | 948 |
948 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) { | 949 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) { |
949 ui_test_utils::NavigateToURL(browser(), url1_); | 950 ui_test_utils::NavigateToURL(browser(), url1_); |
950 ui_test_utils::NavigateToURL(browser(), url2_); | 951 ui_test_utils::NavigateToURL(browser(), url2_); |
951 ui_test_utils::NavigateToURL(browser(), url3_); | 952 ui_test_utils::NavigateToURL(browser(), url3_); |
952 | 953 |
953 GoBack(browser()); | 954 GoBack(browser()); |
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()); |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 // automatically at the start of the test. | 1579 // automatically at the start of the test. |
1579 for (size_t i = 1; i < web_contents().size(); i++) { | 1580 for (size_t i = 1; i < web_contents().size(); i++) { |
1580 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); | 1581 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); |
1581 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); | 1582 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); |
1582 if (i > 0) { | 1583 if (i > 0) { |
1583 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), | 1584 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), |
1584 web_contents()[i]->GetLastActiveTime()); | 1585 web_contents()[i]->GetLastActiveTime()); |
1585 } | 1586 } |
1586 } | 1587 } |
1587 } | 1588 } |
OLD | NEW |