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) { | |
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 */); |
224 } | 230 } |
225 | 231 |
226 void AddServiceWithIPConfig(const std::string& type, | 232 void AddServiceWithIPConfig(const std::string& type, |
227 const std::string& id, | 233 const std::string& id, |
228 const std::string& state, | 234 const std::string& state, |
229 const std::string& ipconfig_path, | 235 const std::string& ipconfig_path) { |
230 bool add_to_watch_list) { | |
231 ASSERT_TRUE(IsValidType(type)); | 236 ASSERT_TRUE(IsValidType(type)); |
232 service_test_->AddServiceWithIPConfig(id, /* service_path */ | 237 service_test_->AddServiceWithIPConfig(id, /* service_path */ |
233 "" /* guid */, | 238 "" /* guid */, |
234 id /* name */, | 239 id /* name */, |
235 type, | 240 type, |
236 state, | 241 state, |
237 ipconfig_path, | 242 ipconfig_path, |
238 true /* visible */, | 243 true /* visible */); |
239 add_to_watch_list); | |
240 } | 244 } |
241 | 245 |
242 void AddServiceToProfile(const std::string& type, | 246 void AddServiceToProfile(const std::string& type, |
243 const std::string& id, | 247 const std::string& id, |
244 bool visible) { | 248 bool visible) { |
245 service_test_->AddService(id, id, type, shill::kStateIdle, | 249 service_test_->AddService(id, id, type, shill::kStateIdle, visible); |
246 visible, false /* watch */); | |
247 std::vector<std::string> profiles; | 250 std::vector<std::string> profiles; |
248 profile_test_->GetProfilePaths(&profiles); | 251 profile_test_->GetProfilePaths(&profiles); |
249 ASSERT_TRUE(profiles.size() > 0); | 252 ASSERT_TRUE(profiles.size() > 0); |
250 base::DictionaryValue properties; // Empty entry | 253 base::DictionaryValue properties; // Empty entry |
251 profile_test_->AddService(profiles[0], id); | 254 profile_test_->AddService(profiles[0], id); |
252 } | 255 } |
253 | 256 |
254 void RemoveService(const std::string& id) { | 257 void RemoveService(const std::string& id) { |
255 service_test_->RemoveService(id); | 258 service_test_->RemoveService(id); |
256 } | 259 } |
(...skipping 17 matching lines...) Expand all Loading... |
274 type == shill::kTypeVPN); | 277 type == shill::kTypeVPN); |
275 } | 278 } |
276 | 279 |
277 protected: | 280 protected: |
278 void SetupDefaultShillState() { | 281 void SetupDefaultShillState() { |
279 message_loop_.RunUntilIdle(); // Process any pending updates | 282 message_loop_.RunUntilIdle(); // Process any pending updates |
280 device_test_->ClearDevices(); | 283 device_test_->ClearDevices(); |
281 AddDevice(shill::kTypeWifi, "stub_wifi_device1"); | 284 AddDevice(shill::kTypeWifi, "stub_wifi_device1"); |
282 AddDevice(shill::kTypeCellular, "stub_cellular_device1"); | 285 AddDevice(shill::kTypeCellular, "stub_cellular_device1"); |
283 service_test_->ClearServices(); | 286 service_test_->ClearServices(); |
284 const bool add_to_watchlist = true; | 287 AddService(shill::kTypeEthernet, "stub_ethernet", shill::kStateOnline); |
285 AddService(shill::kTypeEthernet, "stub_ethernet", | 288 AddService(shill::kTypeWifi, "stub_wifi1", shill::kStateOnline); |
286 shill::kStateOnline, add_to_watchlist); | 289 AddService(shill::kTypeWifi, "stub_wifi2", shill::kStateIdle); |
287 AddService(shill::kTypeWifi, "stub_wifi1", | 290 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 } | 291 } |
294 | 292 |
295 base::MessageLoopForUI message_loop_; | 293 base::MessageLoopForUI message_loop_; |
296 scoped_ptr<TestListener> listener_; | 294 scoped_ptr<TestListener> listener_; |
297 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_; | 295 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_; |
298 ShillManagerClient::TestInterface* manager_test_; | 296 ShillManagerClient::TestInterface* manager_test_; |
299 ShillDeviceClient::TestInterface* device_test_; | 297 ShillDeviceClient::TestInterface* device_test_; |
300 ShillServiceClient::TestInterface* service_test_; | 298 ShillServiceClient::TestInterface* service_test_; |
301 ShillProfileClient::TestInterface* profile_test_; | 299 ShillProfileClient::TestInterface* profile_test_; |
302 | 300 |
(...skipping 12 matching lines...) Expand all Loading... |
315 listener_->entries(shill::kServicesProperty).size()); | 313 listener_->entries(shill::kServicesProperty).size()); |
316 | 314 |
317 EXPECT_EQ(0, listener_->errors()); | 315 EXPECT_EQ(0, listener_->errors()); |
318 } | 316 } |
319 | 317 |
320 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) { | 318 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) { |
321 const int initial_technology_updates = 2; // Available and Enabled lists | 319 const int initial_technology_updates = 2; // Available and Enabled lists |
322 EXPECT_EQ(initial_technology_updates, listener_->technology_list_updates()); | 320 EXPECT_EQ(initial_technology_updates, listener_->technology_list_updates()); |
323 | 321 |
324 // Remove an enabled technology. Updates both the Available and Enabled lists. | 322 // Remove an enabled technology. Updates both the Available and Enabled lists. |
| 323 listener_->reset_list_updates(); |
325 manager_test_->RemoveTechnology(shill::kTypeWifi); | 324 manager_test_->RemoveTechnology(shill::kTypeWifi); |
326 message_loop_.RunUntilIdle(); | 325 message_loop_.RunUntilIdle(); |
327 EXPECT_EQ(initial_technology_updates + 2, | 326 EXPECT_EQ(2, listener_->technology_list_updates()); |
328 listener_->technology_list_updates()); | |
329 | 327 |
330 // Add a disabled technology. | 328 // Add a disabled technology. |
| 329 listener_->reset_list_updates(); |
331 manager_test_->AddTechnology(shill::kTypeWifi, false); | 330 manager_test_->AddTechnology(shill::kTypeWifi, false); |
332 message_loop_.RunUntilIdle(); | 331 message_loop_.RunUntilIdle(); |
333 EXPECT_EQ(initial_technology_updates + 3, | 332 EXPECT_EQ(1, listener_->technology_list_updates()); |
334 listener_->technology_list_updates()); | |
335 EXPECT_TRUE(shill_property_handler_->IsTechnologyAvailable( | 333 EXPECT_TRUE(shill_property_handler_->IsTechnologyAvailable( |
336 shill::kTypeWifi)); | 334 shill::kTypeWifi)); |
337 EXPECT_FALSE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); | 335 EXPECT_FALSE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); |
338 | 336 |
339 // Enable the technology. | 337 // Enable the technology. |
| 338 listener_->reset_list_updates(); |
340 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( | 339 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( |
341 shill::kTypeWifi, | 340 shill::kTypeWifi, |
342 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 341 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
343 message_loop_.RunUntilIdle(); | 342 message_loop_.RunUntilIdle(); |
344 EXPECT_EQ(initial_technology_updates + 4, | 343 EXPECT_EQ(1, listener_->technology_list_updates()); |
345 listener_->technology_list_updates()); | |
346 EXPECT_TRUE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); | 344 EXPECT_TRUE(shill_property_handler_->IsTechnologyEnabled(shill::kTypeWifi)); |
347 | 345 |
348 EXPECT_EQ(0, listener_->errors()); | 346 EXPECT_EQ(0, listener_->errors()); |
349 } | 347 } |
350 | 348 |
351 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) { | 349 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) { |
352 const size_t kNumShillManagerClientStubImplDevices = 2; | 350 const size_t kNumShillManagerClientStubImplDevices = 2; |
353 EXPECT_EQ(kNumShillManagerClientStubImplDevices, | 351 EXPECT_EQ(kNumShillManagerClientStubImplDevices, |
354 listener_->entries(shill::kDevicesProperty).size()); | 352 listener_->entries(shill::kDevicesProperty).size()); |
355 // Add a device. | 353 // Add a device. |
356 listener_->reset_list_updates(); | 354 listener_->reset_list_updates(); |
357 const std::string kTestDevicePath("test_wifi_device1"); | 355 const std::string kTestDevicePath("test_wifi_device1"); |
358 AddDevice(shill::kTypeWifi, kTestDevicePath); | 356 AddDevice(shill::kTypeWifi, kTestDevicePath); |
359 message_loop_.RunUntilIdle(); | 357 message_loop_.RunUntilIdle(); |
360 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); | 358 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); |
361 EXPECT_EQ(kNumShillManagerClientStubImplDevices + 1, | 359 EXPECT_EQ(kNumShillManagerClientStubImplDevices + 1, |
362 listener_->entries(shill::kDevicesProperty).size()); | 360 listener_->entries(shill::kDevicesProperty).size()); |
363 // Device changes are not observed. | 361 |
364 // Remove a device | 362 // Remove a device |
365 listener_->reset_list_updates(); | 363 listener_->reset_list_updates(); |
366 RemoveDevice(kTestDevicePath); | 364 RemoveDevice(kTestDevicePath); |
367 message_loop_.RunUntilIdle(); | 365 message_loop_.RunUntilIdle(); |
368 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); | 366 EXPECT_EQ(1, listener_->list_updates(shill::kDevicesProperty)); |
369 EXPECT_EQ(kNumShillManagerClientStubImplDevices, | 367 EXPECT_EQ(kNumShillManagerClientStubImplDevices, |
370 listener_->entries(shill::kDevicesProperty).size()); | 368 listener_->entries(shill::kDevicesProperty).size()); |
371 | 369 |
372 EXPECT_EQ(0, listener_->errors()); | 370 EXPECT_EQ(0, listener_->errors()); |
373 } | 371 } |
374 | 372 |
375 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) { | 373 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) { |
376 const size_t kNumShillManagerClientStubImplServices = 4; | 374 const size_t kNumShillManagerClientStubImplServices = 4; |
377 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 375 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
378 listener_->entries(shill::kServicesProperty).size()); | 376 listener_->entries(shill::kServicesProperty).size()); |
379 | 377 |
380 // Add an unwatched service. | 378 // Add a service. |
381 listener_->reset_list_updates(); | 379 listener_->reset_list_updates(); |
382 const std::string kTestServicePath("test_wifi_service1"); | 380 const std::string kTestServicePath("test_wifi_service1"); |
383 AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle, false); | 381 AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle); |
384 message_loop_.RunUntilIdle(); | 382 message_loop_.RunUntilIdle(); |
385 // Watched and unwatched services trigger a service list update. | 383 // Add should trigger a service list update and should update entries. |
386 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | 384 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); |
387 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, | 385 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, |
388 listener_->entries(shill::kServicesProperty).size()); | 386 listener_->entries(shill::kServicesProperty).size()); |
389 // Service receives an initial property update. | 387 // Service receives an initial property update. |
390 EXPECT_EQ(1, listener_->initial_property_updates( | 388 EXPECT_EQ(1, listener_->initial_property_updates( |
391 shill::kServicesProperty)[kTestServicePath]); | 389 shill::kServicesProperty)[kTestServicePath]); |
392 // Change a property. | 390 // Change a property. |
393 base::FundamentalValue scan_interval(3); | 391 base::FundamentalValue scan_interval(3); |
394 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 392 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
395 dbus::ObjectPath(kTestServicePath), | 393 dbus::ObjectPath(kTestServicePath), |
396 shill::kScanIntervalProperty, | 394 shill::kScanIntervalProperty, |
397 scan_interval, | 395 scan_interval, |
398 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 396 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
399 message_loop_.RunUntilIdle(); | 397 message_loop_.RunUntilIdle(); |
400 // Property change triggers an update. | 398 // Property change triggers an update (but not a service list update). |
401 EXPECT_EQ(1, listener_->property_updates( | 399 EXPECT_EQ(1, listener_->property_updates( |
402 shill::kServicesProperty)[kTestServicePath]); | 400 shill::kServicesProperty)[kTestServicePath]); |
403 | 401 |
404 // Add the existing service to the watch list. | 402 // 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(); | 403 listener_->reset_list_updates(); |
427 RemoveService(kTestServicePath); | 404 RemoveService(kTestServicePath); |
428 message_loop_.RunUntilIdle(); | 405 message_loop_.RunUntilIdle(); |
429 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | 406 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); |
430 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 407 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
431 listener_->entries(shill::kServicesProperty).size()); | 408 listener_->entries(shill::kServicesProperty).size()); |
432 | 409 |
433 EXPECT_EQ(0, listener_->errors()); | 410 EXPECT_EQ(0, listener_->errors()); |
434 } | 411 } |
435 | 412 |
(...skipping 21 matching lines...) Expand all Loading... |
457 base::StringValue gateway("192.0.0.1"); | 434 base::StringValue gateway("192.0.0.1"); |
458 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( | 435 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( |
459 dbus::ObjectPath(kTestIPConfigPath), | 436 dbus::ObjectPath(kTestIPConfigPath), |
460 shill::kGatewayProperty, gateway, | 437 shill::kGatewayProperty, gateway, |
461 base::Bind(&DoNothingWithCallStatus)); | 438 base::Bind(&DoNothingWithCallStatus)); |
462 message_loop_.RunUntilIdle(); | 439 message_loop_.RunUntilIdle(); |
463 | 440 |
464 // Add a service with an empty ipconfig and then update | 441 // Add a service with an empty ipconfig and then update |
465 // its ipconfig property. | 442 // its ipconfig property. |
466 const std::string kTestServicePath1("test_wifi_service1"); | 443 const std::string kTestServicePath1("test_wifi_service1"); |
467 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle, true); | 444 AddService(shill::kTypeWifi, kTestServicePath1, shill::kStateIdle); |
468 message_loop_.RunUntilIdle(); | 445 message_loop_.RunUntilIdle(); |
469 // This is the initial property update. | 446 // This is the initial property update. |
470 EXPECT_EQ(1, listener_->initial_property_updates( | 447 EXPECT_EQ(1, listener_->initial_property_updates( |
471 shill::kServicesProperty)[kTestServicePath1]); | 448 shill::kServicesProperty)[kTestServicePath1]); |
472 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 449 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
473 dbus::ObjectPath(kTestServicePath1), | 450 dbus::ObjectPath(kTestServicePath1), |
474 shill::kIPConfigProperty, | 451 shill::kIPConfigProperty, |
475 base::StringValue(kTestIPConfigPath), | 452 base::StringValue(kTestIPConfigPath), |
476 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 453 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
477 message_loop_.RunUntilIdle(); | 454 message_loop_.RunUntilIdle(); |
478 // IPConfig property change on the service should trigger an IPConfigs update. | 455 // IPConfig property change on the service should trigger an IPConfigs update. |
479 EXPECT_EQ(1, listener_->property_updates( | 456 EXPECT_EQ(1, listener_->property_updates( |
480 shill::kIPConfigsProperty)[kTestIPConfigPath]); | 457 shill::kIPConfigsProperty)[kTestIPConfigPath]); |
481 | 458 |
482 // Now, Add a new watched service with the IPConfig already set. | 459 // Now, Add a new service with the IPConfig already set. |
483 const std::string kTestServicePath2("test_wifi_service2"); | 460 const std::string kTestServicePath2("test_wifi_service2"); |
484 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2, | 461 AddServiceWithIPConfig(shill::kTypeWifi, kTestServicePath2, |
485 shill::kStateIdle, kTestIPConfigPath, true); | 462 shill::kStateIdle, kTestIPConfigPath); |
486 message_loop_.RunUntilIdle(); | 463 message_loop_.RunUntilIdle(); |
487 // A watched service with the IPConfig property already set should trigger an | 464 // A service with the IPConfig property already set should trigger an |
488 // additional IPConfigs update. | 465 // additional IPConfigs update. |
489 EXPECT_EQ(2, listener_->property_updates( | 466 EXPECT_EQ(2, listener_->property_updates( |
490 shill::kIPConfigsProperty)[kTestIPConfigPath]); | 467 shill::kIPConfigsProperty)[kTestIPConfigPath]); |
491 } | 468 } |
492 | 469 |
493 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceCompleteList) { | 470 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceCompleteList) { |
494 // Add a new entry to the profile only (triggers a Services update). | 471 // Add a new entry to the profile only (triggers a Services update). |
495 const std::string kTestServicePath1("stub_wifi_profile_only1"); | 472 const std::string kTestServicePath1("stub_wifi_profile_only1"); |
496 AddServiceToProfile(shill::kTypeWifi, kTestServicePath1, false); | 473 AddServiceToProfile(shill::kTypeWifi, kTestServicePath1, false /* visible */); |
497 message_loop_.RunUntilIdle(); | 474 message_loop_.RunUntilIdle(); |
498 | 475 |
499 // Update the Manager properties. This should trigger a single list update | 476 // Update the Manager properties. This should trigger a single list update |
500 // for both Services and ServiceCompleteList, and a single property update | 477 // for both Services and ServiceCompleteList, and a single property update |
501 // for ServiceCompleteList. | 478 // for ServiceCompleteList. |
502 listener_->reset_list_updates(); | 479 listener_->reset_list_updates(); |
503 shill_property_handler_->UpdateManagerProperties(); | 480 shill_property_handler_->UpdateManagerProperties(); |
504 message_loop_.RunUntilIdle(); | 481 message_loop_.RunUntilIdle(); |
505 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); | 482 EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty)); |
506 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); | 483 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(); | 522 message_loop_.RunUntilIdle(); |
546 // Property change should trigger an update for the Network only; no | 523 // Property change should trigger an update for the Network only; no |
547 // property updates pushed by Shill affect Favorites. | 524 // property updates pushed by Shill affect Favorites. |
548 EXPECT_EQ(2, listener_->property_updates( | 525 EXPECT_EQ(2, listener_->property_updates( |
549 shill::kServicesProperty)[kTestServicePath2]); | 526 shill::kServicesProperty)[kTestServicePath2]); |
550 EXPECT_EQ(0, listener_->property_updates( | 527 EXPECT_EQ(0, listener_->property_updates( |
551 shill::kServiceCompleteListProperty)[kTestServicePath2]); | 528 shill::kServiceCompleteListProperty)[kTestServicePath2]); |
552 } | 529 } |
553 | 530 |
554 } // namespace chromeos | 531 } // namespace chromeos |
OLD | NEW |