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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
16 #include "chromeos/dbus/shill_device_client.h" | 16 #include "chromeos/dbus/shill_device_client.h" |
| 17 #include "chromeos/dbus/shill_ipconfig_client.h" |
17 #include "chromeos/dbus/shill_manager_client.h" | 18 #include "chromeos/dbus/shill_manager_client.h" |
18 #include "chromeos/dbus/shill_service_client.h" | 19 #include "chromeos/dbus/shill_service_client.h" |
19 #include "dbus/object_path.h" | 20 #include "dbus/object_path.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
22 | 23 |
23 namespace chromeos { | 24 namespace chromeos { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
| 28 void DoNothingWithCallStatus(DBusMethodCallStatus call_status) { |
| 29 } |
| 30 |
27 void ErrorCallbackFunction(const std::string& error_name, | 31 void ErrorCallbackFunction(const std::string& error_name, |
28 const std::string& error_message) { | 32 const std::string& error_message) { |
29 LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message; | 33 LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message; |
30 } | 34 } |
31 | 35 |
32 class TestListener : public internal::ShillPropertyHandler::Listener { | 36 class TestListener : public internal::ShillPropertyHandler::Listener { |
33 public: | 37 public: |
34 TestListener() : manager_updates_(0), errors_(0) { | 38 TestListener() : manager_updates_(0), errors_(0) { |
35 } | 39 } |
36 | 40 |
(...skipping 20 matching lines...) Expand all Loading... |
57 const std::string& device_path, | 61 const std::string& device_path, |
58 const std::string& key, | 62 const std::string& key, |
59 const base::Value& value) OVERRIDE { | 63 const base::Value& value) OVERRIDE { |
60 AddPropertyUpdate(flimflam::kDevicesProperty, device_path); | 64 AddPropertyUpdate(flimflam::kDevicesProperty, device_path); |
61 } | 65 } |
62 | 66 |
63 virtual void ManagerPropertyChanged() OVERRIDE { | 67 virtual void ManagerPropertyChanged() OVERRIDE { |
64 ++manager_updates_; | 68 ++manager_updates_; |
65 } | 69 } |
66 | 70 |
67 virtual void UpdateNetworkServiceIPAddress( | |
68 const std::string& service_path, | |
69 const std::string& ip_address) OVERRIDE { | |
70 AddPropertyUpdate(flimflam::kServicesProperty, service_path); | |
71 } | |
72 | |
73 virtual void ManagedStateListChanged( | 71 virtual void ManagedStateListChanged( |
74 ManagedState::ManagedType type) OVERRIDE { | 72 ManagedState::ManagedType type) OVERRIDE { |
75 AddStateListUpdate(GetTypeString(type)); | 73 AddStateListUpdate(GetTypeString(type)); |
76 } | 74 } |
77 | 75 |
78 std::vector<std::string>& entries(const std::string& type) { | 76 std::vector<std::string>& entries(const std::string& type) { |
79 return entries_[type]; | 77 return entries_[type]; |
80 } | 78 } |
81 std::map<std::string, int>& property_updates(const std::string& type) { | 79 std::map<std::string, int>& property_updates(const std::string& type) { |
82 return property_updates_[type]; | 80 return property_updates_[type]; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // default stub properties. | 148 // default stub properties. |
151 manager_test_ = | 149 manager_test_ = |
152 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); | 150 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); |
153 ASSERT_TRUE(manager_test_); | 151 ASSERT_TRUE(manager_test_); |
154 device_test_ = | 152 device_test_ = |
155 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); | 153 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); |
156 ASSERT_TRUE(device_test_); | 154 ASSERT_TRUE(device_test_); |
157 service_test_ = | 155 service_test_ = |
158 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 156 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
159 ASSERT_TRUE(service_test_); | 157 ASSERT_TRUE(service_test_); |
| 158 SetupShillPropertyHandler(); |
| 159 message_loop_.RunUntilIdle(); |
160 } | 160 } |
161 | 161 |
162 virtual void TearDown() OVERRIDE { | 162 virtual void TearDown() OVERRIDE { |
163 shill_property_handler_.reset(); | 163 shill_property_handler_.reset(); |
164 listener_.reset(); | 164 listener_.reset(); |
165 DBusThreadManager::Shutdown(); | 165 DBusThreadManager::Shutdown(); |
166 } | 166 } |
167 | 167 |
168 void AddDevice(const std::string& type, const std::string& id) { | 168 void AddDevice(const std::string& type, const std::string& id) { |
169 ASSERT_TRUE(IsValidType(type)); | 169 ASSERT_TRUE(IsValidType(type)); |
170 device_test_->AddDevice(id, type, std::string("/device/" + id)); | 170 device_test_->AddDevice(id, type, std::string("/device/" + id)); |
171 } | 171 } |
172 | 172 |
173 void RemoveDevice(const std::string& id) { | 173 void RemoveDevice(const std::string& id) { |
174 device_test_->RemoveDevice(id); | 174 device_test_->RemoveDevice(id); |
175 } | 175 } |
176 | 176 |
177 void AddService(const std::string& type, | 177 void AddService(const std::string& type, |
178 const std::string& id, | 178 const std::string& id, |
179 const std::string& state, | 179 const std::string& state, |
| 180 const std::string& ipconfig_path, |
180 bool add_to_watch_list) { | 181 bool add_to_watch_list) { |
181 ASSERT_TRUE(IsValidType(type)); | 182 ASSERT_TRUE(IsValidType(type)); |
182 service_test_->AddService(id, id, type, state, add_to_watch_list); | 183 service_test_->AddService(id, id, type, state, ipconfig_path, |
| 184 add_to_watch_list); |
183 } | 185 } |
184 | 186 |
185 void RemoveService(const std::string& id) { | 187 void RemoveService(const std::string& id) { |
186 service_test_->RemoveService(id); | 188 service_test_->RemoveService(id); |
187 } | 189 } |
188 | 190 |
189 // Call this after any initial Shill client setup | 191 // Call this after any initial Shill client setup |
190 void SetupShillPropertyHandler() { | 192 void SetupShillPropertyHandler() { |
191 SetupDefaultShillState(); | 193 SetupDefaultShillState(); |
192 listener_.reset(new TestListener); | 194 listener_.reset(new TestListener); |
(...skipping 13 matching lines...) Expand all Loading... |
206 | 208 |
207 protected: | 209 protected: |
208 void SetupDefaultShillState() { | 210 void SetupDefaultShillState() { |
209 message_loop_.RunUntilIdle(); // Process any pending updates | 211 message_loop_.RunUntilIdle(); // Process any pending updates |
210 device_test_->ClearDevices(); | 212 device_test_->ClearDevices(); |
211 AddDevice(flimflam::kTypeWifi, "stub_wifi_device1"); | 213 AddDevice(flimflam::kTypeWifi, "stub_wifi_device1"); |
212 AddDevice(flimflam::kTypeCellular, "stub_cellular_device1"); | 214 AddDevice(flimflam::kTypeCellular, "stub_cellular_device1"); |
213 service_test_->ClearServices(); | 215 service_test_->ClearServices(); |
214 const bool add_to_watchlist = true; | 216 const bool add_to_watchlist = true; |
215 AddService(flimflam::kTypeEthernet, "stub_ethernet", | 217 AddService(flimflam::kTypeEthernet, "stub_ethernet", |
216 flimflam::kStateOnline, add_to_watchlist); | 218 flimflam::kStateOnline, "", add_to_watchlist); |
217 AddService(flimflam::kTypeWifi, "stub_wifi1", | 219 AddService(flimflam::kTypeWifi, "stub_wifi1", |
218 flimflam::kStateOnline, add_to_watchlist); | 220 flimflam::kStateOnline, "", add_to_watchlist); |
219 AddService(flimflam::kTypeWifi, "stub_wifi2", | 221 AddService(flimflam::kTypeWifi, "stub_wifi2", |
220 flimflam::kStateIdle, add_to_watchlist); | 222 flimflam::kStateIdle, "", add_to_watchlist); |
221 AddService(flimflam::kTypeCellular, "stub_cellular1", | 223 AddService(flimflam::kTypeCellular, "stub_cellular1", |
222 flimflam::kStateIdle, add_to_watchlist); | 224 flimflam::kStateIdle, "", add_to_watchlist); |
223 } | 225 } |
224 | 226 |
225 MessageLoopForUI message_loop_; | 227 MessageLoopForUI message_loop_; |
226 scoped_ptr<TestListener> listener_; | 228 scoped_ptr<TestListener> listener_; |
227 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_; | 229 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_; |
228 ShillManagerClient::TestInterface* manager_test_; | 230 ShillManagerClient::TestInterface* manager_test_; |
229 ShillDeviceClient::TestInterface* device_test_; | 231 ShillDeviceClient::TestInterface* device_test_; |
230 ShillServiceClient::TestInterface* service_test_; | 232 ShillServiceClient::TestInterface* service_test_; |
231 | 233 |
232 private: | 234 private: |
233 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandlerTest); | 235 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandlerTest); |
234 }; | 236 }; |
235 | 237 |
236 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerStub) { | 238 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerStub) { |
237 SetupShillPropertyHandler(); | |
238 message_loop_.RunUntilIdle(); | |
239 EXPECT_EQ(1, listener_->manager_updates()); | 239 EXPECT_EQ(1, listener_->manager_updates()); |
240 EXPECT_TRUE(shill_property_handler_->TechnologyAvailable( | 240 EXPECT_TRUE(shill_property_handler_->TechnologyAvailable( |
241 flimflam::kTypeWifi)); | 241 flimflam::kTypeWifi)); |
242 EXPECT_TRUE(shill_property_handler_->TechnologyEnabled( | 242 EXPECT_TRUE(shill_property_handler_->TechnologyEnabled( |
243 flimflam::kTypeWifi)); | 243 flimflam::kTypeWifi)); |
244 const size_t kNumShillManagerClientStubImplDevices = 2; | 244 const size_t kNumShillManagerClientStubImplDevices = 2; |
245 EXPECT_EQ(kNumShillManagerClientStubImplDevices, | 245 EXPECT_EQ(kNumShillManagerClientStubImplDevices, |
246 listener_->entries(flimflam::kDevicesProperty).size()); | 246 listener_->entries(flimflam::kDevicesProperty).size()); |
247 const size_t kNumShillManagerClientStubImplServices = 4; | 247 const size_t kNumShillManagerClientStubImplServices = 4; |
248 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 248 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
249 listener_->entries(flimflam::kServicesProperty).size()); | 249 listener_->entries(flimflam::kServicesProperty).size()); |
250 | 250 |
251 EXPECT_EQ(0, listener_->errors()); | 251 EXPECT_EQ(0, listener_->errors()); |
252 } | 252 } |
253 | 253 |
254 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) { | 254 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerTechnologyChanged) { |
255 SetupShillPropertyHandler(); | |
256 message_loop_.RunUntilIdle(); | |
257 EXPECT_EQ(1, listener_->manager_updates()); | 255 EXPECT_EQ(1, listener_->manager_updates()); |
258 // Add a disabled technology. | 256 // Add a disabled technology. |
259 manager_test_->AddTechnology(flimflam::kTypeWimax, false); | 257 manager_test_->AddTechnology(flimflam::kTypeWimax, false); |
260 message_loop_.RunUntilIdle(); | 258 message_loop_.RunUntilIdle(); |
261 EXPECT_EQ(2, listener_->manager_updates()); | 259 EXPECT_EQ(2, listener_->manager_updates()); |
262 EXPECT_TRUE(shill_property_handler_->TechnologyAvailable( | 260 EXPECT_TRUE(shill_property_handler_->TechnologyAvailable( |
263 flimflam::kTypeWimax)); | 261 flimflam::kTypeWimax)); |
264 EXPECT_FALSE(shill_property_handler_->TechnologyEnabled( | 262 EXPECT_FALSE(shill_property_handler_->TechnologyEnabled( |
265 flimflam::kTypeWimax)); | 263 flimflam::kTypeWimax)); |
266 | 264 |
267 // Enable the technology. | 265 // Enable the technology. |
268 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( | 266 DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology( |
269 flimflam::kTypeWimax, | 267 flimflam::kTypeWimax, |
270 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 268 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
271 message_loop_.RunUntilIdle(); | 269 message_loop_.RunUntilIdle(); |
272 EXPECT_EQ(3, listener_->manager_updates()); | 270 EXPECT_EQ(3, listener_->manager_updates()); |
273 EXPECT_TRUE(shill_property_handler_->TechnologyEnabled( | 271 EXPECT_TRUE(shill_property_handler_->TechnologyEnabled( |
274 flimflam::kTypeWimax)); | 272 flimflam::kTypeWimax)); |
275 | 273 |
276 EXPECT_EQ(0, listener_->errors()); | 274 EXPECT_EQ(0, listener_->errors()); |
277 } | 275 } |
278 | 276 |
279 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) { | 277 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerDevicePropertyChanged) { |
280 SetupShillPropertyHandler(); | |
281 message_loop_.RunUntilIdle(); | |
282 EXPECT_EQ(1, listener_->manager_updates()); | 278 EXPECT_EQ(1, listener_->manager_updates()); |
283 EXPECT_EQ(1, listener_->list_updates(flimflam::kDevicesProperty)); | 279 EXPECT_EQ(1, listener_->list_updates(flimflam::kDevicesProperty)); |
284 const size_t kNumShillManagerClientStubImplDevices = 2; | 280 const size_t kNumShillManagerClientStubImplDevices = 2; |
285 EXPECT_EQ(kNumShillManagerClientStubImplDevices, | 281 EXPECT_EQ(kNumShillManagerClientStubImplDevices, |
286 listener_->entries(flimflam::kDevicesProperty).size()); | 282 listener_->entries(flimflam::kDevicesProperty).size()); |
287 // Add a device. | 283 // Add a device. |
288 const std::string kTestDevicePath("test_wifi_device1"); | 284 const std::string kTestDevicePath("test_wifi_device1"); |
289 AddDevice(flimflam::kTypeWifi, kTestDevicePath); | 285 AddDevice(flimflam::kTypeWifi, kTestDevicePath); |
290 message_loop_.RunUntilIdle(); | 286 message_loop_.RunUntilIdle(); |
291 EXPECT_EQ(1, listener_->manager_updates()); // No new manager updates. | 287 EXPECT_EQ(1, listener_->manager_updates()); // No new manager updates. |
292 EXPECT_EQ(2, listener_->list_updates(flimflam::kDevicesProperty)); | 288 EXPECT_EQ(2, listener_->list_updates(flimflam::kDevicesProperty)); |
293 EXPECT_EQ(kNumShillManagerClientStubImplDevices + 1, | 289 EXPECT_EQ(kNumShillManagerClientStubImplDevices + 1, |
294 listener_->entries(flimflam::kDevicesProperty).size()); | 290 listener_->entries(flimflam::kDevicesProperty).size()); |
295 // Device changes are not observed. | 291 // Device changes are not observed. |
296 // Remove a device | 292 // Remove a device |
297 RemoveDevice(kTestDevicePath); | 293 RemoveDevice(kTestDevicePath); |
298 message_loop_.RunUntilIdle(); | 294 message_loop_.RunUntilIdle(); |
299 EXPECT_EQ(3, listener_->list_updates(flimflam::kDevicesProperty)); | 295 EXPECT_EQ(3, listener_->list_updates(flimflam::kDevicesProperty)); |
300 EXPECT_EQ(kNumShillManagerClientStubImplDevices, | 296 EXPECT_EQ(kNumShillManagerClientStubImplDevices, |
301 listener_->entries(flimflam::kDevicesProperty).size()); | 297 listener_->entries(flimflam::kDevicesProperty).size()); |
302 | 298 |
303 EXPECT_EQ(0, listener_->errors()); | 299 EXPECT_EQ(0, listener_->errors()); |
304 } | 300 } |
305 | 301 |
306 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) { | 302 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) { |
307 SetupShillPropertyHandler(); | |
308 message_loop_.RunUntilIdle(); | |
309 EXPECT_EQ(1, listener_->manager_updates()); | 303 EXPECT_EQ(1, listener_->manager_updates()); |
310 EXPECT_EQ(1, listener_->list_updates(flimflam::kServicesProperty)); | 304 EXPECT_EQ(1, listener_->list_updates(flimflam::kServicesProperty)); |
311 const size_t kNumShillManagerClientStubImplServices = 4; | 305 const size_t kNumShillManagerClientStubImplServices = 4; |
312 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 306 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
313 listener_->entries(flimflam::kServicesProperty).size()); | 307 listener_->entries(flimflam::kServicesProperty).size()); |
314 | 308 |
315 // Add an unwatched service. | 309 // Add an unwatched service. |
316 const std::string kTestServicePath("test_wifi_service1"); | 310 const std::string kTestServicePath("test_wifi_service1"); |
317 AddService(flimflam::kTypeWifi, kTestServicePath, | 311 AddService(flimflam::kTypeWifi, kTestServicePath, |
318 flimflam::kStateIdle, false); | 312 flimflam::kStateIdle, "", false); |
319 message_loop_.RunUntilIdle(); | 313 message_loop_.RunUntilIdle(); |
320 EXPECT_EQ(1, listener_->manager_updates()); // No new manager updates. | 314 EXPECT_EQ(1, listener_->manager_updates()); // No new manager updates. |
321 // Only watched services trigger a service list update. | 315 // Only watched services trigger a service list update. |
322 EXPECT_EQ(1, listener_->list_updates(flimflam::kServicesProperty)); | 316 EXPECT_EQ(1, listener_->list_updates(flimflam::kServicesProperty)); |
323 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, | 317 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, |
324 listener_->entries(flimflam::kServicesProperty).size()); | 318 listener_->entries(flimflam::kServicesProperty).size()); |
325 // Change a property. | 319 // Change a property. |
326 base::FundamentalValue scan_interval(3); | 320 base::FundamentalValue scan_interval(3); |
327 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 321 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
328 dbus::ObjectPath(kTestServicePath), | 322 dbus::ObjectPath(kTestServicePath), |
329 flimflam::kScanIntervalProperty, | 323 flimflam::kScanIntervalProperty, |
330 scan_interval, | 324 scan_interval, |
331 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 325 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
332 message_loop_.RunUntilIdle(); | 326 message_loop_.RunUntilIdle(); |
333 // Property change should NOT trigger an update. | 327 // Property change should NOT trigger an update. |
334 EXPECT_EQ(0, listener_-> | 328 EXPECT_EQ(0, listener_-> |
335 property_updates(flimflam::kServicesProperty)[kTestServicePath]); | 329 property_updates(flimflam::kServicesProperty)[kTestServicePath]); |
336 | 330 |
337 // Add the existing service to the watch list. | 331 // Add the existing service to the watch list. |
338 AddService(flimflam::kTypeWifi, kTestServicePath, | 332 AddService(flimflam::kTypeWifi, kTestServicePath, |
339 flimflam::kStateIdle, true); | 333 flimflam::kStateIdle, "", true); |
340 message_loop_.RunUntilIdle(); | 334 message_loop_.RunUntilIdle(); |
341 // Service list update should be received when watch list changes. | 335 // Service list update should be received when watch list changes. |
342 EXPECT_EQ(2, listener_->list_updates(flimflam::kServicesProperty)); | 336 EXPECT_EQ(2, listener_->list_updates(flimflam::kServicesProperty)); |
343 // Number of services shouldn't change. | 337 // Number of services shouldn't change. |
344 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, | 338 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, |
345 listener_->entries(flimflam::kServicesProperty).size()); | 339 listener_->entries(flimflam::kServicesProperty).size()); |
346 // Property update should be received when watched service is added. | 340 // Property update should be received when watched service is added. |
347 EXPECT_EQ(1, listener_-> | 341 EXPECT_EQ(1, listener_-> |
348 property_updates(flimflam::kServicesProperty)[kTestServicePath]); | 342 property_updates(flimflam::kServicesProperty)[kTestServicePath]); |
349 | 343 |
(...skipping 11 matching lines...) Expand all Loading... |
361 // Remove a service | 355 // Remove a service |
362 RemoveService(kTestServicePath); | 356 RemoveService(kTestServicePath); |
363 message_loop_.RunUntilIdle(); | 357 message_loop_.RunUntilIdle(); |
364 EXPECT_EQ(3, listener_->list_updates(flimflam::kServicesProperty)); | 358 EXPECT_EQ(3, listener_->list_updates(flimflam::kServicesProperty)); |
365 EXPECT_EQ(kNumShillManagerClientStubImplServices, | 359 EXPECT_EQ(kNumShillManagerClientStubImplServices, |
366 listener_->entries(flimflam::kServicesProperty).size()); | 360 listener_->entries(flimflam::kServicesProperty).size()); |
367 | 361 |
368 EXPECT_EQ(0, listener_->errors()); | 362 EXPECT_EQ(0, listener_->errors()); |
369 } | 363 } |
370 | 364 |
371 // TODO(stevenjb): Test IP Configs. | 365 TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) { |
| 366 // Set the properties for an IP Config object. |
| 367 const std::string kTestIPConfigPath("test_ip_config_path"); |
| 368 base::StringValue ip_address("192.168.1.1"); |
| 369 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( |
| 370 dbus::ObjectPath(kTestIPConfigPath), |
| 371 flimflam::kAddressProperty, |
| 372 ip_address, |
| 373 base::Bind(&DoNothingWithCallStatus)); |
| 374 base::ListValue dns_servers; |
| 375 dns_servers.Append(base::Value::CreateStringValue("192.168.1.100")); |
| 376 dns_servers.Append(base::Value::CreateStringValue("192.168.1.101")); |
| 377 DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty( |
| 378 dbus::ObjectPath(kTestIPConfigPath), |
| 379 flimflam::kNameServersProperty, |
| 380 dns_servers, |
| 381 base::Bind(&DoNothingWithCallStatus)); |
| 382 message_loop_.RunUntilIdle(); |
| 383 |
| 384 // Add a service with an empty ipconfig and then update |
| 385 // its ipconfig property. |
| 386 const std::string kTestServicePath("test_wifi_service1"); |
| 387 AddService(flimflam::kTypeWifi, kTestServicePath, |
| 388 flimflam::kStateIdle, "", true); |
| 389 message_loop_.RunUntilIdle(); |
| 390 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
| 391 dbus::ObjectPath(kTestServicePath), |
| 392 shill::kIPConfigProperty, |
| 393 base::StringValue(kTestIPConfigPath), |
| 394 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
| 395 message_loop_.RunUntilIdle(); |
| 396 // IPConfig updates should trigger 2 property updates for IP Address |
| 397 // and DNS. |
| 398 EXPECT_EQ(3, listener_-> |
| 399 property_updates(flimflam::kServicesProperty)[kTestServicePath]); |
| 400 // Now, try adding the service with the IPConfig already set. |
| 401 RemoveService(kTestServicePath); |
| 402 AddService(flimflam::kTypeWifi, kTestServicePath, |
| 403 flimflam::kStateIdle, kTestIPConfigPath, true); |
| 404 message_loop_.RunUntilIdle(); |
| 405 // A watched service with the IPConfig property already set must |
| 406 // trigger property updates for IP Address and DNS. |
| 407 EXPECT_EQ(3, listener_-> |
| 408 property_updates(flimflam::kServicesProperty)[kTestServicePath]); |
| 409 } |
372 | 410 |
373 } // namespace chromeos | 411 } // namespace chromeos |
OLD | NEW |