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/values.h" | 6 #include "base/values.h" |
7 #include "chromeos/dbus/flimflam_client_unittest_base.h" | 7 #include "chromeos/dbus/flimflam_client_unittest_base.h" |
8 #include "chromeos/dbus/flimflam_device_client.h" | 8 #include "chromeos/dbus/flimflam_device_client.h" |
9 #include "dbus/message.h" | 9 #include "dbus/message.h" |
10 #include "dbus/object_path.h" | 10 #include "dbus/object_path.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 PrepareForMethodCall(flimflam::kGetPropertiesFunction, | 114 PrepareForMethodCall(flimflam::kGetPropertiesFunction, |
115 base::Bind(&ExpectNoArgument), | 115 base::Bind(&ExpectNoArgument), |
116 response.get()); | 116 response.get()); |
117 // Call method. | 117 // Call method. |
118 client_->GetProperties(dbus::ObjectPath(kExampleDevicePath), | 118 client_->GetProperties(dbus::ObjectPath(kExampleDevicePath), |
119 base::Bind(&ExpectDictionaryValueResult, &value)); | 119 base::Bind(&ExpectDictionaryValueResult, &value)); |
120 // Run the message loop. | 120 // Run the message loop. |
121 message_loop_.RunAllPending(); | 121 message_loop_.RunAllPending(); |
122 } | 122 } |
123 | 123 |
| 124 TEST_F(FlimflamDeviceClientTest, CallGetPropertiesAndBlock) { |
| 125 const bool kValue = true; |
| 126 // Create response. |
| 127 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 128 dbus::MessageWriter writer(response.get()); |
| 129 dbus::MessageWriter array_writer(NULL); |
| 130 writer.OpenArray("{sv}", &array_writer); |
| 131 dbus::MessageWriter entry_writer(NULL); |
| 132 array_writer.OpenDictEntry(&entry_writer); |
| 133 entry_writer.AppendString(flimflam::kCellularAllowRoamingProperty); |
| 134 entry_writer.AppendVariantOfBool(kValue); |
| 135 array_writer.CloseContainer(&entry_writer); |
| 136 writer.CloseContainer(&array_writer); |
| 137 |
| 138 // Set expectations. |
| 139 base::DictionaryValue value; |
| 140 value.SetWithoutPathExpansion(flimflam::kCellularAllowRoamingProperty, |
| 141 base::Value::CreateBooleanValue(kValue)); |
| 142 PrepareForMethodCall(flimflam::kGetPropertiesFunction, |
| 143 base::Bind(&ExpectNoArgument), |
| 144 response.get()); |
| 145 // Call method. |
| 146 scoped_ptr<base::DictionaryValue> result( |
| 147 client_->CallGetPropertiesAndBlock(dbus::ObjectPath(kExampleDevicePath))); |
| 148 ASSERT_TRUE(result.get()); |
| 149 EXPECT_TRUE(result->Equals(&value)); |
| 150 } |
| 151 |
124 TEST_F(FlimflamDeviceClientTest, ProposeScan) { | 152 TEST_F(FlimflamDeviceClientTest, ProposeScan) { |
125 // Create response. | 153 // Create response. |
126 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 154 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
127 | 155 |
128 // Set expectations. | 156 // Set expectations. |
129 PrepareForMethodCall(flimflam::kProposeScanFunction, | 157 PrepareForMethodCall(flimflam::kProposeScanFunction, |
130 base::Bind(&ExpectNoArgument), | 158 base::Bind(&ExpectNoArgument), |
131 response.get()); | 159 response.get()); |
132 // Call method. | 160 // Call method. |
133 client_->ProposeScan(dbus::ObjectPath(kExampleDevicePath), | 161 client_->ProposeScan(dbus::ObjectPath(kExampleDevicePath), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 flimflam::kCellularAllowRoamingProperty), | 195 flimflam::kCellularAllowRoamingProperty), |
168 response.get()); | 196 response.get()); |
169 // Call method. | 197 // Call method. |
170 client_->ClearProperty(dbus::ObjectPath(kExampleDevicePath), | 198 client_->ClearProperty(dbus::ObjectPath(kExampleDevicePath), |
171 flimflam::kCellularAllowRoamingProperty, | 199 flimflam::kCellularAllowRoamingProperty, |
172 base::Bind(&ExpectNoResultValue)); | 200 base::Bind(&ExpectNoResultValue)); |
173 // Run the message loop. | 201 // Run the message loop. |
174 message_loop_.RunAllPending(); | 202 message_loop_.RunAllPending(); |
175 } | 203 } |
176 | 204 |
| 205 TEST_F(FlimflamDeviceClientTest, AddIPConfig) { |
| 206 const dbus::ObjectPath expected_result("/result/path"); |
| 207 // Create response. |
| 208 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 209 dbus::MessageWriter writer(response.get()); |
| 210 writer.AppendObjectPath(expected_result); |
| 211 |
| 212 // Set expectations. |
| 213 PrepareForMethodCall(flimflam::kAddIPConfigFunction, |
| 214 base::Bind(&ExpectStringArgument, flimflam::kTypeDHCP), |
| 215 response.get()); |
| 216 // Call method. |
| 217 client_->AddIPConfig(dbus::ObjectPath(kExampleDevicePath), |
| 218 flimflam::kTypeDHCP, |
| 219 base::Bind(&ExpectObjectPathResult, expected_result)); |
| 220 // Run the message loop. |
| 221 message_loop_.RunAllPending(); |
| 222 } |
| 223 |
| 224 TEST_F(FlimflamDeviceClientTest, CallAddIPConfigAndBlock) { |
| 225 const dbus::ObjectPath expected_result("/result/path"); |
| 226 // Create response. |
| 227 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 228 dbus::MessageWriter writer(response.get()); |
| 229 writer.AppendObjectPath(expected_result); |
| 230 |
| 231 // Set expectations. |
| 232 PrepareForMethodCall(flimflam::kAddIPConfigFunction, |
| 233 base::Bind(&ExpectStringArgument, flimflam::kTypeDHCP), |
| 234 response.get()); |
| 235 // Call method. |
| 236 const dbus::ObjectPath result = client_->CallAddIPConfigAndBlock( |
| 237 dbus::ObjectPath(kExampleDevicePath), flimflam::kTypeDHCP); |
| 238 EXPECT_EQ(expected_result, result); |
| 239 } |
| 240 |
177 TEST_F(FlimflamDeviceClientTest, RequirePin) { | 241 TEST_F(FlimflamDeviceClientTest, RequirePin) { |
178 const char kPin[] = "123456"; | 242 const char kPin[] = "123456"; |
179 const bool kRequired = true; | 243 const bool kRequired = true; |
180 // Create response. | 244 // Create response. |
181 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 245 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
182 | 246 |
183 // Set expectations. | 247 // Set expectations. |
184 PrepareForMethodCall(flimflam::kRequirePinFunction, | 248 PrepareForMethodCall(flimflam::kRequirePinFunction, |
185 base::Bind(&ExpectStringAndBoolArguments, | 249 base::Bind(&ExpectStringAndBoolArguments, |
186 kPin, | 250 kPin, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 response.get()); | 328 response.get()); |
265 // Call method. | 329 // Call method. |
266 client_->Register(dbus::ObjectPath(kExampleDevicePath), | 330 client_->Register(dbus::ObjectPath(kExampleDevicePath), |
267 kNetworkId, | 331 kNetworkId, |
268 base::Bind(&ExpectNoResultValue)); | 332 base::Bind(&ExpectNoResultValue)); |
269 // Run the message loop. | 333 // Run the message loop. |
270 message_loop_.RunAllPending(); | 334 message_loop_.RunAllPending(); |
271 } | 335 } |
272 | 336 |
273 } // namespace chromeos | 337 } // namespace chromeos |
OLD | NEW |