| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 device_list_changed_count_(0), | 53 device_list_changed_count_(0), |
| 54 device_count_(0), | 54 device_count_(0), |
| 55 network_list_changed_count_(0), | 55 network_list_changed_count_(0), |
| 56 network_count_(0), | 56 network_count_(0), |
| 57 default_network_change_count_(0) { | 57 default_network_change_count_(0) { |
| 58 } | 58 } |
| 59 | 59 |
| 60 virtual ~TestObserver() { | 60 virtual ~TestObserver() { |
| 61 } | 61 } |
| 62 | 62 |
| 63 virtual void DeviceListChanged() OVERRIDE { | 63 virtual void DeviceListChanged() override { |
| 64 NetworkStateHandler::DeviceStateList devices; | 64 NetworkStateHandler::DeviceStateList devices; |
| 65 handler_->GetDeviceList(&devices); | 65 handler_->GetDeviceList(&devices); |
| 66 device_count_ = devices.size(); | 66 device_count_ = devices.size(); |
| 67 ++device_list_changed_count_; | 67 ++device_list_changed_count_; |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual void NetworkListChanged() OVERRIDE { | 70 virtual void NetworkListChanged() override { |
| 71 NetworkStateHandler::NetworkStateList networks; | 71 NetworkStateHandler::NetworkStateList networks; |
| 72 handler_->GetNetworkListByType(chromeos::NetworkTypePattern::Default(), | 72 handler_->GetNetworkListByType(chromeos::NetworkTypePattern::Default(), |
| 73 false /* configured_only */, | 73 false /* configured_only */, |
| 74 false /* visible_only */, | 74 false /* visible_only */, |
| 75 0 /* no limit */, | 75 0 /* no limit */, |
| 76 &networks); | 76 &networks); |
| 77 network_count_ = networks.size(); | 77 network_count_ = networks.size(); |
| 78 if (network_count_ == 0) { | 78 if (network_count_ == 0) { |
| 79 default_network_ = ""; | 79 default_network_ = ""; |
| 80 default_network_connection_state_ = ""; | 80 default_network_connection_state_ = ""; |
| 81 } | 81 } |
| 82 ++network_list_changed_count_; | 82 ++network_list_changed_count_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 virtual void DefaultNetworkChanged(const NetworkState* network) OVERRIDE { | 85 virtual void DefaultNetworkChanged(const NetworkState* network) override { |
| 86 ++default_network_change_count_; | 86 ++default_network_change_count_; |
| 87 default_network_ = network ? network->path() : ""; | 87 default_network_ = network ? network->path() : ""; |
| 88 default_network_connection_state_ = | 88 default_network_connection_state_ = |
| 89 network ? network->connection_state() : ""; | 89 network ? network->connection_state() : ""; |
| 90 DVLOG(1) << "DefaultNetworkChanged: " << default_network_ | 90 DVLOG(1) << "DefaultNetworkChanged: " << default_network_ |
| 91 << " State: " << default_network_connection_state_; | 91 << " State: " << default_network_connection_state_; |
| 92 } | 92 } |
| 93 | 93 |
| 94 virtual void NetworkConnectionStateChanged( | 94 virtual void NetworkConnectionStateChanged( |
| 95 const NetworkState* network) OVERRIDE { | 95 const NetworkState* network) override { |
| 96 network_connection_state_[network->path()] = network->connection_state(); | 96 network_connection_state_[network->path()] = network->connection_state(); |
| 97 connection_state_changes_[network->path()]++; | 97 connection_state_changes_[network->path()]++; |
| 98 } | 98 } |
| 99 | 99 |
| 100 virtual void NetworkPropertiesUpdated(const NetworkState* network) OVERRIDE { | 100 virtual void NetworkPropertiesUpdated(const NetworkState* network) override { |
| 101 DCHECK(network); | 101 DCHECK(network); |
| 102 property_updates_[network->path()]++; | 102 property_updates_[network->path()]++; |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual void DevicePropertiesUpdated(const DeviceState* device) OVERRIDE { | 105 virtual void DevicePropertiesUpdated(const DeviceState* device) override { |
| 106 DCHECK(device); | 106 DCHECK(device); |
| 107 device_property_updates_[device->path()]++; | 107 device_property_updates_[device->path()]++; |
| 108 } | 108 } |
| 109 | 109 |
| 110 size_t device_list_changed_count() { return device_list_changed_count_; } | 110 size_t device_list_changed_count() { return device_list_changed_count_; } |
| 111 size_t device_count() { return device_count_; } | 111 size_t device_count() { return device_count_; } |
| 112 size_t network_list_changed_count() { return network_list_changed_count_; } | 112 size_t network_list_changed_count() { return network_list_changed_count_; } |
| 113 size_t network_count() { return network_count_; } | 113 size_t network_count() { return network_count_; } |
| 114 size_t default_network_change_count() { | 114 size_t default_network_change_count() { |
| 115 return default_network_change_count_; | 115 return default_network_change_count_; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 class NetworkStateHandlerTest : public testing::Test { | 171 class NetworkStateHandlerTest : public testing::Test { |
| 172 public: | 172 public: |
| 173 NetworkStateHandlerTest() | 173 NetworkStateHandlerTest() |
| 174 : device_test_(NULL), | 174 : device_test_(NULL), |
| 175 manager_test_(NULL), | 175 manager_test_(NULL), |
| 176 profile_test_(NULL), | 176 profile_test_(NULL), |
| 177 service_test_(NULL) {} | 177 service_test_(NULL) {} |
| 178 virtual ~NetworkStateHandlerTest() {} | 178 virtual ~NetworkStateHandlerTest() {} |
| 179 | 179 |
| 180 virtual void SetUp() OVERRIDE { | 180 virtual void SetUp() override { |
| 181 // Initialize DBusThreadManager with a stub implementation. | 181 // Initialize DBusThreadManager with a stub implementation. |
| 182 DBusThreadManager::Initialize(); | 182 DBusThreadManager::Initialize(); |
| 183 SetupDefaultShillState(); | 183 SetupDefaultShillState(); |
| 184 network_state_handler_.reset(new NetworkStateHandler); | 184 network_state_handler_.reset(new NetworkStateHandler); |
| 185 test_observer_.reset(new TestObserver(network_state_handler_.get())); | 185 test_observer_.reset(new TestObserver(network_state_handler_.get())); |
| 186 network_state_handler_->AddObserver(test_observer_.get(), FROM_HERE); | 186 network_state_handler_->AddObserver(test_observer_.get(), FROM_HERE); |
| 187 network_state_handler_->InitShillPropertyHandler(); | 187 network_state_handler_->InitShillPropertyHandler(); |
| 188 message_loop_.RunUntilIdle(); | 188 message_loop_.RunUntilIdle(); |
| 189 test_observer_->reset_change_counts(); | 189 test_observer_->reset_change_counts(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 virtual void TearDown() OVERRIDE { | 192 virtual void TearDown() override { |
| 193 network_state_handler_->RemoveObserver(test_observer_.get(), FROM_HERE); | 193 network_state_handler_->RemoveObserver(test_observer_.get(), FROM_HERE); |
| 194 test_observer_.reset(); | 194 test_observer_.reset(); |
| 195 network_state_handler_.reset(); | 195 network_state_handler_.reset(); |
| 196 DBusThreadManager::Shutdown(); | 196 DBusThreadManager::Shutdown(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 protected: | 199 protected: |
| 200 void AddService(const std::string& service_path, | 200 void AddService(const std::string& service_path, |
| 201 const std::string& guid, | 201 const std::string& guid, |
| 202 const std::string& name, | 202 const std::string& name, |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 kShillManagerClientStubDefaultWifi, shill::kIPConfigProperty, | 774 kShillManagerClientStubDefaultWifi, shill::kIPConfigProperty, |
| 775 base::StringValue(kIPConfigPath)); | 775 base::StringValue(kIPConfigPath)); |
| 776 UpdateManagerProperties(); | 776 UpdateManagerProperties(); |
| 777 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( | 777 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( |
| 778 kShillManagerClientStubWifiDevice)); | 778 kShillManagerClientStubWifiDevice)); |
| 779 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( | 779 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( |
| 780 kShillManagerClientStubDefaultWifi)); | 780 kShillManagerClientStubDefaultWifi)); |
| 781 } | 781 } |
| 782 | 782 |
| 783 } // namespace chromeos | 783 } // namespace chromeos |
| OLD | NEW |