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

Unified Diff: chromeos/network/network_state_unittest.cc

Issue 873713004: Introduce NetworkState::is_captive_portal() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback, unit test 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 | « chromeos/network/network_state_handler.cc ('k') | chromeos/network/onc/onc_translator_shill_to_onc.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_state_unittest.cc
diff --git a/chromeos/network/network_state_unittest.cc b/chromeos/network/network_state_unittest.cc
index 37a3763ef0c4f032040c85c0bc3f765b77e206bd..aa636d7b613bec4f2bde70837e9f0076c18cac3a 100644
--- a/chromeos/network/network_state_unittest.cc
+++ b/chromeos/network/network_state_unittest.cc
@@ -171,4 +171,46 @@ TEST_F(NetworkStateTest, SsidHexMultipleUpdates) {
EXPECT_TRUE(SetStringProperty(shill::kWifiHexSsid, wifi_hex));
}
+TEST_F(NetworkStateTest, CaptivePortalState) {
+ std::string network_name = "test";
+ EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeWifi));
+ EXPECT_TRUE(SetStringProperty(shill::kNameProperty, network_name));
+ std::string hex_ssid =
+ base::HexEncode(network_name.c_str(), network_name.length());
+ EXPECT_TRUE(SetStringProperty(shill::kWifiHexSsid, hex_ssid));
+
+ // State != portal -> is_captive_portal == false
+ EXPECT_TRUE(SetStringProperty(shill::kStateProperty, shill::kStateReady));
+ SignalInitialPropertiesReceived();
+ EXPECT_FALSE(network_state_.is_captive_portal());
+
+ // State == portal, kPortalDetection* not set -> is_captive_portal = true
+ EXPECT_TRUE(SetStringProperty(shill::kStateProperty, shill::kStatePortal));
+ SignalInitialPropertiesReceived();
+ EXPECT_TRUE(network_state_.is_captive_portal());
+
+ // Set kPortalDetectionFailed* properties to states that should not trigger
+ // is_captive_portal.
+ SetStringProperty(shill::kPortalDetectionFailedPhaseProperty,
+ shill::kPortalDetectionPhaseUnknown);
+ SetStringProperty(shill::kPortalDetectionFailedStatusProperty,
+ shill::kPortalDetectionStatusTimeout);
+ SignalInitialPropertiesReceived();
+ EXPECT_FALSE(network_state_.is_captive_portal());
+
+ // Set just the phase property to the expected captive portal state.
+ // is_captive_portal should still be false.
+ SetStringProperty(shill::kPortalDetectionFailedPhaseProperty,
+ shill::kPortalDetectionPhaseContent);
+ SignalInitialPropertiesReceived();
+ EXPECT_FALSE(network_state_.is_captive_portal());
+
+ // Set the status property to the expected captive portal state property.
+ // is_captive_portal should now be true.
+ SetStringProperty(shill::kPortalDetectionFailedStatusProperty,
+ shill::kPortalDetectionStatusFailure);
+ SignalInitialPropertiesReceived();
+ EXPECT_TRUE(network_state_.is_captive_portal());
+}
+
} // namespace chromeos
« no previous file with comments | « chromeos/network/network_state_handler.cc ('k') | chromeos/network/onc/onc_translator_shill_to_onc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698