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

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

Issue 10164026: Reimplement RequestHiddenWifiNetworkProperties and RequestVirtualNetworkProperties without Libcros (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and review fix Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gvalue_util.h" 9 #include "chrome/browser/chromeos/cros/gvalue_util.h"
10 #include "chrome/browser/chromeos/cros/mock_chromeos_network.h" 10 #include "chrome/browser/chromeos/cros/mock_chromeos_network.h"
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 EXPECT_CALL(*mock_profile_client_, 969 EXPECT_CALL(*mock_profile_client_,
970 GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _)) 970 GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _))
971 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); 971 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry));
972 972
973 CrosRequestNetworkProfileEntryProperties( 973 CrosRequestNetworkProfileEntryProperties(
974 profile_path, profile_entry_path, 974 profile_path, profile_entry_path,
975 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path, 975 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path,
976 result)); 976 result));
977 } 977 }
978 978
979 TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) {
980 const std::string ssid = "ssid";
981 const std::string security = "security";
982 const std::string key1 = "key1";
983 const std::string value1 = "value1";
984 const std::string key2 = "key.2.";
985 const std::string value2 = "value2";
986 // Create result value.
987 base::DictionaryValue result;
988 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
989 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
990 dictionary_value_result_ = &result;
991 // Create expected argument to FlimflamManagerClient::GetService.
992 base::DictionaryValue properties;
993 properties.SetWithoutPathExpansion(
994 flimflam::kModeProperty,
995 base::Value::CreateStringValue(flimflam::kModeManaged));
996 properties.SetWithoutPathExpansion(
997 flimflam::kTypeProperty,
998 base::Value::CreateStringValue(flimflam::kTypeWifi));
999 properties.SetWithoutPathExpansion(
1000 flimflam::kSSIDProperty,
1001 base::Value::CreateStringValue(ssid));
1002 properties.SetWithoutPathExpansion(
1003 flimflam::kSecurityProperty,
1004 base::Value::CreateStringValue(security));
1005 // Set expectations.
1006 const dbus::ObjectPath service_path("/service/path");
1007 FlimflamClientHelper::ObjectPathCallback callback;
1008 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _))
1009 .WillOnce(SaveArg<1>(&callback));
1010 EXPECT_CALL(*mock_service_client_,
1011 GetProperties(service_path, _)).WillOnce(
1012 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
1013
1014 // Call function.
1015 CrosRequestHiddenWifiNetworkProperties(
1016 ssid, security,
1017 MockNetworkPropertiesCallback::CreateCallback(service_path.value(),
1018 result));
1019 // Run callback to invoke GetProperties.
1020 callback.Run(DBUS_METHOD_CALL_SUCCESS, service_path);
1021 }
1022
1023 TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) {
1024 const std::string service_name = "service name";
1025 const std::string server_hostname = "server hostname";
1026 const std::string provider_type = "provider type";
1027 const std::string key1 = "key1";
1028 const std::string value1 = "value1";
1029 const std::string key2 = "key.2.";
1030 const std::string value2 = "value2";
1031 // Create result value.
1032 base::DictionaryValue result;
1033 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
1034 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
1035 dictionary_value_result_ = &result;
1036 // Create expected argument to FlimflamManagerClient::GetService.
1037 base::DictionaryValue properties;
1038 properties.SetWithoutPathExpansion(
1039 flimflam::kTypeProperty, base::Value::CreateStringValue("vpn"));
1040 properties.SetWithoutPathExpansion(
1041 flimflam::kProviderNameProperty,
1042 base::Value::CreateStringValue(service_name));
1043 properties.SetWithoutPathExpansion(
1044 flimflam::kProviderHostProperty,
1045 base::Value::CreateStringValue(server_hostname));
1046 properties.SetWithoutPathExpansion(
1047 flimflam::kProviderTypeProperty,
1048 base::Value::CreateStringValue(provider_type));
1049 properties.SetWithoutPathExpansion(
1050 flimflam::kVPNDomainProperty,
1051 base::Value::CreateStringValue(service_name));
1052
1053 // Set expectations.
1054 const dbus::ObjectPath service_path("/service/path");
1055 FlimflamClientHelper::ObjectPathCallback callback;
1056 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _))
1057 .WillOnce(SaveArg<1>(&callback));
1058 EXPECT_CALL(*mock_service_client_,
1059 GetProperties(service_path, _)).WillOnce(
1060 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
1061
1062 // Call function.
1063 CrosRequestVirtualNetworkProperties(
1064 service_name, server_hostname, provider_type,
1065 MockNetworkPropertiesCallback::CreateCallback(service_path.value(),
1066 result));
1067 // Run callback to invoke GetProperties.
1068 callback.Run(DBUS_METHOD_CALL_SUCCESS, service_path);
1069 }
1070
979 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) { 1071 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) {
980 const std::string service_path = "/service/path"; 1072 const std::string service_path = "/service/path";
981 EXPECT_CALL(*mock_service_client_, 1073 EXPECT_CALL(*mock_service_client_,
982 Disconnect(dbus::ObjectPath(service_path), _)).Times(1); 1074 Disconnect(dbus::ObjectPath(service_path), _)).Times(1);
983 CrosRequestNetworkServiceDisconnect(service_path); 1075 CrosRequestNetworkServiceDisconnect(service_path);
984 } 1076 }
985 1077
986 TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) { 1078 TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) {
987 const std::string service_path = "/service/path"; 1079 const std::string service_path = "/service/path";
988 EXPECT_CALL(*mock_service_client_, 1080 EXPECT_CALL(*mock_service_client_,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 const std::string string2 = "string2"; 1125 const std::string string2 = "string2";
1034 base::DictionaryValue value; 1126 base::DictionaryValue value;
1035 value.SetString(key1, string1); 1127 value.SetString(key1, string1);
1036 value.SetString(key2, string2); 1128 value.SetString(key2, string2);
1037 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _)) 1129 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _))
1038 .Times(1); 1130 .Times(1);
1039 CrosConfigureService(value); 1131 CrosConfigureService(value);
1040 } 1132 }
1041 1133
1042 } // namespace chromeos 1134 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698