OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "chrome/test/automation/tab_proxy.h" | 7 #include "chrome/test/automation/tab_proxy.h" |
8 #include "chrome/test/automation/browser_proxy.h" | 8 #include "chrome/test/automation/browser_proxy.h" |
9 #include "chrome/test/ui/ui_test.h" | 9 #include "chrome/test/ui/ui_test.h" |
10 #include "net/url_request/url_request_unittest.h" | 10 #include "net/url_request/url_request_unittest.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 }; | 45 }; |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 // Shows and hides an interstitial page. | 49 // Shows and hides an interstitial page. |
50 // Note that we cannot rely on the page title in this case (and we use the page | 50 // Note that we cannot rely on the page title in this case (and we use the page |
51 // type instead) as showing an interstitial without creating a navigation entry | 51 // type instead) as showing an interstitial without creating a navigation entry |
52 // causes the actual navigation entry (title) to be modified by the content of | 52 // causes the actual navigation entry (title) to be modified by the content of |
53 // the interstitial. | 53 // the interstitial. |
54 TEST_F(InterstitialPageTest, TestShowHideInterstitial) { | 54 TEST_F(InterstitialPageTest, TestShowHideInterstitial) { |
55 scoped_refptr<HTTPTestServer> server = | 55 TestServer server(kDocRoot); |
56 HTTPTestServer::CreateServer(kDocRoot); | |
57 ASSERT_TRUE(NULL != server.get()); | |
58 | |
59 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); | 56 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); |
60 NavigateTab(tab.get(), | 57 NavigateTab(tab.get(), |
61 server->TestServerPageW(L"files/interstitial_page/google.html")); | 58 server.TestServerPageW(L"files/interstitial_page/google.html")); |
62 NavigationEntry::PageType page_type; | 59 NavigationEntry::PageType page_type; |
63 EXPECT_TRUE(tab->GetPageType(&page_type)); | 60 EXPECT_TRUE(tab->GetPageType(&page_type)); |
64 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type); | 61 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type); |
65 | 62 |
66 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); | 63 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); |
67 EXPECT_TRUE(tab->GetPageType(&page_type)); | 64 EXPECT_TRUE(tab->GetPageType(&page_type)); |
68 EXPECT_EQ(NavigationEntry::INTERSTITIAL_PAGE, page_type); | 65 EXPECT_EQ(NavigationEntry::INTERSTITIAL_PAGE, page_type); |
69 | 66 |
70 tab->HideInterstitialPage(); | 67 tab->HideInterstitialPage(); |
71 EXPECT_TRUE(tab->GetPageType(&page_type)); | 68 EXPECT_TRUE(tab->GetPageType(&page_type)); |
72 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type); | 69 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type); |
73 } | 70 } |
74 | 71 |
75 // Shows an interstitial page then goes back. | 72 // Shows an interstitial page then goes back. |
76 // TODO(creis): We are disabling this test for now. We need to revisit | 73 // TODO(creis): We are disabling this test for now. We need to revisit |
77 // whether the interstitial page should actually commit a NavigationEntry, | 74 // whether the interstitial page should actually commit a NavigationEntry, |
78 // because this clears the forward list and changes the meaning of back. It | 75 // because this clears the forward list and changes the meaning of back. It |
79 // seems like the interstitial should not affect the NavigationController, | 76 // seems like the interstitial should not affect the NavigationController, |
80 // who will remain in a pending state until the user either proceeds or cancels | 77 // who will remain in a pending state until the user either proceeds or cancels |
81 // the interstitial. In the mean time, we are treating Back like cancelling | 78 // the interstitial. In the mean time, we are treating Back like cancelling |
82 // the interstitial, which breaks this test because no notification occurs. | 79 // the interstitial, which breaks this test because no notification occurs. |
83 TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenBack) { | 80 TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenBack) { |
84 scoped_refptr<HTTPTestServer> server = | 81 TestServer server(kDocRoot); |
85 HTTPTestServer::CreateServer(kDocRoot); | |
86 ASSERT_TRUE(NULL != server.get()); | |
87 | |
88 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); | 82 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); |
89 NavigateTab(tab.get(), | 83 NavigateTab(tab.get(), |
90 server->TestServerPageW(L"files/interstitial_page/google.html")); | 84 server.TestServerPageW(L"files/interstitial_page/google.html")); |
91 EXPECT_EQ(L"Google", GetActiveTabTitle()); | 85 EXPECT_EQ(L"Google", GetActiveTabTitle()); |
92 | 86 |
93 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); | 87 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); |
94 EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); | 88 EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); |
95 | 89 |
96 tab->GoBack(); | 90 tab->GoBack(); |
97 EXPECT_EQ(L"Google", GetActiveTabTitle()); | 91 EXPECT_EQ(L"Google", GetActiveTabTitle()); |
98 } | 92 } |
99 | 93 |
100 // Shows an interstitial page then navigates to a new URL. | 94 // Shows an interstitial page then navigates to a new URL. |
101 // Flacky on Windows 2000 bot. Disabled for now bug #1173138. | 95 // Flacky on Windows 2000 bot. Disabled for now bug #1173138. |
102 TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenNavigate) { | 96 TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenNavigate) { |
103 scoped_refptr<HTTPTestServer> server = | 97 TestServer server(kDocRoot); |
104 HTTPTestServer::CreateServer(kDocRoot); | |
105 ASSERT_TRUE(NULL != server.get()); | |
106 | |
107 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); | 98 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); |
108 NavigateTab(tab.get(), | 99 NavigateTab(tab.get(), |
109 server->TestServerPageW(L"files/interstitial_page/google.html")); | 100 server.TestServerPageW(L"files/interstitial_page/google.html")); |
110 EXPECT_EQ(L"Google", GetActiveTabTitle()); | 101 EXPECT_EQ(L"Google", GetActiveTabTitle()); |
111 | 102 |
112 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); | 103 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); |
113 EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); | 104 EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); |
114 | 105 |
115 tab->NavigateToURL( | 106 tab->NavigateToURL( |
116 server->TestServerPageW(L"files/interstitial_page/shopping.html")); | 107 server.TestServerPageW(L"files/interstitial_page/shopping.html")); |
117 EXPECT_EQ(L"Google Product Search", GetActiveTabTitle()); | 108 EXPECT_EQ(L"Google Product Search", GetActiveTabTitle()); |
118 } | 109 } |
119 | 110 |
120 // Shows an interstitial page then closes the tab (to make sure we don't crash). | 111 // Shows an interstitial page then closes the tab (to make sure we don't crash). |
121 TEST_F(InterstitialPageTest, TestShowInterstitialThenCloseTab) { | 112 TEST_F(InterstitialPageTest, TestShowInterstitialThenCloseTab) { |
122 scoped_refptr<HTTPTestServer> server = | 113 TestServer server(kDocRoot); |
123 HTTPTestServer::CreateServer(kDocRoot); | |
124 ASSERT_TRUE(NULL != server.get()); | |
125 | 114 |
126 // Create 2 tabs so closing one does not close the browser. | 115 // Create 2 tabs so closing one does not close the browser. |
127 AppendTab(server->TestServerPageW(L"files/interstitial_page/google.html")); | 116 AppendTab(server.TestServerPageW(L"files/interstitial_page/google.html")); |
128 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); | 117 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); |
129 EXPECT_EQ(L"Google", GetActiveTabTitle()); | 118 EXPECT_EQ(L"Google", GetActiveTabTitle()); |
130 | 119 |
131 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); | 120 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); |
132 EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); | 121 EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); |
133 tab->Close(); | 122 tab->Close(); |
134 } | 123 } |
135 | 124 |
136 // Shows an interstitial page then closes the browser (to make sure we don't | 125 // Shows an interstitial page then closes the browser (to make sure we don't |
137 // crash). | 126 // crash). |
138 // This test is disabled. See bug #1119448. | 127 // This test is disabled. See bug #1119448. |
139 TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenCloseBrowser) { | 128 TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenCloseBrowser) { |
140 scoped_refptr<HTTPTestServer> server = | 129 TestServer server(kDocRoot); |
141 HTTPTestServer::CreateServer(kDocRoot); | |
142 ASSERT_TRUE(NULL != server.get()); | |
143 | 130 |
144 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); | 131 ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); |
145 tab->NavigateToURL( | 132 tab->NavigateToURL( |
146 server->TestServerPageW(L"files/interstitial_page/google.html")); | 133 server.TestServerPageW(L"files/interstitial_page/google.html")); |
147 EXPECT_EQ(L"Google", GetActiveTabTitle()); | 134 EXPECT_EQ(L"Google", GetActiveTabTitle()); |
148 | 135 |
149 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); | 136 tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); |
150 EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); | 137 EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); |
151 | 138 |
152 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 139 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
153 EXPECT_TRUE(browser_proxy.get()); | 140 EXPECT_TRUE(browser_proxy.get()); |
154 bool application_closed; | 141 bool application_closed; |
155 EXPECT_TRUE(CloseBrowser(browser_proxy.get(), &application_closed)); | 142 EXPECT_TRUE(CloseBrowser(browser_proxy.get(), &application_closed)); |
156 EXPECT_TRUE(application_closed); | 143 EXPECT_TRUE(application_closed); |
157 } | 144 } |
158 | 145 |
159 | 146 |
160 | 147 |
OLD | NEW |