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

Side by Side 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, 10 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chromeos/network/network_state.h" 5 #include "chromeos/network/network_state.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/i18n/streaming_utf8_validator.h" 8 #include "base/i18n/streaming_utf8_validator.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 TEST_F(NetworkStateTest, SsidHexMultipleUpdates) { 164 TEST_F(NetworkStateTest, SsidHexMultipleUpdates) {
165 EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeWifi)); 165 EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeWifi));
166 166
167 std::string wifi_hex_result = "This is HEX SSID!"; 167 std::string wifi_hex_result = "This is HEX SSID!";
168 std::string wifi_hex = 168 std::string wifi_hex =
169 base::HexEncode(wifi_hex_result.c_str(), wifi_hex_result.length()); 169 base::HexEncode(wifi_hex_result.c_str(), wifi_hex_result.length());
170 EXPECT_TRUE(SetStringProperty(shill::kWifiHexSsid, wifi_hex)); 170 EXPECT_TRUE(SetStringProperty(shill::kWifiHexSsid, wifi_hex));
171 EXPECT_TRUE(SetStringProperty(shill::kWifiHexSsid, wifi_hex)); 171 EXPECT_TRUE(SetStringProperty(shill::kWifiHexSsid, wifi_hex));
172 } 172 }
173 173
174 TEST_F(NetworkStateTest, CaptivePortalState) {
175 std::string network_name = "test";
176 EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeWifi));
177 EXPECT_TRUE(SetStringProperty(shill::kNameProperty, network_name));
178 std::string hex_ssid =
179 base::HexEncode(network_name.c_str(), network_name.length());
180 EXPECT_TRUE(SetStringProperty(shill::kWifiHexSsid, hex_ssid));
181
182 // State != portal -> is_captive_portal == false
183 EXPECT_TRUE(SetStringProperty(shill::kStateProperty, shill::kStateReady));
184 SignalInitialPropertiesReceived();
185 EXPECT_FALSE(network_state_.is_captive_portal());
186
187 // State == portal, kPortalDetection* not set -> is_captive_portal = true
188 EXPECT_TRUE(SetStringProperty(shill::kStateProperty, shill::kStatePortal));
189 SignalInitialPropertiesReceived();
190 EXPECT_TRUE(network_state_.is_captive_portal());
191
192 // Set kPortalDetectionFailed* properties to states that should not trigger
193 // is_captive_portal.
194 SetStringProperty(shill::kPortalDetectionFailedPhaseProperty,
195 shill::kPortalDetectionPhaseUnknown);
196 SetStringProperty(shill::kPortalDetectionFailedStatusProperty,
197 shill::kPortalDetectionStatusTimeout);
198 SignalInitialPropertiesReceived();
199 EXPECT_FALSE(network_state_.is_captive_portal());
200
201 // Set just the phase property to the expected captive portal state.
202 // is_captive_portal should still be false.
203 SetStringProperty(shill::kPortalDetectionFailedPhaseProperty,
204 shill::kPortalDetectionPhaseContent);
205 SignalInitialPropertiesReceived();
206 EXPECT_FALSE(network_state_.is_captive_portal());
207
208 // Set the status property to the expected captive portal state property.
209 // is_captive_portal should now be true.
210 SetStringProperty(shill::kPortalDetectionFailedStatusProperty,
211 shill::kPortalDetectionStatusFailure);
212 SignalInitialPropertiesReceived();
213 EXPECT_TRUE(network_state_.is_captive_portal());
214 }
215
174 } // namespace chromeos 216 } // namespace chromeos
OLDNEW
« 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