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 "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 5 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "chrome/browser/captive_portal/captive_portal_service.h" | 8 #include "chrome/browser/captive_portal/captive_portal_service.h" |
9 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" | 9 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" |
10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 CaptivePortalTabHelper tab_helper_; | 139 CaptivePortalTabHelper tab_helper_; |
140 | 140 |
141 // Owned by |tab_helper_|. | 141 // Owned by |tab_helper_|. |
142 testing::StrictMock<MockCaptivePortalTabReloader>* mock_reloader_; | 142 testing::StrictMock<MockCaptivePortalTabReloader>* mock_reloader_; |
143 | 143 |
144 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelperTest); | 144 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelperTest); |
145 }; | 145 }; |
146 | 146 |
147 TEST_F(CaptivePortalTabHelperTest, HttpSuccess) { | 147 TEST_F(CaptivePortalTabHelperTest, HttpSuccess) { |
148 SimulateSuccess(GURL(kHttpUrl)); | 148 SimulateSuccess(GURL(kHttpUrl)); |
149 tab_helper().DidStopLoading(); | 149 tab_helper().DidStopLoading(NULL); |
150 } | 150 } |
151 | 151 |
152 TEST_F(CaptivePortalTabHelperTest, HttpTimeout) { | 152 TEST_F(CaptivePortalTabHelperTest, HttpTimeout) { |
153 SimulateTimeout(GURL(kHttpUrl)); | 153 SimulateTimeout(GURL(kHttpUrl)); |
154 tab_helper().DidStopLoading(); | 154 tab_helper().DidStopLoading(NULL); |
155 } | 155 } |
156 | 156 |
157 // Same as above, but simulates what happens when the Link Doctor is enabled, | 157 // Same as above, but simulates what happens when the Link Doctor is enabled, |
158 // which adds another provisional load/commit for the error page, after the | 158 // which adds another provisional load/commit for the error page, after the |
159 // first two. | 159 // first two. |
160 TEST_F(CaptivePortalTabHelperTest, HttpTimeoutLinkDoctor) { | 160 TEST_F(CaptivePortalTabHelperTest, HttpTimeoutLinkDoctor) { |
161 SimulateTimeout(GURL(kHttpUrl)); | 161 SimulateTimeout(GURL(kHttpUrl)); |
162 | 162 |
163 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); | 163 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); |
164 // Provisional load starts for the error page. | 164 // Provisional load starts for the error page. |
165 tab_helper().DidStartProvisionalLoadForFrame( | 165 tab_helper().DidStartProvisionalLoadForFrame( |
166 1, true, GURL(kErrorPageUrl), true, NULL); | 166 1, true, GURL(kErrorPageUrl), true, NULL); |
167 | 167 |
168 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); | 168 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); |
169 tab_helper().DidCommitProvisionalLoadForFrame( | 169 tab_helper().DidCommitProvisionalLoadForFrame( |
170 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, NULL); | 170 1, true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, NULL); |
171 tab_helper().DidStopLoading(); | 171 tab_helper().DidStopLoading(NULL); |
172 } | 172 } |
173 | 173 |
174 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) { | 174 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) { |
175 SimulateSuccess(GURL(kHttpsUrl)); | 175 SimulateSuccess(GURL(kHttpsUrl)); |
176 tab_helper().DidStopLoading(); | 176 tab_helper().DidStopLoading(NULL); |
177 EXPECT_FALSE(tab_helper().IsLoginTab()); | 177 EXPECT_FALSE(tab_helper().IsLoginTab()); |
178 } | 178 } |
179 | 179 |
180 TEST_F(CaptivePortalTabHelperTest, HttpsTimeout) { | 180 TEST_F(CaptivePortalTabHelperTest, HttpsTimeout) { |
181 SimulateTimeout(GURL(kHttpsUrl)); | 181 SimulateTimeout(GURL(kHttpsUrl)); |
182 // Make sure no state was carried over from the timeout. | 182 // Make sure no state was carried over from the timeout. |
183 SimulateSuccess(GURL(kHttpsUrl)); | 183 SimulateSuccess(GURL(kHttpsUrl)); |
184 EXPECT_FALSE(tab_helper().IsLoginTab()); | 184 EXPECT_FALSE(tab_helper().IsLoginTab()); |
185 } | 185 } |
186 | 186 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 EXPECT_FALSE(tab_helper().IsLoginTab()); | 368 EXPECT_FALSE(tab_helper().IsLoginTab()); |
369 | 369 |
370 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE); | 370 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE); |
371 EXPECT_FALSE(tab_helper().IsLoginTab()); | 371 EXPECT_FALSE(tab_helper().IsLoginTab()); |
372 | 372 |
373 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED); | 373 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED); |
374 EXPECT_FALSE(tab_helper().IsLoginTab()); | 374 EXPECT_FALSE(tab_helper().IsLoginTab()); |
375 } | 375 } |
376 | 376 |
377 } // namespace captive_portal | 377 } // namespace captive_portal |
OLD | NEW |