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