| 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, | 441 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, |
| 442 test_observer_->network_count()); | 442 test_observer_->network_count()); |
| 443 | 443 |
| 444 // Get visible networks. | 444 // Get visible networks. |
| 445 NetworkStateHandler::NetworkStateList networks; | 445 NetworkStateHandler::NetworkStateList networks; |
| 446 network_state_handler_->GetVisibleNetworkList(&networks); | 446 network_state_handler_->GetVisibleNetworkList(&networks); |
| 447 EXPECT_EQ(kNumShillManagerClientStubImplServices, networks.size()); | 447 EXPECT_EQ(kNumShillManagerClientStubImplServices, networks.size()); |
| 448 | 448 |
| 449 // Change the visible state of a network. | 449 // Change the visible state of a network. |
| 450 SetServiceProperty(kShillManagerClientStubWifi2, shill::kVisibleProperty, | 450 SetServiceProperty(kShillManagerClientStubWifi2, shill::kVisibleProperty, |
| 451 base::FundamentalValue(false)); | 451 base::Value(false)); |
| 452 base::RunLoop().RunUntilIdle(); | 452 base::RunLoop().RunUntilIdle(); |
| 453 network_state_handler_->GetVisibleNetworkList(&networks); | 453 network_state_handler_->GetVisibleNetworkList(&networks); |
| 454 EXPECT_EQ(kNumShillManagerClientStubImplServices - 1, networks.size()); | 454 EXPECT_EQ(kNumShillManagerClientStubImplServices - 1, networks.size()); |
| 455 } | 455 } |
| 456 | 456 |
| 457 TEST_F(NetworkStateHandlerTest, TechnologyChanged) { | 457 TEST_F(NetworkStateHandlerTest, TechnologyChanged) { |
| 458 // Disable a technology. Will immediately set the state to AVAILABLE and | 458 // Disable a technology. Will immediately set the state to AVAILABLE and |
| 459 // notify observers. | 459 // notify observers. |
| 460 network_state_handler_->SetTechnologyEnabled( | 460 network_state_handler_->SetTechnologyEnabled( |
| 461 NetworkTypePattern::WiFi(), false, network_handler::ErrorCallback()); | 461 NetworkTypePattern::WiFi(), false, network_handler::ErrorCallback()); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 // Updating a property on the default network should also trigger | 705 // Updating a property on the default network should also trigger |
| 706 // a default network change. | 706 // a default network change. |
| 707 test_observer_->reset_change_counts(); | 707 test_observer_->reset_change_counts(); |
| 708 SetServiceProperty(wifi1, shill::kSecurityClassProperty, | 708 SetServiceProperty(wifi1, shill::kSecurityClassProperty, |
| 709 base::StringValue("TestSecurityClass")); | 709 base::StringValue("TestSecurityClass")); |
| 710 base::RunLoop().RunUntilIdle(); | 710 base::RunLoop().RunUntilIdle(); |
| 711 EXPECT_EQ(1u, test_observer_->default_network_change_count()); | 711 EXPECT_EQ(1u, test_observer_->default_network_change_count()); |
| 712 | 712 |
| 713 // No default network updates for signal strength changes. | 713 // No default network updates for signal strength changes. |
| 714 test_observer_->reset_change_counts(); | 714 test_observer_->reset_change_counts(); |
| 715 SetServiceProperty(wifi1, shill::kSignalStrengthProperty, | 715 SetServiceProperty(wifi1, shill::kSignalStrengthProperty, base::Value(32)); |
| 716 base::FundamentalValue(32)); | |
| 717 base::RunLoop().RunUntilIdle(); | 716 base::RunLoop().RunUntilIdle(); |
| 718 EXPECT_EQ(0u, test_observer_->default_network_change_count()); | 717 EXPECT_EQ(0u, test_observer_->default_network_change_count()); |
| 719 | 718 |
| 720 // Change the default network to a Connecting network, then set the | 719 // Change the default network to a Connecting network, then set the |
| 721 // state to Connected. The DefaultNetworkChange notification should only | 720 // state to Connected. The DefaultNetworkChange notification should only |
| 722 // fire once when the network is connected. | 721 // fire once when the network is connected. |
| 723 test_observer_->reset_change_counts(); | 722 test_observer_->reset_change_counts(); |
| 724 SetServiceProperty(wifi1, shill::kStateProperty, | 723 SetServiceProperty(wifi1, shill::kStateProperty, |
| 725 base::StringValue(shill::kStateIdle)); | 724 base::StringValue(shill::kStateIdle)); |
| 726 base::RunLoop().RunUntilIdle(); | 725 base::RunLoop().RunUntilIdle(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 TEST_F(NetworkStateHandlerTest, DeviceListChanged) { | 824 TEST_F(NetworkStateHandlerTest, DeviceListChanged) { |
| 826 size_t stub_device_count = test_observer_->device_count(); | 825 size_t stub_device_count = test_observer_->device_count(); |
| 827 // Add an additional device. | 826 // Add an additional device. |
| 828 const std::string wifi_device = "/service/stub_wifi_device2"; | 827 const std::string wifi_device = "/service/stub_wifi_device2"; |
| 829 device_test_->AddDevice(wifi_device, shill::kTypeWifi, "stub_wifi_device2"); | 828 device_test_->AddDevice(wifi_device, shill::kTypeWifi, "stub_wifi_device2"); |
| 830 UpdateManagerProperties(); | 829 UpdateManagerProperties(); |
| 831 // Expect a device list update. | 830 // Expect a device list update. |
| 832 EXPECT_EQ(stub_device_count + 1, test_observer_->device_count()); | 831 EXPECT_EQ(stub_device_count + 1, test_observer_->device_count()); |
| 833 EXPECT_EQ(0, test_observer_->PropertyUpdatesForDevice(wifi_device)); | 832 EXPECT_EQ(0, test_observer_->PropertyUpdatesForDevice(wifi_device)); |
| 834 // Change a device property. | 833 // Change a device property. |
| 835 device_test_->SetDeviceProperty( | 834 device_test_->SetDeviceProperty(wifi_device, shill::kScanningProperty, |
| 836 wifi_device, shill::kScanningProperty, base::FundamentalValue(true)); | 835 base::Value(true)); |
| 837 UpdateManagerProperties(); | 836 UpdateManagerProperties(); |
| 838 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice(wifi_device)); | 837 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice(wifi_device)); |
| 839 } | 838 } |
| 840 | 839 |
| 841 TEST_F(NetworkStateHandlerTest, IPConfigChanged) { | 840 TEST_F(NetworkStateHandlerTest, IPConfigChanged) { |
| 842 test_observer_->reset_updates(); | 841 test_observer_->reset_updates(); |
| 843 EXPECT_EQ(0, test_observer_->PropertyUpdatesForDevice( | 842 EXPECT_EQ(0, test_observer_->PropertyUpdatesForDevice( |
| 844 kShillManagerClientStubWifiDevice)); | 843 kShillManagerClientStubWifiDevice)); |
| 845 EXPECT_EQ(0, test_observer_->PropertyUpdatesForService( | 844 EXPECT_EQ(0, test_observer_->PropertyUpdatesForService( |
| 846 kShillManagerClientStubDefaultWifi)); | 845 kShillManagerClientStubDefaultWifi)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 860 kShillManagerClientStubDefaultWifi, shill::kIPConfigProperty, | 859 kShillManagerClientStubDefaultWifi, shill::kIPConfigProperty, |
| 861 base::StringValue(kIPConfigPath)); | 860 base::StringValue(kIPConfigPath)); |
| 862 UpdateManagerProperties(); | 861 UpdateManagerProperties(); |
| 863 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( | 862 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( |
| 864 kShillManagerClientStubWifiDevice)); | 863 kShillManagerClientStubWifiDevice)); |
| 865 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( | 864 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( |
| 866 kShillManagerClientStubDefaultWifi)); | 865 kShillManagerClientStubDefaultWifi)); |
| 867 } | 866 } |
| 868 | 867 |
| 869 } // namespace chromeos | 868 } // namespace chromeos |
| OLD | NEW |