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_device_client.h" | 8 #include "chromeos/dbus/shill_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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 189 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
190 | 190 |
191 // Set expectations. | 191 // Set expectations. |
192 const base::FundamentalValue value(kValue); | 192 const base::FundamentalValue value(kValue); |
193 PrepareForMethodCall(flimflam::kSetPropertyFunction, | 193 PrepareForMethodCall(flimflam::kSetPropertyFunction, |
194 base::Bind(&ExpectStringAndValueArguments, | 194 base::Bind(&ExpectStringAndValueArguments, |
195 flimflam::kCellularAllowRoamingProperty, | 195 flimflam::kCellularAllowRoamingProperty, |
196 &value), | 196 &value), |
197 response.get()); | 197 response.get()); |
198 // Call method. | 198 // Call method. |
| 199 MockClosure mock_closure; |
| 200 MockErrorCallback mock_error_callback; |
199 client_->SetProperty(dbus::ObjectPath(kExampleDevicePath), | 201 client_->SetProperty(dbus::ObjectPath(kExampleDevicePath), |
200 flimflam::kCellularAllowRoamingProperty, | 202 flimflam::kCellularAllowRoamingProperty, |
201 value, | 203 value, |
202 base::Bind(&ExpectNoResultValue)); | 204 mock_closure.GetCallback(), |
| 205 mock_error_callback.GetCallback()); |
| 206 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 207 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 208 |
203 // Run the message loop. | 209 // Run the message loop. |
204 message_loop_.RunAllPending(); | 210 message_loop_.RunAllPending(); |
205 } | 211 } |
206 | 212 |
207 TEST_F(ShillDeviceClientTest, ClearProperty) { | 213 TEST_F(ShillDeviceClientTest, ClearProperty) { |
208 // Create response. | 214 // Create response. |
209 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 215 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
210 | 216 |
211 // Set expectations. | 217 // Set expectations. |
212 PrepareForMethodCall(flimflam::kClearPropertyFunction, | 218 PrepareForMethodCall(flimflam::kClearPropertyFunction, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 271 |
266 // Set expectations. | 272 // Set expectations. |
267 MockClosure mock_closure; | 273 MockClosure mock_closure; |
268 MockErrorCallback mock_error_callback; | 274 MockErrorCallback mock_error_callback; |
269 PrepareForMethodCall(flimflam::kRequirePinFunction, | 275 PrepareForMethodCall(flimflam::kRequirePinFunction, |
270 base::Bind(&ExpectStringAndBoolArguments, | 276 base::Bind(&ExpectStringAndBoolArguments, |
271 kPin, | 277 kPin, |
272 kRequired), | 278 kRequired), |
273 response.get()); | 279 response.get()); |
274 EXPECT_CALL(mock_closure, Run()).Times(1); | 280 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 281 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
275 // Call method. | 282 // Call method. |
276 client_->RequirePin(dbus::ObjectPath(kExampleDevicePath), | 283 client_->RequirePin(dbus::ObjectPath(kExampleDevicePath), |
277 kPin, | 284 kPin, |
278 kRequired, | 285 kRequired, |
279 mock_closure.GetCallback(), | 286 mock_closure.GetCallback(), |
280 mock_error_callback.GetCallback()); | 287 mock_error_callback.GetCallback()); |
281 // Run the message loop. | 288 // Run the message loop. |
282 message_loop_.RunAllPending(); | 289 message_loop_.RunAllPending(); |
283 } | 290 } |
284 | 291 |
285 TEST_F(ShillDeviceClientTest, EnterPin) { | 292 TEST_F(ShillDeviceClientTest, EnterPin) { |
286 const char kPin[] = "123456"; | 293 const char kPin[] = "123456"; |
287 // Create response. | 294 // Create response. |
288 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 295 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
289 | 296 |
290 // Set expectations. | 297 // Set expectations. |
291 MockClosure mock_closure; | 298 MockClosure mock_closure; |
292 MockErrorCallback mock_error_callback; | 299 MockErrorCallback mock_error_callback; |
293 PrepareForMethodCall(flimflam::kEnterPinFunction, | 300 PrepareForMethodCall(flimflam::kEnterPinFunction, |
294 base::Bind(&ExpectStringArgument, | 301 base::Bind(&ExpectStringArgument, |
295 kPin), | 302 kPin), |
296 response.get()); | 303 response.get()); |
297 EXPECT_CALL(mock_closure, Run()).Times(1); | 304 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 305 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 306 |
298 // Call method. | 307 // Call method. |
299 client_->EnterPin(dbus::ObjectPath(kExampleDevicePath), | 308 client_->EnterPin(dbus::ObjectPath(kExampleDevicePath), |
300 kPin, | 309 kPin, |
301 mock_closure.GetCallback(), | 310 mock_closure.GetCallback(), |
302 mock_error_callback.GetCallback()); | 311 mock_error_callback.GetCallback()); |
303 // Run the message loop. | 312 // Run the message loop. |
304 message_loop_.RunAllPending(); | 313 message_loop_.RunAllPending(); |
305 } | 314 } |
306 | 315 |
307 TEST_F(ShillDeviceClientTest, UnblockPin) { | 316 TEST_F(ShillDeviceClientTest, UnblockPin) { |
308 const char kPuk[] = "987654"; | 317 const char kPuk[] = "987654"; |
309 const char kPin[] = "123456"; | 318 const char kPin[] = "123456"; |
310 // Create response. | 319 // Create response. |
311 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 320 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
312 | 321 |
313 // Set expectations. | 322 // Set expectations. |
314 MockClosure mock_closure; | 323 MockClosure mock_closure; |
315 MockErrorCallback mock_error_callback; | 324 MockErrorCallback mock_error_callback; |
316 PrepareForMethodCall(flimflam::kUnblockPinFunction, | 325 PrepareForMethodCall(flimflam::kUnblockPinFunction, |
317 base::Bind(&ExpectTwoStringArguments, kPuk, kPin), | 326 base::Bind(&ExpectTwoStringArguments, kPuk, kPin), |
318 response.get()); | 327 response.get()); |
319 EXPECT_CALL(mock_closure, Run()).Times(1); | 328 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 329 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 330 |
320 // Call method. | 331 // Call method. |
321 client_->UnblockPin(dbus::ObjectPath(kExampleDevicePath), | 332 client_->UnblockPin(dbus::ObjectPath(kExampleDevicePath), |
322 kPuk, | 333 kPuk, |
323 kPin, | 334 kPin, |
324 mock_closure.GetCallback(), | 335 mock_closure.GetCallback(), |
325 mock_error_callback.GetCallback()); | 336 mock_error_callback.GetCallback()); |
326 // Run the message loop. | 337 // Run the message loop. |
327 message_loop_.RunAllPending(); | 338 message_loop_.RunAllPending(); |
328 } | 339 } |
329 | 340 |
330 TEST_F(ShillDeviceClientTest, ChangePin) { | 341 TEST_F(ShillDeviceClientTest, ChangePin) { |
331 const char kOldPin[] = "123456"; | 342 const char kOldPin[] = "123456"; |
332 const char kNewPin[] = "234567"; | 343 const char kNewPin[] = "234567"; |
333 // Create response. | 344 // Create response. |
334 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 345 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
335 | 346 |
336 // Set expectations. | 347 // Set expectations. |
337 MockClosure mock_closure; | 348 MockClosure mock_closure; |
338 MockErrorCallback mock_error_callback; | 349 MockErrorCallback mock_error_callback; |
339 PrepareForMethodCall(flimflam::kChangePinFunction, | 350 PrepareForMethodCall(flimflam::kChangePinFunction, |
340 base::Bind(&ExpectTwoStringArguments, | 351 base::Bind(&ExpectTwoStringArguments, |
341 kOldPin, | 352 kOldPin, |
342 kNewPin), | 353 kNewPin), |
343 response.get()); | 354 response.get()); |
344 EXPECT_CALL(mock_closure, Run()).Times(1); | 355 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 356 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 357 |
345 // Call method. | 358 // Call method. |
346 client_->ChangePin(dbus::ObjectPath(kExampleDevicePath), | 359 client_->ChangePin(dbus::ObjectPath(kExampleDevicePath), |
347 kOldPin, | 360 kOldPin, |
348 kNewPin, | 361 kNewPin, |
349 mock_closure.GetCallback(), | 362 mock_closure.GetCallback(), |
350 mock_error_callback.GetCallback()); | 363 mock_error_callback.GetCallback()); |
351 // Run the message loop. | 364 // Run the message loop. |
352 message_loop_.RunAllPending(); | 365 message_loop_.RunAllPending(); |
353 } | 366 } |
354 | 367 |
355 TEST_F(ShillDeviceClientTest, Register) { | 368 TEST_F(ShillDeviceClientTest, Register) { |
356 const char kNetworkId[] = "networkid"; | 369 const char kNetworkId[] = "networkid"; |
357 // Create response. | 370 // Create response. |
358 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 371 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
359 | 372 |
360 // Set expectations. | 373 // Set expectations. |
361 MockClosure mock_closure; | 374 MockClosure mock_closure; |
362 MockErrorCallback mock_error_callback; | 375 MockErrorCallback mock_error_callback; |
363 PrepareForMethodCall(flimflam::kRegisterFunction, | 376 PrepareForMethodCall(flimflam::kRegisterFunction, |
364 base::Bind(&ExpectStringArgument, kNetworkId), | 377 base::Bind(&ExpectStringArgument, kNetworkId), |
365 response.get()); | 378 response.get()); |
366 EXPECT_CALL(mock_closure, Run()).Times(1); | 379 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 380 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 381 |
367 // Call method. | 382 // Call method. |
368 client_->Register(dbus::ObjectPath(kExampleDevicePath), | 383 client_->Register(dbus::ObjectPath(kExampleDevicePath), |
369 kNetworkId, | 384 kNetworkId, |
370 mock_closure.GetCallback(), | 385 mock_closure.GetCallback(), |
371 mock_error_callback.GetCallback()); | 386 mock_error_callback.GetCallback()); |
372 // Run the message loop. | 387 // Run the message loop. |
373 message_loop_.RunAllPending(); | 388 message_loop_.RunAllPending(); |
374 } | 389 } |
375 | 390 |
376 TEST_F(ShillDeviceClientTest, SetCarrier) { | 391 TEST_F(ShillDeviceClientTest, SetCarrier) { |
(...skipping 11 matching lines...) Expand all Loading... |
388 // Call method. | 403 // Call method. |
389 client_->SetCarrier(dbus::ObjectPath(kExampleDevicePath), | 404 client_->SetCarrier(dbus::ObjectPath(kExampleDevicePath), |
390 kCarrier, | 405 kCarrier, |
391 mock_closure.GetCallback(), | 406 mock_closure.GetCallback(), |
392 mock_error_callback.GetCallback()); | 407 mock_error_callback.GetCallback()); |
393 // Run the message loop. | 408 // Run the message loop. |
394 message_loop_.RunAllPending(); | 409 message_loop_.RunAllPending(); |
395 } | 410 } |
396 | 411 |
397 } // namespace chromeos | 412 } // namespace chromeos |
OLD | NEW |