| 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 WiFiService::NetworkProperties network_properties; | 17 WiFiService::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_ethernet"; | 19 network_properties.guid = "stub_ethernet"; |
| 20 network_properties.name = "eth0"; | 20 network_properties.name = "eth0"; |
| 21 network_properties.type = onc::network_type::kEthernet; | 21 network_properties.type = onc::network_type::kEthernet; |
| 22 network_properties.json_extra = | 22 network_properties.json_extra = |
| 23 " {" | 23 " {" |
| 24 " \"Authentication\": \"None\"" | 24 " \"Authentication\": \"None\"" |
| 25 " }"; | 25 " }"; |
| 26 networks_.push_back(network_properties); | 26 networks_.push_back(network_properties); |
| 27 } | 27 } |
| 28 { | 28 { |
| 29 WiFiService::NetworkProperties network_properties; | 29 WiFiService::NetworkProperties network_properties; |
| 30 network_properties.connectable = true; |
| 30 network_properties.connection_state = onc::connection_state::kConnected; | 31 network_properties.connection_state = onc::connection_state::kConnected; |
| 31 network_properties.guid = "stub_wifi1"; | 32 network_properties.guid = "stub_wifi1"; |
| 32 network_properties.name = "wifi1"; | 33 network_properties.name = "wifi1"; |
| 33 network_properties.type = onc::network_type::kWiFi; | 34 network_properties.type = onc::network_type::kWiFi; |
| 34 network_properties.frequency = 0; | 35 network_properties.frequency = 0; |
| 35 network_properties.ssid = "stub_wifi1"; | 36 network_properties.ssid = "stub_wifi1"; |
| 36 network_properties.security = onc::wifi::kWEP_PSK; | 37 network_properties.security = onc::wifi::kWEP_PSK; |
| 37 network_properties.signal_strength = 0; | 38 network_properties.signal_strength = 0; |
| 38 networks_.push_back(network_properties); | 39 networks_.push_back(network_properties); |
| 39 } | 40 } |
| 40 { | 41 { |
| 41 WiFiService::NetworkProperties network_properties; | 42 WiFiService::NetworkProperties network_properties; |
| 42 network_properties.connection_state = onc::connection_state::kConnected; | 43 network_properties.connection_state = onc::connection_state::kConnected; |
| 43 network_properties.guid = "stub_vpn1"; | 44 network_properties.guid = "stub_vpn1"; |
| 44 network_properties.name = "vpn1"; | 45 network_properties.name = "vpn1"; |
| 45 network_properties.type = onc::network_type::kVPN; | 46 network_properties.type = onc::network_type::kVPN; |
| 46 networks_.push_back(network_properties); | 47 networks_.push_back(network_properties); |
| 47 } | 48 } |
| 48 { | 49 { |
| 49 WiFiService::NetworkProperties network_properties; | 50 WiFiService::NetworkProperties network_properties; |
| 51 network_properties.connectable = true; |
| 50 network_properties.connection_state = onc::connection_state::kNotConnected; | 52 network_properties.connection_state = onc::connection_state::kNotConnected; |
| 51 network_properties.guid = "stub_wifi2"; | 53 network_properties.guid = "stub_wifi2"; |
| 52 network_properties.name = "wifi2_PSK"; | 54 network_properties.name = "wifi2_PSK"; |
| 53 network_properties.type = onc::network_type::kWiFi; | 55 network_properties.type = onc::network_type::kWiFi; |
| 54 network_properties.frequency = 5000; | 56 network_properties.frequency = 5000; |
| 55 network_properties.frequency_set.insert(2400); | 57 network_properties.frequency_set.insert(2400); |
| 56 network_properties.frequency_set.insert(5000); | 58 network_properties.frequency_set.insert(5000); |
| 57 network_properties.ssid = "wifi2_PSK"; | 59 network_properties.ssid = "wifi2_PSK"; |
| 58 network_properties.security = onc::wifi::kWPA_PSK; | 60 network_properties.security = onc::wifi::kWPA_PSK; |
| 59 network_properties.signal_strength = 80; | 61 network_properties.signal_strength = 80; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 FROM_HERE, base::Bind(network_list_changed_observer_, current_networks)); | 320 FROM_HERE, base::Bind(network_list_changed_observer_, current_networks)); |
| 319 } | 321 } |
| 320 | 322 |
| 321 void FakeWiFiService::NotifyNetworkChanged(const std::string& network_guid) { | 323 void FakeWiFiService::NotifyNetworkChanged(const std::string& network_guid) { |
| 322 WiFiService::NetworkGuidList changed_networks(1, network_guid); | 324 WiFiService::NetworkGuidList changed_networks(1, network_guid); |
| 323 message_loop_proxy_->PostTask( | 325 message_loop_proxy_->PostTask( |
| 324 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); | 326 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); |
| 325 } | 327 } |
| 326 | 328 |
| 327 } // namespace wifi | 329 } // namespace wifi |
| OLD | NEW |