| 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 } | 783 } |
| 784 | 784 |
| 785 } // namespace | 785 } // namespace |
| 786 | 786 |
| 787 class CaptivePortalBrowserTest : public InProcessBrowserTest { | 787 class CaptivePortalBrowserTest : public InProcessBrowserTest { |
| 788 public: | 788 public: |
| 789 CaptivePortalBrowserTest(); | 789 CaptivePortalBrowserTest(); |
| 790 | 790 |
| 791 // InProcessBrowserTest: | 791 // InProcessBrowserTest: |
| 792 virtual void SetUpOnMainThread() OVERRIDE; | 792 virtual void SetUpOnMainThread() OVERRIDE; |
| 793 virtual void CleanUpOnMainThread() OVERRIDE; | 793 virtual void TearDownOnMainThread() OVERRIDE; |
| 794 | 794 |
| 795 // Sets the captive portal checking preference. Does not affect the command | 795 // Sets the captive portal checking preference. Does not affect the command |
| 796 // line flag, which is set in SetUpCommandLine. | 796 // line flag, which is set in SetUpCommandLine. |
| 797 void EnableCaptivePortalDetection(Profile* profile, bool enabled); | 797 void EnableCaptivePortalDetection(Profile* profile, bool enabled); |
| 798 | 798 |
| 799 // Sets up the captive portal service for the given profile so that | 799 // Sets up the captive portal service for the given profile so that |
| 800 // all checks go to |test_url|. Also disables all timers. | 800 // all checks go to |test_url|. Also disables all timers. |
| 801 void SetUpCaptivePortalService(Profile* profile, const GURL& test_url); | 801 void SetUpCaptivePortalService(Profile* profile, const GURL& test_url); |
| 802 | 802 |
| 803 // Returns true if |browser|'s profile is currently running a captive portal | 803 // Returns true if |browser|'s profile is currently running a captive portal |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 CaptivePortalService::set_state_for_testing( | 961 CaptivePortalService::set_state_for_testing( |
| 962 CaptivePortalService::SKIP_OS_CHECK_FOR_TESTING); | 962 CaptivePortalService::SKIP_OS_CHECK_FOR_TESTING); |
| 963 EnableCaptivePortalDetection(browser()->profile(), true); | 963 EnableCaptivePortalDetection(browser()->profile(), true); |
| 964 | 964 |
| 965 // Set the captive portal service to use URLRequestMockCaptivePortalJob's | 965 // Set the captive portal service to use URLRequestMockCaptivePortalJob's |
| 966 // mock URL, by default. | 966 // mock URL, by default. |
| 967 SetUpCaptivePortalService(browser()->profile(), | 967 SetUpCaptivePortalService(browser()->profile(), |
| 968 GURL(kMockCaptivePortalTestUrl)); | 968 GURL(kMockCaptivePortalTestUrl)); |
| 969 } | 969 } |
| 970 | 970 |
| 971 void CaptivePortalBrowserTest::CleanUpOnMainThread() { | 971 void CaptivePortalBrowserTest::TearDownOnMainThread() { |
| 972 // No test should have a captive portal check pending on quit. | 972 // No test should have a captive portal check pending on quit. |
| 973 EXPECT_FALSE(CheckPending(browser())); | 973 EXPECT_FALSE(CheckPending(browser())); |
| 974 } | 974 } |
| 975 | 975 |
| 976 void CaptivePortalBrowserTest::EnableCaptivePortalDetection( | 976 void CaptivePortalBrowserTest::EnableCaptivePortalDetection( |
| 977 Profile* profile, bool enabled) { | 977 Profile* profile, bool enabled) { |
| 978 profile->GetPrefs()->SetBoolean(prefs::kAlternateErrorPagesEnabled, enabled); | 978 profile->GetPrefs()->SetBoolean(prefs::kAlternateErrorPagesEnabled, enabled); |
| 979 } | 979 } |
| 980 | 980 |
| 981 void CaptivePortalBrowserTest::SetUpCaptivePortalService(Profile* profile, | 981 void CaptivePortalBrowserTest::SetUpCaptivePortalService(Profile* profile, |
| (...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2194 content::BrowserThread::PostTask( | 2194 content::BrowserThread::PostTask( |
| 2195 content::BrowserThread::IO, FROM_HERE, | 2195 content::BrowserThread::IO, FROM_HERE, |
| 2196 base::Bind(&AddHstsHost, | 2196 base::Bind(&AddHstsHost, |
| 2197 make_scoped_refptr(browser()->profile()->GetRequestContext()), | 2197 make_scoped_refptr(browser()->profile()->GetRequestContext()), |
| 2198 http_timeout_url.host())); | 2198 http_timeout_url.host())); |
| 2199 | 2199 |
| 2200 SlowLoadBehindCaptivePortal(browser(), true, http_timeout_url, 1, 1); | 2200 SlowLoadBehindCaptivePortal(browser(), true, http_timeout_url, 1, 1); |
| 2201 Login(browser(), 1, 0); | 2201 Login(browser(), 1, 0); |
| 2202 FailLoadsAfterLogin(browser(), 1); | 2202 FailLoadsAfterLogin(browser(), 1); |
| 2203 } | 2203 } |
| OLD | NEW |