Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "content/public/test/web_contents_tester.h" | 24 #include "content/public/test/web_contents_tester.h" |
| 25 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 28 |
| 29 using captive_portal::CaptivePortalResult; | 29 using captive_portal::CaptivePortalResult; |
| 30 using content::ResourceType; | 30 using content::ResourceType; |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 const char* const kStartUrl = "http://whatever.com/index.html"; | |
| 34 const char* const kHttpUrl = "http://whatever.com/"; | 35 const char* const kHttpUrl = "http://whatever.com/"; |
| 35 const char* const kHttpsUrl = "https://whatever.com/"; | 36 const char* const kHttpsUrl = "https://whatever.com/"; |
| 36 | 37 |
| 37 // Used for cross-process navigations. Shouldn't actually matter whether this | 38 // Used for cross-process navigations. Shouldn't actually matter whether this |
| 38 // is different from kHttpsUrl, but best to keep things consistent. | 39 // is different from kHttpsUrl, but best to keep things consistent. |
| 39 const char* const kHttpsUrl2 = "https://cross_process.com/"; | 40 const char* const kHttpsUrl2 = "https://cross_process.com/"; |
| 40 | 41 |
| 41 // Some navigations behave differently depending on if they're cross-process | 42 // Some navigations behave differently depending on if they're cross-process |
| 42 // or not. | 43 // or not. |
| 43 enum NavigationType { | 44 enum NavigationType { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 67 // the harness in any other way. | 68 // the harness in any other way. |
| 68 class CaptivePortalTabHelperTest : public ChromeRenderViewHostTestHarness { | 69 class CaptivePortalTabHelperTest : public ChromeRenderViewHostTestHarness { |
| 69 public: | 70 public: |
| 70 CaptivePortalTabHelperTest() | 71 CaptivePortalTabHelperTest() |
| 71 : mock_reloader_(new testing::StrictMock<MockCaptivePortalTabReloader>) {} | 72 : mock_reloader_(new testing::StrictMock<MockCaptivePortalTabReloader>) {} |
| 72 ~CaptivePortalTabHelperTest() override {} | 73 ~CaptivePortalTabHelperTest() override {} |
| 73 | 74 |
| 74 void SetUp() override { | 75 void SetUp() override { |
| 75 ChromeRenderViewHostTestHarness::SetUp(); | 76 ChromeRenderViewHostTestHarness::SetUp(); |
| 76 | 77 |
| 77 // Load kHttpUrl. This ensures that any subsequent navigation to kHttpsUrl2 | 78 // Load kStartUrl. This ensures that any subsequent navigation to kHttpsUrl2 |
|
Charlie Reis
2016/10/27 20:51:24
Why was this change necessary? Maybe mention in t
nasko
2016/10/27 21:22:34
Done.
| |
| 78 // will be properly registered as cross-process. | 79 // will be properly registered as cross-process. |
| 79 content::WebContentsTester* web_contents_tester = | 80 content::WebContentsTester* web_contents_tester = |
| 80 content::WebContentsTester::For(web_contents()); | 81 content::WebContentsTester::For(web_contents()); |
| 81 web_contents_tester->NavigateAndCommit(GURL(kHttpUrl)); | 82 web_contents_tester->NavigateAndCommit(GURL(kStartUrl)); |
| 82 content::RenderFrameHostTester* rfh_tester = | 83 content::RenderFrameHostTester* rfh_tester = |
| 83 content::RenderFrameHostTester::For(main_rfh()); | 84 content::RenderFrameHostTester::For(main_rfh()); |
| 84 rfh_tester->SimulateNavigationStop(); | 85 rfh_tester->SimulateNavigationStop(); |
| 85 | 86 |
| 86 tab_helper_.reset(new CaptivePortalTabHelper(web_contents())); | 87 tab_helper_.reset(new CaptivePortalTabHelper(web_contents())); |
| 87 tab_helper_->profile_ = nullptr; | 88 tab_helper_->profile_ = nullptr; |
| 88 tab_helper_->SetTabReloaderForTest(mock_reloader_); | 89 tab_helper_->SetTabReloaderForTest(mock_reloader_); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void TearDown() override { | 92 void TearDown() override { |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 EXPECT_FALSE(tab_helper()->IsLoginTab()); | 525 EXPECT_FALSE(tab_helper()->IsLoginTab()); |
| 525 | 526 |
| 526 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, | 527 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, |
| 527 captive_portal::RESULT_NO_RESPONSE); | 528 captive_portal::RESULT_NO_RESPONSE); |
| 528 EXPECT_FALSE(tab_helper()->IsLoginTab()); | 529 EXPECT_FALSE(tab_helper()->IsLoginTab()); |
| 529 | 530 |
| 530 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, | 531 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, |
| 531 captive_portal::RESULT_INTERNET_CONNECTED); | 532 captive_portal::RESULT_INTERNET_CONNECTED); |
| 532 EXPECT_FALSE(tab_helper()->IsLoginTab()); | 533 EXPECT_FALSE(tab_helper()->IsLoginTab()); |
| 533 } | 534 } |
| OLD | NEW |