Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: chromeos/components/tether/tether_connector_unittest.cc

Issue 2819303002: Changed wifi arcs to mobile bars for Tether network. (Closed)
Patch Set: khorimoto@ comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), 188 GetTetherNetworkGuid(test_devices_[1].GetDeviceId()),
189 "TetherNetworkName2", "TetherNetworkCarrier2", 189 "TetherNetworkName2", "TetherNetworkCarrier2",
190 90 /* battery_percentage */, 50 /* signal_strength */); 190 90 /* battery_percentage */, 50 /* signal_strength */);
191 } 191 }
192 192
193 void SuccessfullyJoinWifiNetwork() { 193 void SuccessfullyJoinWifiNetwork() {
194 ConfigureService(CreateWifiConfigurationJsonString()); 194 ConfigureService(CreateWifiConfigurationJsonString());
195 fake_wifi_hotspot_connector_->CallMostRecentCallback(kWifiNetworkGuid); 195 fake_wifi_hotspot_connector_->CallMostRecentCallback(kWifiNetworkGuid);
196 } 196 }
197 197
198 void VerifyTetherAndWifiNetworkAssociation(
199 const std::string& tether_network_guid) {
200 const NetworkState* tether_network_state =
201 network_state_handler()->GetNetworkStateFromGuid(tether_network_guid);
202 EXPECT_TRUE(tether_network_state);
203 EXPECT_EQ(kWifiNetworkGuid, tether_network_state->tether_guid());
204
205 const NetworkState* wifi_network_state =
206 network_state_handler()->GetNetworkStateFromGuid(kWifiNetworkGuid);
207 EXPECT_TRUE(wifi_network_state);
208 EXPECT_EQ(tether_network_guid, wifi_network_state->tether_guid());
209 }
210
211 void SuccessCallback() { result_ = kSuccessResult; } 198 void SuccessCallback() { result_ = kSuccessResult; }
212 199
213 void ErrorCallback(const std::string& error_name, 200 void ErrorCallback(const std::string& error_name,
214 std::unique_ptr<base::DictionaryValue> error_data) { 201 std::unique_ptr<base::DictionaryValue> error_data) {
215 result_ = error_name; 202 result_ = error_name;
216 } 203 }
217 204
218 void CallTetherDelegate(const std::string& tether_network_guid) { 205 void CallTetherDelegate(const std::string& tether_network_guid) {
219 test_network_connection_handler_->CallTetherDelegate( 206 test_network_connection_handler_->CallTetherDelegate(
220 tether_network_guid, 207 tether_network_guid,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 EXPECT_EQ(ActiveHost::ActiveHostStatus::CONNECTING, 338 EXPECT_EQ(ActiveHost::ActiveHostStatus::CONNECTING,
352 fake_active_host_->GetActiveHostStatus()); 339 fake_active_host_->GetActiveHostStatus());
353 340
354 // |fake_wifi_hotspot_connector_| should have received the SSID and password 341 // |fake_wifi_hotspot_connector_| should have received the SSID and password
355 // above. Verify this, then return the GUID corresponding to the connected 342 // above. Verify this, then return the GUID corresponding to the connected
356 // Wi-Fi network. 343 // Wi-Fi network.
357 EXPECT_EQ(kSsid, fake_wifi_hotspot_connector_->most_recent_ssid()); 344 EXPECT_EQ(kSsid, fake_wifi_hotspot_connector_->most_recent_ssid());
358 EXPECT_EQ(kPassword, fake_wifi_hotspot_connector_->most_recent_password()); 345 EXPECT_EQ(kPassword, fake_wifi_hotspot_connector_->most_recent_password());
359 SuccessfullyJoinWifiNetwork(); 346 SuccessfullyJoinWifiNetwork();
360 347
361 // The active host should now be connected, and the tether and Wi-Fi networks 348 // The active host should now be connected.
362 // should be associated.
363 EXPECT_EQ(ActiveHost::ActiveHostStatus::CONNECTED, 349 EXPECT_EQ(ActiveHost::ActiveHostStatus::CONNECTED,
364 fake_active_host_->GetActiveHostStatus()); 350 fake_active_host_->GetActiveHostStatus());
365 EXPECT_EQ(test_devices_[0].GetDeviceId(), 351 EXPECT_EQ(test_devices_[0].GetDeviceId(),
366 fake_active_host_->GetActiveHostDeviceId()); 352 fake_active_host_->GetActiveHostDeviceId());
367 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[0].GetDeviceId()), 353 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[0].GetDeviceId()),
368 fake_active_host_->GetTetherNetworkGuid()); 354 fake_active_host_->GetTetherNetworkGuid());
369 EXPECT_EQ(kWifiNetworkGuid, fake_active_host_->GetWifiNetworkGuid()); 355 EXPECT_EQ(kWifiNetworkGuid, fake_active_host_->GetWifiNetworkGuid());
370 VerifyTetherAndWifiNetworkAssociation( 356
371 GetTetherNetworkGuid(test_devices_[0].GetDeviceId()));
372 EXPECT_EQ(kSuccessResult, GetResultAndReset()); 357 EXPECT_EQ(kSuccessResult, GetResultAndReset());
373 } 358 }
374 359
375 TEST_F(TetherConnectorTest, 360 TEST_F(TetherConnectorTest,
376 TestNewConnectionAttemptDuringFetch_DifferentDevice) { 361 TestNewConnectionAttemptDuringFetch_DifferentDevice) {
377 CallTetherDelegate(GetTetherNetworkGuid(test_devices_[0].GetDeviceId())); 362 CallTetherDelegate(GetTetherNetworkGuid(test_devices_[0].GetDeviceId()));
378 363
379 // Instead of invoking the pending callbacks on |fake_tether_host_fetcher_|, 364 // Instead of invoking the pending callbacks on |fake_tether_host_fetcher_|,
380 // attempt another connection attempt, this time to another device. 365 // attempt another connection attempt, this time to another device.
381 CallTetherDelegate(GetTetherNetworkGuid(test_devices_[1].GetDeviceId())); 366 CallTetherDelegate(GetTetherNetworkGuid(test_devices_[1].GetDeviceId()));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 EXPECT_EQ(test_devices_[1].GetDeviceId(), 461 EXPECT_EQ(test_devices_[1].GetDeviceId(),
477 fake_active_host_->GetActiveHostDeviceId()); 462 fake_active_host_->GetActiveHostDeviceId());
478 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[1].GetDeviceId()), 463 EXPECT_EQ(GetTetherNetworkGuid(test_devices_[1].GetDeviceId()),
479 fake_active_host_->GetTetherNetworkGuid()); 464 fake_active_host_->GetTetherNetworkGuid());
480 EXPECT_TRUE(fake_active_host_->GetWifiNetworkGuid().empty()); 465 EXPECT_TRUE(fake_active_host_->GetWifiNetworkGuid().empty());
481 } 466 }
482 467
483 } // namespace tether 468 } // namespace tether
484 469
485 } // namespace chromeos 470 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698