Chromium Code Reviews| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 network_state_handler()->AddTetherNetworkState( | 205 network_state_handler()->AddTetherNetworkState( |
| 206 GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), | 206 GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), |
| 207 kTetherNetwork2Name); | 207 kTetherNetwork2Name); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void SuccessfullyJoinWifiNetwork() { | 210 void SuccessfullyJoinWifiNetwork() { |
| 211 ConfigureService(CreateWifiConfigurationJsonString()); | 211 ConfigureService(CreateWifiConfigurationJsonString()); |
| 212 fake_wifi_hotspot_connector_->CallMostRecentCallback(kWifiNetworkGuid); | 212 fake_wifi_hotspot_connector_->CallMostRecentCallback(kWifiNetworkGuid); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void VerifyTetherAndWifiNetworkAssociation( | 215 /* void VerifyTetherAndWifiNetworkAssociation( |
|
Kyle Horimoto
2017/04/17 19:50:04
Remove this if it is unused.
lesliewatkins
2017/04/27 00:33:53
Done.
| |
| 216 const std::string& tether_network_guid) { | 216 const std::string& tether_network_guid) { |
| 217 const NetworkState* tether_network_state = | 217 const NetworkState* tether_network_state = |
| 218 network_state_handler()->GetNetworkStateFromGuid(tether_network_guid); | 218 network_state_handler()->GetNetworkStateFromGuid(tether_network_guid); |
| 219 EXPECT_TRUE(tether_network_state); | 219 EXPECT_TRUE(tether_network_state); |
| 220 EXPECT_EQ(kWifiNetworkGuid, tether_network_state->tether_guid()); | 220 EXPECT_EQ(kWifiNetworkGuid, tether_network_state->tether_guid()); |
| 221 | 221 |
| 222 const NetworkState* wifi_network_state = | 222 const NetworkState* wifi_network_state = |
| 223 network_state_handler()->GetNetworkStateFromGuid(kWifiNetworkGuid); | 223 network_state_handler()->GetNetworkStateFromGuid(kWifiNetworkGuid); |
| 224 EXPECT_TRUE(wifi_network_state); | 224 EXPECT_TRUE(wifi_network_state); |
| 225 EXPECT_EQ(tether_network_guid, wifi_network_state->tether_guid()); | 225 EXPECT_EQ(tether_network_guid, wifi_network_state->tether_guid()); |
| 226 } | 226 }*/ |
| 227 | 227 |
| 228 const std::vector<cryptauth::RemoteDevice> test_devices_; | 228 const std::vector<cryptauth::RemoteDevice> test_devices_; |
| 229 const base::MessageLoop message_loop_; | 229 const base::MessageLoop message_loop_; |
| 230 | 230 |
| 231 std::unique_ptr<FakeConnectTetheringOperationFactory> fake_operation_factory_; | 231 std::unique_ptr<FakeConnectTetheringOperationFactory> fake_operation_factory_; |
| 232 std::unique_ptr<TestNetworkConnect> test_network_connect_; | 232 std::unique_ptr<TestNetworkConnect> test_network_connect_; |
| 233 std::unique_ptr<FakeWifiHotspotConnector> fake_wifi_hotspot_connector_; | 233 std::unique_ptr<FakeWifiHotspotConnector> fake_wifi_hotspot_connector_; |
| 234 std::unique_ptr<FakeActiveHost> fake_active_host_; | 234 std::unique_ptr<FakeActiveHost> fake_active_host_; |
| 235 std::unique_ptr<FakeTetherHostFetcher> fake_tether_host_fetcher_; | 235 std::unique_ptr<FakeTetherHostFetcher> fake_tether_host_fetcher_; |
| 236 std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_; | 236 std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 EXPECT_EQ(ActiveHost::ActiveHostStatus::CONNECTING, | 337 EXPECT_EQ(ActiveHost::ActiveHostStatus::CONNECTING, |
| 338 fake_active_host_->GetActiveHostStatus()); | 338 fake_active_host_->GetActiveHostStatus()); |
| 339 | 339 |
| 340 // |fake_wifi_hotspot_connector_| should have received the SSID and password | 340 // |fake_wifi_hotspot_connector_| should have received the SSID and password |
| 341 // above. Verify this, then return the GUID corresponding to the connected | 341 // above. Verify this, then return the GUID corresponding to the connected |
| 342 // Wi-Fi network. | 342 // Wi-Fi network. |
| 343 EXPECT_EQ(kSsid, fake_wifi_hotspot_connector_->most_recent_ssid()); | 343 EXPECT_EQ(kSsid, fake_wifi_hotspot_connector_->most_recent_ssid()); |
| 344 EXPECT_EQ(kPassword, fake_wifi_hotspot_connector_->most_recent_password()); | 344 EXPECT_EQ(kPassword, fake_wifi_hotspot_connector_->most_recent_password()); |
| 345 SuccessfullyJoinWifiNetwork(); | 345 SuccessfullyJoinWifiNetwork(); |
| 346 | 346 |
| 347 // The active host should now be connected, and the tether and Wi-Fi networks | 347 // The active host should now be connected |
| 348 // should be associated. | |
| 349 EXPECT_EQ(ActiveHost::ActiveHostStatus::CONNECTED, | 348 EXPECT_EQ(ActiveHost::ActiveHostStatus::CONNECTED, |
| 350 fake_active_host_->GetActiveHostStatus()); | 349 fake_active_host_->GetActiveHostStatus()); |
| 351 EXPECT_EQ(test_devices_[0].GetDeviceId(), | 350 EXPECT_EQ(test_devices_[0].GetDeviceId(), |
| 352 fake_active_host_->GetActiveHostDeviceId()); | 351 fake_active_host_->GetActiveHostDeviceId()); |
| 353 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[0].GetDeviceId()), | 352 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[0].GetDeviceId()), |
| 354 fake_active_host_->GetTetherNetworkGuid()); | 353 fake_active_host_->GetTetherNetworkGuid()); |
| 355 EXPECT_EQ(kWifiNetworkGuid, fake_active_host_->GetWifiNetworkGuid()); | 354 EXPECT_EQ(kWifiNetworkGuid, fake_active_host_->GetWifiNetworkGuid()); |
| 356 VerifyTetherAndWifiNetworkAssociation( | |
| 357 GetTetherNetworkGuid(test_devices_[0].GetDeviceId())); | |
| 358 } | 355 } |
| 359 | 356 |
| 360 TEST_F(TetherConnectorTest, TestNewConnectionAttemptDuringFetch_SameDevice) { | 357 TEST_F(TetherConnectorTest, TestNewConnectionAttemptDuringFetch_SameDevice) { |
| 361 test_network_connect_->CallTetherDelegate( | 358 test_network_connect_->CallTetherDelegate( |
| 362 GetTetherNetworkGuid(test_devices_[0].GetDeviceId())); | 359 GetTetherNetworkGuid(test_devices_[0].GetDeviceId())); |
| 363 | 360 |
| 364 // Instead of invoking the pending callbacks on |fake_tether_host_fetcher_|, | 361 // Instead of invoking the pending callbacks on |fake_tether_host_fetcher_|, |
| 365 // attempt another connection attempt. | 362 // attempt another connection attempt. |
| 366 test_network_connect_->CallTetherDelegate( | 363 test_network_connect_->CallTetherDelegate( |
| 367 GetTetherNetworkGuid(test_devices_[0].GetDeviceId())); | 364 GetTetherNetworkGuid(test_devices_[0].GetDeviceId())); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 EXPECT_EQ(test_devices_[1].GetDeviceId(), | 467 EXPECT_EQ(test_devices_[1].GetDeviceId(), |
| 471 fake_active_host_->GetActiveHostDeviceId()); | 468 fake_active_host_->GetActiveHostDeviceId()); |
| 472 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), | 469 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), |
| 473 fake_active_host_->GetTetherNetworkGuid()); | 470 fake_active_host_->GetTetherNetworkGuid()); |
| 474 EXPECT_TRUE(fake_active_host_->GetWifiNetworkGuid().empty()); | 471 EXPECT_TRUE(fake_active_host_->GetWifiNetworkGuid().empty()); |
| 475 } | 472 } |
| 476 | 473 |
| 477 } // namespace tether | 474 } // namespace tether |
| 478 | 475 |
| 479 } // namespace cryptauth | 476 } // namespace cryptauth |
| OLD | NEW |