OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/components/tether/tether_connector.h" | 5 #include "chromeos/components/tether/tether_connector.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "chromeos/components/tether/connect_tethering_operation.h" | 9 #include "chromeos/components/tether/connect_tethering_operation.h" |
10 #include "chromeos/components/tether/device_id_tether_network_guid_map.h" | 10 #include "chromeos/components/tether/device_id_tether_network_guid_map.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 namespace tether { | 30 namespace tether { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 const char kSsid[] = "ssid"; | 34 const char kSsid[] = "ssid"; |
35 const char kPassword[] = "password"; | 35 const char kPassword[] = "password"; |
36 | 36 |
37 const char kWifiNetworkGuid[] = "wifiNetworkGuid"; | 37 const char kWifiNetworkGuid[] = "wifiNetworkGuid"; |
38 | 38 |
39 const char kTetherNetwork1Name[] = "tetherNetwork1Name"; | |
40 const char kTetherNetwork2Name[] = "tetherNetwork2Name"; | |
41 | |
42 std::string CreateWifiConfigurationJsonString() { | 39 std::string CreateWifiConfigurationJsonString() { |
43 std::stringstream ss; | 40 std::stringstream ss; |
44 ss << "{" | 41 ss << "{" |
45 << " \"GUID\": \"" << kWifiNetworkGuid << "\"," | 42 << " \"GUID\": \"" << kWifiNetworkGuid << "\"," |
46 << " \"Type\": \"" << shill::kTypeWifi << "\"," | 43 << " \"Type\": \"" << shill::kTypeWifi << "\"," |
47 << " \"State\": \"" << shill::kStateIdle << "\"" | 44 << " \"State\": \"" << shill::kStateIdle << "\"" |
48 << "}"; | 45 << "}"; |
49 return ss.str(); | 46 return ss.str(); |
50 } | 47 } |
51 | 48 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 return device_id_tether_network_guid_map_->GetTetherNetworkGuidForDeviceId( | 191 return device_id_tether_network_guid_map_->GetTetherNetworkGuidForDeviceId( |
195 device_id); | 192 device_id); |
196 } | 193 } |
197 | 194 |
198 void SetUpTetherNetworks() { | 195 void SetUpTetherNetworks() { |
199 // Add a tether network corresponding to both of the test devices. These | 196 // Add a tether network corresponding to both of the test devices. These |
200 // networks are expected to be added already before TetherConnector receives | 197 // networks are expected to be added already before TetherConnector receives |
201 // its ConnectToNetwork() callback. | 198 // its ConnectToNetwork() callback. |
202 network_state_handler()->AddTetherNetworkState( | 199 network_state_handler()->AddTetherNetworkState( |
203 GetTetherNetworkGuid(test_devices_[0].GetDeviceId()), | 200 GetTetherNetworkGuid(test_devices_[0].GetDeviceId()), |
204 kTetherNetwork1Name); | 201 "TetherNetworkName1", "TetherNetworkCarrier1", |
| 202 85 /* battery_percentage */, 75 /* signal_strength */); |
205 network_state_handler()->AddTetherNetworkState( | 203 network_state_handler()->AddTetherNetworkState( |
206 GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), | 204 GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), |
207 kTetherNetwork2Name); | 205 "TetherNetworkName2", "TetherNetworkCarrier2", |
| 206 90 /* battery_percentage */, 50 /* signal_strength */); |
208 } | 207 } |
209 | 208 |
210 void SuccessfullyJoinWifiNetwork() { | 209 void SuccessfullyJoinWifiNetwork() { |
211 ConfigureService(CreateWifiConfigurationJsonString()); | 210 ConfigureService(CreateWifiConfigurationJsonString()); |
212 fake_wifi_hotspot_connector_->CallMostRecentCallback(kWifiNetworkGuid); | 211 fake_wifi_hotspot_connector_->CallMostRecentCallback(kWifiNetworkGuid); |
213 } | 212 } |
214 | 213 |
215 void VerifyTetherAndWifiNetworkAssociation( | 214 void VerifyTetherAndWifiNetworkAssociation( |
216 const std::string& tether_network_guid) { | 215 const std::string& tether_network_guid) { |
217 const NetworkState* tether_network_state = | 216 const NetworkState* tether_network_state = |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 fake_active_host_->GetActiveHostStatus()); | 468 fake_active_host_->GetActiveHostStatus()); |
470 EXPECT_EQ(test_devices_[1].GetDeviceId(), | 469 EXPECT_EQ(test_devices_[1].GetDeviceId(), |
471 fake_active_host_->GetActiveHostDeviceId()); | 470 fake_active_host_->GetActiveHostDeviceId()); |
472 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), | 471 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), |
473 fake_active_host_->GetTetherNetworkGuid()); | 472 fake_active_host_->GetTetherNetworkGuid()); |
474 EXPECT_TRUE(fake_active_host_->GetWifiNetworkGuid().empty()); | 473 EXPECT_TRUE(fake_active_host_->GetWifiNetworkGuid().empty()); |
475 } | 474 } |
476 | 475 |
477 } // namespace tether | 476 } // namespace tether |
478 | 477 |
479 } // namespace cryptauth | 478 } // namespace chromeos |
OLD | NEW |