diff options
author | mef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-05 00:50:37 +0000 |
---|---|---|
committer | mef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-05 00:50:37 +0000 |
commit | 4adfc3b9f3248205a61829893ef7a604bb89e38b (patch) | |
tree | 58169e658344404baa8fef6a73de8f5e2aeb234e /components/wifi/fake_wifi_service.cc | |
parent | e1d0d62afb1c251c976e498df738460f6211a29d (diff) | |
download | chromium_src-4adfc3b9f3248205a61829893ef7a604bb89e38b.zip chromium_src-4adfc3b9f3248205a61829893ef7a604bb89e38b.tar.gz chromium_src-4adfc3b9f3248205a61829893ef7a604bb89e38b.tar.bz2 |
Added GetState, GetManagedProperties, CreateNetwork methods to WiFiService.
Initially implemented only to satisfy Networking Private Api browser_tests.
Moved hard-coded test data for NetworkingPrivateApiTest into fake_wifi_service.cc
BUG=267667
Review URL: https://codereview.chromium.org/100493002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238835 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/wifi/fake_wifi_service.cc')
-rw-r--r-- | components/wifi/fake_wifi_service.cc | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/components/wifi/fake_wifi_service.cc b/components/wifi/fake_wifi_service.cc index a1eac21..9ca63ef 100644 --- a/components/wifi/fake_wifi_service.cc +++ b/components/wifi/fake_wifi_service.cc @@ -5,6 +5,7 @@ #include "components/wifi/wifi_service.h" #include "base/bind.h" +#include "base/json/json_reader.h" #include "base/message_loop/message_loop.h" #include "components/onc/onc_constants.h" @@ -97,6 +98,92 @@ class FakeWiFiService : public WiFiService { } } + virtual void GetManagedProperties(const std::string& network_guid, + DictionaryValue* managed_properties, + std::string* error) OVERRIDE { + const std::string network_properties = + "{" + " \"ConnectionState\": {" + " \"Active\": \"NotConnected\"," + " \"Effective\": \"Unmanaged\"" + " }," + " \"GUID\": \"stub_wifi2\"," + " \"Name\": {" + " \"Active\": \"wifi2_PSK\"," + " \"Effective\": \"UserPolicy\"," + " \"UserPolicy\": \"My WiFi Network\"" + " }," + " \"Type\": {" + " \"Active\": \"WiFi\"," + " \"Effective\": \"UserPolicy\"," + " \"UserPolicy\": \"WiFi\"" + " }," + " \"WiFi\": {" + " \"AutoConnect\": {" + " \"Active\": false," + " \"UserEditable\": true" + " }," + " \"Frequency\" : {" + " \"Active\": 5000," + " \"Effective\": \"Unmanaged\"" + " }," + " \"FrequencyList\" : {" + " \"Active\": [2400, 5000]," + " \"Effective\": \"Unmanaged\"" + " }," + " \"Passphrase\": {" + " \"Effective\": \"UserSetting\"," + " \"UserEditable\": true," + " \"UserSetting\": \"FAKE_CREDENTIAL_VPaJDV9x\"" + " }," + " \"SSID\": {" + " \"Active\": \"wifi2_PSK\"," + " \"Effective\": \"UserPolicy\"," + " \"UserPolicy\": \"wifi2_PSK\"" + " }," + " \"Security\": {" + " \"Active\": \"WPA-PSK\"," + " \"Effective\": \"UserPolicy\"," + " \"UserPolicy\": \"WPA-PSK\"" + " }," + " \"SignalStrength\": {" + " \"Active\": 80," + " \"Effective\": \"Unmanaged\"" + " }" + " }" + "}"; + scoped_ptr<DictionaryValue> properties_value( + reinterpret_cast<DictionaryValue*>( + base::JSONReader::Read(network_properties))); + managed_properties->MergeDictionary(properties_value.get()); + } + + virtual void GetState(const std::string& network_guid, + DictionaryValue* properties, + std::string* error) OVERRIDE { + NetworkList::iterator network_properties = FindNetwork(network_guid); + if (network_properties == networks_.end()) { + *error = "Error.InvalidParameter"; + return; + } + + const std::string network_state = + "{" + " \"ConnectionState\": \"NotConnected\"," + " \"GUID\": \"stub_wifi2\"," + " \"Name\": \"wifi2_PSK\"," + " \"Type\": \"WiFi\"," + " \"WiFi\": {" + " \"Security\": \"WPA-PSK\"," + " \"SignalStrength\": 80" + " }" + "}"; + scoped_ptr<DictionaryValue> properties_value( + reinterpret_cast<DictionaryValue*>( + base::JSONReader::Read(network_state))); + properties->MergeDictionary(properties_value.get()); + } + virtual void SetProperties(const std::string& network_guid, scoped_ptr<base::DictionaryValue> properties, std::string* error) OVERRIDE { @@ -107,6 +194,20 @@ class FakeWiFiService : public WiFiService { } } + virtual void CreateNetwork(bool shared, + scoped_ptr<base::DictionaryValue> properties, + std::string* network_guid, + std::string* error) OVERRIDE { + WiFiService::NetworkProperties network_properties; + if (network_properties.UpdateFromValue(*properties)) { + network_properties.guid = network_properties.ssid; + networks_.push_back(network_properties); + *network_guid = network_properties.guid; + } else { + *error = "Error.DBusFailed"; + } + } + virtual void GetVisibleNetworks(const std::string& network_type, ListValue* network_list) OVERRIDE { for (WiFiService::NetworkList::const_iterator it = networks_.begin(); |