| OLD | NEW |
| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, | 409 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, |
| 410 test_observer_->network_count()); | 410 test_observer_->network_count()); |
| 411 | 411 |
| 412 // Get visible networks. | 412 // Get visible networks. |
| 413 NetworkStateHandler::NetworkStateList networks; | 413 NetworkStateHandler::NetworkStateList networks; |
| 414 network_state_handler_->GetVisibleNetworkList(&networks); | 414 network_state_handler_->GetVisibleNetworkList(&networks); |
| 415 EXPECT_EQ(kNumShillManagerClientStubImplServices, networks.size()); | 415 EXPECT_EQ(kNumShillManagerClientStubImplServices, networks.size()); |
| 416 | 416 |
| 417 // Change the visible state of a network. | 417 // Change the visible state of a network. |
| 418 SetServiceProperty(kShillManagerClientStubWifi2, shill::kVisibleProperty, | 418 SetServiceProperty(kShillManagerClientStubWifi2, shill::kVisibleProperty, |
| 419 base::FundamentalValue(false)); | 419 base::Value(false)); |
| 420 base::RunLoop().RunUntilIdle(); | 420 base::RunLoop().RunUntilIdle(); |
| 421 network_state_handler_->GetVisibleNetworkList(&networks); | 421 network_state_handler_->GetVisibleNetworkList(&networks); |
| 422 EXPECT_EQ(kNumShillManagerClientStubImplServices - 1, networks.size()); | 422 EXPECT_EQ(kNumShillManagerClientStubImplServices - 1, networks.size()); |
| 423 } | 423 } |
| 424 | 424 |
| 425 TEST_F(NetworkStateHandlerTest, TechnologyChanged) { | 425 TEST_F(NetworkStateHandlerTest, TechnologyChanged) { |
| 426 // Disable a technology. Will immediately set the state to AVAILABLE and | 426 // Disable a technology. Will immediately set the state to AVAILABLE and |
| 427 // notify observers. | 427 // notify observers. |
| 428 network_state_handler_->SetTechnologyEnabled( | 428 network_state_handler_->SetTechnologyEnabled( |
| 429 NetworkTypePattern::WiFi(), false, network_handler::ErrorCallback()); | 429 NetworkTypePattern::WiFi(), false, network_handler::ErrorCallback()); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 // Updating a property on the default network should also trigger | 640 // Updating a property on the default network should also trigger |
| 641 // a default network change. | 641 // a default network change. |
| 642 test_observer_->reset_change_counts(); | 642 test_observer_->reset_change_counts(); |
| 643 SetServiceProperty(wifi1, shill::kSecurityClassProperty, | 643 SetServiceProperty(wifi1, shill::kSecurityClassProperty, |
| 644 base::StringValue("TestSecurityClass")); | 644 base::StringValue("TestSecurityClass")); |
| 645 base::RunLoop().RunUntilIdle(); | 645 base::RunLoop().RunUntilIdle(); |
| 646 EXPECT_EQ(1u, test_observer_->default_network_change_count()); | 646 EXPECT_EQ(1u, test_observer_->default_network_change_count()); |
| 647 | 647 |
| 648 // No default network updates for signal strength changes. | 648 // No default network updates for signal strength changes. |
| 649 test_observer_->reset_change_counts(); | 649 test_observer_->reset_change_counts(); |
| 650 SetServiceProperty(wifi1, shill::kSignalStrengthProperty, | 650 SetServiceProperty(wifi1, shill::kSignalStrengthProperty, base::Value(32)); |
| 651 base::FundamentalValue(32)); | |
| 652 base::RunLoop().RunUntilIdle(); | 651 base::RunLoop().RunUntilIdle(); |
| 653 EXPECT_EQ(0u, test_observer_->default_network_change_count()); | 652 EXPECT_EQ(0u, test_observer_->default_network_change_count()); |
| 654 | 653 |
| 655 // Change the default network to a Connecting network, then set the | 654 // Change the default network to a Connecting network, then set the |
| 656 // state to Connected. The DefaultNetworkChange notification should only | 655 // state to Connected. The DefaultNetworkChange notification should only |
| 657 // fire once when the network is connected. | 656 // fire once when the network is connected. |
| 658 test_observer_->reset_change_counts(); | 657 test_observer_->reset_change_counts(); |
| 659 SetServiceProperty(wifi1, shill::kStateProperty, | 658 SetServiceProperty(wifi1, shill::kStateProperty, |
| 660 base::StringValue(shill::kStateIdle)); | 659 base::StringValue(shill::kStateIdle)); |
| 661 base::RunLoop().RunUntilIdle(); | 660 base::RunLoop().RunUntilIdle(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 TEST_F(NetworkStateHandlerTest, DeviceListChanged) { | 759 TEST_F(NetworkStateHandlerTest, DeviceListChanged) { |
| 761 size_t stub_device_count = test_observer_->device_count(); | 760 size_t stub_device_count = test_observer_->device_count(); |
| 762 // Add an additional device. | 761 // Add an additional device. |
| 763 const std::string wifi_device = "/service/stub_wifi_device2"; | 762 const std::string wifi_device = "/service/stub_wifi_device2"; |
| 764 device_test_->AddDevice(wifi_device, shill::kTypeWifi, "stub_wifi_device2"); | 763 device_test_->AddDevice(wifi_device, shill::kTypeWifi, "stub_wifi_device2"); |
| 765 UpdateManagerProperties(); | 764 UpdateManagerProperties(); |
| 766 // Expect a device list update. | 765 // Expect a device list update. |
| 767 EXPECT_EQ(stub_device_count + 1, test_observer_->device_count()); | 766 EXPECT_EQ(stub_device_count + 1, test_observer_->device_count()); |
| 768 EXPECT_EQ(0, test_observer_->PropertyUpdatesForDevice(wifi_device)); | 767 EXPECT_EQ(0, test_observer_->PropertyUpdatesForDevice(wifi_device)); |
| 769 // Change a device property. | 768 // Change a device property. |
| 770 device_test_->SetDeviceProperty( | 769 device_test_->SetDeviceProperty(wifi_device, shill::kScanningProperty, |
| 771 wifi_device, shill::kScanningProperty, base::FundamentalValue(true)); | 770 base::Value(true)); |
| 772 UpdateManagerProperties(); | 771 UpdateManagerProperties(); |
| 773 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice(wifi_device)); | 772 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice(wifi_device)); |
| 774 } | 773 } |
| 775 | 774 |
| 776 TEST_F(NetworkStateHandlerTest, IPConfigChanged) { | 775 TEST_F(NetworkStateHandlerTest, IPConfigChanged) { |
| 777 test_observer_->reset_updates(); | 776 test_observer_->reset_updates(); |
| 778 EXPECT_EQ(0, test_observer_->PropertyUpdatesForDevice( | 777 EXPECT_EQ(0, test_observer_->PropertyUpdatesForDevice( |
| 779 kShillManagerClientStubWifiDevice)); | 778 kShillManagerClientStubWifiDevice)); |
| 780 EXPECT_EQ(0, test_observer_->PropertyUpdatesForService( | 779 EXPECT_EQ(0, test_observer_->PropertyUpdatesForService( |
| 781 kShillManagerClientStubDefaultWifi)); | 780 kShillManagerClientStubDefaultWifi)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 795 kShillManagerClientStubDefaultWifi, shill::kIPConfigProperty, | 794 kShillManagerClientStubDefaultWifi, shill::kIPConfigProperty, |
| 796 base::StringValue(kIPConfigPath)); | 795 base::StringValue(kIPConfigPath)); |
| 797 UpdateManagerProperties(); | 796 UpdateManagerProperties(); |
| 798 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( | 797 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( |
| 799 kShillManagerClientStubWifiDevice)); | 798 kShillManagerClientStubWifiDevice)); |
| 800 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( | 799 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( |
| 801 kShillManagerClientStubDefaultWifi)); | 800 kShillManagerClientStubDefaultWifi)); |
| 802 } | 801 } |
| 803 | 802 |
| 804 } // namespace chromeos | 803 } // namespace chromeos |
| OLD | NEW |