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::PropertyChangedHandler handler; |
316 EXPECT_CALL(*mock_manager_client_, SetPropertyChangedHandler(_)) | 327 EXPECT_CALL(*mock_manager_client_, SetPropertyChangedHandler(_)) |
317 .WillOnce(SaveArg<0>(&handler)); | 328 .WillOnce(SaveArg<0>(&handler)); |
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 handler.Run(key, value); |
323 // Stop monitoring. | 334 // Stop monitoring. |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 const std::string key1 = "key1"; | 623 const std::string key1 = "key1"; |
613 const std::string value1 = "value1"; | 624 const std::string value1 = "value1"; |
614 const std::string key2 = "key.2."; | 625 const std::string key2 = "key.2."; |
615 const std::string value2 = "value2"; | 626 const std::string value2 = "value2"; |
616 // Create result value. | 627 // Create result value. |
617 base::DictionaryValue result; | 628 base::DictionaryValue result; |
618 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 629 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
619 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 630 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
620 // Set expectations. | 631 // Set expectations. |
621 dictionary_value_result_ = &result; | 632 dictionary_value_result_ = &result; |
622 EXPECT_CALL(*mock_profile_client_, | 633 EXPECT_CALL( |
623 GetProperties(dbus::ObjectPath(profile_path), _)).WillOnce( | 634 *mock_profile_client_, |
624 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); | 635 GetProperties(dbus::ObjectPath(profile_path), _, _)).WillOnce( |
| 636 Invoke(this, |
| 637 &CrosNetworkFunctionsTest::OnGetPropertiesWithoutStatus)); |
625 | 638 |
626 CrosRequestNetworkProfileProperties( | 639 CrosRequestNetworkProfileProperties( |
627 profile_path, | 640 profile_path, |
628 MockNetworkPropertiesCallback::CreateCallback(profile_path, result)); | 641 MockNetworkPropertiesCallback::CreateCallback(profile_path, result)); |
629 } | 642 } |
630 | 643 |
631 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { | 644 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { |
632 const std::string profile_path = "profile path"; | 645 const std::string profile_path = "profile path"; |
633 const std::string profile_entry_path = "profile entry path"; | 646 const std::string profile_entry_path = "profile entry path"; |
634 const std::string key1 = "key1"; | 647 const std::string key1 = "key1"; |
635 const std::string value1 = "value1"; | 648 const std::string value1 = "value1"; |
636 const std::string key2 = "key.2."; | 649 const std::string key2 = "key.2."; |
637 const std::string value2 = "value2"; | 650 const std::string value2 = "value2"; |
638 // Create result value. | 651 // Create result value. |
639 base::DictionaryValue result; | 652 base::DictionaryValue result; |
640 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); | 653 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); |
641 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); | 654 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); |
642 // Set expectations. | 655 // Set expectations. |
643 dictionary_value_result_ = &result; | 656 dictionary_value_result_ = &result; |
644 EXPECT_CALL(*mock_profile_client_, | 657 EXPECT_CALL(*mock_profile_client_, |
645 GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _)) | 658 GetEntry(dbus::ObjectPath(profile_path), |
| 659 profile_entry_path, _, _)) |
646 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); | 660 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); |
647 | 661 |
648 CrosRequestNetworkProfileEntryProperties( | 662 CrosRequestNetworkProfileEntryProperties( |
649 profile_path, profile_entry_path, | 663 profile_path, profile_entry_path, |
650 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path, | 664 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path, |
651 result)); | 665 result)); |
652 } | 666 } |
653 | 667 |
654 TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) { | 668 TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) { |
655 const std::string ssid = "ssid"; | 669 const std::string ssid = "ssid"; |
(...skipping 16 matching lines...) Expand all Loading... |
672 flimflam::kTypeProperty, | 686 flimflam::kTypeProperty, |
673 base::Value::CreateStringValue(flimflam::kTypeWifi)); | 687 base::Value::CreateStringValue(flimflam::kTypeWifi)); |
674 properties.SetWithoutPathExpansion( | 688 properties.SetWithoutPathExpansion( |
675 flimflam::kSSIDProperty, | 689 flimflam::kSSIDProperty, |
676 base::Value::CreateStringValue(ssid)); | 690 base::Value::CreateStringValue(ssid)); |
677 properties.SetWithoutPathExpansion( | 691 properties.SetWithoutPathExpansion( |
678 flimflam::kSecurityProperty, | 692 flimflam::kSecurityProperty, |
679 base::Value::CreateStringValue(security)); | 693 base::Value::CreateStringValue(security)); |
680 // Set expectations. | 694 // Set expectations. |
681 const dbus::ObjectPath service_path("/service/path"); | 695 const dbus::ObjectPath service_path("/service/path"); |
682 ObjectPathDBusMethodCallback callback; | 696 ObjectPathCallbackWithoutStatus callback; |
683 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _)) | 697 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _)) |
684 .WillOnce(SaveArg<1>(&callback)); | 698 .WillOnce(SaveArg<1>(&callback)); |
685 EXPECT_CALL(*mock_service_client_, | 699 EXPECT_CALL(*mock_service_client_, |
686 GetProperties(service_path, _)).WillOnce( | 700 GetProperties(service_path, _)).WillOnce( |
687 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); | 701 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
688 | 702 |
689 // Call function. | 703 // Call function. |
690 CrosRequestHiddenWifiNetworkProperties( | 704 CrosRequestHiddenWifiNetworkProperties( |
691 ssid, security, | 705 ssid, security, |
692 MockNetworkPropertiesCallback::CreateCallback(service_path.value(), | 706 MockNetworkPropertiesCallback::CreateCallback(service_path.value(), |
693 result)); | 707 result)); |
694 // Run callback to invoke GetProperties. | 708 // Run callback to invoke GetProperties. |
695 callback.Run(DBUS_METHOD_CALL_SUCCESS, service_path); | 709 callback.Run(service_path); |
696 } | 710 } |
697 | 711 |
698 TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) { | 712 TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) { |
699 const std::string service_name = "service name"; | 713 const std::string service_name = "service name"; |
700 const std::string server_hostname = "server hostname"; | 714 const std::string server_hostname = "server hostname"; |
701 const std::string provider_type = "provider type"; | 715 const std::string provider_type = "provider type"; |
702 const std::string key1 = "key1"; | 716 const std::string key1 = "key1"; |
703 const std::string value1 = "value1"; | 717 const std::string value1 = "value1"; |
704 const std::string key2 = "key.2."; | 718 const std::string key2 = "key.2."; |
705 const std::string value2 = "value2"; | 719 const std::string value2 = "value2"; |
(...skipping 14 matching lines...) Expand all Loading... |
720 base::Value::CreateStringValue(server_hostname)); | 734 base::Value::CreateStringValue(server_hostname)); |
721 properties.SetWithoutPathExpansion( | 735 properties.SetWithoutPathExpansion( |
722 flimflam::kProviderTypeProperty, | 736 flimflam::kProviderTypeProperty, |
723 base::Value::CreateStringValue(provider_type)); | 737 base::Value::CreateStringValue(provider_type)); |
724 properties.SetWithoutPathExpansion( | 738 properties.SetWithoutPathExpansion( |
725 flimflam::kVPNDomainProperty, | 739 flimflam::kVPNDomainProperty, |
726 base::Value::CreateStringValue(service_name)); | 740 base::Value::CreateStringValue(service_name)); |
727 | 741 |
728 // Set expectations. | 742 // Set expectations. |
729 const dbus::ObjectPath service_path("/service/path"); | 743 const dbus::ObjectPath service_path("/service/path"); |
730 ObjectPathDBusMethodCallback callback; | 744 ObjectPathCallbackWithoutStatus callback; |
731 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _)) | 745 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _)) |
732 .WillOnce(SaveArg<1>(&callback)); | 746 .WillOnce(SaveArg<1>(&callback)); |
733 EXPECT_CALL(*mock_service_client_, | 747 EXPECT_CALL(*mock_service_client_, |
734 GetProperties(service_path, _)).WillOnce( | 748 GetProperties(service_path, _)).WillOnce( |
735 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); | 749 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
736 | 750 |
737 // Call function. | 751 // Call function. |
738 CrosRequestVirtualNetworkProperties( | 752 CrosRequestVirtualNetworkProperties( |
739 service_name, server_hostname, provider_type, | 753 service_name, server_hostname, provider_type, |
740 MockNetworkPropertiesCallback::CreateCallback(service_path.value(), | 754 MockNetworkPropertiesCallback::CreateCallback(service_path.value(), |
741 result)); | 755 result)); |
742 // Run callback to invoke GetProperties. | 756 // Run callback to invoke GetProperties. |
743 callback.Run(DBUS_METHOD_CALL_SUCCESS, service_path); | 757 callback.Run(service_path); |
744 } | 758 } |
745 | 759 |
746 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) { | 760 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) { |
747 const std::string service_path = "/service/path"; | 761 const std::string service_path = "/service/path"; |
748 EXPECT_CALL(*mock_service_client_, | 762 EXPECT_CALL(*mock_service_client_, |
749 Disconnect(dbus::ObjectPath(service_path), _)).Times(1); | 763 Disconnect(dbus::ObjectPath(service_path), _, _)).Times(1); |
750 CrosRequestNetworkServiceDisconnect(service_path); | 764 CrosRequestNetworkServiceDisconnect(service_path); |
751 } | 765 } |
752 | 766 |
753 TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) { | 767 TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) { |
754 const std::string service_path = "/service/path"; | 768 const std::string service_path = "/service/path"; |
755 EXPECT_CALL(*mock_service_client_, | 769 EXPECT_CALL(*mock_service_client_, |
756 Remove(dbus::ObjectPath(service_path), _)).Times(1); | 770 Remove(dbus::ObjectPath(service_path), _, _)).Times(1); |
757 CrosRequestRemoveNetworkService(service_path); | 771 CrosRequestRemoveNetworkService(service_path); |
758 } | 772 } |
759 | 773 |
760 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkScan) { | 774 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkScan) { |
761 EXPECT_CALL(*mock_manager_client_, | 775 EXPECT_CALL(*mock_manager_client_, |
762 RequestScan(flimflam::kTypeWifi, _)).Times(1); | 776 RequestScan(flimflam::kTypeWifi, _, _)).Times(1); |
763 CrosRequestNetworkScan(flimflam::kTypeWifi); | 777 CrosRequestNetworkScan(flimflam::kTypeWifi); |
764 } | 778 } |
765 | 779 |
766 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceEnable) { | 780 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceEnable) { |
767 const bool kEnable = true; | 781 const bool kEnable = true; |
768 EXPECT_CALL(*mock_manager_client_, | 782 EXPECT_CALL(*mock_manager_client_, |
769 EnableTechnology(flimflam::kTypeWifi, _)).Times(1); | 783 EnableTechnology(flimflam::kTypeWifi, _, _)).Times(1); |
770 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); | 784 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); |
771 | 785 |
772 const bool kDisable = false; | 786 const bool kDisable = false; |
773 EXPECT_CALL(*mock_manager_client_, | 787 EXPECT_CALL(*mock_manager_client_, |
774 DisableTechnology(flimflam::kTypeWifi, _)).Times(1); | 788 DisableTechnology(flimflam::kTypeWifi, _, _)).Times(1); |
775 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable); | 789 CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable); |
776 } | 790 } |
777 | 791 |
778 TEST_F(CrosNetworkFunctionsTest, CrosRequestRequirePin) { | 792 TEST_F(CrosNetworkFunctionsTest, CrosRequestRequirePin) { |
779 const std::string device_path = "/device/path"; | 793 const std::string device_path = "/device/path"; |
780 const std::string pin = "123456"; | 794 const std::string pin = "123456"; |
781 const bool kRequire = true; | 795 const bool kRequire = true; |
782 | 796 |
783 // Set expectations. | 797 // Set expectations. |
784 base::Closure callback; | 798 base::Closure callback; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 base::Bind(&CrosNetworkFunctionsTest::MockNetworkOperationCallback, | 889 base::Bind(&CrosNetworkFunctionsTest::MockNetworkOperationCallback, |
876 base::Unretained(this))); | 890 base::Unretained(this))); |
877 // Run saved callback. | 891 // Run saved callback. |
878 callback.Run(); | 892 callback.Run(); |
879 } | 893 } |
880 | 894 |
881 TEST_F(CrosNetworkFunctionsTest, CrosSetOfflineMode) { | 895 TEST_F(CrosNetworkFunctionsTest, CrosSetOfflineMode) { |
882 const bool kOffline = true; | 896 const bool kOffline = true; |
883 const base::FundamentalValue value(kOffline); | 897 const base::FundamentalValue value(kOffline); |
884 EXPECT_CALL(*mock_manager_client_, SetProperty( | 898 EXPECT_CALL(*mock_manager_client_, SetProperty( |
885 flimflam::kOfflineModeProperty, IsEqualTo(&value), _)).Times(1); | 899 flimflam::kOfflineModeProperty, IsEqualTo(&value), _, _)).Times(1); |
886 CrosSetOfflineMode(kOffline); | 900 CrosSetOfflineMode(kOffline); |
887 } | 901 } |
888 | 902 |
889 TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigs) { | 903 TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigs) { |
890 const std::string device_path = "/device/path"; | 904 const std::string device_path = "/device/path"; |
891 std::string ipconfig_path = "/ipconfig/path"; | 905 std::string ipconfig_path = "/ipconfig/path"; |
892 | 906 |
893 const IPConfigType kType = IPCONFIG_TYPE_DHCP; | 907 const IPConfigType kType = IPCONFIG_TYPE_DHCP; |
894 const std::string address = "address"; | 908 const std::string address = "address"; |
895 const int kMtu = 123; | 909 const int kMtu = 123; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 } | 1066 } |
1053 | 1067 |
1054 TEST_F(CrosNetworkFunctionsTest, CrosConfigureService) { | 1068 TEST_F(CrosNetworkFunctionsTest, CrosConfigureService) { |
1055 const std::string key1 = "key1"; | 1069 const std::string key1 = "key1"; |
1056 const std::string string1 = "string1"; | 1070 const std::string string1 = "string1"; |
1057 const std::string key2 = "key2"; | 1071 const std::string key2 = "key2"; |
1058 const std::string string2 = "string2"; | 1072 const std::string string2 = "string2"; |
1059 base::DictionaryValue value; | 1073 base::DictionaryValue value; |
1060 value.SetString(key1, string1); | 1074 value.SetString(key1, string1); |
1061 value.SetString(key2, string2); | 1075 value.SetString(key2, string2); |
1062 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _)) | 1076 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _, _)) |
1063 .Times(1); | 1077 .Times(1); |
1064 CrosConfigureService(value); | 1078 CrosConfigureService(value); |
1065 } | 1079 } |
1066 | 1080 |
1067 TEST_F(CrosNetworkFunctionsTest, NetmaskToPrefixLength) { | 1081 TEST_F(CrosNetworkFunctionsTest, NetmaskToPrefixLength) { |
1068 // Valid netmasks | 1082 // Valid netmasks |
1069 EXPECT_EQ(32, CrosNetmaskToPrefixLength("255.255.255.255")); | 1083 EXPECT_EQ(32, CrosNetmaskToPrefixLength("255.255.255.255")); |
1070 EXPECT_EQ(31, CrosNetmaskToPrefixLength("255.255.255.254")); | 1084 EXPECT_EQ(31, CrosNetmaskToPrefixLength("255.255.255.254")); |
1071 EXPECT_EQ(30, CrosNetmaskToPrefixLength("255.255.255.252")); | 1085 EXPECT_EQ(30, CrosNetmaskToPrefixLength("255.255.255.252")); |
1072 EXPECT_EQ(29, CrosNetmaskToPrefixLength("255.255.255.248")); | 1086 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)); | 1161 EXPECT_EQ("192.0.0.0", CrosPrefixLengthToNetmask(2)); |
1148 EXPECT_EQ("128.0.0.0", CrosPrefixLengthToNetmask(1)); | 1162 EXPECT_EQ("128.0.0.0", CrosPrefixLengthToNetmask(1)); |
1149 EXPECT_EQ("0.0.0.0", CrosPrefixLengthToNetmask(0)); | 1163 EXPECT_EQ("0.0.0.0", CrosPrefixLengthToNetmask(0)); |
1150 // Invalid Prefix Lengths | 1164 // Invalid Prefix Lengths |
1151 EXPECT_EQ("", CrosPrefixLengthToNetmask(-1)); | 1165 EXPECT_EQ("", CrosPrefixLengthToNetmask(-1)); |
1152 EXPECT_EQ("", CrosPrefixLengthToNetmask(33)); | 1166 EXPECT_EQ("", CrosPrefixLengthToNetmask(33)); |
1153 EXPECT_EQ("", CrosPrefixLengthToNetmask(255)); | 1167 EXPECT_EQ("", CrosPrefixLengthToNetmask(255)); |
1154 } | 1168 } |
1155 | 1169 |
1156 } // namespace chromeos | 1170 } // namespace chromeos |
OLD | NEW |