Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698