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

Unified Diff: chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc

Issue 894153003: Captive Portal Interstitial: Use SSID even if connection type isn't Wi-Fi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove Linux check 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ssl/captive_portal_blocking_page.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
diff --git a/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc b/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
index 857d469ab9015cc94a465a259ca2bb5d4749f8c8..2e6b6cd82e949585d36170ae0fcee2f9ebdc1322 100644
--- a/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
+++ b/chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc
@@ -64,6 +64,22 @@ enum ExpectLoginURL {
} // namespace
+class FakeConnectionInfoDelegate : public CaptivePortalBlockingPage::Delegate {
+ public:
+ FakeConnectionInfoDelegate(bool is_wifi_connection, std::string wifi_ssid)
+ : is_wifi_connection_(is_wifi_connection), wifi_ssid_(wifi_ssid) {}
+ ~FakeConnectionInfoDelegate() override {}
+
+ bool IsWifiConnection() const override { return is_wifi_connection_; }
+ std::string GetWiFiSSID() const override { return wifi_ssid_; }
+
+ private:
+ const bool is_wifi_connection_;
+ const std::string wifi_ssid_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeConnectionInfoDelegate);
+};
+
class CaptivePortalBlockingPageTest : public InProcessBrowserTest {
public:
CaptivePortalBlockingPageTest() {}
@@ -98,11 +114,13 @@ void CaptivePortalBlockingPageTest::TestInterstitial(
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
DCHECK(contents);
+ // Delegate is owned by the blocking page.
+ FakeConnectionInfoDelegate* delegate =
+ new FakeConnectionInfoDelegate(is_wifi_connection, wifi_ssid);
// Blocking page is owned by the interstitial.
CaptivePortalBlockingPage* blocking_page = new CaptivePortalBlockingPage(
contents, GURL(kBrokenSSL), login_url, base::Callback<void(bool)>());
- blocking_page->SetWiFiConnectionForTesting(is_wifi_connection);
- blocking_page->SetWiFiSSIDForTesting(wifi_ssid);
+ blocking_page->SetDelegateForTesting(delegate);
blocking_page->Show();
WaitForInterstitialAttach(contents);
@@ -140,9 +158,16 @@ void CaptivePortalBlockingPageTest::TestInterstitial(
// captive portal interstitial should be displayed.
IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
WiredNetwork_LoginURL) {
- TestInterstitial(false, kWiFiSSID, GURL("http://captive.portal/landing_url"),
+ TestInterstitial(false, "", GURL("http://captive.portal/landing_url"),
EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_YES);
+}
+// Same as above, but SSID is available, so the connection should be assumed to
+// be Wi-Fi.
+IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
+ WiredNetwork_LoginURL_With_SSID) {
+ TestInterstitial(false, kWiFiSSID, GURL("http://captive.portal/landing_url"),
+ EXPECT_WIFI_YES, EXPECT_WIFI_SSID_YES, EXPECT_LOGIN_URL_YES);
}
// Same as above, expect the login URL is the same as the captive portal ping
@@ -151,8 +176,17 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
WiredNetwork_NoLoginURL) {
const GURL kLandingUrl(captive_portal::CaptivePortalDetector::kDefaultURL);
- TestInterstitial(false, kWiFiSSID, kLandingUrl,
- EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_NO);
+ TestInterstitial(false, "", kLandingUrl, EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO,
+ EXPECT_LOGIN_URL_NO);
+}
+
+// Same as above, but SSID is available, so the connection should be assumed to
+// be Wi-Fi.
+IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageTest,
+ WiredNetwork_NoLoginURL_With_SSID) {
+ const GURL kLandingUrl(captive_portal::CaptivePortalDetector::kDefaultURL);
+ TestInterstitial(false, kWiFiSSID, kLandingUrl, EXPECT_WIFI_YES,
+ EXPECT_WIFI_SSID_YES, EXPECT_LOGIN_URL_NO);
}
// If the connection is a Wi-Fi connection, the Wi-Fi version of the captive
@@ -209,7 +243,6 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageIDNTest,
base::StringPrintf("http://%s/landing_url", kHostname);
GURL landing_url(landing_url_spec);
- TestInterstitial(false, kWiFiSSID, landing_url,
- EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO, EXPECT_LOGIN_URL_YES,
- kHostnameJSUnicode);
+ TestInterstitial(false, "", landing_url, EXPECT_WIFI_NO, EXPECT_WIFI_SSID_NO,
+ EXPECT_LOGIN_URL_YES, kHostnameJSUnicode);
}
« no previous file with comments | « chrome/browser/ssl/captive_portal_blocking_page.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698