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/shill_client_unittest_base.h" | 7 #include "chromeos/dbus/shill_client_unittest_base.h" |
8 #include "chromeos/dbus/shill_manager_client.h" | 8 #include "chromeos/dbus/shill_manager_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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // Create response. | 214 // Create response. |
215 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 215 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
216 // Set expectations. | 216 // Set expectations. |
217 base::StringValue value("portal list"); | 217 base::StringValue value("portal list"); |
218 PrepareForMethodCall(flimflam::kSetPropertyFunction, | 218 PrepareForMethodCall(flimflam::kSetPropertyFunction, |
219 base::Bind(ExpectStringAndValueArguments, | 219 base::Bind(ExpectStringAndValueArguments, |
220 flimflam::kCheckPortalListProperty, | 220 flimflam::kCheckPortalListProperty, |
221 &value), | 221 &value), |
222 response.get()); | 222 response.get()); |
223 // Call method. | 223 // Call method. |
| 224 MockClosure mock_closure; |
| 225 MockErrorCallback mock_error_callback; |
224 client_->SetProperty(flimflam::kCheckPortalListProperty, | 226 client_->SetProperty(flimflam::kCheckPortalListProperty, |
225 value, | 227 value, |
226 base::Bind(&ExpectNoResultValue)); | 228 mock_closure.GetCallback(), |
| 229 mock_error_callback.GetCallback()); |
| 230 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 231 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 232 |
227 // Run the message loop. | 233 // Run the message loop. |
228 message_loop_.RunAllPending(); | 234 message_loop_.RunAllPending(); |
229 } | 235 } |
230 | 236 |
231 TEST_F(ShillManagerClientTest, RequestScan) { | 237 TEST_F(ShillManagerClientTest, RequestScan) { |
232 // Create response. | 238 // Create response. |
233 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 239 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
234 // Set expectations. | 240 // Set expectations. |
235 PrepareForMethodCall(flimflam::kRequestScanFunction, | 241 PrepareForMethodCall(flimflam::kRequestScanFunction, |
236 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), | 242 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), |
237 response.get()); | 243 response.get()); |
238 // Call method. | 244 // Call method. |
239 client_->RequestScan(flimflam::kTypeWifi, base::Bind(&ExpectNoResultValue)); | 245 MockClosure mock_closure; |
| 246 MockErrorCallback mock_error_callback; |
| 247 client_->RequestScan(flimflam::kTypeWifi, |
| 248 mock_closure.GetCallback(), |
| 249 mock_error_callback.GetCallback()); |
| 250 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 251 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 252 |
240 // Run the message loop. | 253 // Run the message loop. |
241 message_loop_.RunAllPending(); | 254 message_loop_.RunAllPending(); |
242 } | 255 } |
243 | 256 |
244 TEST_F(ShillManagerClientTest, EnableTechnology) { | 257 TEST_F(ShillManagerClientTest, EnableTechnology) { |
245 // Create response. | 258 // Create response. |
246 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 259 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
247 // Set expectations. | 260 // Set expectations. |
248 PrepareForMethodCall(flimflam::kEnableTechnologyFunction, | 261 PrepareForMethodCall(flimflam::kEnableTechnologyFunction, |
249 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), | 262 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), |
250 response.get()); | 263 response.get()); |
251 // Call method. | 264 // Call method. |
| 265 MockClosure mock_closure; |
| 266 MockErrorCallback mock_error_callback; |
252 client_->EnableTechnology(flimflam::kTypeWifi, | 267 client_->EnableTechnology(flimflam::kTypeWifi, |
253 base::Bind(&ExpectNoResultValue)); | 268 mock_closure.GetCallback(), |
| 269 mock_error_callback.GetCallback()); |
| 270 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 271 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 272 |
254 // Run the message loop. | 273 // Run the message loop. |
255 message_loop_.RunAllPending(); | 274 message_loop_.RunAllPending(); |
256 } | 275 } |
257 | 276 |
258 TEST_F(ShillManagerClientTest, DisableTechnology) { | 277 TEST_F(ShillManagerClientTest, DisableTechnology) { |
259 // Create response. | 278 // Create response. |
260 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 279 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
261 // Set expectations. | 280 // Set expectations. |
262 PrepareForMethodCall(flimflam::kDisableTechnologyFunction, | 281 PrepareForMethodCall(flimflam::kDisableTechnologyFunction, |
263 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), | 282 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), |
264 response.get()); | 283 response.get()); |
265 // Call method. | 284 // Call method. |
| 285 MockClosure mock_closure; |
| 286 MockErrorCallback mock_error_callback; |
266 client_->DisableTechnology(flimflam::kTypeWifi, | 287 client_->DisableTechnology(flimflam::kTypeWifi, |
267 base::Bind(&ExpectNoResultValue)); | 288 mock_closure.GetCallback(), |
| 289 mock_error_callback.GetCallback()); |
| 290 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 291 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 292 |
268 // Run the message loop. | 293 // Run the message loop. |
269 message_loop_.RunAllPending(); | 294 message_loop_.RunAllPending(); |
270 } | 295 } |
271 | 296 |
272 TEST_F(ShillManagerClientTest, ConfigureService) { | 297 TEST_F(ShillManagerClientTest, ConfigureService) { |
273 // Create response. | 298 // Create response. |
274 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 299 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
275 // Create the argument dictionary. | 300 // Create the argument dictionary. |
276 scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties()); | 301 scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties()); |
277 // Set expectations. | 302 // Set expectations. |
278 PrepareForMethodCall(flimflam::kConfigureServiceFunction, | 303 PrepareForMethodCall(flimflam::kConfigureServiceFunction, |
279 base::Bind(&ExpectDictionaryValueArgument, arg.get()), | 304 base::Bind(&ExpectDictionaryValueArgument, arg.get()), |
280 response.get()); | 305 response.get()); |
281 // Call method. | 306 // Call method. |
282 client_->ConfigureService(*arg, base::Bind(&ExpectNoResultValue)); | 307 MockClosure mock_closure; |
| 308 MockErrorCallback mock_error_callback; |
| 309 client_->ConfigureService(*arg, |
| 310 mock_closure.GetCallback(), |
| 311 mock_error_callback.GetCallback()); |
| 312 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 313 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 314 |
283 // Run the message loop. | 315 // Run the message loop. |
284 message_loop_.RunAllPending(); | 316 message_loop_.RunAllPending(); |
285 } | 317 } |
286 | 318 |
287 TEST_F(ShillManagerClientTest, GetService) { | 319 TEST_F(ShillManagerClientTest, GetService) { |
288 // Create response. | 320 // Create response. |
289 const dbus::ObjectPath object_path("/"); | 321 const dbus::ObjectPath object_path("/"); |
290 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 322 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
291 dbus::MessageWriter writer(response.get()); | 323 dbus::MessageWriter writer(response.get()); |
292 writer.AppendObjectPath(object_path); | 324 writer.AppendObjectPath(object_path); |
293 // Create the argument dictionary. | 325 // Create the argument dictionary. |
294 scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties()); | 326 scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties()); |
295 // Set expectations. | 327 // Set expectations. |
296 PrepareForMethodCall(flimflam::kGetServiceFunction, | 328 PrepareForMethodCall(flimflam::kGetServiceFunction, |
297 base::Bind(&ExpectDictionaryValueArgument, arg.get()), | 329 base::Bind(&ExpectDictionaryValueArgument, arg.get()), |
298 response.get()); | 330 response.get()); |
299 // Call method. | 331 // Call method. |
300 client_->GetService(*arg, base::Bind(&ExpectObjectPathResult, object_path)); | 332 MockErrorCallback mock_error_callback; |
| 333 client_->GetService(*arg, |
| 334 base::Bind(&ExpectObjectPathResultWithoutStatus, |
| 335 object_path), |
| 336 mock_error_callback.GetCallback()); |
| 337 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 338 |
301 // Run the message loop. | 339 // Run the message loop. |
302 message_loop_.RunAllPending(); | 340 message_loop_.RunAllPending(); |
303 } | 341 } |
304 | 342 |
305 } // namespace chromeos | 343 } // namespace chromeos |
OLD | NEW |