| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 EXPECT_EQ(expected_result, result); | 238 EXPECT_EQ(expected_result, result); |
| 239 } | 239 } |
| 240 | 240 |
| 241 TEST_F(FlimflamDeviceClientTest, RequirePin) { | 241 TEST_F(FlimflamDeviceClientTest, RequirePin) { |
| 242 const char kPin[] = "123456"; | 242 const char kPin[] = "123456"; |
| 243 const bool kRequired = true; | 243 const bool kRequired = true; |
| 244 // Create response. | 244 // Create response. |
| 245 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 245 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 246 | 246 |
| 247 // Set expectations. | 247 // Set expectations. |
| 248 MockClosure mock_closure; |
| 249 MockErrorCallback mock_error_callback; |
| 248 PrepareForMethodCall(flimflam::kRequirePinFunction, | 250 PrepareForMethodCall(flimflam::kRequirePinFunction, |
| 249 base::Bind(&ExpectStringAndBoolArguments, | 251 base::Bind(&ExpectStringAndBoolArguments, |
| 250 kPin, | 252 kPin, |
| 251 kRequired), | 253 kRequired), |
| 252 response.get()); | 254 response.get()); |
| 255 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 253 // Call method. | 256 // Call method. |
| 254 client_->RequirePin(dbus::ObjectPath(kExampleDevicePath), | 257 client_->RequirePin(dbus::ObjectPath(kExampleDevicePath), |
| 255 kPin, | 258 kPin, |
| 256 kRequired, | 259 kRequired, |
| 257 base::Bind(&ExpectNoResultValue)); | 260 mock_closure.GetCallback(), |
| 261 mock_error_callback.GetCallback()); |
| 258 // Run the message loop. | 262 // Run the message loop. |
| 259 message_loop_.RunAllPending(); | 263 message_loop_.RunAllPending(); |
| 260 } | 264 } |
| 261 | 265 |
| 262 TEST_F(FlimflamDeviceClientTest, EnterPin) { | 266 TEST_F(FlimflamDeviceClientTest, EnterPin) { |
| 263 const char kPin[] = "123456"; | 267 const char kPin[] = "123456"; |
| 264 // Create response. | 268 // Create response. |
| 265 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 269 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 266 | 270 |
| 267 // Set expectations. | 271 // Set expectations. |
| 272 MockClosure mock_closure; |
| 273 MockErrorCallback mock_error_callback; |
| 268 PrepareForMethodCall(flimflam::kEnterPinFunction, | 274 PrepareForMethodCall(flimflam::kEnterPinFunction, |
| 269 base::Bind(&ExpectStringArgument, | 275 base::Bind(&ExpectStringArgument, |
| 270 kPin), | 276 kPin), |
| 271 response.get()); | 277 response.get()); |
| 278 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 272 // Call method. | 279 // Call method. |
| 273 client_->EnterPin(dbus::ObjectPath(kExampleDevicePath), | 280 client_->EnterPin(dbus::ObjectPath(kExampleDevicePath), |
| 274 kPin, | 281 kPin, |
| 275 base::Bind(&ExpectNoResultValue)); | 282 mock_closure.GetCallback(), |
| 283 mock_error_callback.GetCallback()); |
| 276 // Run the message loop. | 284 // Run the message loop. |
| 277 message_loop_.RunAllPending(); | 285 message_loop_.RunAllPending(); |
| 278 } | 286 } |
| 279 | 287 |
| 280 TEST_F(FlimflamDeviceClientTest, UnblockPin) { | 288 TEST_F(FlimflamDeviceClientTest, UnblockPin) { |
| 281 const char kPuk[] = "987654"; | 289 const char kPuk[] = "987654"; |
| 282 const char kPin[] = "123456"; | 290 const char kPin[] = "123456"; |
| 283 // Create response. | 291 // Create response. |
| 284 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 292 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 285 | 293 |
| 286 // Set expectations. | 294 // Set expectations. |
| 295 MockClosure mock_closure; |
| 296 MockErrorCallback mock_error_callback; |
| 287 PrepareForMethodCall(flimflam::kUnblockPinFunction, | 297 PrepareForMethodCall(flimflam::kUnblockPinFunction, |
| 288 base::Bind(&ExpectTwoStringArguments, kPuk, kPin), | 298 base::Bind(&ExpectTwoStringArguments, kPuk, kPin), |
| 289 response.get()); | 299 response.get()); |
| 300 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 290 // Call method. | 301 // Call method. |
| 291 client_->UnblockPin(dbus::ObjectPath(kExampleDevicePath), | 302 client_->UnblockPin(dbus::ObjectPath(kExampleDevicePath), |
| 292 kPuk, | 303 kPuk, |
| 293 kPin, | 304 kPin, |
| 294 base::Bind(&ExpectNoResultValue)); | 305 mock_closure.GetCallback(), |
| 306 mock_error_callback.GetCallback()); |
| 295 // Run the message loop. | 307 // Run the message loop. |
| 296 message_loop_.RunAllPending(); | 308 message_loop_.RunAllPending(); |
| 297 } | 309 } |
| 298 | 310 |
| 299 TEST_F(FlimflamDeviceClientTest, ChangePin) { | 311 TEST_F(FlimflamDeviceClientTest, ChangePin) { |
| 300 const char kOldPin[] = "123456"; | 312 const char kOldPin[] = "123456"; |
| 301 const char kNewPin[] = "234567"; | 313 const char kNewPin[] = "234567"; |
| 302 // Create response. | 314 // Create response. |
| 303 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 315 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 304 | 316 |
| 305 // Set expectations. | 317 // Set expectations. |
| 318 MockClosure mock_closure; |
| 319 MockErrorCallback mock_error_callback; |
| 306 PrepareForMethodCall(flimflam::kChangePinFunction, | 320 PrepareForMethodCall(flimflam::kChangePinFunction, |
| 307 base::Bind(&ExpectTwoStringArguments, | 321 base::Bind(&ExpectTwoStringArguments, |
| 308 kOldPin, | 322 kOldPin, |
| 309 kNewPin), | 323 kNewPin), |
| 310 response.get()); | 324 response.get()); |
| 325 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 311 // Call method. | 326 // Call method. |
| 312 client_->ChangePin(dbus::ObjectPath(kExampleDevicePath), | 327 client_->ChangePin(dbus::ObjectPath(kExampleDevicePath), |
| 313 kOldPin, | 328 kOldPin, |
| 314 kNewPin, | 329 kNewPin, |
| 315 base::Bind(&ExpectNoResultValue)); | 330 mock_closure.GetCallback(), |
| 331 mock_error_callback.GetCallback()); |
| 316 // Run the message loop. | 332 // Run the message loop. |
| 317 message_loop_.RunAllPending(); | 333 message_loop_.RunAllPending(); |
| 318 } | 334 } |
| 319 | 335 |
| 320 TEST_F(FlimflamDeviceClientTest, Register) { | 336 TEST_F(FlimflamDeviceClientTest, Register) { |
| 321 const char kNetworkId[] = "networkid"; | 337 const char kNetworkId[] = "networkid"; |
| 322 // Create response. | 338 // Create response. |
| 323 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 339 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 324 | 340 |
| 325 // Set expectations. | 341 // Set expectations. |
| 342 MockClosure mock_closure; |
| 343 MockErrorCallback mock_error_callback; |
| 326 PrepareForMethodCall(flimflam::kRegisterFunction, | 344 PrepareForMethodCall(flimflam::kRegisterFunction, |
| 327 base::Bind(&ExpectStringArgument, kNetworkId), | 345 base::Bind(&ExpectStringArgument, kNetworkId), |
| 328 response.get()); | 346 response.get()); |
| 347 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 329 // Call method. | 348 // Call method. |
| 330 client_->Register(dbus::ObjectPath(kExampleDevicePath), | 349 client_->Register(dbus::ObjectPath(kExampleDevicePath), |
| 331 kNetworkId, | 350 kNetworkId, |
| 332 base::Bind(&ExpectNoResultValue)); | 351 mock_closure.GetCallback(), |
| 352 mock_error_callback.GetCallback()); |
| 333 // Run the message loop. | 353 // Run the message loop. |
| 334 message_loop_.RunAllPending(); | 354 message_loop_.RunAllPending(); |
| 335 } | 355 } |
| 336 | 356 |
| 337 } // namespace chromeos | 357 } // namespace chromeos |
| OLD | NEW |