Chromium Code Reviews| 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/shill_property_handler.h" | 5 #include "chromeos/network/shill_property_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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 | 71 |
| 72 virtual void UpdateIPConfigProperties( | 72 virtual void UpdateIPConfigProperties( |
| 73 ManagedState::ManagedType type, | 73 ManagedState::ManagedType type, |
| 74 const std::string& path, | 74 const std::string& path, |
| 75 const std::string& ip_config_path, | 75 const std::string& ip_config_path, |
| 76 const base::DictionaryValue& properties) OVERRIDE { | 76 const base::DictionaryValue& properties) OVERRIDE { |
| 77 AddPropertyUpdate(shill::kIPConfigsProperty, ip_config_path); | 77 AddPropertyUpdate(shill::kIPConfigsProperty, ip_config_path); |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual void TechnologyListChanged() OVERRIDE { | 80 virtual void TechnologyListChanged() OVERRIDE { |
| 81 VLOG(1) << "TechnologyListChanged."; | |
| 81 ++technology_list_updates_; | 82 ++technology_list_updates_; |
| 82 } | 83 } |
| 83 | 84 |
| 84 virtual void CheckPortalListChanged( | 85 virtual void CheckPortalListChanged( |
| 85 const std::string& check_portal_list) OVERRIDE { | 86 const std::string& check_portal_list) OVERRIDE { |
| 86 } | 87 } |
| 87 | 88 |
| 88 virtual void ManagedStateListChanged( | 89 virtual void ManagedStateListChanged( |
| 89 ManagedState::ManagedType type) OVERRIDE { | 90 ManagedState::ManagedType type) OVERRIDE { |
| 90 AddStateListUpdate(GetTypeString(type)); | 91 AddStateListUpdate(GetTypeString(type)); |
| 91 } | 92 } |
| 92 | 93 |
| 93 virtual void DefaultNetworkServiceChanged( | 94 virtual void DefaultNetworkServiceChanged( |
| 94 const std::string& service_path) OVERRIDE { | 95 const std::string& service_path) OVERRIDE { |
| 95 } | 96 } |
| 96 | 97 |
| 97 std::vector<std::string>& entries(const std::string& type) { | 98 std::vector<std::string>& entries(const std::string& type) { |
| 98 return entries_[type]; | 99 return entries_[type]; |
| 99 } | 100 } |
| 100 std::map<std::string, int>& property_updates(const std::string& type) { | 101 std::map<std::string, int>& property_updates(const std::string& type) { |
| 101 return property_updates_[type]; | 102 return property_updates_[type]; |
| 102 } | 103 } |
| 103 std::map<std::string, int>& initial_property_updates( | 104 std::map<std::string, int>& initial_property_updates( |
| 104 const std::string& type) { | 105 const std::string& type) { |
| 105 return initial_property_updates_[type]; | 106 return initial_property_updates_[type]; |
| 106 } | 107 } |
| 107 int list_updates(const std::string& type) { return list_updates_[type]; } | 108 int list_updates(const std::string& type) { return list_updates_[type]; } |
| 108 void reset_list_updates() { list_updates_.clear(); } | |
| 109 int technology_list_updates() { return technology_list_updates_; } | 109 int technology_list_updates() { return technology_list_updates_; } |
| 110 void reset_list_updates() { | |
| 111 VLOG(1) << "=== RESET LIST UPDATES ==="; | |
| 112 list_updates_.clear(); | |
| 113 technology_list_updates_ = 0; | |
| 114 } | |
| 110 int errors() { return errors_; } | 115 int errors() { return errors_; } |
| 111 | 116 |
| 112 private: | 117 private: |
| 113 std::string GetTypeString(ManagedState::ManagedType type) { | 118 std::string GetTypeString(ManagedState::ManagedType type) { |
| 114 if (type == ManagedState::MANAGED_TYPE_NETWORK) { | 119 if (type == ManagedState::MANAGED_TYPE_NETWORK) { |
| 115 return shill::kServicesProperty; | 120 return shill::kServicesProperty; |
| 116 } else if (type == ManagedState::MANAGED_TYPE_FAVORITE) { | 121 } else if (type == ManagedState::MANAGED_TYPE_FAVORITE) { |
| 117 return shill::kServiceCompleteListProperty; | 122 return shill::kServiceCompleteListProperty; |
| 118 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { | 123 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { |
| 119 return shill::kDevicesProperty; | 124 return shill::kDevicesProperty; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 131 iter != entries.end(); ++iter) { | 136 iter != entries.end(); ++iter) { |
| 132 std::string path; | 137 std::string path; |
| 133 if ((*iter)->GetAsString(&path)) | 138 if ((*iter)->GetAsString(&path)) |
| 134 entries_[type].push_back(path); | 139 entries_[type].push_back(path); |
| 135 } | 140 } |
| 136 } | 141 } |
| 137 | 142 |
| 138 void AddPropertyUpdate(const std::string& type, const std::string& path) { | 143 void AddPropertyUpdate(const std::string& type, const std::string& path) { |
| 139 if (type.empty()) | 144 if (type.empty()) |
| 140 return; | 145 return; |
| 146 VLOG(2) << "AddPropertyUpdate: " << type; | |
| 141 property_updates(type)[path] += 1; | 147 property_updates(type)[path] += 1; |
| 142 } | 148 } |
| 143 | 149 |
| 144 void AddInitialPropertyUpdate(const std::string& type, | 150 void AddInitialPropertyUpdate(const std::string& type, |
| 145 const std::string& path) { | 151 const std::string& path) { |
| 146 if (type.empty()) | 152 if (type.empty()) |
| 147 return; | 153 return; |
| 154 VLOG(2) << "AddInitialPropertyUpdate: " << type; | |
| 148 initial_property_updates(type)[path] += 1; | 155 initial_property_updates(type)[path] += 1; |
| 149 } | 156 } |
| 150 | 157 |
| 151 void AddStateListUpdate(const std::string& type) { | 158 void AddStateListUpdate(const std::string& type) { |
| 152 if (type.empty()) | 159 if (type.empty()) |
| 153 return; | 160 return; |
| 154 list_updates_[type] += 1; | 161 list_updates_[type] += 1; |
| 155 } | 162 } |
| 156 | 163 |
| 157 // Map of list-type -> paths | 164 // Map of list-type -> paths |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 } | 207 } |
| 201 | 208 |
| 202 virtual void TearDown() OVERRIDE { | 209 virtual void TearDown() OVERRIDE { |
| 203 shill_property_handler_.reset(); | 210 shill_property_handler_.reset(); |
| 204 listener_.reset(); | 211 listener_.reset(); |
| 205 DBusThreadManager::Shutdown(); | 212 DBusThreadManager::Shutdown(); |
| 206 } | 213 } |
| 207 | 214 |
| 208 void AddDevice(const std::string& type, const std::string& id) { | 215 void AddDevice(const std::string& type, const std::string& id) { |
| 209 ASSERT_TRUE(IsValidType(type)); | 216 ASSERT_TRUE(IsValidType(type)); |
| 210 device_test_->AddDevice(id, type, std::string("/device/" + id)); | 217 device_test_->AddDevice(id, type, id); |
| 211 } | 218 } |
| 212 | 219 |
| 213 void RemoveDevice(const std::string& id) { | 220 void RemoveDevice(const std::string& id) { |
| 214 device_test_->RemoveDevice(id); | 221 device_test_->RemoveDevice(id); |
| 215 } | 222 } |
| 216 | 223 |
| 217 void AddService(const std::string& type, | 224 void AddService(const std::string& type, |
| 218 const std::string& id, | 225 const std::string& id, |
| 219 const std::string& state, | 226 const std::string& state) { |
| 220 bool add_to_watch_list) { | |
|
stevenjb
2014/05/28 22:47:22
We no longer pay attention to the watch list, so I
pneubeck (no reviews)
2014/06/04 09:30:27
Could add_to_watch_list then also be removed from
stevenjb
2014/06/05 20:38:19
Yes. I was originally going to avoid that big of a
| |
| 221 ASSERT_TRUE(IsValidType(type)); | 227 ASSERT_TRUE(IsValidType(type)); |
| 222 service_test_->AddService(id, id, type, state, | 228 service_test_->AddService(id, id, type, state, |
| 223 true /* visible */, add_to_watch_list); | 229 true /* visible */, |
| 230 true /* add_to_watch_list */); | |
| 224 } | 231 } |
| 225 | 232 |
| 226 void AddServiceWithIPConfig(const std::string& type, | 233 void AddServiceWithIPConfig(const std::string& type, |
| 227 const std::string& id, | 234 const std::string& id, |
| 228 const std::string& state, | 235 const std::string& state, |
| 229 const std::string& ipconfig_path, | 236 const std::string& ipconfig_path) { |
| 230 bool add_to_watch_list) { | |
| 231 ASSERT_TRUE(IsValidType(type)); | 237 ASSERT_TRUE(IsValidType(type)); |
| 232 service_test_->AddServiceWithIPConfig(id, /* service_path */ | 238 service_test_->AddServiceWithIPConfig(id, /* service_path */ |
| 233 "" /* guid */, | 239 "" /* guid */, |
| 234 id /* name */, | 240 id /* name */, |
| 235 type, | 241 type, |
| 236 state, | 242 state, |
| 237 ipconfig_path, | 243 ipconfig_path, |
| 238 true /* visible */, | 244 true /* visible */, |
| 239 add_to_watch_list); | 245 true /* add_to_watch_list */); |
| 240 } | 246 } |
| 241 | 247 |
| 242 void AddServiceToProfile(const std::string& type, | 248 void AddServiceToProfile(const std::string& type, |
| 243 const std::string& id, | 249 const std::string& id, |
| 244 bool visible) { | 250 bool visible) { |
| 245 service_test_->AddService(id, id, type, shill::kStateIdle, | 251 service_test_->AddService(id, id, type, shill::kStateIdle, |
| 246 visible, false /* watch */); | 252 visible, true /* watch */); |
| 247 std::vector<std::string> profiles; | 253 std::vector<std::string> profiles; |
| 248 profile_test_->GetProfilePaths(&profiles); | 254 profile_test_->GetProfilePaths(&profiles); |
| 249 ASSERT_TRUE(profiles.size() > 0); | 255 ASSERT_TRUE(profiles.size() > 0); |
| 250 base::DictionaryValue properties; // Empty entry | 256 base::DictionaryValue properties; // Empty entry |
| 251 profile_test_->AddService(profiles[0], id); | 257 profile_test_->AddService(profiles[0], id); |
| 252 } | 258 } |
| 253 | 259 |
| 254 void RemoveService(const std::string& id) { | 260 void RemoveService(const std::string& id) { |
| 255 service_test_->RemoveService(id); | 261 service_test_->RemoveService(id); |
| 256 } | 262 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 274 type == shill::kTypeVPN); | 280 type == shill::kTypeVPN); |
| 275 } | 281 } |
| 276 | 282 |
| 277 protected: | 283 protected: |
| 278 void SetupDefaultShillState() { | 284 void SetupDefaultShillState() { |
| 279 message_loop_.RunUntilIdle(); // Process any pending updates | 285 message_loop_.RunUntilIdle(); // Process any pending updates |
| 280 device_test_->ClearDevices(); | 286 device_test_->ClearDevices(); |
| 281 AddDevice(shill::kTypeWifi, "stub_wifi_device1"); | 287 AddDevice(shill::kTypeWifi, "stub_wifi_device1"); |
| 282 AddDevice(shill::kTypeCellular, "stub_cellular_device1"); | 288 AddDevice(shill::kTypeCellular, "stub_cellular_device1"); |
| 283 service_test_->ClearServices(); | 289 service_test_->ClearServices(); |
| 284 const bool add_to_watchlist = true; | 290 AddService(shill::kTypeEthernet, "stub_ethernet", shill::kStateOnline); |
| 285 AddService(shill::kTypeEthernet, "stub_ethernet", | 291 AddService(shill::kTypeWifi, "stub_wifi1", shill::kStateOnline); |
| 286 shill::kStateOnline, add_to_watchlist); | 292 AddService(shill::kTypeWifi, "stub_wifi2", shill::kStateIdle); |
| 287 AddService(shill::kTypeWifi, "stub_wifi1", | 293 AddService(shill::kTypeCellular, "stub_cellular1", shill::kStateIdle); |
| 288 shill::kStateOnline, add_to_watchlist); | |
| 289 AddService(shill::kTypeWifi, "stub_wifi2", | |
| 290 shill::kStateIdle, add_to_watchlist); | |
| 291 AddService(shill::kTypeCellular, "stub_cellular1", | |
| 292 shill::kStateIdle, add_to_watchlist); | |
| 293 } | 294 } |
| 294 | 295 |
| 295 base::MessageLoopForUI message_loop_; | 296 base::MessageLoopForUI message_loop_; |
| 296 scoped_ptr<TestListener> listener_; | 297 scoped_ptr<TestListener> listener_; |
| 297 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_; | 298 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_; |
| 298 ShillManagerClient::TestInterface* manager_test_; | 299 ShillManagerClient::TestInterface* manager_test_; |
| 299 ShillDeviceClient::TestInterface* device_test_; | 300 ShillDeviceClient::TestInterface* device_test_; |
| 300 ShillServiceClient::TestInterface* service_test_; | 301 ShillServiceClient::TestInterface* service_test_; |
| 301 ShillProfileClient::TestInterface* profile_test_; | 302 ShillProfileClient::TestInterface* profile_test_; |
| 302 | 303 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 315 listener_->entries(shill::kServicesProperty).size()); | 316 listener_->entries(shill::kServicesProperty).size()); |
| 316 | 317 |
| 317 EXPECT_EQ(0, listener_->errors()); | 318 EXPECT_EQ(0, listener_->errors()); |
| 318 } | 319 } |
| 319 | 320 |
| 320 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) { | 321 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) { |
| 321 const int initial_technology_updates = 2; // Available and Enabled lists | 322 const int initial_technology_updates = 2; // Available and Enabled lists |
| 322 EXPECT_EQ(initial_technology_updates, listener_->technology_list_updates()); | 323 EXPECT_EQ(initial_technology_updates, listener_->technology_list_updates()); |
| 323 | 324 |
| 324 // Remove an enabled technology. Updates both the Available and Enabled lists. | 325 // Remove an enabled technology. Updates both the Available and Enabled lists. |
| 326 listener_->reset_list_updates(); | |
| 325 manager_test_->RemoveTechnology(shill::kTypeWifi); | 327 manager_test_->RemoveTechnology(shill::kTypeWifi); |
| 326 message_loop_.RunUntilIdle(); | 328 message_loop_.RunUntilIdle(); |
| 327 EXPECT_EQ(initial_technology_updates + 2, | 329 EXPECT_EQ(2, listener_->technology_list_updates()); |
| 328 listener_->technology_list_updates()); | |
| 329 | 330 |
| 330 // Add a disabled technology. | 331 // Add a disabled technology. |
| 332 listener_->reset_list_updates(); | |
| 331 manager_test_->AddTechnology(shill::kTypeWifi, false); | 333 manager_test_->AddTechnology(shill::kTypeWifi, false); |
| 332 message_loop_.RunUntilIdle(); | 334 message_loop_.RunUntilIdle(); |
| 333 EXPECT_EQ(initial_technology_updates + 3, | 335 EXPECT_EQ(1, listener_->technology_list_updates()); |
| 334 listener_->technology_list_updates()); | |
| 335 EXPECT_TRUE(shill_property_handler_->IsTechnologyAvailable( | 336 EXPECT_TRUE(shill_property_handler_->IsTechnologyAvailable( |
| 336 shill::kTypeWifi)); | 337 shill::kTypeWifi)); |
| 337 EXPECT_FALSE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); | 338 EXPECT_FALSE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); |
| 338 | 339 |
| 339 // Enable the technology. | 340 // Enable the technology. |
| 341 listener_->reset_list_updates(); | |
| 340 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( | 342 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( |
| 341 shill::kTypeWifi, | 343 shill::kTypeWifi, |
| 342 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 344 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
| 343 message_loop_.RunUntilIdle(); | 345 message_loop_.RunUntilIdle(); |
| 344 EXPECT_EQ(initial_technology_updates + 4, | 346 EXPECT_EQ(1, listener_->technology_list_updates()); |
| 345 listener_->technology_list_updates()); | |
| 346 EXPECT_TRUE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); | 347 EXPECT_TRUE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); |
| 347 | 348 |
| 348 EXPECT_EQ(0, listener_->errors()); | 349 EXPECT_EQ(0, listener_->errors()); |
| 349 } | 350 } |
| 350 | 351 |
| 351 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) { | 352 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) { |
| 352 const size_t kNumShillManagerClientStubImplDevices = 2; | 353 const size_t kNumShillManagerClientStubImplDevices = 2; |
| 353 EXPECT_EQ(kNumShillManagerClientStubImplDevices, | 354 EXPECT_EQ(kNumShillManagerClientStubImplDevices, |
| 354 listener_->entries(shill::kDevicesProperty).size()); | 355 listener_->entries(shill::kDevicesProperty).size()); |
| 355 // Add a device. | 356 // Add a device. |
| 356 listener_->reset_list_updates(); | 357 listener_->reset_list_updates(); |
| 357 const std::string kTestDevicePath("test_wifi_device1"); | 358 const std::string kTestDevicePath("test_wifi_device1"); |
| 358 AddDevice(shill::kTypeWifi, kTestDevicePath); | 359 AddDevice(shill::kTypeWifi, kTestDevicePath); |
| 359 message_loop_.RunUntilIdle(); | 360 message_loop_.RunUntilIdle(); |
| 360 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); | 361 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); |
| 361 EXPECT_EQ(kNumShillManagerClientStubImplDevices + 1, | 362 EXPECT_EQ(kNumShillManagerClientStubImplDevices + 1, |
| 362 listener_->entries(shill::kDevicesProperty).size()); | 363 listener_->entries(shill::kDevicesProperty).size()); |
| 363 // Device changes are not observed. | 364 |
| 364 // Remove a device | 365 // Remove a device |
| 365 listener_->reset_list_updates(); | 366 listener_->reset_list_updates(); |
| 366 RemoveDevice(kTestDevicePath); | 367 RemoveDevice(kTestDevicePath); |
| 367 message_loop_.RunUntilIdle(); | 368 message_loop_.RunUntilIdle(); |
| 368 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); | 369 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); |
| 369 EXPECT_EQ(kNumShillManagerClientStubImplDevices, | 370 EXPECT_EQ(kNumShillManagerClientStubImplDevices, |
| 370 listener_->entries(shill::kDevicesProperty).size()); | 371 listener_->entries(shill::kDevicesProperty).size()); |
| 371 | 372 |
| 372 EXPECT_EQ(0, listener_->errors()); | 373 EXPECT_EQ(0, listener_->errors()); |
| 373 } | 374 } |
| 374 | 375 |
| 375 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) { | 376 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) { |
| 376 const size_t kNumShillManagerClientStubImplServices = 4; | 377 const size_t kNumShillManagerClientStubImplServices = 4; |
| 377 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 378 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
| 378 listener_->entries(shill::kServicesProperty).size()); | 379 listener_->entries(shill::kServicesProperty).size()); |
| 379 | 380 |
| 380 // Add an unwatched service. | 381 // Add a service. |
| 381 listener_->reset_list_updates(); | 382 listener_->reset_list_updates(); |
| 382 const std::string kTestServicePath("test_wifi_service1"); | 383 const std::string kTestServicePath("test_wifi_service1"); |
| 383 AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle, false); | 384 AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle); |
| 384 message_loop_.RunUntilIdle(); | 385 message_loop_.RunUntilIdle(); |
| 385 // Watched and unwatched services trigger a service list update. | 386 // Add should trigger a service list update and update entries. |
| 386 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | 387 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); |
| 387 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, | 388 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, |
| 388 listener_->entries(shill::kServicesProperty).size()); | 389 listener_->entries(shill::kServicesProperty).size()); |
| 389 // Service receives an initial property update. | 390 // Service receives an initial property update. |
| 390 EXPECT_EQ(1, listener_->initial_property_updates( | 391 EXPECT_EQ(1, listener_->initial_property_updates( |
| 391 shill::kServicesProperty)[kTestServicePath]); | 392 shill::kServicesProperty)[kTestServicePath]); |
| 392 // Change a property. | 393 // Change a property. |
| 393 base::FundamentalValue scan_interval(3); | 394 base::FundamentalValue scan_interval(3); |
| 394 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 395 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
| 395 dbus::ObjectPath(kTestServicePath), | 396 dbus::ObjectPath(kTestServicePath), |
| 396 shill::kScanIntervalProperty, | 397 shill::kScanIntervalProperty, |
| 397 scan_interval, | 398 scan_interval, |
| 398 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 399 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
| 399 message_loop_.RunUntilIdle(); | 400 message_loop_.RunUntilIdle(); |
| 400 // Property change triggers an update. | 401 // Property change triggers an update (but not a service list update). |
| 401 EXPECT_EQ(1, listener_->property_updates( | 402 EXPECT_EQ(1, listener_->property_updates( |
| 402 shill::kServicesProperty)[kTestServicePath]); | 403 shill::kServicesProperty)[kTestServicePath]); |
| 403 | 404 |
| 404 // Add the existing service to the watch list. | 405 // Remove a service. |
| 405 listener_->reset_list_updates(); | |
| 406 AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle, true); | |
| 407 message_loop_.RunUntilIdle(); | |
| 408 // Service list update should be received when watch list changes. | |
| 409 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | |
| 410 // Number of services shouldn't change. | |
| 411 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, | |
| 412 listener_->entries(shill::kServicesProperty).size()); | |
| 413 | |
| 414 // Change a property. | |
| 415 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | |
| 416 dbus::ObjectPath(kTestServicePath), | |
| 417 shill::kScanIntervalProperty, | |
| 418 scan_interval, | |
| 419 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | |
| 420 message_loop_.RunUntilIdle(); | |
| 421 // Property change should trigger another update. | |
| 422 EXPECT_EQ(2, listener_->property_updates( | |
| 423 shill::kServicesProperty)[kTestServicePath]); | |
| 424 | |
| 425 // Remove a service | |
| 426 listener_->reset_list_updates(); | 406 listener_->reset_list_updates(); |
| 427 RemoveService(kTestServicePath); | 407 RemoveService(kTestServicePath); |
| 428 message_loop_.RunUntilIdle(); | 408 message_loop_.RunUntilIdle(); |
| 429 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | 409 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); |
| 430 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 410 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
| 431 listener_->entries(shill::kServicesProperty).size()); | 411 listener_->entries(shill::kServicesProperty).size()); |
| 432 | 412 |
| 433 EXPECT_EQ(0, listener_->errors()); | 413 EXPECT_EQ(0, listener_->errors()); |
| 434 } | 414 } |
| 435 | 415 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 457 base::StringValue gateway("192.0.0.1"); | 437 base::StringValue gateway("192.0.0.1"); |
| 458 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( | 438 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( |
| 459 dbus::ObjectPath(kTestIPConfigPath), | 439 dbus::ObjectPath(kTestIPConfigPath), |
| 460 shill::kGatewayProperty, gateway, | 440 shill::kGatewayProperty, gateway, |
| 461 base::Bind(&DoNothingWithCallStatus)); | 441 base::Bind(&DoNothingWithCallStatus)); |
| 462 message_loop_.RunUntilIdle(); | 442 message_loop_.RunUntilIdle(); |
| 463 | 443 |
| 464 // Add a service with an empty ipconfig and then update | 444 // Add a service with an empty ipconfig and then update |
| 465 // its ipconfig property. | 445 // its ipconfig property. |
| 466 const std::string kTestServicePath1("test_wifi_service1"); | 446 const std::string kTestServicePath1("test_wifi_service1"); |
| 467 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle, true); | 447 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle); |
| 468 message_loop_.RunUntilIdle(); | 448 message_loop_.RunUntilIdle(); |
| 469 // This is the initial property update. | 449 // This is the initial property update. |
| 470 EXPECT_EQ(1, listener_->initial_property_updates( | 450 EXPECT_EQ(1, listener_->initial_property_updates( |
| 471 shill::kServicesProperty)[kTestServicePath1]); | 451 shill::kServicesProperty)[kTestServicePath1]); |
| 472 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 452 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
| 473 dbus::ObjectPath(kTestServicePath1), | 453 dbus::ObjectPath(kTestServicePath1), |
| 474 shill::kIPConfigProperty, | 454 shill::kIPConfigProperty, |
| 475 base::StringValue(kTestIPConfigPath), | 455 base::StringValue(kTestIPConfigPath), |
| 476 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 456 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
| 477 message_loop_.RunUntilIdle(); | 457 message_loop_.RunUntilIdle(); |
| 478 // IPConfig property change on the service should trigger an IPConfigs update. | 458 // IPConfig property change on the service should trigger an IPConfigs update. |
| 479 EXPECT_EQ(1, listener_->property_updates( | 459 EXPECT_EQ(1, listener_->property_updates( |
| 480 shill::kIPConfigsProperty)[kTestIPConfigPath]); | 460 shill::kIPConfigsProperty)[kTestIPConfigPath]); |
| 481 | 461 |
| 482 // Now, Add a new watched service with the IPConfig already set. | 462 // Now, Add a new service with the IPConfig already set. |
| 483 const std::string kTestServicePath2("test_wifi_service2"); | 463 const std::string kTestServicePath2("test_wifi_service2"); |
| 484 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2, | 464 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2, |
| 485 shill::kStateIdle, kTestIPConfigPath, true); | 465 shill::kStateIdle, kTestIPConfigPath); |
| 486 message_loop_.RunUntilIdle(); | 466 message_loop_.RunUntilIdle(); |
| 487 // A watched service with the IPConfig property already set should trigger an | 467 // A service with the IPConfig property already set should trigger an |
| 488 // additional IPConfigs update. | 468 // additional IPConfigs update. |
| 489 EXPECT_EQ(2, listener_->property_updates( | 469 EXPECT_EQ(2, listener_->property_updates( |
| 490 shill::kIPConfigsProperty)[kTestIPConfigPath]); | 470 shill::kIPConfigsProperty)[kTestIPConfigPath]); |
| 491 } | 471 } |
| 492 | 472 |
| 493 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceCompleteList) { | 473 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceCompleteList) { |
| 494 // Add a new entry to the profile only (triggers a Services update). | 474 // Add a new entry to the profile only (triggers a Services update). |
| 495 const std::string kTestServicePath1("stub_wifi_profile_only1"); | 475 const std::string kTestServicePath1("stub_wifi_profile_only1"); |
| 496 AddServiceToProfile(shill::kTypeWifi, kTestServicePath1, false); | 476 AddServiceToProfile(shill::kTypeWifi, kTestServicePath1, false /* visible */); |
| 497 message_loop_.RunUntilIdle(); | 477 message_loop_.RunUntilIdle(); |
| 498 | 478 |
| 499 // Update the Manager properties. This should trigger a single list update | 479 // Update the Manager properties. This should trigger a single list update |
| 500 // for both Services and ServiceCompleteList, and a single property update | 480 // for both Services and ServiceCompleteList, and a single property update |
| 501 // for ServiceCompleteList. | 481 // for ServiceCompleteList. |
| 502 listener_->reset_list_updates(); | 482 listener_->reset_list_updates(); |
| 503 shill_property_handler_->UpdateManagerProperties(); | 483 shill_property_handler_->UpdateManagerProperties(); |
| 504 message_loop_.RunUntilIdle(); | 484 message_loop_.RunUntilIdle(); |
| 505 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | 485 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); |
| 506 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); | 486 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 message_loop_.RunUntilIdle(); | 525 message_loop_.RunUntilIdle(); |
| 546 // Property change should trigger an update for the Network only; no | 526 // Property change should trigger an update for the Network only; no |
| 547 // property updates pushed by Shill affect Favorites. | 527 // property updates pushed by Shill affect Favorites. |
| 548 EXPECT_EQ(2, listener_->property_updates( | 528 EXPECT_EQ(2, listener_->property_updates( |
| 549 shill::kServicesProperty)[kTestServicePath2]); | 529 shill::kServicesProperty)[kTestServicePath2]); |
| 550 EXPECT_EQ(0, listener_->property_updates( | 530 EXPECT_EQ(0, listener_->property_updates( |
| 551 shill::kServiceCompleteListProperty)[kTestServicePath2]); | 531 shill::kServiceCompleteListProperty)[kTestServicePath2]); |
| 552 } | 532 } |
| 553 | 533 |
| 554 } // namespace chromeos | 534 } // namespace chromeos |
| OLD | NEW |