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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/chromeos/cros/cros_network_functions.h" | 8 #include "chrome/browser/chromeos/cros/cros_network_functions.h" |
9 #include "chrome/browser/chromeos/cros/sms_watcher.h" | 9 #include "chrome/browser/chromeos/cros/sms_watcher.h" |
10 #include "chromeos/dbus/mock_cashew_client.h" | 10 #include "chromeos/dbus/mock_cashew_client.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); | 185 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); |
186 } | 186 } |
187 | 187 |
188 // Handles responses for GetProperties method calls. | 188 // Handles responses for GetProperties method calls. |
189 void OnGetProperties( | 189 void OnGetProperties( |
190 const dbus::ObjectPath& path, | 190 const dbus::ObjectPath& path, |
191 const ShillClientHelper::DictionaryValueCallback& callback) { | 191 const ShillClientHelper::DictionaryValueCallback& callback) { |
192 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); | 192 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); |
193 } | 193 } |
194 | 194 |
195 // Handles responses for GetProperties method calls that return | |
196 // errors in an error callback. | |
197 void OnGetPropertiesWithoutStatus( | |
198 const dbus::ObjectPath& path, | |
199 const ShillClientHelper::DictionaryValueCallbackWithoutStatus& callback, | |
200 const ShillClientHelper::ErrorCallback& error_callback) { | |
201 callback.Run(*dictionary_value_result_); | |
202 } | |
203 | |
195 // Handles responses for GetEntry method calls. | 204 // Handles responses for GetEntry method calls. |
196 void OnGetEntry( | 205 void OnGetEntry( |
197 const dbus::ObjectPath& profile_path, | 206 const dbus::ObjectPath& profile_path, |
198 const std::string& entry_path, | 207 const std::string& entry_path, |
199 const ShillClientHelper::DictionaryValueCallback& callback) { | 208 const ShillClientHelper::DictionaryValueCallbackWithoutStatus& callback, |
200 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); | 209 const ShillClientHelper::ErrorCallback& error_callback) { |
210 callback.Run(*dictionary_value_result_); | |
201 } | 211 } |
202 | 212 |
203 // Mock NetworkOperationCallback. | 213 // Mock NetworkOperationCallback. |
204 MOCK_METHOD3(MockNetworkOperationCallback, | 214 MOCK_METHOD3(MockNetworkOperationCallback, |
205 void(const std::string& path, | 215 void(const std::string& path, |
206 NetworkMethodErrorType error, | 216 NetworkMethodErrorType error, |
207 const std::string& error_message)); | 217 const std::string& error_message)); |
208 | 218 |
209 // Mock MonitorSMSCallback. | 219 // Mock MonitorSMSCallback. |
210 MOCK_METHOD2(MockMonitorSMSCallback, | 220 MOCK_METHOD2(MockMonitorSMSCallback, |
(...skipping 26 matching lines...) Expand all Loading... | |
237 const std::string property = "property"; | 247 const std::string property = "property"; |
238 const std::string key1 = "key1"; | 248 const std::string key1 = "key1"; |
239 const std::string string1 = "string1"; | 249 const std::string string1 = "string1"; |
240 const std::string key2 = "key2"; | 250 const std::string key2 = "key2"; |
241 const std::string string2 = "string2"; | 251 const std::string string2 = "string2"; |
242 base::DictionaryValue value; | 252 base::DictionaryValue value; |
243 value.SetString(key1, string1); | 253 value.SetString(key1, string1); |
244 value.SetString(key2, string2); | 254 value.SetString(key2, string2); |
245 EXPECT_CALL(*mock_service_client_, | 255 EXPECT_CALL(*mock_service_client_, |
246 SetProperty(dbus::ObjectPath(service_path), property, | 256 SetProperty(dbus::ObjectPath(service_path), property, |
247 IsEqualTo(&value), _)).Times(1); | 257 IsEqualTo(&value), _, _)).Times(1); |
248 | 258 |
249 CrosSetNetworkServiceProperty(service_path, property, value); | 259 CrosSetNetworkServiceProperty(service_path, property, value); |
250 } | 260 } |
251 | 261 |
252 TEST_F(CrosNetworkFunctionsTest, CrosClearNetworkServiceProperty) { | 262 TEST_F(CrosNetworkFunctionsTest, CrosClearNetworkServiceProperty) { |
253 const std::string service_path = "/"; | 263 const std::string service_path = "/"; |
254 const std::string property = "property"; | 264 const std::string property = "property"; |
255 EXPECT_CALL(*mock_service_client_, | 265 EXPECT_CALL(*mock_service_client_, |
256 ClearProperty(dbus::ObjectPath(service_path), property, _)) | 266 ClearProperty(dbus::ObjectPath(service_path), property, _, _)) |
257 .Times(1); | 267 .Times(1); |
258 | 268 |
259 CrosClearNetworkServiceProperty(service_path, property); | 269 CrosClearNetworkServiceProperty(service_path, property); |
260 } | 270 } |
261 | 271 |
262 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkDeviceProperty) { | 272 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkDeviceProperty) { |
263 const std::string device_path = "/"; | 273 const std::string device_path = "/"; |
264 const std::string property = "property"; | 274 const std::string property = "property"; |
265 const bool kBool = true; | 275 const bool kBool = true; |
266 const base::FundamentalValue value(kBool); | 276 const base::FundamentalValue value(kBool); |
267 EXPECT_CALL(*mock_device_client_, | 277 EXPECT_CALL(*mock_device_client_, |
268 SetProperty(dbus::ObjectPath(device_path), StrEq(property), | 278 SetProperty(dbus::ObjectPath(device_path), StrEq(property), |
269 IsEqualTo(&value), _)).Times(1); | 279 IsEqualTo(&value), _, _)).Times(1); |
270 | 280 |
271 CrosSetNetworkDeviceProperty(device_path, property, value); | 281 CrosSetNetworkDeviceProperty(device_path, property, value); |
272 } | 282 } |
273 | 283 |
274 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkIPConfigProperty) { | 284 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkIPConfigProperty) { |
275 const std::string ipconfig_path = "/"; | 285 const std::string ipconfig_path = "/"; |
276 const std::string property = "property"; | 286 const std::string property = "property"; |
277 const int kInt = 1234; | 287 const int kInt = 1234; |
278 const base::FundamentalValue value(kInt); | 288 const base::FundamentalValue value(kInt); |
279 EXPECT_CALL(*mock_ipconfig_client_, | 289 EXPECT_CALL(*mock_ipconfig_client_, |
280 SetProperty(dbus::ObjectPath(ipconfig_path), property, | 290 SetProperty(dbus::ObjectPath(ipconfig_path), property, |
281 IsEqualTo(&value), _)).Times(1); | 291 IsEqualTo(&value), _)).Times(1); |
282 CrosSetNetworkIPConfigProperty(ipconfig_path, property, value); | 292 CrosSetNetworkIPConfigProperty(ipconfig_path, property, value); |
283 } | 293 } |
284 | 294 |
285 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkManagerProperty) { | 295 TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkManagerProperty) { |
286 const std::string property = "property"; | 296 const std::string property = "property"; |
287 const base::StringValue value("string"); | 297 const base::StringValue value("string"); |
288 EXPECT_CALL(*mock_manager_client_, | 298 EXPECT_CALL(*mock_manager_client_, |
289 SetProperty(property, IsEqualTo(&value), _)).Times(1); | 299 SetProperty(property, IsEqualTo(&value), _, _)).Times(1); |
290 | 300 |
291 CrosSetNetworkManagerProperty(property, value); | 301 CrosSetNetworkManagerProperty(property, value); |
292 } | 302 } |
293 | 303 |
294 TEST_F(CrosNetworkFunctionsTest, CrosDeleteServiceFromProfile) { | 304 TEST_F(CrosNetworkFunctionsTest, CrosDeleteServiceFromProfile) { |
295 const std::string profile_path("/profile/path"); | 305 const std::string profile_path("/profile/path"); |
296 const std::string service_path("/service/path"); | 306 const std::string service_path("/service/path"); |
297 EXPECT_CALL(*mock_profile_client_, | 307 EXPECT_CALL(*mock_profile_client_, |
298 DeleteEntry(dbus::ObjectPath(profile_path), service_path, _)) | 308 DeleteEntry(dbus::ObjectPath(profile_path), service_path, _, _)) |
299 .Times(1); | 309 .Times(1); |
300 CrosDeleteServiceFromProfile(profile_path, service_path); | 310 CrosDeleteServiceFromProfile(profile_path, service_path); |
301 } | 311 } |
302 | 312 |
303 TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularDataPlanUpdate) { | 313 TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularDataPlanUpdate) { |
304 const std::string modem_service_path = "/modem/service/path"; | 314 const std::string modem_service_path = "/modem/service/path"; |
305 EXPECT_CALL(*mock_cashew_client_, | 315 EXPECT_CALL(*mock_cashew_client_, |
306 RequestDataPlansUpdate(modem_service_path)).Times(1); | 316 RequestDataPlansUpdate(modem_service_path)).Times(1); |
307 CrosRequestCellularDataPlanUpdate(modem_service_path); | 317 CrosRequestCellularDataPlanUpdate(modem_service_path); |
308 } | 318 } |
309 | 319 |
310 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) { | 320 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) { |
311 const std::string key = "key"; | 321 const std::string key = "key"; |
312 const int kValue = 42; | 322 const int kValue = 42; |
313 const base::FundamentalValue value(kValue); | 323 const base::FundamentalValue value(kValue); |
324 | |
314 // Start monitoring. | 325 // Start monitoring. |
315 ShillClientHelper::PropertyChangedHandler handler; | 326 ShillClientHelper::PropertyChangedObserver* observer; |
hashimoto
2012/09/21 11:52:01
Please initialize with NULL.
Greg Spencer (Chromium)
2012/09/21 22:03:47
Done, and the ones below.
| |
316 EXPECT_CALL(*mock_manager_client_, SetPropertyChangedHandler(_)) | 327 EXPECT_CALL(*mock_manager_client_, AddPropertyChangedObserver(_)) |
317 .WillOnce(SaveArg<0>(&handler)); | 328 .WillOnce(SaveArg<0>(&observer)); |
318 CrosNetworkWatcher* watcher = CrosMonitorNetworkManagerProperties( | 329 CrosNetworkWatcher* watcher = CrosMonitorNetworkManagerProperties( |
319 MockNetworkPropertiesWatcherCallback::CreateCallback( | 330 MockNetworkPropertiesWatcherCallback::CreateCallback( |
320 flimflam::kFlimflamServicePath, key, value)); | 331 flimflam::kFlimflamServicePath, key, value)); |
321 // Call callback. | 332 // Call callback. |
322 handler.Run(key, value); | 333 observer->OnPropertyChanged(key, value); |
323 // Stop monitoring. | 334 // Stop monitoring. |
324 EXPECT_CALL(*mock_manager_client_, ResetPropertyChangedHandler()).Times(1); | 335 EXPECT_CALL(*mock_manager_client_, |
336 RemovePropertyChangedObserver(_)).Times(1); | |
325 delete watcher; | 337 delete watcher; |
326 } | 338 } |
327 | 339 |
328 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) { | 340 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) { |
329 const dbus::ObjectPath path("/path"); | 341 const dbus::ObjectPath path("/path"); |
330 const std::string key = "key"; | 342 const std::string key = "key"; |
331 const int kValue = 42; | 343 const int kValue = 42; |
332 const base::FundamentalValue value(kValue); | 344 const base::FundamentalValue value(kValue); |
333 // Start monitoring. | 345 // Start monitoring. |
334 ShillClientHelper::PropertyChangedHandler handler; | 346 ShillClientHelper::PropertyChangedObserver* observer; |
hashimoto
2012/09/21 11:52:01
ditto.
| |
335 EXPECT_CALL(*mock_service_client_, SetPropertyChangedHandler(path, _)) | 347 EXPECT_CALL(*mock_service_client_, AddPropertyChangedObserver(path, _)) |
336 .WillOnce(SaveArg<1>(&handler)); | 348 .WillOnce(SaveArg<1>(&observer)); |
337 NetworkPropertiesWatcherCallback callback = | 349 NetworkPropertiesWatcherCallback callback = |
338 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(), | 350 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(), |
339 key, value); | 351 key, value); |
340 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( | 352 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( |
341 callback, path.value()); | 353 callback, path.value()); |
342 // Call callback. | 354 // Call callback. |
343 handler.Run(key, value); | 355 observer->OnPropertyChanged(key, value); |
344 // Stop monitoring. | 356 // Stop monitoring. |
345 EXPECT_CALL(*mock_service_client_, | 357 EXPECT_CALL(*mock_service_client_, |
346 ResetPropertyChangedHandler(path)).Times(1); | 358 RemovePropertyChangedObserver(path, _)).Times(1); |
347 delete watcher; | 359 delete watcher; |
348 } | 360 } |
349 | 361 |
350 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) { | 362 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) { |
351 const dbus::ObjectPath path("/path"); | 363 const dbus::ObjectPath path("/path"); |
352 const std::string key = "key"; | 364 const std::string key = "key"; |
353 const int kValue = 42; | 365 const int kValue = 42; |
354 const base::FundamentalValue value(kValue); | 366 const base::FundamentalValue value(kValue); |
355 // Start monitoring. | 367 // Start monitoring. |
356 ShillClientHelper::PropertyChangedHandler handler; | 368 ShillClientHelper::PropertyChangedObserver* observer; |
hashimoto
2012/09/21 11:52:01
ditto.
| |
357 EXPECT_CALL(*mock_device_client_, SetPropertyChangedHandler(path, _)) | 369 EXPECT_CALL(*mock_device_client_, AddPropertyChangedObserver(path, _)) |
358 .WillOnce(SaveArg<1>(&handler)); | 370 .WillOnce(SaveArg<1>(&observer)); |
359 NetworkPropertiesWatcherCallback callback = | 371 NetworkPropertiesWatcherCallback callback = |
360 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(), | 372 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(), |
361 key, value); | 373 key, value); |
362 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( | 374 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( |
363 callback, path.value()); | 375 callback, path.value()); |
364 // Call callback. | 376 // Call callback. |
365 handler.Run(key, value); | 377 observer->OnPropertyChanged(key, value); |
366 // Stop monitoring. | 378 // Stop monitoring. |
367 EXPECT_CALL(*mock_device_client_, | 379 EXPECT_CALL(*mock_device_client_, |
368 ResetPropertyChangedHandler(path)).Times(1); | 380 RemovePropertyChangedObserver(path, _)).Times(1); |
369 delete watcher; | 381 delete watcher; |
370 } | 382 } |
371 | 383 |
372 TEST_F(CrosNetworkFunctionsTest, CrosMonitorCellularDataPlan) { | 384 TEST_F(CrosNetworkFunctionsTest, CrosMonitorCellularDataPlan) { |
373 const std::string modem_service_path = "/modem/path"; | 385 const std::string modem_service_path = "/modem/path"; |
374 const int64 kUpdateTime = 123456; | 386 const int64 kUpdateTime = 123456; |
375 const int64 kPlanStartTime = 234567; | 387 const int64 kPlanStartTime = 234567; |
376 const int64 kPlanEndTime = 345678; | 388 const int64 kPlanEndTime = 345678; |
377 | 389 |
378 CellularDataPlan* data_plan = new CellularDataPlan; | 390 CellularDataPlan* data_plan = new CellularDataPlan; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 const std::string key1 = "key1"; | 624 const std::string key1 = "key1"; |
613 const std::string value1 = "value1"; | 625 const std::string value1 = "value1"; |
614 const std::string key2 = "key.2."; | 626 const std::string key2 = "key.2."; |
615 const std::string value2 = "value2"; | 627 const std::string value2 = "value2"; |
616 // Create result value. | 628 // Create result value. |
617 base::DictionaryValue result; | 629 base::DictionaryValue result; |
618 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 630 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
619 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 631 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
620 // Set expectations. | 632 // Set expectations. |
621 dictionary_value_result_ = &result; | 633 dictionary_value_result_ = &result; |
622 EXPECT_CALL(*mock_profile_client_, | 634 EXPECT_CALL( |
623 GetProperties(dbus::ObjectPath(profile_path), _)).WillOnce( | 635 *mock_profile_client_, |
624 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); | 636 GetProperties(dbus::ObjectPath(profile_path), _, _)).WillOnce( |
637 Invoke(this, | |
638 &CrosNetworkFunctionsTest::OnGetPropertiesWithoutStatus)); | |
625 | 639 |
626 CrosRequestNetworkProfileProperties( | 640 CrosRequestNetworkProfileProperties( |
627 profile_path, | 641 profile_path, |
628 MockNetworkPropertiesCallback::CreateCallback(profile_path, result)); | 642 MockNetworkPropertiesCallback::CreateCallback(profile_path, result)); |
629 } | 643 } |
630 | 644 |
631 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { | 645 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { |
632 const std::string profile_path = "profile path"; | 646 const std::string profile_path = "profile path"; |
633 const std::string profile_entry_path = "profile entry path"; | 647 const std::string profile_entry_path = "profile entry path"; |
634 const std::string key1 = "key1"; | 648 const std::string key1 = "key1"; |
635 const std::string value1 = "value1"; | 649 const std::string value1 = "value1"; |
636 const std::string key2 = "key.2."; | 650 const std::string key2 = "key.2."; |
637 const std::string value2 = "value2"; | 651 const std::string value2 = "value2"; |
638 // Create result value. | 652 // Create result value. |
639 base::DictionaryValue result; | 653 base::DictionaryValue result; |
640 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 654 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
641 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 655 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
642 // Set expectations. | 656 // Set expectations. |
643 dictionary_value_result_ = &result; | 657 dictionary_value_result_ = &result; |
644 EXPECT_CALL(*mock_profile_client_, | 658 EXPECT_CALL(*mock_profile_client_, |
645 GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _)) | 659 GetEntry(dbus::ObjectPath(profile_path), |
660 profile_entry_path, _, _)) | |
646 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); | 661 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); |
647 | 662 |
648 CrosRequestNetworkProfileEntryProperties( | 663 CrosRequestNetworkProfileEntryProperties( |
649 profile_path, profile_entry_path, | 664 profile_path, profile_entry_path, |
650 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path, | 665 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path, |
651 result)); | 666 result)); |
652 } | 667 } |
653 | 668 |
654 TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) { | 669 TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) { |
655 const std::string ssid = "ssid"; | 670 const std::string ssid = "ssid"; |
(...skipping 17 matching lines...) Expand all Loading... | |
673 base::Value::CreateStringValue(flimflam::kTypeWifi)); | 688 base::Value::CreateStringValue(flimflam::kTypeWifi)); |
674 properties.SetWithoutPathExpansion( | 689 properties.SetWithoutPathExpansion( |
675 flimflam::kSSIDProperty, | 690 flimflam::kSSIDProperty, |
676 base::Value::CreateStringValue(ssid)); | 691 base::Value::CreateStringValue(ssid)); |
677 properties.SetWithoutPathExpansion( | 692 properties.SetWithoutPathExpansion( |
678 flimflam::kSecurityProperty, | 693 flimflam::kSecurityProperty, |
679 base::Value::CreateStringValue(security)); | 694 base::Value::CreateStringValue(security)); |
680 // Set expectations. | 695 // Set expectations. |
681 const dbus::ObjectPath service_path("/service/path"); | 696 const dbus::ObjectPath service_path("/service/path"); |
682 ObjectPathDBusMethodCallback callback; | 697 ObjectPathDBusMethodCallback callback; |
683 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _)) | 698 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _)) |
684 .WillOnce(SaveArg<1>(&callback)); | 699 .WillOnce(SaveArg<1>(&callback)); |
685 EXPECT_CALL(*mock_service_client_, | 700 EXPECT_CALL(*mock_service_client_, |
686 GetProperties(service_path, _)).WillOnce( | 701 GetProperties(service_path, _)).WillOnce( |
687 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); | 702 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
688 | 703 |
689 // Call function. | 704 // Call function. |
690 CrosRequestHiddenWifiNetworkProperties( | 705 CrosRequestHiddenWifiNetworkProperties( |
691 ssid, security, | 706 ssid, security, |
692 MockNetworkPropertiesCallback::CreateCallback(service_path.value(), | 707 MockNetworkPropertiesCallback::CreateCallback(service_path.value(), |
693 result)); | 708 result)); |
(...skipping 27 matching lines...) Expand all Loading... | |
721 properties.SetWithoutPathExpansion( | 736 properties.SetWithoutPathExpansion( |
722 flimflam::kProviderTypeProperty, | 737 flimflam::kProviderTypeProperty, |
723 base::Value::CreateStringValue(provider_type)); | 738 base::Value::CreateStringValue(provider_type)); |
724 properties.SetWithoutPathExpansion( | 739 properties.SetWithoutPathExpansion( |
725 flimflam::kVPNDomainProperty, | 740 flimflam::kVPNDomainProperty, |
726 base::Value::CreateStringValue(service_name)); | 741 base::Value::CreateStringValue(service_name)); |
727 | 742 |
728 // Set expectations. | 743 // Set expectations. |
729 const dbus::ObjectPath service_path("/service/path"); | 744 const dbus::ObjectPath service_path("/service/path"); |
730 ObjectPathDBusMethodCallback callback; | 745 ObjectPathDBusMethodCallback callback; |
731 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _)) | 746 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _)) |
732 .WillOnce(SaveArg<1>(&callback)); | 747 .WillOnce(SaveArg<1>(&callback)); |
733 EXPECT_CALL(*mock_service_client_, | 748 EXPECT_CALL(*mock_service_client_, |
734 GetProperties(service_path, _)).WillOnce( | 749 GetProperties(service_path, _)).WillOnce( |
735 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); | 750 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
736 | 751 |
737 // Call function. | 752 // Call function. |
738 CrosRequestVirtualNetworkProperties( | 753 CrosRequestVirtualNetworkProperties( |
739 service_name, server_hostname, provider_type, | 754 service_name, server_hostname, provider_type, |
740 MockNetworkPropertiesCallback::CreateCallback(service_path.value(), | 755 MockNetworkPropertiesCallback::CreateCallback(service_path.value(), |
741 result)); | 756 result)); |
742 // Run callback to invoke GetProperties. | 757 // Run callback to invoke GetProperties. |
743 callback.Run(DBUS_METHOD_CALL_SUCCESS, service_path); | 758 callback.Run(DBUS_METHOD_CALL_SUCCESS, service_path); |
744 } | 759 } |
745 | 760 |
746 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) { | 761 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) { |
747 const std::string service_path = "/service/path"; | 762 const std::string service_path = "/service/path"; |
748 EXPECT_CALL(*mock_service_client_, | 763 EXPECT_CALL(*mock_service_client_, |
749 Disconnect(dbus::ObjectPath(service_path), _)).Times(1); | 764 Disconnect(dbus::ObjectPath(service_path), _, _)).Times(1); |
750 CrosRequestNetworkServiceDisconnect(service_path); | 765 CrosRequestNetworkServiceDisconnect(service_path); |
751 } | 766 } |
752 | 767 |
753 TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) { | 768 TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) { |
754 const std::string service_path = "/service/path"; | 769 const std::string service_path = "/service/path"; |
755 EXPECT_CALL(*mock_service_client_, | 770 EXPECT_CALL(*mock_service_client_, |
756 Remove(dbus::ObjectPath(service_path), _)).Times(1); | 771 Remove(dbus::ObjectPath(service_path), _, _)).Times(1); |
757 CrosRequestRemoveNetworkService(service_path); | 772 CrosRequestRemoveNetworkService(service_path); |
758 } | 773 } |
759 | 774 |
760 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkScan) { | 775 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkScan) { |
761 EXPECT_CALL(*mock_manager_client_, | 776 EXPECT_CALL(*mock_manager_client_, |
762 RequestScan(flimflam::kTypeWifi, _)).Times(1); | 777 RequestScan(flimflam::kTypeWifi, _, _)).Times(1); |
763 CrosRequestNetworkScan(flimflam::kTypeWifi); | 778 CrosRequestNetworkScan(flimflam::kTypeWifi); |
764 } | 779 } |
765 | 780 |
766 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceEnable) { | 781 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceEnable) { |
767 const bool kEnable = true; | 782 const bool kEnable = true; |
768 EXPECT_CALL(*mock_manager_client_, | 783 EXPECT_CALL(*mock_manager_client_, |
769 EnableTechnology(flimflam::kTypeWifi, _)).Times(1); | 784 EnableTechnology(flimflam::kTypeWifi, _, _)).Times(1); |
770 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); | 785 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); |
771 | 786 |
772 const bool kDisable = false; | 787 const bool kDisable = false; |
773 EXPECT_CALL(*mock_manager_client_, | 788 EXPECT_CALL(*mock_manager_client_, |
774 DisableTechnology(flimflam::kTypeWifi, _)).Times(1); | 789 DisableTechnology(flimflam::kTypeWifi, _, _)).Times(1); |
775 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable); | 790 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable); |
776 } | 791 } |
777 | 792 |
778 TEST_F(CrosNetworkFunctionsTest, CrosRequestRequirePin) { | 793 TEST_F(CrosNetworkFunctionsTest, CrosRequestRequirePin) { |
779 const std::string device_path = "/device/path"; | 794 const std::string device_path = "/device/path"; |
780 const std::string pin = "123456"; | 795 const std::string pin = "123456"; |
781 const bool kRequire = true; | 796 const bool kRequire = true; |
782 | 797 |
783 // Set expectations. | 798 // Set expectations. |
784 base::Closure callback; | 799 base::Closure callback; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 base::Bind(&CrosNetworkFunctionsTest::MockNetworkOperationCallback, | 890 base::Bind(&CrosNetworkFunctionsTest::MockNetworkOperationCallback, |
876 base::Unretained(this))); | 891 base::Unretained(this))); |
877 // Run saved callback. | 892 // Run saved callback. |
878 callback.Run(); | 893 callback.Run(); |
879 } | 894 } |
880 | 895 |
881 TEST_F(CrosNetworkFunctionsTest, CrosSetOfflineMode) { | 896 TEST_F(CrosNetworkFunctionsTest, CrosSetOfflineMode) { |
882 const bool kOffline = true; | 897 const bool kOffline = true; |
883 const base::FundamentalValue value(kOffline); | 898 const base::FundamentalValue value(kOffline); |
884 EXPECT_CALL(*mock_manager_client_, SetProperty( | 899 EXPECT_CALL(*mock_manager_client_, SetProperty( |
885 flimflam::kOfflineModeProperty, IsEqualTo(&value), _)).Times(1); | 900 flimflam::kOfflineModeProperty, IsEqualTo(&value), _, _)).Times(1); |
886 CrosSetOfflineMode(kOffline); | 901 CrosSetOfflineMode(kOffline); |
887 } | 902 } |
888 | 903 |
889 TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigs) { | 904 TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigs) { |
890 const std::string device_path = "/device/path"; | 905 const std::string device_path = "/device/path"; |
891 std::string ipconfig_path = "/ipconfig/path"; | 906 std::string ipconfig_path = "/ipconfig/path"; |
892 | 907 |
893 const IPConfigType kType = IPCONFIG_TYPE_DHCP; | 908 const IPConfigType kType = IPCONFIG_TYPE_DHCP; |
894 const std::string address = "address"; | 909 const std::string address = "address"; |
895 const int kMtu = 123; | 910 const int kMtu = 123; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1052 } | 1067 } |
1053 | 1068 |
1054 TEST_F(CrosNetworkFunctionsTest, CrosConfigureService) { | 1069 TEST_F(CrosNetworkFunctionsTest, CrosConfigureService) { |
1055 const std::string key1 = "key1"; | 1070 const std::string key1 = "key1"; |
1056 const std::string string1 = "string1"; | 1071 const std::string string1 = "string1"; |
1057 const std::string key2 = "key2"; | 1072 const std::string key2 = "key2"; |
1058 const std::string string2 = "string2"; | 1073 const std::string string2 = "string2"; |
1059 base::DictionaryValue value; | 1074 base::DictionaryValue value; |
1060 value.SetString(key1, string1); | 1075 value.SetString(key1, string1); |
1061 value.SetString(key2, string2); | 1076 value.SetString(key2, string2); |
1062 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _)) | 1077 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _, _)) |
1063 .Times(1); | 1078 .Times(1); |
1064 CrosConfigureService(value); | 1079 CrosConfigureService(value); |
1065 } | 1080 } |
1066 | 1081 |
1067 TEST_F(CrosNetworkFunctionsTest, NetmaskToPrefixLength) { | 1082 TEST_F(CrosNetworkFunctionsTest, NetmaskToPrefixLength) { |
1068 // Valid netmasks | 1083 // Valid netmasks |
1069 EXPECT_EQ(32, CrosNetmaskToPrefixLength("255.255.255.255")); | 1084 EXPECT_EQ(32, CrosNetmaskToPrefixLength("255.255.255.255")); |
1070 EXPECT_EQ(31, CrosNetmaskToPrefixLength("255.255.255.254")); | 1085 EXPECT_EQ(31, CrosNetmaskToPrefixLength("255.255.255.254")); |
1071 EXPECT_EQ(30, CrosNetmaskToPrefixLength("255.255.255.252")); | 1086 EXPECT_EQ(30, CrosNetmaskToPrefixLength("255.255.255.252")); |
1072 EXPECT_EQ(29, CrosNetmaskToPrefixLength("255.255.255.248")); | 1087 EXPECT_EQ(29, CrosNetmaskToPrefixLength("255.255.255.248")); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1147 EXPECT_EQ("192.0.0.0", CrosPrefixLengthToNetmask(2)); | 1162 EXPECT_EQ("192.0.0.0", CrosPrefixLengthToNetmask(2)); |
1148 EXPECT_EQ("128.0.0.0", CrosPrefixLengthToNetmask(1)); | 1163 EXPECT_EQ("128.0.0.0", CrosPrefixLengthToNetmask(1)); |
1149 EXPECT_EQ("0.0.0.0", CrosPrefixLengthToNetmask(0)); | 1164 EXPECT_EQ("0.0.0.0", CrosPrefixLengthToNetmask(0)); |
1150 // Invalid Prefix Lengths | 1165 // Invalid Prefix Lengths |
1151 EXPECT_EQ("", CrosPrefixLengthToNetmask(-1)); | 1166 EXPECT_EQ("", CrosPrefixLengthToNetmask(-1)); |
1152 EXPECT_EQ("", CrosPrefixLengthToNetmask(33)); | 1167 EXPECT_EQ("", CrosPrefixLengthToNetmask(33)); |
1153 EXPECT_EQ("", CrosPrefixLengthToNetmask(255)); | 1168 EXPECT_EQ("", CrosPrefixLengthToNetmask(255)); |
1154 } | 1169 } |
1155 | 1170 |
1156 } // namespace chromeos | 1171 } // namespace chromeos |
OLD | NEW |