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

Side by Side Diff: chromeos/network/network_state_unittest.cc

Issue 1019033002: Add an ONC property for the third-party VPN provider extension ID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 protected: 56 protected:
57 bool SetStringProperty(const std::string& key, const std::string& value) { 57 bool SetStringProperty(const std::string& key, const std::string& value) {
58 TestStringValue* string_value = new TestStringValue(value); 58 TestStringValue* string_value = new TestStringValue(value);
59 bool res = network_state_.PropertyChanged(key, *string_value); 59 bool res = network_state_.PropertyChanged(key, *string_value);
60 properties_.SetWithoutPathExpansion(key, string_value); 60 properties_.SetWithoutPathExpansion(key, string_value);
61 return res; 61 return res;
62 } 62 }
63 63
64 bool SetProperty(const std::string& key, scoped_ptr<base::Value> value) {
pneubeck (no reviews) 2015/03/18 19:35:29 nit: SetStringProperty above could call this funct
bartfab (slow) 2015/03/18 20:02:14 Done.
65 const bool result = network_state_.PropertyChanged(key, *value);
66 properties_.SetWithoutPathExpansion(key, value.release());
67 return result;
68 }
69
64 bool SignalInitialPropertiesReceived() { 70 bool SignalInitialPropertiesReceived() {
65 return network_state_.InitialPropertiesReceived(properties_); 71 return network_state_.InitialPropertiesReceived(properties_);
66 } 72 }
67 73
68 NetworkState network_state_; 74 NetworkState network_state_;
69 75
70 private: 76 private:
71 base::DictionaryValue properties_; 77 base::DictionaryValue properties_;
72 78
73 DISALLOW_COPY_AND_ASSIGN(NetworkStateTest); 79 DISALLOW_COPY_AND_ASSIGN(NetworkStateTest);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 EXPECT_FALSE(network_state_.is_captive_portal()); 212 EXPECT_FALSE(network_state_.is_captive_portal());
207 213
208 // Set the status property to the expected captive portal state property. 214 // Set the status property to the expected captive portal state property.
209 // is_captive_portal should now be true. 215 // is_captive_portal should now be true.
210 SetStringProperty(shill::kPortalDetectionFailedStatusProperty, 216 SetStringProperty(shill::kPortalDetectionFailedStatusProperty,
211 shill::kPortalDetectionStatusFailure); 217 shill::kPortalDetectionStatusFailure);
212 SignalInitialPropertiesReceived(); 218 SignalInitialPropertiesReceived();
213 EXPECT_TRUE(network_state_.is_captive_portal()); 219 EXPECT_TRUE(network_state_.is_captive_portal());
214 } 220 }
215 221
222 // Third-party VPN provider.
223 TEST_F(NetworkStateTest, VPNThirdPartyProvider) {
224 EXPECT_TRUE(SetStringProperty(shill::kTypeProperty, shill::kTypeVPN));
225 EXPECT_TRUE(SetStringProperty(shill::kNameProperty, "VPN"));
226
227 scoped_ptr<base::DictionaryValue> provider(new base::DictionaryValue);
228 provider->SetStringWithoutPathExpansion(shill::kTypeProperty,
229 shill::kProviderThirdPartyVpn);
230 provider->SetStringWithoutPathExpansion(
231 shill::kHostProperty, "third-party-vpn-provider-extension-id");
232 EXPECT_TRUE(SetProperty(shill::kProviderProperty, provider.Pass()));
233 SignalInitialPropertiesReceived();
234 EXPECT_EQ(network_state_.vpn_provider_type(), shill::kProviderThirdPartyVpn);
235 EXPECT_EQ(network_state_.third_party_vpn_provider_extension_id(),
236 "third-party-vpn-provider-extension-id");
237 }
238
216 } // namespace chromeos 239 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698