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

Side by Side Diff: chromeos/network/network_state_handler_unittest.cc

Issue 2819993002: [CrOS Tether] Add the notion of a tether DeviceState. (Closed)
Patch Set: hansberry@ comments. Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/network/network_state_handler.h" 5 #include "chromeos/network/network_state_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 10 matching lines...) Expand all
21 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/dbus/shill_device_client.h" 22 #include "chromeos/dbus/shill_device_client.h"
23 #include "chromeos/dbus/shill_ipconfig_client.h" 23 #include "chromeos/dbus/shill_ipconfig_client.h"
24 #include "chromeos/dbus/shill_manager_client.h" 24 #include "chromeos/dbus/shill_manager_client.h"
25 #include "chromeos/dbus/shill_profile_client.h" 25 #include "chromeos/dbus/shill_profile_client.h"
26 #include "chromeos/dbus/shill_service_client.h" 26 #include "chromeos/dbus/shill_service_client.h"
27 #include "chromeos/network/device_state.h" 27 #include "chromeos/network/device_state.h"
28 #include "chromeos/network/network_state.h" 28 #include "chromeos/network/network_state.h"
29 #include "chromeos/network/network_state_handler.h" 29 #include "chromeos/network/network_state_handler.h"
30 #include "chromeos/network/network_state_handler_observer.h" 30 #include "chromeos/network/network_state_handler_observer.h"
31 #include "chromeos/network/tether_constants.h"
31 #include "dbus/object_path.h" 32 #include "dbus/object_path.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 #include "third_party/cros_system_api/dbus/service_constants.h" 34 #include "third_party/cros_system_api/dbus/service_constants.h"
34 35
35 namespace { 36 namespace {
36 37
37 void ErrorCallbackFunction(const std::string& error_name, 38 void ErrorCallbackFunction(const std::string& error_name,
38 const std::string& error_message) { 39 const std::string& error_message) {
39 LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message; 40 LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message;
40 } 41 }
(...skipping 25 matching lines...) Expand all
66 using chromeos::NetworkStateHandler; 67 using chromeos::NetworkStateHandler;
67 68
68 class TestObserver : public chromeos::NetworkStateHandlerObserver { 69 class TestObserver : public chromeos::NetworkStateHandlerObserver {
69 public: 70 public:
70 explicit TestObserver(NetworkStateHandler* handler) 71 explicit TestObserver(NetworkStateHandler* handler)
71 : handler_(handler), 72 : handler_(handler),
72 device_list_changed_count_(0), 73 device_list_changed_count_(0),
73 device_count_(0), 74 device_count_(0),
74 network_list_changed_count_(0), 75 network_list_changed_count_(0),
75 network_count_(0), 76 network_count_(0),
76 default_network_change_count_(0) { 77 default_network_change_count_(0),
77 } 78 scan_completed_count_(0) {}
78 79
79 ~TestObserver() override {} 80 ~TestObserver() override {}
80 81
81 void DeviceListChanged() override { 82 void DeviceListChanged() override {
82 NetworkStateHandler::DeviceStateList devices; 83 NetworkStateHandler::DeviceStateList devices;
83 handler_->GetDeviceList(&devices); 84 handler_->GetDeviceList(&devices);
84 device_count_ = devices.size(); 85 device_count_ = devices.size();
85 ++device_list_changed_count_; 86 ++device_list_changed_count_;
86 } 87 }
87 88
(...skipping 30 matching lines...) Expand all
118 void NetworkPropertiesUpdated(const NetworkState* network) override { 119 void NetworkPropertiesUpdated(const NetworkState* network) override {
119 DCHECK(network); 120 DCHECK(network);
120 property_updates_[network->path()]++; 121 property_updates_[network->path()]++;
121 } 122 }
122 123
123 void DevicePropertiesUpdated(const DeviceState* device) override { 124 void DevicePropertiesUpdated(const DeviceState* device) override {
124 DCHECK(device); 125 DCHECK(device);
125 device_property_updates_[device->path()]++; 126 device_property_updates_[device->path()]++;
126 } 127 }
127 128
129 void ScanCompleted(const DeviceState* device) override {
130 DCHECK(device);
131 scan_completed_count_++;
132 }
133
128 size_t device_list_changed_count() { return device_list_changed_count_; } 134 size_t device_list_changed_count() { return device_list_changed_count_; }
129 size_t device_count() { return device_count_; } 135 size_t device_count() { return device_count_; }
130 size_t network_list_changed_count() { return network_list_changed_count_; } 136 size_t network_list_changed_count() { return network_list_changed_count_; }
131 size_t network_count() { return network_count_; } 137 size_t network_count() { return network_count_; }
132 size_t default_network_change_count() { 138 size_t default_network_change_count() {
133 return default_network_change_count_; 139 return default_network_change_count_;
134 } 140 }
141 size_t scan_completed_count() { return scan_completed_count_; }
135 void reset_change_counts() { 142 void reset_change_counts() {
136 DVLOG(1) << "=== RESET CHANGE COUNTS ==="; 143 DVLOG(1) << "=== RESET CHANGE COUNTS ===";
137 default_network_change_count_ = 0; 144 default_network_change_count_ = 0;
138 device_list_changed_count_ = 0; 145 device_list_changed_count_ = 0;
139 network_list_changed_count_ = 0; 146 network_list_changed_count_ = 0;
147 scan_completed_count_ = 0;
140 connection_state_changes_.clear(); 148 connection_state_changes_.clear();
141 } 149 }
142 void reset_updates() { 150 void reset_updates() {
143 property_updates_.clear(); 151 property_updates_.clear();
144 device_property_updates_.clear(); 152 device_property_updates_.clear();
145 } 153 }
146 std::string default_network() { return default_network_; } 154 std::string default_network() { return default_network_; }
147 std::string default_network_connection_state() { 155 std::string default_network_connection_state() {
148 return default_network_connection_state_; 156 return default_network_connection_state_;
149 } 157 }
(...skipping 15 matching lines...) Expand all
165 return network_connection_state_[service_path]; 173 return network_connection_state_[service_path];
166 } 174 }
167 175
168 private: 176 private:
169 NetworkStateHandler* handler_; 177 NetworkStateHandler* handler_;
170 size_t device_list_changed_count_; 178 size_t device_list_changed_count_;
171 size_t device_count_; 179 size_t device_count_;
172 size_t network_list_changed_count_; 180 size_t network_list_changed_count_;
173 size_t network_count_; 181 size_t network_count_;
174 size_t default_network_change_count_; 182 size_t default_network_change_count_;
183 size_t scan_completed_count_;
175 std::string default_network_; 184 std::string default_network_;
176 std::string default_network_connection_state_; 185 std::string default_network_connection_state_;
177 std::map<std::string, int> property_updates_; 186 std::map<std::string, int> property_updates_;
178 std::map<std::string, int> device_property_updates_; 187 std::map<std::string, int> device_property_updates_;
179 std::map<std::string, int> connection_state_changes_; 188 std::map<std::string, int> connection_state_changes_;
180 std::map<std::string, std::string> network_connection_state_; 189 std::map<std::string, std::string> network_connection_state_;
181 190
182 DISALLOW_COPY_AND_ASSIGN(TestObserver); 191 DISALLOW_COPY_AND_ASSIGN(TestObserver);
183 }; 192 };
184 193
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 ShillManagerClient::TestInterface* manager_test_; 302 ShillManagerClient::TestInterface* manager_test_;
294 ShillProfileClient::TestInterface* profile_test_; 303 ShillProfileClient::TestInterface* profile_test_;
295 ShillServiceClient::TestInterface* service_test_; 304 ShillServiceClient::TestInterface* service_test_;
296 305
297 private: 306 private:
298 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandlerTest); 307 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandlerTest);
299 }; 308 };
300 309
301 TEST_F(NetworkStateHandlerTest, NetworkStateHandlerStub) { 310 TEST_F(NetworkStateHandlerTest, NetworkStateHandlerStub) {
302 // Ensure that the device and network list are the expected size. 311 // Ensure that the device and network list are the expected size.
303 const size_t kNumShillManagerClientStubImplDevices = 2; 312 const size_t kNumShillManagerClientStubImplDevices = 3;
304 EXPECT_EQ(kNumShillManagerClientStubImplDevices, 313 EXPECT_EQ(kNumShillManagerClientStubImplDevices,
305 test_observer_->device_count()); 314 test_observer_->device_count());
306 const size_t kNumShillManagerClientStubImplServices = 4; 315 const size_t kNumShillManagerClientStubImplServices = 4;
307 EXPECT_EQ(kNumShillManagerClientStubImplServices, 316 EXPECT_EQ(kNumShillManagerClientStubImplServices,
308 test_observer_->network_count()); 317 test_observer_->network_count());
309 // Ensure that the first stub network is the default network. 318 // Ensure that the first stub network is the default network.
310 EXPECT_EQ(kShillManagerClientStubDefaultService, 319 EXPECT_EQ(kShillManagerClientStubDefaultService,
311 test_observer_->default_network()); 320 test_observer_->default_network());
312 ASSERT_TRUE(network_state_handler_->DefaultNetwork()); 321 ASSERT_TRUE(network_state_handler_->DefaultNetwork());
313 EXPECT_EQ(kShillManagerClientStubDefaultService, 322 EXPECT_EQ(kShillManagerClientStubDefaultService,
314 network_state_handler_->DefaultNetwork()->path()); 323 network_state_handler_->DefaultNetwork()->path());
315 EXPECT_EQ(kShillManagerClientStubDefaultService, 324 EXPECT_EQ(kShillManagerClientStubDefaultService,
316 network_state_handler_->ConnectedNetworkByType( 325 network_state_handler_->ConnectedNetworkByType(
317 NetworkTypePattern::Ethernet())->path()); 326 NetworkTypePattern::Ethernet())->path());
318 EXPECT_EQ(kShillManagerClientStubDefaultWifi, 327 EXPECT_EQ(kShillManagerClientStubDefaultWifi,
319 network_state_handler_->ConnectedNetworkByType( 328 network_state_handler_->ConnectedNetworkByType(
320 NetworkTypePattern::WiFi())->path()); 329 NetworkTypePattern::WiFi())->path());
321 EXPECT_EQ(kShillManagerClientStubCellular, 330 EXPECT_EQ(kShillManagerClientStubCellular,
322 network_state_handler_->FirstNetworkByType( 331 network_state_handler_->FirstNetworkByType(
323 NetworkTypePattern::Mobile())->path()); 332 NetworkTypePattern::Mobile())->path());
324 EXPECT_EQ( 333 EXPECT_EQ(
325 kShillManagerClientStubCellular, 334 kShillManagerClientStubCellular,
326 network_state_handler_->FirstNetworkByType(NetworkTypePattern::Cellular()) 335 network_state_handler_->FirstNetworkByType(NetworkTypePattern::Cellular())
327 ->path()); 336 ->path());
328 EXPECT_EQ(shill::kStateOnline, 337 EXPECT_EQ(shill::kStateOnline,
329 test_observer_->default_network_connection_state()); 338 test_observer_->default_network_connection_state());
330 } 339 }
331 340
332 TEST_F(NetworkStateHandlerTest, GetNetworkList) { 341 TEST_F(NetworkStateHandlerTest, GetNetworkList) {
342 network_state_handler_->SetTetherTechnologyState(
343 NetworkStateHandler::TECHNOLOGY_ENABLED);
344
333 // Ensure that the network list is the expected size. 345 // Ensure that the network list is the expected size.
334 const size_t kNumShillManagerClientStubImplServices = 4; 346 const size_t kNumShillManagerClientStubImplServices = 4;
335 EXPECT_EQ(kNumShillManagerClientStubImplServices, 347 EXPECT_EQ(kNumShillManagerClientStubImplServices,
336 test_observer_->network_count()); 348 test_observer_->network_count());
337 // Add a non-visible network to the profile. 349 // Add a non-visible network to the profile.
338 const std::string profile = "/profile/profile1"; 350 const std::string profile = "/profile/profile1";
339 const std::string wifi_favorite_path = "/service/wifi_faviorite"; 351 const std::string wifi_favorite_path = "/service/wifi_faviorite";
340 service_test_->AddService(wifi_favorite_path, 352 service_test_->AddService(wifi_favorite_path,
341 "wifi_faviorite_guid", 353 "wifi_faviorite_guid",
342 "wifi_faviorite", 354 "wifi_faviorite",
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // Get configured (profile) networks. 420 // Get configured (profile) networks.
409 network_state_handler_->GetNetworkListByType(NetworkTypePattern::Default(), 421 network_state_handler_->GetNetworkListByType(NetworkTypePattern::Default(),
410 true /* configured_only */, 422 true /* configured_only */,
411 false /* visible_only */, 423 false /* visible_only */,
412 0 /* no limit */, 424 0 /* no limit */,
413 &networks); 425 &networks);
414 EXPECT_EQ(kNumTetherNetworks + 1u, networks.size()); 426 EXPECT_EQ(kNumTetherNetworks + 1u, networks.size());
415 } 427 }
416 428
417 TEST_F(NetworkStateHandlerTest, GetTetherNetworkList) { 429 TEST_F(NetworkStateHandlerTest, GetTetherNetworkList) {
430 network_state_handler_->SetTetherTechnologyState(
431 NetworkStateHandler::TECHNOLOGY_ENABLED);
432
418 NetworkStateHandler::NetworkStateList tether_networks; 433 NetworkStateHandler::NetworkStateList tether_networks;
419 434
420 GetTetherNetworkList(0 /* no limit */, &tether_networks); 435 GetTetherNetworkList(0 /* no limit */, &tether_networks);
421 EXPECT_EQ(0u, tether_networks.size()); 436 EXPECT_EQ(0u, tether_networks.size());
422 437
423 network_state_handler_->AddTetherNetworkState( 438 network_state_handler_->AddTetherNetworkState(
424 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1, 439 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1,
425 kTetherSignalStrength1); 440 kTetherSignalStrength1);
426 441
427 GetTetherNetworkList(0 /* no limit */, &tether_networks); 442 GetTetherNetworkList(0 /* no limit */, &tether_networks);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 574
560 manager_test_->RemoveTechnology(shill::kTypeWimax); 575 manager_test_->RemoveTechnology(shill::kTypeWimax);
561 base::RunLoop().RunUntilIdle(); 576 base::RunLoop().RunUntilIdle();
562 EXPECT_EQ( 577 EXPECT_EQ(
563 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE, 578 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE,
564 network_state_handler_->GetTechnologyState(NetworkTypePattern::Wimax())); 579 network_state_handler_->GetTechnologyState(NetworkTypePattern::Wimax()));
565 } 580 }
566 581
567 TEST_F(NetworkStateHandlerTest, TetherTechnologyState) { 582 TEST_F(NetworkStateHandlerTest, TetherTechnologyState) {
568 EXPECT_EQ( 583 EXPECT_EQ(
584 NetworkStateHandler::TECHNOLOGY_PROHIBITED,
585 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether()));
586
587 // Test SetTetherTechnologyState():
588 network_state_handler_->SetTetherTechnologyState(
589 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE);
590 EXPECT_EQ(1u, test_observer_->device_list_changed_count());
591 EXPECT_EQ(
569 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE, 592 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE,
570 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether())); 593 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether()));
571 594
572 base::CommandLine::ForCurrentProcess()->AppendSwitch( 595 network_state_handler_->SetTetherTechnologyState(
573 chromeos::switches::kEnableTether); 596 NetworkStateHandler::TECHNOLOGY_AVAILABLE);
597 EXPECT_EQ(2u, test_observer_->device_list_changed_count());
598 EXPECT_EQ(
599 NetworkStateHandler::TECHNOLOGY_AVAILABLE,
600 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether()));
574 601
602 // Test SetTechnologyEnabled() with a tether network:
603 network_state_handler_->SetTechnologyEnabled(
604 NetworkTypePattern::Tether(), true, network_handler::ErrorCallback());
605 EXPECT_EQ(3u, test_observer_->device_list_changed_count());
575 EXPECT_EQ( 606 EXPECT_EQ(
576 NetworkStateHandler::TECHNOLOGY_ENABLED, 607 NetworkStateHandler::TECHNOLOGY_ENABLED,
577 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether())); 608 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether()));
609
610 // Test SetProhibitedTechnologies() with a tether network:
611 network_state_handler_->SetProhibitedTechnologies(
612 std::vector<std::string>{kTypeTether}, network_handler::ErrorCallback());
613 EXPECT_EQ(4u, test_observer_->device_list_changed_count());
614 EXPECT_EQ(
615 NetworkStateHandler::TECHNOLOGY_PROHIBITED,
616 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether()));
617 }
618
619 TEST_F(NetworkStateHandlerTest, TetherScanningState) {
620 const DeviceState* tether_device_state =
621 network_state_handler_->GetDeviceStateByType(
622 NetworkTypePattern::Tether());
623 EXPECT_TRUE(tether_device_state);
624 EXPECT_FALSE(tether_device_state->scanning());
625 EXPECT_EQ(0u, test_observer_->scan_completed_count());
626
627 network_state_handler_->SetTetherScanState(true /* is_scanning */);
628 tether_device_state = network_state_handler_->GetDeviceStateByType(
629 NetworkTypePattern::Tether());
630 EXPECT_TRUE(tether_device_state);
631 EXPECT_TRUE(tether_device_state->scanning());
632 EXPECT_EQ(0u, test_observer_->scan_completed_count());
633
634 network_state_handler_->SetTetherScanState(false /* is_scanning */);
635 tether_device_state = network_state_handler_->GetDeviceStateByType(
636 NetworkTypePattern::Tether());
637 EXPECT_TRUE(tether_device_state);
638 EXPECT_FALSE(tether_device_state->scanning());
639 EXPECT_EQ(1u, test_observer_->scan_completed_count());
578 } 640 }
579 641
580 TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) { 642 TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) {
581 // Set a service property. 643 // Set a service property.
582 const std::string eth1 = kShillManagerClientStubDefaultService; 644 const std::string eth1 = kShillManagerClientStubDefaultService;
583 const NetworkState* ethernet = network_state_handler_->GetNetworkState(eth1); 645 const NetworkState* ethernet = network_state_handler_->GetNetworkState(eth1);
584 ASSERT_TRUE(ethernet); 646 ASSERT_TRUE(ethernet);
585 EXPECT_EQ("", ethernet->security_class()); 647 EXPECT_EQ("", ethernet->security_class());
586 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(eth1)); 648 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(eth1));
587 base::Value security_class_value("TestSecurityClass"); 649 base::Value security_class_value("TestSecurityClass");
(...skipping 30 matching lines...) Expand all
618 network_state_handler_->GetNetworkStateFromGuid(wifi_network->guid()); 680 network_state_handler_->GetNetworkStateFromGuid(wifi_network->guid());
619 EXPECT_EQ(wifi_network, wifi_network_guid); 681 EXPECT_EQ(wifi_network, wifi_network_guid);
620 682
621 // Remove the service, verify that there is no longer a NetworkState for it. 683 // Remove the service, verify that there is no longer a NetworkState for it.
622 service_test_->RemoveService(wifi_path); 684 service_test_->RemoveService(wifi_path);
623 UpdateManagerProperties(); 685 UpdateManagerProperties();
624 EXPECT_FALSE(network_state_handler_->GetNetworkState(wifi_path)); 686 EXPECT_FALSE(network_state_handler_->GetNetworkState(wifi_path));
625 } 687 }
626 688
627 TEST_F(NetworkStateHandlerTest, TetherNetworkState) { 689 TEST_F(NetworkStateHandlerTest, TetherNetworkState) {
690 network_state_handler_->SetTetherTechnologyState(
691 NetworkStateHandler::TECHNOLOGY_ENABLED);
692
628 EXPECT_EQ(0u, test_observer_->network_list_changed_count()); 693 EXPECT_EQ(0u, test_observer_->network_list_changed_count());
629 694
630 network_state_handler_->AddTetherNetworkState( 695 network_state_handler_->AddTetherNetworkState(
631 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1, 696 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1,
632 kTetherSignalStrength1); 697 kTetherSignalStrength1);
633 698
634 EXPECT_EQ(1u, test_observer_->network_list_changed_count()); 699 EXPECT_EQ(1u, test_observer_->network_list_changed_count());
635 700
636 const NetworkState* tether_network = 701 const NetworkState* tether_network =
637 network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1); 702 network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1);
(...skipping 26 matching lines...) Expand all
664 729
665 ASSERT_FALSE(network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1)); 730 ASSERT_FALSE(network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1));
666 731
667 // Updating tether properties should fail since the network was removed. 732 // Updating tether properties should fail since the network was removed.
668 EXPECT_FALSE(network_state_handler_->UpdateTetherNetworkProperties( 733 EXPECT_FALSE(network_state_handler_->UpdateTetherNetworkProperties(
669 kTetherGuid1, "NewNewCarrier", 15 /* battery_percentage */, 734 kTetherGuid1, "NewNewCarrier", 15 /* battery_percentage */,
670 20 /* signal_strength */)); 735 20 /* signal_strength */));
671 } 736 }
672 737
673 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation) { 738 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation) {
739 network_state_handler_->SetTetherTechnologyState(
740 NetworkStateHandler::TECHNOLOGY_ENABLED);
741
674 EXPECT_EQ(0u, test_observer_->network_list_changed_count()); 742 EXPECT_EQ(0u, test_observer_->network_list_changed_count());
675 743
676 const std::string profile = "/profile/profile1"; 744 const std::string profile = "/profile/profile1";
677 const std::string wifi_path = "/service/wifi_with_guid"; 745 const std::string wifi_path = "/service/wifi_with_guid";
678 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi, 746 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi,
679 shill::kStateOnline); 747 shill::kStateOnline);
680 profile_test_->AddProfile(profile, "" /* userhash */); 748 profile_test_->AddProfile(profile, "" /* userhash */);
681 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path)); 749 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path));
682 UpdateManagerProperties(); 750 UpdateManagerProperties();
683 751
(...skipping 21 matching lines...) Expand all
705 773
706 network_state_handler_->RemoveTetherNetworkState(kTetherGuid1); 774 network_state_handler_->RemoveTetherNetworkState(kTetherGuid1);
707 775
708 EXPECT_EQ(4u, test_observer_->network_list_changed_count()); 776 EXPECT_EQ(4u, test_observer_->network_list_changed_count());
709 777
710 wifi_network = network_state_handler_->GetNetworkStateFromGuid(kWifiGuid1); 778 wifi_network = network_state_handler_->GetNetworkStateFromGuid(kWifiGuid1);
711 ASSERT_TRUE(wifi_network->tether_guid().empty()); 779 ASSERT_TRUE(wifi_network->tether_guid().empty());
712 } 780 }
713 781
714 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociationWifiRemoved) { 782 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociationWifiRemoved) {
783 network_state_handler_->SetTetherTechnologyState(
784 NetworkStateHandler::TECHNOLOGY_ENABLED);
785
715 const std::string profile = "/profile/profile1"; 786 const std::string profile = "/profile/profile1";
716 const std::string wifi_path = "/service/wifi_with_guid"; 787 const std::string wifi_path = "/service/wifi_with_guid";
717 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi, 788 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi,
718 shill::kStateOnline); 789 shill::kStateOnline);
719 profile_test_->AddProfile(profile, "" /* userhash */); 790 profile_test_->AddProfile(profile, "" /* userhash */);
720 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path)); 791 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path));
721 UpdateManagerProperties(); 792 UpdateManagerProperties();
722 793
723 network_state_handler_->AddTetherNetworkState( 794 network_state_handler_->AddTetherNetworkState(
724 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1, 795 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1,
(...skipping 12 matching lines...) Expand all
737 808
738 service_test_->RemoveService(wifi_path); 809 service_test_->RemoveService(wifi_path);
739 UpdateManagerProperties(); 810 UpdateManagerProperties();
740 811
741 tether_network = 812 tether_network =
742 network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1); 813 network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1);
743 ASSERT_TRUE(tether_network->tether_guid().empty()); 814 ASSERT_TRUE(tether_network->tether_guid().empty());
744 } 815 }
745 816
746 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation_NoWifiNetwork) { 817 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation_NoWifiNetwork) {
818 network_state_handler_->SetTetherTechnologyState(
819 NetworkStateHandler::TECHNOLOGY_ENABLED);
820
747 network_state_handler_->AddTetherNetworkState( 821 network_state_handler_->AddTetherNetworkState(
748 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1, 822 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1,
749 kTetherSignalStrength1); 823 kTetherSignalStrength1);
750 824
751 EXPECT_FALSE( 825 EXPECT_FALSE(
752 network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork( 826 network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork(
753 kTetherGuid1, kWifiGuid1)); 827 kTetherGuid1, kWifiGuid1));
754 } 828 }
755 829
756 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation_NoTetherNetwork) { 830 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation_NoTetherNetwork) {
831 network_state_handler_->SetTetherTechnologyState(
832 NetworkStateHandler::TECHNOLOGY_ENABLED);
833
757 const std::string profile = "/profile/profile1"; 834 const std::string profile = "/profile/profile1";
758 const std::string wifi_path = "/service/wifi_with_guid"; 835 const std::string wifi_path = "/service/wifi_with_guid";
759 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi, 836 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi,
760 shill::kStateOnline); 837 shill::kStateOnline);
761 profile_test_->AddProfile(profile, "" /* userhash */); 838 profile_test_->AddProfile(profile, "" /* userhash */);
762 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path)); 839 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path));
763 UpdateManagerProperties(); 840 UpdateManagerProperties();
764 841
765 ASSERT_FALSE( 842 ASSERT_FALSE(
766 network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork( 843 network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork(
767 kTetherGuid1, kWifiGuid1)); 844 kTetherGuid1, kWifiGuid1));
768 } 845 }
769 846
770 TEST_F(NetworkStateHandlerTest, SetTetherNetworkStateConnectionState) { 847 TEST_F(NetworkStateHandlerTest, SetTetherNetworkStateConnectionState) {
848 network_state_handler_->SetTetherTechnologyState(
849 NetworkStateHandler::TECHNOLOGY_ENABLED);
850
771 network_state_handler_->AddTetherNetworkState( 851 network_state_handler_->AddTetherNetworkState(
772 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1, 852 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1,
773 kTetherSignalStrength1); 853 kTetherSignalStrength1);
774 854
775 // Add corresponding Wi-Fi network. 855 // Add corresponding Wi-Fi network.
776 const std::string profile = "/profile/profile1"; 856 const std::string profile = "/profile/profile1";
777 const std::string wifi_path = "/service/wifi_with_guid"; 857 const std::string wifi_path = "/service/wifi_with_guid";
778 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi, 858 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi,
779 shill::kStateOnline); 859 shill::kStateOnline);
780 profile_test_->AddProfile(profile, "" /* userhash */); 860 profile_test_->AddProfile(profile, "" /* userhash */);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 shill::kIPConfigProperty, 1135 shill::kIPConfigProperty,
1056 base::Value(kIPConfigPath)); 1136 base::Value(kIPConfigPath));
1057 UpdateManagerProperties(); 1137 UpdateManagerProperties();
1058 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( 1138 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice(
1059 kShillManagerClientStubWifiDevice)); 1139 kShillManagerClientStubWifiDevice));
1060 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( 1140 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(
1061 kShillManagerClientStubDefaultWifi)); 1141 kShillManagerClientStubDefaultWifi));
1062 } 1142 }
1063 1143
1064 } // namespace chromeos 1144 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698