| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/wifi/fake_wifi_service.h" | 5 #include "components/wifi/fake_wifi_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "components/onc/onc_constants.h" | 10 #include "components/onc/onc_constants.h" |
| 11 | 11 |
| 12 namespace wifi { | 12 namespace wifi { |
| 13 | 13 |
| 14 FakeWiFiService::FakeWiFiService() { | 14 FakeWiFiService::FakeWiFiService() { |
| 15 // Populate data expected by unit test. | 15 // Populate data expected by unit test. |
| 16 { | 16 { |
| 17 NetworkProperties network_properties; | 17 NetworkProperties network_properties; |
| 18 network_properties.connection_state = onc::connection_state::kConnected; | 18 network_properties.connection_state = onc::connection_state::kConnected; |
| 19 network_properties.guid = "stub_wifi1"; | 19 network_properties.guid = "stub_wifi1_GUID"; |
| 20 network_properties.name = "wifi1"; | 20 network_properties.name = "wifi1"; |
| 21 network_properties.type = onc::network_type::kWiFi; | 21 network_properties.type = onc::network_type::kWiFi; |
| 22 network_properties.frequency = 0; | 22 network_properties.frequency = 0; |
| 23 network_properties.ssid = "wifi1"; | 23 network_properties.ssid = "wifi1"; |
| 24 network_properties.security = onc::wifi::kWEP_PSK; | 24 network_properties.security = onc::wifi::kWEP_PSK; |
| 25 network_properties.signal_strength = 40; | 25 network_properties.signal_strength = 40; |
| 26 network_properties.json_extra = | 26 network_properties.json_extra = |
| 27 "{" | 27 "{" |
| 28 " \"MacAddress\": \"00:11:22:AA:BB:CC\"," | 28 " \"MacAddress\": \"00:11:22:AA:BB:CC\"," |
| 29 " \"IPConfigs\": [{" | 29 " \"IPConfigs\": [{" |
| 30 " \"Gateway\": \"0.0.0.1\"," | 30 " \"Gateway\": \"0.0.0.1\"," |
| 31 " \"IPAddress\": \"0.0.0.0\"," | 31 " \"IPAddress\": \"0.0.0.0\"," |
| 32 " \"RoutingPrefix\": 0," | 32 " \"RoutingPrefix\": 0," |
| 33 " \"Type\": \"IPv4\"" | 33 " \"Type\": \"IPv4\"" |
| 34 " }]," | 34 " }]," |
| 35 " \"WiFi\": {" | 35 " \"WiFi\": {" |
| 36 " \"Frequency\": 2400," | 36 " \"Frequency\": 2400," |
| 37 " \"FrequencyList\": [2400]" | 37 " \"FrequencyList\": [2400]" |
| 38 " }" | 38 " }" |
| 39 "}"; | 39 "}"; |
| 40 networks_.push_back(network_properties); | 40 networks_.push_back(network_properties); |
| 41 } | 41 } |
| 42 { | 42 { |
| 43 NetworkProperties network_properties; | 43 NetworkProperties network_properties; |
| 44 network_properties.connection_state = onc::connection_state::kNotConnected; | 44 network_properties.connection_state = onc::connection_state::kNotConnected; |
| 45 network_properties.guid = "stub_wifi2"; | 45 network_properties.guid = "stub_wifi2_GUID"; |
| 46 network_properties.name = "wifi2_PSK"; | 46 network_properties.name = "wifi2_PSK"; |
| 47 network_properties.type = onc::network_type::kWiFi; | 47 network_properties.type = onc::network_type::kWiFi; |
| 48 network_properties.frequency = 5000; | 48 network_properties.frequency = 5000; |
| 49 network_properties.frequency_set.insert(2400); | 49 network_properties.frequency_set.insert(2400); |
| 50 network_properties.frequency_set.insert(5000); | 50 network_properties.frequency_set.insert(5000); |
| 51 network_properties.ssid = "wifi2_PSK"; | 51 network_properties.ssid = "wifi2_PSK"; |
| 52 network_properties.security = onc::wifi::kWPA_PSK; | 52 network_properties.security = onc::wifi::kWPA_PSK; |
| 53 network_properties.signal_strength = 80; | 53 network_properties.signal_strength = 80; |
| 54 networks_.push_back(network_properties); | 54 networks_.push_back(network_properties); |
| 55 } | 55 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 FROM_HERE, base::Bind(network_list_changed_observer_, current_networks)); | 219 FROM_HERE, base::Bind(network_list_changed_observer_, current_networks)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void FakeWiFiService::NotifyNetworkChanged(const std::string& network_guid) { | 222 void FakeWiFiService::NotifyNetworkChanged(const std::string& network_guid) { |
| 223 WiFiService::NetworkGuidList changed_networks(1, network_guid); | 223 WiFiService::NetworkGuidList changed_networks(1, network_guid); |
| 224 message_loop_proxy_->PostTask( | 224 message_loop_proxy_->PostTask( |
| 225 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); | 225 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace wifi | 228 } // namespace wifi |
| OLD | NEW |