Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: chrome/browser/captive_portal/captive_portal_browsertest.cc

Issue 819443003: Add finch gate for captive portal interstitial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ssl/ssl_error_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 898
899 } // namespace 899 } // namespace
900 900
901 class CaptivePortalBrowserTest : public InProcessBrowserTest { 901 class CaptivePortalBrowserTest : public InProcessBrowserTest {
902 public: 902 public:
903 CaptivePortalBrowserTest(); 903 CaptivePortalBrowserTest();
904 904
905 // InProcessBrowserTest: 905 // InProcessBrowserTest:
906 void SetUpOnMainThread() override; 906 void SetUpOnMainThread() override;
907 void TearDownOnMainThread() override; 907 void TearDownOnMainThread() override;
908 void SetUpCommandLine(base::CommandLine* command_line) override;
908 909
909 // Sets the captive portal checking preference. Does not affect the command 910 // Sets the captive portal checking preference. Does not affect the command
910 // line flag, which is set in SetUpCommandLine. 911 // line flag, which is set in SetUpCommandLine.
911 void EnableCaptivePortalDetection(Profile* profile, bool enabled); 912 void EnableCaptivePortalDetection(Profile* profile, bool enabled);
912 913
913 // Enables or disables actual captive portal probes. Should only be called 914 // Enables or disables actual captive portal probes. Should only be called
914 // after captive portal service setup is done. When disabled, probe requests 915 // after captive portal service setup is done. When disabled, probe requests
915 // are silently ignored, never receiving a response. 916 // are silently ignored, never receiving a response.
916 void RespondToProbeRequests(bool enabled); 917 void RespondToProbeRequests(bool enabled);
917 918
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 // is guaranteed to arrive during this window, and a captive portal 1112 // is guaranteed to arrive during this window, and a captive portal
1112 // error page is displayed instead of an SSL interstitial. 1113 // error page is displayed instead of an SSL interstitial.
1113 SSLErrorHandler::SetInterstitialDelayTypeForTest(SSLErrorHandler::LONG); 1114 SSLErrorHandler::SetInterstitialDelayTypeForTest(SSLErrorHandler::LONG);
1114 } 1115 }
1115 1116
1116 void CaptivePortalBrowserTest::TearDownOnMainThread() { 1117 void CaptivePortalBrowserTest::TearDownOnMainThread() {
1117 // No test should have a captive portal check pending on quit. 1118 // No test should have a captive portal check pending on quit.
1118 EXPECT_FALSE(CheckPending(browser())); 1119 EXPECT_FALSE(CheckPending(browser()));
1119 } 1120 }
1120 1121
1122 void CaptivePortalBrowserTest::SetUpCommandLine(
1123 base::CommandLine* command_line) {
1124 // Enable finch experiment for captive portal interstitials.
1125 command_line->AppendSwitchASCII(
1126 switches::kForceFieldTrials, "CaptivePortalInterstitial/Enabled/");
1127 }
1128
1121 void CaptivePortalBrowserTest::EnableCaptivePortalDetection( 1129 void CaptivePortalBrowserTest::EnableCaptivePortalDetection(
1122 Profile* profile, bool enabled) { 1130 Profile* profile, bool enabled) {
1123 profile->GetPrefs()->SetBoolean(prefs::kAlternateErrorPagesEnabled, enabled); 1131 profile->GetPrefs()->SetBoolean(prefs::kAlternateErrorPagesEnabled, enabled);
1124 } 1132 }
1125 1133
1126 void CaptivePortalBrowserTest::RespondToProbeRequests(bool enabled) { 1134 void CaptivePortalBrowserTest::RespondToProbeRequests(bool enabled) {
1127 if (enabled) { 1135 if (enabled) {
1128 EXPECT_EQ(CaptivePortalService::IGNORE_REQUESTS_FOR_TESTING, 1136 EXPECT_EQ(CaptivePortalService::IGNORE_REQUESTS_FOR_TESTING,
1129 CaptivePortalService::get_state_for_testing()); 1137 CaptivePortalService::get_state_for_testing());
1130 CaptivePortalService::set_state_for_testing( 1138 CaptivePortalService::set_state_for_testing(
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 2738
2731 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, 2739 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD,
2732 GetStateOfTabReloaderAt(browser(), broken_tab_index)); 2740 GetStateOfTabReloaderAt(browser(), broken_tab_index));
2733 2741
2734 WaitForInterstitialAttach(broken_tab_contents); 2742 WaitForInterstitialAttach(broken_tab_contents);
2735 portal_observer.WaitForResults(1); 2743 portal_observer.WaitForResults(1);
2736 2744
2737 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, 2745 EXPECT_EQ(SSLBlockingPage::kTypeForTesting,
2738 GetInterstitialType(broken_tab_contents)); 2746 GetInterstitialType(broken_tab_contents));
2739 } 2747 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ssl/ssl_error_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698