| 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/captive_portal/captive_portal_service.h" | 9 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" | 10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 CaptivePortalTabHelper tab_helper_; | 238 CaptivePortalTabHelper tab_helper_; |
| 239 | 239 |
| 240 // Owned by |tab_helper_|. | 240 // Owned by |tab_helper_|. |
| 241 testing::StrictMock<MockCaptivePortalTabReloader>* mock_reloader_; | 241 testing::StrictMock<MockCaptivePortalTabReloader>* mock_reloader_; |
| 242 | 242 |
| 243 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelperTest); | 243 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelperTest); |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 TEST_F(CaptivePortalTabHelperTest, HttpSuccess) { | 246 TEST_F(CaptivePortalTabHelperTest, HttpSuccess) { |
| 247 SimulateSuccess(GURL(kHttpUrl), render_view_host1()); | 247 SimulateSuccess(GURL(kHttpUrl), render_view_host1()); |
| 248 tab_helper().DidStopLoading(render_view_host1()); | 248 tab_helper().DidStopLoading(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 TEST_F(CaptivePortalTabHelperTest, HttpTimeout) { | 251 TEST_F(CaptivePortalTabHelperTest, HttpTimeout) { |
| 252 SimulateTimeout(GURL(kHttpUrl), render_view_host1()); | 252 SimulateTimeout(GURL(kHttpUrl), render_view_host1()); |
| 253 tab_helper().DidStopLoading(render_view_host1()); | 253 tab_helper().DidStopLoading(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 // Same as above, but simulates what happens when the Link Doctor is enabled, | 256 // Same as above, but simulates what happens when the Link Doctor is enabled, |
| 257 // which adds another provisional load/commit for the error page, after the | 257 // which adds another provisional load/commit for the error page, after the |
| 258 // first two. | 258 // first two. |
| 259 TEST_F(CaptivePortalTabHelperTest, HttpTimeoutLinkDoctor) { | 259 TEST_F(CaptivePortalTabHelperTest, HttpTimeoutLinkDoctor) { |
| 260 SimulateTimeout(GURL(kHttpUrl), render_view_host1()); | 260 SimulateTimeout(GURL(kHttpUrl), render_view_host1()); |
| 261 | 261 |
| 262 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); | 262 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); |
| 263 // Provisional load starts for the error page. | 263 // Provisional load starts for the error page. |
| 264 tab_helper().DidStartProvisionalLoadForFrame( | 264 tab_helper().DidStartProvisionalLoadForFrame( |
| 265 main_render_frame1(), GURL(kErrorPageUrl), true, false); | 265 main_render_frame1(), GURL(kErrorPageUrl), true, false); |
| 266 | 266 |
| 267 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); | 267 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); |
| 268 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), | 268 tab_helper().DidCommitProvisionalLoadForFrame(main_render_frame1(), |
| 269 GURL(kErrorPageUrl), | 269 GURL(kErrorPageUrl), |
| 270 ui::PAGE_TRANSITION_LINK); | 270 ui::PAGE_TRANSITION_LINK); |
| 271 tab_helper().DidStopLoading(render_view_host1()); | 271 tab_helper().DidStopLoading(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) { | 274 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) { |
| 275 SimulateSuccess(GURL(kHttpsUrl), render_view_host1()); | 275 SimulateSuccess(GURL(kHttpsUrl), render_view_host1()); |
| 276 tab_helper().DidStopLoading(render_view_host1()); | 276 tab_helper().DidStopLoading(); |
| 277 EXPECT_FALSE(tab_helper().IsLoginTab()); | 277 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 278 } | 278 } |
| 279 | 279 |
| 280 TEST_F(CaptivePortalTabHelperTest, HttpsTimeout) { | 280 TEST_F(CaptivePortalTabHelperTest, HttpsTimeout) { |
| 281 SimulateTimeout(GURL(kHttpsUrl), render_view_host1()); | 281 SimulateTimeout(GURL(kHttpsUrl), render_view_host1()); |
| 282 // Make sure no state was carried over from the timeout. | 282 // Make sure no state was carried over from the timeout. |
| 283 SimulateSuccess(GURL(kHttpsUrl), render_view_host1()); | 283 SimulateSuccess(GURL(kHttpsUrl), render_view_host1()); |
| 284 EXPECT_FALSE(tab_helper().IsLoginTab()); | 284 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 285 } | 285 } |
| 286 | 286 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 EXPECT_FALSE(tab_helper().IsLoginTab()); | 632 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 633 | 633 |
| 634 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, | 634 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, |
| 635 captive_portal::RESULT_NO_RESPONSE); | 635 captive_portal::RESULT_NO_RESPONSE); |
| 636 EXPECT_FALSE(tab_helper().IsLoginTab()); | 636 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 637 | 637 |
| 638 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, | 638 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, |
| 639 captive_portal::RESULT_INTERNET_CONNECTED); | 639 captive_portal::RESULT_INTERNET_CONNECTED); |
| 640 EXPECT_FALSE(tab_helper().IsLoginTab()); | 640 EXPECT_FALSE(tab_helper().IsLoginTab()); |
| 641 } | 641 } |
| OLD | NEW |