| 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 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 class TestListener : public internal::ShillPropertyHandler::Listener { | 37 class TestListener : public internal::ShillPropertyHandler::Listener { |
| 38 public: | 38 public: |
| 39 TestListener() : technology_list_updates_(0), | 39 TestListener() : technology_list_updates_(0), |
| 40 errors_(0) { | 40 errors_(0) { |
| 41 } | 41 } |
| 42 | 42 |
| 43 virtual void UpdateManagedList(ManagedState::ManagedType type, | 43 virtual void UpdateManagedList(ManagedState::ManagedType type, |
| 44 const base::ListValue& entries) OVERRIDE { | 44 const base::ListValue& entries) OVERRIDE { |
| 45 VLOG(1) << "UpdateManagedList[" << ManagedState::TypeToString(type) << "]: " |
| 46 << entries.GetSize(); |
| 45 UpdateEntries(GetTypeString(type), entries); | 47 UpdateEntries(GetTypeString(type), entries); |
| 46 } | 48 } |
| 47 | 49 |
| 50 virtual void UpdateVisibleNetworks(const base::ListValue& entries) OVERRIDE { |
| 51 VLOG(1) << "UpdateVisibleNetworks: " << entries.GetSize(); |
| 52 UpdateEntries(shill::kServicesProperty, entries); |
| 53 } |
| 54 |
| 48 virtual void UpdateManagedStateProperties( | 55 virtual void UpdateManagedStateProperties( |
| 49 ManagedState::ManagedType type, | 56 ManagedState::ManagedType type, |
| 50 const std::string& path, | 57 const std::string& path, |
| 51 const base::DictionaryValue& properties) OVERRIDE { | 58 const base::DictionaryValue& properties) OVERRIDE { |
| 52 AddInitialPropertyUpdate(GetTypeString(type), path); | 59 VLOG(2) << "UpdateManagedStateProperties: " << GetTypeString(type); |
| 60 initial_property_updates(GetTypeString(type))[path] += 1; |
| 53 } | 61 } |
| 54 | 62 |
| 55 virtual void ProfileListChanged() OVERRIDE { | 63 virtual void ProfileListChanged() OVERRIDE { |
| 56 } | 64 } |
| 57 | 65 |
| 58 virtual void UpdateNetworkServiceProperty( | 66 virtual void UpdateNetworkServiceProperty( |
| 59 const std::string& service_path, | 67 const std::string& service_path, |
| 60 const std::string& key, | 68 const std::string& key, |
| 61 const base::Value& value) OVERRIDE { | 69 const base::Value& value) OVERRIDE { |
| 62 AddPropertyUpdate(shill::kServicesProperty, service_path); | 70 AddPropertyUpdate(shill::kServiceCompleteListProperty, service_path); |
| 63 } | 71 } |
| 64 | 72 |
| 65 virtual void UpdateDeviceProperty( | 73 virtual void UpdateDeviceProperty( |
| 66 const std::string& device_path, | 74 const std::string& device_path, |
| 67 const std::string& key, | 75 const std::string& key, |
| 68 const base::Value& value) OVERRIDE { | 76 const base::Value& value) OVERRIDE { |
| 69 AddPropertyUpdate(shill::kDevicesProperty, device_path); | 77 AddPropertyUpdate(shill::kDevicesProperty, device_path); |
| 70 } | 78 } |
| 71 | 79 |
| 72 virtual void UpdateIPConfigProperties( | 80 virtual void UpdateIPConfigProperties( |
| 73 ManagedState::ManagedType type, | 81 ManagedState::ManagedType type, |
| 74 const std::string& path, | 82 const std::string& path, |
| 75 const std::string& ip_config_path, | 83 const std::string& ip_config_path, |
| 76 const base::DictionaryValue& properties) OVERRIDE { | 84 const base::DictionaryValue& properties) OVERRIDE { |
| 77 AddPropertyUpdate(shill::kIPConfigsProperty, ip_config_path); | 85 AddPropertyUpdate(shill::kIPConfigsProperty, ip_config_path); |
| 78 } | 86 } |
| 79 | 87 |
| 80 virtual void TechnologyListChanged() OVERRIDE { | 88 virtual void TechnologyListChanged() OVERRIDE { |
| 81 VLOG(1) << "TechnologyListChanged."; | 89 VLOG(1) << "TechnologyListChanged."; |
| 82 ++technology_list_updates_; | 90 ++technology_list_updates_; |
| 83 } | 91 } |
| 84 | 92 |
| 85 virtual void CheckPortalListChanged( | 93 virtual void CheckPortalListChanged( |
| 86 const std::string& check_portal_list) OVERRIDE { | 94 const std::string& check_portal_list) OVERRIDE { |
| 87 } | 95 } |
| 88 | 96 |
| 89 virtual void ManagedStateListChanged( | 97 virtual void ManagedStateListChanged( |
| 90 ManagedState::ManagedType type) OVERRIDE { | 98 ManagedState::ManagedType type) OVERRIDE { |
| 99 VLOG(1) << "ManagedStateListChanged: " << GetTypeString(type); |
| 91 AddStateListUpdate(GetTypeString(type)); | 100 AddStateListUpdate(GetTypeString(type)); |
| 92 } | 101 } |
| 93 | 102 |
| 94 virtual void DefaultNetworkServiceChanged( | 103 virtual void DefaultNetworkServiceChanged( |
| 95 const std::string& service_path) OVERRIDE { | 104 const std::string& service_path) OVERRIDE { |
| 96 } | 105 } |
| 97 | 106 |
| 98 std::vector<std::string>& entries(const std::string& type) { | 107 std::vector<std::string>& entries(const std::string& type) { |
| 99 return entries_[type]; | 108 return entries_[type]; |
| 100 } | 109 } |
| 101 std::map<std::string, int>& property_updates(const std::string& type) { | 110 std::map<std::string, int>& property_updates(const std::string& type) { |
| 102 return property_updates_[type]; | 111 return property_updates_[type]; |
| 103 } | 112 } |
| 104 std::map<std::string, int>& initial_property_updates( | 113 std::map<std::string, int>& initial_property_updates( |
| 105 const std::string& type) { | 114 const std::string& type) { |
| 106 return initial_property_updates_[type]; | 115 return initial_property_updates_[type]; |
| 107 } | 116 } |
| 108 int list_updates(const std::string& type) { return list_updates_[type]; } | 117 int list_updates(const std::string& type) { return list_updates_[type]; } |
| 109 int technology_list_updates() { return technology_list_updates_; } | 118 int technology_list_updates() { return technology_list_updates_; } |
| 110 void reset_list_updates() { | 119 void reset_list_updates() { |
| 111 VLOG(1) << "=== RESET LIST UPDATES ==="; | 120 VLOG(1) << "=== RESET LIST UPDATES ==="; |
| 112 list_updates_.clear(); | 121 list_updates_.clear(); |
| 113 technology_list_updates_ = 0; | 122 technology_list_updates_ = 0; |
| 114 } | 123 } |
| 115 int errors() { return errors_; } | 124 int errors() { return errors_; } |
| 116 | 125 |
| 117 private: | 126 private: |
| 118 std::string GetTypeString(ManagedState::ManagedType type) { | 127 std::string GetTypeString(ManagedState::ManagedType type) { |
| 119 if (type == ManagedState::MANAGED_TYPE_NETWORK) { | 128 if (type == ManagedState::MANAGED_TYPE_NETWORK) |
| 120 return shill::kServicesProperty; | |
| 121 } else if (type == ManagedState::MANAGED_TYPE_FAVORITE) { | |
| 122 return shill::kServiceCompleteListProperty; | 129 return shill::kServiceCompleteListProperty; |
| 123 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { | 130 if (type == ManagedState::MANAGED_TYPE_DEVICE) |
| 124 return shill::kDevicesProperty; | 131 return shill::kDevicesProperty; |
| 125 } | 132 NOTREACHED(); |
| 126 LOG(ERROR) << "UpdateManagedList called with unrecognized type: " << type; | |
| 127 ++errors_; | |
| 128 return std::string(); | 133 return std::string(); |
| 129 } | 134 } |
| 130 | 135 |
| 131 void UpdateEntries(const std::string& type, const base::ListValue& entries) { | 136 void UpdateEntries(const std::string& type, const base::ListValue& entries) { |
| 132 if (type.empty()) | 137 if (type.empty()) |
| 133 return; | 138 return; |
| 134 entries_[type].clear(); | 139 entries_[type].clear(); |
| 135 for (base::ListValue::const_iterator iter = entries.begin(); | 140 for (base::ListValue::const_iterator iter = entries.begin(); |
| 136 iter != entries.end(); ++iter) { | 141 iter != entries.end(); ++iter) { |
| 137 std::string path; | 142 std::string path; |
| 138 if ((*iter)->GetAsString(&path)) | 143 if ((*iter)->GetAsString(&path)) |
| 139 entries_[type].push_back(path); | 144 entries_[type].push_back(path); |
| 140 } | 145 } |
| 141 } | 146 } |
| 142 | 147 |
| 143 void AddPropertyUpdate(const std::string& type, const std::string& path) { | 148 void AddPropertyUpdate(const std::string& type, const std::string& path) { |
| 144 if (type.empty()) | 149 DCHECK(!type.empty()); |
| 145 return; | |
| 146 VLOG(2) << "AddPropertyUpdate: " << type; | 150 VLOG(2) << "AddPropertyUpdate: " << type; |
| 147 property_updates(type)[path] += 1; | 151 property_updates(type)[path] += 1; |
| 148 } | 152 } |
| 149 | 153 |
| 150 void AddInitialPropertyUpdate(const std::string& type, | |
| 151 const std::string& path) { | |
| 152 if (type.empty()) | |
| 153 return; | |
| 154 VLOG(2) << "AddInitialPropertyUpdate: " << type; | |
| 155 initial_property_updates(type)[path] += 1; | |
| 156 } | |
| 157 | |
| 158 void AddStateListUpdate(const std::string& type) { | 154 void AddStateListUpdate(const std::string& type) { |
| 159 if (type.empty()) | 155 DCHECK(!type.empty()); |
| 160 return; | |
| 161 list_updates_[type] += 1; | 156 list_updates_[type] += 1; |
| 162 } | 157 } |
| 163 | 158 |
| 164 // Map of list-type -> paths | 159 // Map of list-type -> paths |
| 165 std::map<std::string, std::vector<std::string> > entries_; | 160 std::map<std::string, std::vector<std::string> > entries_; |
| 166 // Map of list-type -> map of paths -> update counts | 161 // Map of list-type -> map of paths -> update counts |
| 167 std::map<std::string, std::map<std::string, int> > property_updates_; | 162 std::map<std::string, std::map<std::string, int> > property_updates_; |
| 168 std::map<std::string, std::map<std::string, int> > initial_property_updates_; | 163 std::map<std::string, std::map<std::string, int> > initial_property_updates_; |
| 169 // Map of list-type -> list update counts | 164 // Map of list-type -> list update counts |
| 170 std::map<std::string, int > list_updates_; | 165 std::map<std::string, int > list_updates_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 device_test_->AddDevice(id, type, id); | 212 device_test_->AddDevice(id, type, id); |
| 218 } | 213 } |
| 219 | 214 |
| 220 void RemoveDevice(const std::string& id) { | 215 void RemoveDevice(const std::string& id) { |
| 221 device_test_->RemoveDevice(id); | 216 device_test_->RemoveDevice(id); |
| 222 } | 217 } |
| 223 | 218 |
| 224 void AddService(const std::string& type, | 219 void AddService(const std::string& type, |
| 225 const std::string& id, | 220 const std::string& id, |
| 226 const std::string& state) { | 221 const std::string& state) { |
| 222 VLOG(2) << "AddService: " << type << ": " << id << ": " << state; |
| 227 ASSERT_TRUE(IsValidType(type)); | 223 ASSERT_TRUE(IsValidType(type)); |
| 228 service_test_->AddService(id, id, type, state, | 224 service_test_->AddService(id, id, type, state, true /* visible */); |
| 229 true /* visible */); | |
| 230 } | 225 } |
| 231 | 226 |
| 232 void AddServiceWithIPConfig(const std::string& type, | 227 void AddServiceWithIPConfig(const std::string& type, |
| 233 const std::string& id, | 228 const std::string& id, |
| 234 const std::string& state, | 229 const std::string& state, |
| 235 const std::string& ipconfig_path) { | 230 const std::string& ipconfig_path) { |
| 236 ASSERT_TRUE(IsValidType(type)); | 231 ASSERT_TRUE(IsValidType(type)); |
| 237 service_test_->AddServiceWithIPConfig(id, /* service_path */ | 232 service_test_->AddServiceWithIPConfig(id, /* service_path */ |
| 238 "" /* guid */, | 233 "" /* guid */, |
| 239 id /* name */, | 234 id /* name */, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) { | 368 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) { |
| 374 const size_t kNumShillManagerClientStubImplServices = 4; | 369 const size_t kNumShillManagerClientStubImplServices = 4; |
| 375 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 370 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
| 376 listener_->entries(shill::kServicesProperty).size()); | 371 listener_->entries(shill::kServicesProperty).size()); |
| 377 | 372 |
| 378 // Add a service. | 373 // Add a service. |
| 379 listener_->reset_list_updates(); | 374 listener_->reset_list_updates(); |
| 380 const std::string kTestServicePath("test_wifi_service1"); | 375 const std::string kTestServicePath("test_wifi_service1"); |
| 381 AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle); | 376 AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle); |
| 382 message_loop_.RunUntilIdle(); | 377 message_loop_.RunUntilIdle(); |
| 383 // Add should trigger a service list update and should update entries. | 378 // Add should trigger a service list update and update entries. |
| 384 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | 379 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); |
| 385 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, | 380 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, |
| 386 listener_->entries(shill::kServicesProperty).size()); | 381 listener_->entries(shill::kServicesProperty).size()); |
| 387 // Service receives an initial property update. | 382 // Service receives an initial property update. |
| 388 EXPECT_EQ(1, listener_->initial_property_updates( | 383 EXPECT_EQ(1, listener_->initial_property_updates( |
| 389 shill::kServicesProperty)[kTestServicePath]); | 384 shill::kServiceCompleteListProperty)[kTestServicePath]); |
| 390 // Change a property. | 385 // Change a property. |
| 391 base::FundamentalValue scan_interval(3); | 386 base::FundamentalValue scan_interval(3); |
| 392 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 387 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
| 393 dbus::ObjectPath(kTestServicePath), | 388 dbus::ObjectPath(kTestServicePath), |
| 394 shill::kScanIntervalProperty, | 389 shill::kScanIntervalProperty, |
| 395 scan_interval, | 390 scan_interval, |
| 396 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 391 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
| 397 message_loop_.RunUntilIdle(); | 392 message_loop_.RunUntilIdle(); |
| 398 // Property change triggers an update (but not a service list update). | 393 // Property change triggers an update (but not a service list update). |
| 399 EXPECT_EQ(1, listener_->property_updates( | 394 EXPECT_EQ(1, listener_->property_updates( |
| 400 shill::kServicesProperty)[kTestServicePath]); | 395 shill::kServiceCompleteListProperty)[kTestServicePath]); |
| 401 | 396 |
| 402 // Remove a service. | 397 // Remove a service. This will update the entries and signal a service list |
| 398 // update. |
| 403 listener_->reset_list_updates(); | 399 listener_->reset_list_updates(); |
| 404 RemoveService(kTestServicePath); | 400 RemoveService(kTestServicePath); |
| 405 message_loop_.RunUntilIdle(); | 401 message_loop_.RunUntilIdle(); |
| 406 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | 402 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); |
| 407 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 403 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
| 408 listener_->entries(shill::kServicesProperty).size()); | 404 listener_->entries(shill::kServicesProperty).size()); |
| 409 | 405 |
| 410 EXPECT_EQ(0, listener_->errors()); | 406 EXPECT_EQ(0, listener_->errors()); |
| 411 } | 407 } |
| 412 | 408 |
| 413 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) { | 409 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) { |
| 414 // Set the properties for an IP Config object. | 410 // Set the properties for an IP Config object. |
| 415 const std::string kTestIPConfigPath("test_ip_config_path"); | 411 const std::string kTestIPConfigPath("test_ip_config_path"); |
| 416 | 412 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 438 base::Bind(&DoNothingWithCallStatus)); | 434 base::Bind(&DoNothingWithCallStatus)); |
| 439 message_loop_.RunUntilIdle(); | 435 message_loop_.RunUntilIdle(); |
| 440 | 436 |
| 441 // Add a service with an empty ipconfig and then update | 437 // Add a service with an empty ipconfig and then update |
| 442 // its ipconfig property. | 438 // its ipconfig property. |
| 443 const std::string kTestServicePath1("test_wifi_service1"); | 439 const std::string kTestServicePath1("test_wifi_service1"); |
| 444 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle); | 440 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle); |
| 445 message_loop_.RunUntilIdle(); | 441 message_loop_.RunUntilIdle(); |
| 446 // This is the initial property update. | 442 // This is the initial property update. |
| 447 EXPECT_EQ(1, listener_->initial_property_updates( | 443 EXPECT_EQ(1, listener_->initial_property_updates( |
| 448 shill::kServicesProperty)[kTestServicePath1]); | 444 shill::kServiceCompleteListProperty)[kTestServicePath1]); |
| 449 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 445 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
| 450 dbus::ObjectPath(kTestServicePath1), | 446 dbus::ObjectPath(kTestServicePath1), |
| 451 shill::kIPConfigProperty, | 447 shill::kIPConfigProperty, |
| 452 base::StringValue(kTestIPConfigPath), | 448 base::StringValue(kTestIPConfigPath), |
| 453 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 449 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
| 454 message_loop_.RunUntilIdle(); | 450 message_loop_.RunUntilIdle(); |
| 455 // IPConfig property change on the service should trigger an IPConfigs update. | 451 // IPConfig property change on the service should trigger an IPConfigs update. |
| 456 EXPECT_EQ(1, listener_->property_updates( | 452 EXPECT_EQ(1, listener_->property_updates( |
| 457 shill::kIPConfigsProperty)[kTestIPConfigPath]); | 453 shill::kIPConfigsProperty)[kTestIPConfigPath]); |
| 458 | 454 |
| 459 // Now, Add a new service with the IPConfig already set. | 455 // Now, Add a new service with the IPConfig already set. |
| 460 const std::string kTestServicePath2("test_wifi_service2"); | 456 const std::string kTestServicePath2("test_wifi_service2"); |
| 461 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2, | 457 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2, |
| 462 shill::kStateIdle, kTestIPConfigPath); | 458 shill::kStateIdle, kTestIPConfigPath); |
| 463 message_loop_.RunUntilIdle(); | 459 message_loop_.RunUntilIdle(); |
| 464 // A service with the IPConfig property already set should trigger an | 460 // A service with the IPConfig property already set should trigger an |
| 465 // additional IPConfigs update. | 461 // additional IPConfigs update. |
| 466 EXPECT_EQ(2, listener_->property_updates( | 462 EXPECT_EQ(2, listener_->property_updates( |
| 467 shill::kIPConfigsProperty)[kTestIPConfigPath]); | 463 shill::kIPConfigsProperty)[kTestIPConfigPath]); |
| 468 } | 464 } |
| 469 | 465 |
| 470 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceCompleteList) { | 466 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceList) { |
| 471 // Add a new entry to the profile only (triggers a Services update). | 467 // Add an entry to the profile only. |
| 472 const std::string kTestServicePath1("stub_wifi_profile_only1"); | 468 const std::string kTestServicePath1("stub_wifi_profile_only1"); |
| 473 AddServiceToProfile(shill::kTypeWifi, kTestServicePath1, false /* visible */); | 469 AddServiceToProfile(shill::kTypeWifi, kTestServicePath1, false /* visible */); |
| 474 message_loop_.RunUntilIdle(); | 470 message_loop_.RunUntilIdle(); |
| 475 | 471 |
| 476 // Update the Manager properties. This should trigger a single list update | 472 // Update the Manager properties. This should trigger a single list update |
| 477 // for both Services and ServiceCompleteList, and a single property update | 473 // and a single initial property update. |
| 478 // for ServiceCompleteList. | |
| 479 listener_->reset_list_updates(); | 474 listener_->reset_list_updates(); |
| 480 shill_property_handler_->UpdateManagerProperties(); | 475 shill_property_handler_->UpdateManagerProperties(); |
| 481 message_loop_.RunUntilIdle(); | 476 message_loop_.RunUntilIdle(); |
| 482 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | |
| 483 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); | 477 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); |
| 484 EXPECT_EQ(0, listener_->initial_property_updates( | |
| 485 shill::kServicesProperty)[kTestServicePath1]); | |
| 486 EXPECT_EQ(1, listener_->initial_property_updates( | 478 EXPECT_EQ(1, listener_->initial_property_updates( |
| 487 shill::kServiceCompleteListProperty)[kTestServicePath1]); | 479 shill::kServiceCompleteListProperty)[kTestServicePath1]); |
| 488 EXPECT_EQ(0, listener_->property_updates( | 480 |
| 489 shill::kServicesProperty)[kTestServicePath1]); | |
| 490 EXPECT_EQ(0, listener_->property_updates( | 481 EXPECT_EQ(0, listener_->property_updates( |
| 491 shill::kServiceCompleteListProperty)[kTestServicePath1]); | 482 shill::kServiceCompleteListProperty)[kTestServicePath1]); |
| 492 | 483 |
| 493 // Add a new entry to the services and the profile; should also trigger a | 484 // Add a new entry to the services and the profile; should also trigger a |
| 494 // single list update for both Services and ServiceCompleteList, and should | 485 // service list update, and a property update. |
| 495 // trigger tow property updates for Services (one when the Profile propety | |
| 496 // changes, and one for the Request) and one ServiceCompleteList change for | |
| 497 // the Request. | |
| 498 listener_->reset_list_updates(); | 486 listener_->reset_list_updates(); |
| 499 const std::string kTestServicePath2("stub_wifi_profile_only2"); | 487 const std::string kTestServicePath2("stub_wifi_profile_only2"); |
| 500 AddServiceToProfile(shill::kTypeWifi, kTestServicePath2, true); | 488 AddServiceToProfile(shill::kTypeWifi, kTestServicePath2, true); |
| 501 shill_property_handler_->UpdateManagerProperties(); | 489 shill_property_handler_->UpdateManagerProperties(); |
| 502 message_loop_.RunUntilIdle(); | 490 message_loop_.RunUntilIdle(); |
| 503 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | |
| 504 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); | 491 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); |
| 505 EXPECT_EQ(1, listener_->initial_property_updates( | 492 EXPECT_EQ(1, listener_->initial_property_updates( |
| 506 shill::kServicesProperty)[kTestServicePath2]); | |
| 507 EXPECT_EQ(1, listener_->initial_property_updates( | |
| 508 shill::kServiceCompleteListProperty)[kTestServicePath2]); | 493 shill::kServiceCompleteListProperty)[kTestServicePath2]); |
| 509 // Expect one property update for the Profile property of the Network. | |
| 510 EXPECT_EQ(1, listener_->property_updates( | 494 EXPECT_EQ(1, listener_->property_updates( |
| 511 shill::kServicesProperty)[kTestServicePath2]); | |
| 512 EXPECT_EQ(0, listener_->property_updates( | |
| 513 shill::kServiceCompleteListProperty)[kTestServicePath2]); | |
| 514 | |
| 515 // Change a property of a Network in a Profile. | |
| 516 base::FundamentalValue scan_interval(3); | |
| 517 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | |
| 518 dbus::ObjectPath(kTestServicePath2), | |
| 519 shill::kScanIntervalProperty, | |
| 520 scan_interval, | |
| 521 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | |
| 522 message_loop_.RunUntilIdle(); | |
| 523 // Property change should trigger an update for the Network only; no | |
| 524 // property updates pushed by Shill affect Favorites. | |
| 525 EXPECT_EQ(2, listener_->property_updates( | |
| 526 shill::kServicesProperty)[kTestServicePath2]); | |
| 527 EXPECT_EQ(0, listener_->property_updates( | |
| 528 shill::kServiceCompleteListProperty)[kTestServicePath2]); | 495 shill::kServiceCompleteListProperty)[kTestServicePath2]); |
| 529 } | 496 } |
| 530 | 497 |
| 531 } // namespace chromeos | 498 } // namespace chromeos |
| OLD | NEW |