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

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: stevenjb@ comment. 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
« no previous file with comments | « chromeos/network/network_state_handler.cc ('k') | chromeos/network/tether_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
569 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE, 584 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE,
570 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether())); 585 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether()));
586 EXPECT_FALSE(network_state_handler_->GetDeviceState(kTetherDevicePath));
587 EXPECT_FALSE(network_state_handler_->GetDeviceStateByType(
588 NetworkTypePattern::Tether()));
571 589
572 base::CommandLine::ForCurrentProcess()->AppendSwitch( 590 // Test SetTetherTechnologyState():
573 chromeos::switches::kEnableTether); 591 network_state_handler_->SetTetherTechnologyState(
592 NetworkStateHandler::TECHNOLOGY_AVAILABLE);
593 EXPECT_EQ(1u, test_observer_->device_list_changed_count());
594 EXPECT_EQ(
595 NetworkStateHandler::TECHNOLOGY_AVAILABLE,
596 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether()));
597 const DeviceState* tether_device_state =
598 network_state_handler_->GetDeviceState(kTetherDevicePath);
599 EXPECT_TRUE(tether_device_state);
600 EXPECT_EQ(tether_device_state, network_state_handler_->GetDeviceStateByType(
601 NetworkTypePattern::Tether()));
574 602
603 // Test SetTechnologyEnabled() with a tether network:
604 network_state_handler_->SetTechnologyEnabled(
605 NetworkTypePattern::Tether(), true, network_handler::ErrorCallback());
606 EXPECT_EQ(2u, test_observer_->device_list_changed_count());
575 EXPECT_EQ( 607 EXPECT_EQ(
576 NetworkStateHandler::TECHNOLOGY_ENABLED, 608 NetworkStateHandler::TECHNOLOGY_ENABLED,
577 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether())); 609 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether()));
610 EXPECT_EQ(tether_device_state,
611 network_state_handler_->GetDeviceState(kTetherDevicePath));
612 EXPECT_EQ(tether_device_state, network_state_handler_->GetDeviceStateByType(
613 NetworkTypePattern::Tether()));
614
615 // Test SetProhibitedTechnologies() with a tether network:
616 network_state_handler_->SetProhibitedTechnologies(
617 std::vector<std::string>{kTypeTether}, network_handler::ErrorCallback());
618 EXPECT_EQ(3u, test_observer_->device_list_changed_count());
619 EXPECT_EQ(
620 NetworkStateHandler::TECHNOLOGY_PROHIBITED,
621 network_state_handler_->GetTechnologyState(NetworkTypePattern::Tether()));
622 EXPECT_EQ(tether_device_state,
623 network_state_handler_->GetDeviceState(kTetherDevicePath));
624 EXPECT_EQ(tether_device_state, network_state_handler_->GetDeviceStateByType(
625 NetworkTypePattern::Tether()));
626
627 // Set back to TECHNOLOGY_UNAVAILABLE; this should result in nullptr being
628 // returned by getters.
629 network_state_handler_->SetTetherTechnologyState(
630 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE);
631 EXPECT_FALSE(network_state_handler_->GetDeviceState(kTetherDevicePath));
632 EXPECT_FALSE(network_state_handler_->GetDeviceStateByType(
633 NetworkTypePattern::Tether()));
634 }
635
636 TEST_F(NetworkStateHandlerTest, TetherScanningState) {
637 network_state_handler_->SetTetherTechnologyState(
638 NetworkStateHandler::TECHNOLOGY_ENABLED);
639
640 const DeviceState* tether_device_state =
641 network_state_handler_->GetDeviceStateByType(
642 NetworkTypePattern::Tether());
643 EXPECT_TRUE(tether_device_state);
644 EXPECT_FALSE(tether_device_state->scanning());
645 EXPECT_EQ(0u, test_observer_->scan_completed_count());
646
647 network_state_handler_->SetTetherScanState(true /* is_scanning */);
648 tether_device_state = network_state_handler_->GetDeviceStateByType(
649 NetworkTypePattern::Tether());
650 EXPECT_TRUE(tether_device_state);
651 EXPECT_TRUE(tether_device_state->scanning());
652 EXPECT_EQ(0u, test_observer_->scan_completed_count());
653
654 network_state_handler_->SetTetherScanState(false /* is_scanning */);
655 tether_device_state = network_state_handler_->GetDeviceStateByType(
656 NetworkTypePattern::Tether());
657 EXPECT_TRUE(tether_device_state);
658 EXPECT_FALSE(tether_device_state->scanning());
659 EXPECT_EQ(1u, test_observer_->scan_completed_count());
578 } 660 }
579 661
580 TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) { 662 TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) {
581 // Set a service property. 663 // Set a service property.
582 const std::string eth1 = kShillManagerClientStubDefaultService; 664 const std::string eth1 = kShillManagerClientStubDefaultService;
583 const NetworkState* ethernet = network_state_handler_->GetNetworkState(eth1); 665 const NetworkState* ethernet = network_state_handler_->GetNetworkState(eth1);
584 ASSERT_TRUE(ethernet); 666 ASSERT_TRUE(ethernet);
585 EXPECT_EQ("", ethernet->security_class()); 667 EXPECT_EQ("", ethernet->security_class());
586 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(eth1)); 668 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(eth1));
587 base::Value security_class_value("TestSecurityClass"); 669 base::Value security_class_value("TestSecurityClass");
(...skipping 30 matching lines...) Expand all
618 network_state_handler_->GetNetworkStateFromGuid(wifi_network->guid()); 700 network_state_handler_->GetNetworkStateFromGuid(wifi_network->guid());
619 EXPECT_EQ(wifi_network, wifi_network_guid); 701 EXPECT_EQ(wifi_network, wifi_network_guid);
620 702
621 // Remove the service, verify that there is no longer a NetworkState for it. 703 // Remove the service, verify that there is no longer a NetworkState for it.
622 service_test_->RemoveService(wifi_path); 704 service_test_->RemoveService(wifi_path);
623 UpdateManagerProperties(); 705 UpdateManagerProperties();
624 EXPECT_FALSE(network_state_handler_->GetNetworkState(wifi_path)); 706 EXPECT_FALSE(network_state_handler_->GetNetworkState(wifi_path));
625 } 707 }
626 708
627 TEST_F(NetworkStateHandlerTest, TetherNetworkState) { 709 TEST_F(NetworkStateHandlerTest, TetherNetworkState) {
710 network_state_handler_->SetTetherTechnologyState(
711 NetworkStateHandler::TECHNOLOGY_ENABLED);
712
628 EXPECT_EQ(0u, test_observer_->network_list_changed_count()); 713 EXPECT_EQ(0u, test_observer_->network_list_changed_count());
629 714
630 network_state_handler_->AddTetherNetworkState( 715 network_state_handler_->AddTetherNetworkState(
631 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1, 716 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1,
632 kTetherSignalStrength1); 717 kTetherSignalStrength1);
633 718
634 EXPECT_EQ(1u, test_observer_->network_list_changed_count()); 719 EXPECT_EQ(1u, test_observer_->network_list_changed_count());
635 720
636 const NetworkState* tether_network = 721 const NetworkState* tether_network =
637 network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1); 722 network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1);
(...skipping 26 matching lines...) Expand all
664 749
665 ASSERT_FALSE(network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1)); 750 ASSERT_FALSE(network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1));
666 751
667 // Updating tether properties should fail since the network was removed. 752 // Updating tether properties should fail since the network was removed.
668 EXPECT_FALSE(network_state_handler_->UpdateTetherNetworkProperties( 753 EXPECT_FALSE(network_state_handler_->UpdateTetherNetworkProperties(
669 kTetherGuid1, "NewNewCarrier", 15 /* battery_percentage */, 754 kTetherGuid1, "NewNewCarrier", 15 /* battery_percentage */,
670 20 /* signal_strength */)); 755 20 /* signal_strength */));
671 } 756 }
672 757
673 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation) { 758 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation) {
759 network_state_handler_->SetTetherTechnologyState(
760 NetworkStateHandler::TECHNOLOGY_ENABLED);
761
674 EXPECT_EQ(0u, test_observer_->network_list_changed_count()); 762 EXPECT_EQ(0u, test_observer_->network_list_changed_count());
675 763
676 const std::string profile = "/profile/profile1"; 764 const std::string profile = "/profile/profile1";
677 const std::string wifi_path = "/service/wifi_with_guid"; 765 const std::string wifi_path = "/service/wifi_with_guid";
678 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi, 766 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi,
679 shill::kStateOnline); 767 shill::kStateOnline);
680 profile_test_->AddProfile(profile, "" /* userhash */); 768 profile_test_->AddProfile(profile, "" /* userhash */);
681 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path)); 769 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path));
682 UpdateManagerProperties(); 770 UpdateManagerProperties();
683 771
(...skipping 21 matching lines...) Expand all
705 793
706 network_state_handler_->RemoveTetherNetworkState(kTetherGuid1); 794 network_state_handler_->RemoveTetherNetworkState(kTetherGuid1);
707 795
708 EXPECT_EQ(4u, test_observer_->network_list_changed_count()); 796 EXPECT_EQ(4u, test_observer_->network_list_changed_count());
709 797
710 wifi_network = network_state_handler_->GetNetworkStateFromGuid(kWifiGuid1); 798 wifi_network = network_state_handler_->GetNetworkStateFromGuid(kWifiGuid1);
711 ASSERT_TRUE(wifi_network->tether_guid().empty()); 799 ASSERT_TRUE(wifi_network->tether_guid().empty());
712 } 800 }
713 801
714 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociationWifiRemoved) { 802 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociationWifiRemoved) {
803 network_state_handler_->SetTetherTechnologyState(
804 NetworkStateHandler::TECHNOLOGY_ENABLED);
805
715 const std::string profile = "/profile/profile1"; 806 const std::string profile = "/profile/profile1";
716 const std::string wifi_path = "/service/wifi_with_guid"; 807 const std::string wifi_path = "/service/wifi_with_guid";
717 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi, 808 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi,
718 shill::kStateOnline); 809 shill::kStateOnline);
719 profile_test_->AddProfile(profile, "" /* userhash */); 810 profile_test_->AddProfile(profile, "" /* userhash */);
720 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path)); 811 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path));
721 UpdateManagerProperties(); 812 UpdateManagerProperties();
722 813
723 network_state_handler_->AddTetherNetworkState( 814 network_state_handler_->AddTetherNetworkState(
724 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1, 815 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1,
(...skipping 12 matching lines...) Expand all
737 828
738 service_test_->RemoveService(wifi_path); 829 service_test_->RemoveService(wifi_path);
739 UpdateManagerProperties(); 830 UpdateManagerProperties();
740 831
741 tether_network = 832 tether_network =
742 network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1); 833 network_state_handler_->GetNetworkStateFromGuid(kTetherGuid1);
743 ASSERT_TRUE(tether_network->tether_guid().empty()); 834 ASSERT_TRUE(tether_network->tether_guid().empty());
744 } 835 }
745 836
746 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation_NoWifiNetwork) { 837 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation_NoWifiNetwork) {
838 network_state_handler_->SetTetherTechnologyState(
839 NetworkStateHandler::TECHNOLOGY_ENABLED);
840
747 network_state_handler_->AddTetherNetworkState( 841 network_state_handler_->AddTetherNetworkState(
748 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1, 842 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1,
749 kTetherSignalStrength1); 843 kTetherSignalStrength1);
750 844
751 EXPECT_FALSE( 845 EXPECT_FALSE(
752 network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork( 846 network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork(
753 kTetherGuid1, kWifiGuid1)); 847 kTetherGuid1, kWifiGuid1));
754 } 848 }
755 849
756 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation_NoTetherNetwork) { 850 TEST_F(NetworkStateHandlerTest, TetherNetworkStateAssociation_NoTetherNetwork) {
851 network_state_handler_->SetTetherTechnologyState(
852 NetworkStateHandler::TECHNOLOGY_ENABLED);
853
757 const std::string profile = "/profile/profile1"; 854 const std::string profile = "/profile/profile1";
758 const std::string wifi_path = "/service/wifi_with_guid"; 855 const std::string wifi_path = "/service/wifi_with_guid";
759 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi, 856 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi,
760 shill::kStateOnline); 857 shill::kStateOnline);
761 profile_test_->AddProfile(profile, "" /* userhash */); 858 profile_test_->AddProfile(profile, "" /* userhash */);
762 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path)); 859 EXPECT_TRUE(profile_test_->AddService(profile, wifi_path));
763 UpdateManagerProperties(); 860 UpdateManagerProperties();
764 861
765 ASSERT_FALSE( 862 ASSERT_FALSE(
766 network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork( 863 network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork(
767 kTetherGuid1, kWifiGuid1)); 864 kTetherGuid1, kWifiGuid1));
768 } 865 }
769 866
770 TEST_F(NetworkStateHandlerTest, SetTetherNetworkStateConnectionState) { 867 TEST_F(NetworkStateHandlerTest, SetTetherNetworkStateConnectionState) {
868 network_state_handler_->SetTetherTechnologyState(
869 NetworkStateHandler::TECHNOLOGY_ENABLED);
870
771 network_state_handler_->AddTetherNetworkState( 871 network_state_handler_->AddTetherNetworkState(
772 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1, 872 kTetherGuid1, kTetherName1, kTetherCarrier1, kTetherBatteryPercentage1,
773 kTetherSignalStrength1); 873 kTetherSignalStrength1);
774 874
775 // Add corresponding Wi-Fi network. 875 // Add corresponding Wi-Fi network.
776 const std::string profile = "/profile/profile1"; 876 const std::string profile = "/profile/profile1";
777 const std::string wifi_path = "/service/wifi_with_guid"; 877 const std::string wifi_path = "/service/wifi_with_guid";
778 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi, 878 AddService(wifi_path, kWifiGuid1, kWifiName1, shill::kTypeWifi,
779 shill::kStateOnline); 879 shill::kStateOnline);
780 profile_test_->AddProfile(profile, "" /* userhash */); 880 profile_test_->AddProfile(profile, "" /* userhash */);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 shill::kIPConfigProperty, 1155 shill::kIPConfigProperty,
1056 base::Value(kIPConfigPath)); 1156 base::Value(kIPConfigPath));
1057 UpdateManagerProperties(); 1157 UpdateManagerProperties();
1058 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( 1158 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice(
1059 kShillManagerClientStubWifiDevice)); 1159 kShillManagerClientStubWifiDevice));
1060 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( 1160 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(
1061 kShillManagerClientStubDefaultWifi)); 1161 kShillManagerClientStubDefaultWifi));
1062 } 1162 }
1063 1163
1064 } // namespace chromeos 1164 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_state_handler.cc ('k') | chromeos/network/tether_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698