OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "chromeos/dbus/dbus_thread_manager.h" | 8 #include "chromeos/dbus/dbus_thread_manager.h" |
9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
11 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 11 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
12 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" | 12 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" |
13 #include "chromeos/dbus/fake_bluetooth_input_client.h" | 13 #include "chromeos/dbus/fake_bluetooth_input_client.h" |
14 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" | 14 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" |
| 15 #include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" |
15 #include "device/bluetooth/bluetooth_adapter.h" | 16 #include "device/bluetooth/bluetooth_adapter.h" |
16 #include "device/bluetooth/bluetooth_adapter_chromeos.h" | 17 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
17 #include "device/bluetooth/bluetooth_adapter_factory.h" | 18 #include "device/bluetooth/bluetooth_adapter_factory.h" |
18 #include "device/bluetooth/bluetooth_device.h" | 19 #include "device/bluetooth/bluetooth_device.h" |
19 #include "device/bluetooth/bluetooth_device_chromeos.h" | 20 #include "device/bluetooth/bluetooth_device_chromeos.h" |
20 #include "device/bluetooth/bluetooth_socket.h" | 21 #include "device/bluetooth/bluetooth_socket.h" |
21 #include "device/bluetooth/bluetooth_socket_chromeos.h" | 22 #include "device/bluetooth/bluetooth_socket_chromeos.h" |
22 #include "device/bluetooth/bluetooth_socket_thread.h" | 23 #include "device/bluetooth/bluetooth_socket_thread.h" |
23 #include "device/bluetooth/bluetooth_uuid.h" | 24 #include "device/bluetooth/bluetooth_uuid.h" |
24 #include "net/base/io_buffer.h" | 25 #include "net/base/io_buffer.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ++error_callback_count_; | 138 ++error_callback_count_; |
138 last_reason_ = reason; | 139 last_reason_ = reason; |
139 last_message_ = error_message; | 140 last_message_ = error_message; |
140 | 141 |
141 message_loop_.Quit(); | 142 message_loop_.Quit(); |
142 } | 143 } |
143 | 144 |
144 void CreateServiceSuccessCallback(scoped_refptr<BluetoothSocket> socket) { | 145 void CreateServiceSuccessCallback(scoped_refptr<BluetoothSocket> socket) { |
145 ++success_callback_count_; | 146 ++success_callback_count_; |
146 last_socket_ = socket; | 147 last_socket_ = socket; |
| 148 |
| 149 if (message_loop_.is_running()) |
| 150 message_loop_.Quit(); |
147 } | 151 } |
148 | 152 |
149 void AcceptSuccessCallback(const BluetoothDevice* device, | 153 void AcceptSuccessCallback(const BluetoothDevice* device, |
150 scoped_refptr<BluetoothSocket> socket) { | 154 scoped_refptr<BluetoothSocket> socket) { |
151 ++success_callback_count_; | 155 ++success_callback_count_; |
152 last_device_ = device; | 156 last_device_ = device; |
153 last_socket_ = socket; | 157 last_socket_ = socket; |
154 | 158 |
155 message_loop_.Quit(); | 159 message_loop_.Quit(); |
156 } | 160 } |
(...skipping 23 matching lines...) Expand all Loading... |
180 BluetoothDevice* device = adapter_->GetDevice( | 184 BluetoothDevice* device = adapter_->GetDevice( |
181 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 185 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
182 ASSERT_TRUE(device != NULL); | 186 ASSERT_TRUE(device != NULL); |
183 | 187 |
184 device->ConnectToService( | 188 device->ConnectToService( |
185 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), | 189 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), |
186 base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, | 190 base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, |
187 base::Unretained(this)), | 191 base::Unretained(this)), |
188 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, | 192 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, |
189 base::Unretained(this))); | 193 base::Unretained(this))); |
190 | |
191 message_loop_.Run(); | 194 message_loop_.Run(); |
192 | 195 |
193 EXPECT_EQ(1U, success_callback_count_); | 196 EXPECT_EQ(1U, success_callback_count_); |
194 EXPECT_EQ(0U, error_callback_count_); | 197 EXPECT_EQ(0U, error_callback_count_); |
195 EXPECT_TRUE(last_socket_.get() != NULL); | 198 EXPECT_TRUE(last_socket_.get() != NULL); |
196 | 199 |
197 // Take ownership of the socket for the remainder of the test. | 200 // Take ownership of the socket for the remainder of the test. |
198 scoped_refptr<BluetoothSocket> socket = last_socket_; | 201 scoped_refptr<BluetoothSocket> socket = last_socket_; |
199 last_socket_ = NULL; | 202 last_socket_ = NULL; |
200 success_callback_count_ = 0; | 203 success_callback_count_ = 0; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 293 |
291 TEST_F(BluetoothSocketChromeOSTest, Listen) { | 294 TEST_F(BluetoothSocketChromeOSTest, Listen) { |
292 adapter_->CreateRfcommService( | 295 adapter_->CreateRfcommService( |
293 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), | 296 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), |
294 BluetoothAdapter::ServiceOptions(), | 297 BluetoothAdapter::ServiceOptions(), |
295 base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, | 298 base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, |
296 base::Unretained(this)), | 299 base::Unretained(this)), |
297 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, | 300 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, |
298 base::Unretained(this))); | 301 base::Unretained(this))); |
299 | 302 |
| 303 message_loop_.Run(); |
| 304 |
300 EXPECT_EQ(1U, success_callback_count_); | 305 EXPECT_EQ(1U, success_callback_count_); |
301 EXPECT_EQ(0U, error_callback_count_); | 306 EXPECT_EQ(0U, error_callback_count_); |
302 EXPECT_TRUE(last_socket_.get() != NULL); | 307 EXPECT_TRUE(last_socket_.get() != NULL); |
303 | 308 |
304 // Take ownership of the socket for the remainder of the test. | 309 // Take ownership of the socket for the remainder of the test. |
305 scoped_refptr<BluetoothSocket> server_socket = last_socket_; | 310 scoped_refptr<BluetoothSocket> server_socket = last_socket_; |
306 last_socket_ = NULL; | 311 last_socket_ = NULL; |
307 success_callback_count_ = 0; | 312 success_callback_count_ = 0; |
308 error_callback_count_ = 0; | 313 error_callback_count_ = 0; |
309 | 314 |
310 // Simulate an incoming connection by just calling the ConnectProfile method | 315 // Simulate an incoming connection by just calling the ConnectProfile method |
311 // of the underlying fake device client (from the BlueZ point of view, | 316 // of the underlying fake device client (from the BlueZ point of view, |
312 // outgoing and incoming look the same). | 317 // outgoing and incoming look the same). |
313 // | 318 // |
314 // This is done before the Accept() call to simulate a pending call at the | 319 // This is done before the Accept() call to simulate a pending call at the |
315 // point that Accept() is called. | 320 // point that Accept() is called. |
316 FakeBluetoothDeviceClient* fake_bluetooth_device_client = | 321 FakeBluetoothDeviceClient* fake_bluetooth_device_client = |
317 static_cast<FakeBluetoothDeviceClient*>( | 322 static_cast<FakeBluetoothDeviceClient*>( |
318 DBusThreadManager::Get()->GetBluetoothDeviceClient()); | 323 DBusThreadManager::Get()->GetBluetoothDeviceClient()); |
319 BluetoothDevice* device = adapter_->GetDevice( | 324 BluetoothDevice* device = adapter_->GetDevice( |
320 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 325 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
321 ASSERT_TRUE(device != NULL); | 326 ASSERT_TRUE(device != NULL); |
322 fake_bluetooth_device_client->ConnectProfile( | 327 fake_bluetooth_device_client->ConnectProfile( |
323 static_cast<BluetoothDeviceChromeOS*>(device)->object_path(), | 328 static_cast<BluetoothDeviceChromeOS*>(device)->object_path(), |
324 FakeBluetoothProfileManagerClient::kRfcommUuid, | 329 FakeBluetoothProfileManagerClient::kRfcommUuid, |
325 base::Bind(&base::DoNothing), | 330 base::Bind(&base::DoNothing), |
326 base::Bind(&DoNothingDBusErrorCallback)); | 331 base::Bind(&DoNothingDBusErrorCallback)); |
327 | 332 |
| 333 message_loop_.RunUntilIdle(); |
| 334 |
328 server_socket->Accept( | 335 server_socket->Accept( |
329 base::Bind(&BluetoothSocketChromeOSTest::AcceptSuccessCallback, | 336 base::Bind(&BluetoothSocketChromeOSTest::AcceptSuccessCallback, |
330 base::Unretained(this)), | 337 base::Unretained(this)), |
331 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, | 338 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, |
332 base::Unretained(this))); | 339 base::Unretained(this))); |
333 | 340 |
334 message_loop_.Run(); | 341 message_loop_.Run(); |
335 | 342 |
336 EXPECT_EQ(1U, success_callback_count_); | 343 EXPECT_EQ(1U, success_callback_count_); |
337 EXPECT_EQ(0U, error_callback_count_); | 344 EXPECT_EQ(0U, error_callback_count_); |
(...skipping 18 matching lines...) Expand all Loading... |
356 error_callback_count_ = 0; | 363 error_callback_count_ = 0; |
357 | 364 |
358 // Run a second connection test, this time calling Accept() before the | 365 // Run a second connection test, this time calling Accept() before the |
359 // incoming connection comes in. | 366 // incoming connection comes in. |
360 server_socket->Accept( | 367 server_socket->Accept( |
361 base::Bind(&BluetoothSocketChromeOSTest::AcceptSuccessCallback, | 368 base::Bind(&BluetoothSocketChromeOSTest::AcceptSuccessCallback, |
362 base::Unretained(this)), | 369 base::Unretained(this)), |
363 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, | 370 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, |
364 base::Unretained(this))); | 371 base::Unretained(this))); |
365 | 372 |
| 373 message_loop_.RunUntilIdle(); |
| 374 |
366 fake_bluetooth_device_client->ConnectProfile( | 375 fake_bluetooth_device_client->ConnectProfile( |
367 static_cast<BluetoothDeviceChromeOS*>(device)->object_path(), | 376 static_cast<BluetoothDeviceChromeOS*>(device)->object_path(), |
368 FakeBluetoothProfileManagerClient::kRfcommUuid, | 377 FakeBluetoothProfileManagerClient::kRfcommUuid, |
369 base::Bind(&base::DoNothing), | 378 base::Bind(&base::DoNothing), |
370 base::Bind(&DoNothingDBusErrorCallback)); | 379 base::Bind(&DoNothingDBusErrorCallback)); |
371 | 380 |
372 message_loop_.Run(); | 381 message_loop_.Run(); |
373 | 382 |
374 EXPECT_EQ(1U, success_callback_count_); | 383 EXPECT_EQ(1U, success_callback_count_); |
375 EXPECT_EQ(0U, error_callback_count_); | 384 EXPECT_EQ(0U, error_callback_count_); |
(...skipping 15 matching lines...) Expand all Loading... |
391 EXPECT_EQ(1U, success_callback_count_); | 400 EXPECT_EQ(1U, success_callback_count_); |
392 client_socket = NULL; | 401 client_socket = NULL; |
393 success_callback_count_ = 0; | 402 success_callback_count_ = 0; |
394 error_callback_count_ = 0; | 403 error_callback_count_ = 0; |
395 | 404 |
396 // Now close the server socket. | 405 // Now close the server socket. |
397 server_socket->Disconnect( | 406 server_socket->Disconnect( |
398 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, | 407 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, |
399 base::Unretained(this))); | 408 base::Unretained(this))); |
400 | 409 |
| 410 message_loop_.RunUntilIdle(); |
| 411 |
401 EXPECT_EQ(1U, success_callback_count_); | 412 EXPECT_EQ(1U, success_callback_count_); |
402 } | 413 } |
403 | 414 |
404 TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { | 415 TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { |
405 // Start off with an invisible adapter, register the profile, then make | 416 // Start off with an invisible adapter, register the profile, then make |
406 // the adapter visible. | 417 // the adapter visible. |
407 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = | 418 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = |
408 static_cast<FakeBluetoothAdapterClient*>( | 419 static_cast<FakeBluetoothAdapterClient*>( |
409 DBusThreadManager::Get()->GetBluetoothAdapterClient()); | 420 DBusThreadManager::Get()->GetBluetoothAdapterClient()); |
410 fake_bluetooth_adapter_client->SetVisible(false); | 421 fake_bluetooth_adapter_client->SetVisible(false); |
411 | 422 |
412 adapter_->CreateRfcommService( | 423 adapter_->CreateRfcommService( |
413 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), | 424 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), |
414 BluetoothAdapter::ServiceOptions(), | 425 BluetoothAdapter::ServiceOptions(), |
415 base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, | 426 base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, |
416 base::Unretained(this)), | 427 base::Unretained(this)), |
417 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, | 428 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, |
418 base::Unretained(this))); | 429 base::Unretained(this))); |
| 430 message_loop_.Run(); |
419 | 431 |
420 EXPECT_EQ(1U, success_callback_count_); | 432 EXPECT_EQ(1U, success_callback_count_); |
421 EXPECT_EQ(0U, error_callback_count_); | 433 EXPECT_EQ(0U, error_callback_count_); |
422 EXPECT_TRUE(last_socket_.get() != NULL); | 434 EXPECT_TRUE(last_socket_.get() != NULL); |
423 | 435 |
424 // Take ownership of the socket for the remainder of the test. | 436 // Take ownership of the socket for the remainder of the test. |
425 scoped_refptr<BluetoothSocket> socket = last_socket_; | 437 scoped_refptr<BluetoothSocket> socket = last_socket_; |
426 last_socket_ = NULL; | 438 last_socket_ = NULL; |
427 success_callback_count_ = 0; | 439 success_callback_count_ = 0; |
428 error_callback_count_ = 0; | 440 error_callback_count_ = 0; |
429 | 441 |
430 // But there shouldn't be a profile registered yet. | 442 // But there shouldn't be a profile registered yet. |
431 FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = | 443 FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = |
432 static_cast<FakeBluetoothProfileManagerClient*>( | 444 static_cast<FakeBluetoothProfileManagerClient*>( |
433 DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); | 445 DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); |
434 FakeBluetoothProfileServiceProvider* profile_service_provider = | 446 FakeBluetoothProfileServiceProvider* profile_service_provider = |
435 fake_bluetooth_profile_manager_client->GetProfileServiceProvider( | 447 fake_bluetooth_profile_manager_client->GetProfileServiceProvider( |
436 FakeBluetoothProfileManagerClient::kRfcommUuid); | 448 FakeBluetoothProfileManagerClient::kRfcommUuid); |
437 EXPECT_TRUE(profile_service_provider == NULL); | 449 EXPECT_TRUE(profile_service_provider == NULL); |
438 | 450 |
439 // Make the adapter visible. This should register a profile. | 451 // Make the adapter visible. This should register a profile. |
440 fake_bluetooth_adapter_client->SetVisible(true); | 452 fake_bluetooth_adapter_client->SetVisible(true); |
441 | 453 |
| 454 message_loop_.RunUntilIdle(); |
| 455 |
442 profile_service_provider = | 456 profile_service_provider = |
443 fake_bluetooth_profile_manager_client->GetProfileServiceProvider( | 457 fake_bluetooth_profile_manager_client->GetProfileServiceProvider( |
444 FakeBluetoothProfileManagerClient::kRfcommUuid); | 458 FakeBluetoothProfileManagerClient::kRfcommUuid); |
445 EXPECT_TRUE(profile_service_provider != NULL); | 459 EXPECT_TRUE(profile_service_provider != NULL); |
446 | 460 |
447 // Cleanup the socket. | 461 // Cleanup the socket. |
448 socket->Disconnect( | 462 socket->Disconnect( |
449 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, | 463 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, |
450 base::Unretained(this))); | 464 base::Unretained(this))); |
451 | 465 |
| 466 message_loop_.RunUntilIdle(); |
| 467 |
452 EXPECT_EQ(1U, success_callback_count_); | 468 EXPECT_EQ(1U, success_callback_count_); |
453 } | 469 } |
454 | 470 |
455 TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { | 471 TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { |
456 // The fake adapter starts off visible by default. | 472 // The fake adapter starts off visible by default. |
457 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = | 473 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = |
458 static_cast<FakeBluetoothAdapterClient*>( | 474 static_cast<FakeBluetoothAdapterClient*>( |
459 DBusThreadManager::Get()->GetBluetoothAdapterClient()); | 475 DBusThreadManager::Get()->GetBluetoothAdapterClient()); |
460 | 476 |
461 adapter_->CreateRfcommService( | 477 adapter_->CreateRfcommService( |
462 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), | 478 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), |
463 BluetoothAdapter::ServiceOptions(), | 479 BluetoothAdapter::ServiceOptions(), |
464 base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, | 480 base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, |
465 base::Unretained(this)), | 481 base::Unretained(this)), |
466 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, | 482 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, |
467 base::Unretained(this))); | 483 base::Unretained(this))); |
| 484 message_loop_.Run(); |
468 | 485 |
469 EXPECT_EQ(1U, success_callback_count_); | 486 EXPECT_EQ(1U, success_callback_count_); |
470 EXPECT_EQ(0U, error_callback_count_); | 487 EXPECT_EQ(0U, error_callback_count_); |
471 EXPECT_TRUE(last_socket_.get() != NULL); | 488 EXPECT_TRUE(last_socket_.get() != NULL); |
472 | 489 |
473 // Take ownership of the socket for the remainder of the test. | 490 // Take ownership of the socket for the remainder of the test. |
474 scoped_refptr<BluetoothSocket> socket = last_socket_; | 491 scoped_refptr<BluetoothSocket> socket = last_socket_; |
475 last_socket_ = NULL; | 492 last_socket_ = NULL; |
476 success_callback_count_ = 0; | 493 success_callback_count_ = 0; |
477 error_callback_count_ = 0; | 494 error_callback_count_ = 0; |
478 | 495 |
479 // Make sure the profile was registered with the daemon. | 496 // Make sure the profile was registered with the daemon. |
480 FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = | 497 FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = |
481 static_cast<FakeBluetoothProfileManagerClient*>( | 498 static_cast<FakeBluetoothProfileManagerClient*>( |
482 DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); | 499 DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); |
483 FakeBluetoothProfileServiceProvider* profile_service_provider = | 500 FakeBluetoothProfileServiceProvider* profile_service_provider = |
484 fake_bluetooth_profile_manager_client->GetProfileServiceProvider( | 501 fake_bluetooth_profile_manager_client->GetProfileServiceProvider( |
485 FakeBluetoothProfileManagerClient::kRfcommUuid); | 502 FakeBluetoothProfileManagerClient::kRfcommUuid); |
486 EXPECT_TRUE(profile_service_provider != NULL); | 503 EXPECT_TRUE(profile_service_provider != NULL); |
487 | 504 |
488 // Make the adapter invisible, and fiddle with the profile fake to unregister | 505 // Make the adapter invisible, and fiddle with the profile fake to unregister |
489 // the profile since this doesn't happen automatically. | 506 // the profile since this doesn't happen automatically. |
490 fake_bluetooth_adapter_client->SetVisible(false); | 507 fake_bluetooth_adapter_client->SetVisible(false); |
491 fake_bluetooth_profile_manager_client->UnregisterProfile( | 508 |
492 static_cast<BluetoothSocketChromeOS*>(socket.get())->object_path(), | 509 message_loop_.RunUntilIdle(); |
493 base::Bind(&base::DoNothing), | |
494 base::Bind(&DoNothingDBusErrorCallback)); | |
495 | 510 |
496 // Then make the adapter visible again. This should re-register the profile. | 511 // Then make the adapter visible again. This should re-register the profile. |
497 fake_bluetooth_adapter_client->SetVisible(true); | 512 fake_bluetooth_adapter_client->SetVisible(true); |
498 | 513 |
| 514 message_loop_.RunUntilIdle(); |
| 515 |
499 profile_service_provider = | 516 profile_service_provider = |
500 fake_bluetooth_profile_manager_client->GetProfileServiceProvider( | 517 fake_bluetooth_profile_manager_client->GetProfileServiceProvider( |
501 FakeBluetoothProfileManagerClient::kRfcommUuid); | 518 FakeBluetoothProfileManagerClient::kRfcommUuid); |
502 EXPECT_TRUE(profile_service_provider != NULL); | 519 EXPECT_TRUE(profile_service_provider != NULL); |
503 | 520 |
504 // Cleanup the socket. | 521 // Cleanup the socket. |
505 socket->Disconnect( | 522 socket->Disconnect( |
506 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, | 523 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, |
507 base::Unretained(this))); | 524 base::Unretained(this))); |
508 | 525 |
| 526 message_loop_.RunUntilIdle(); |
| 527 |
509 EXPECT_EQ(1U, success_callback_count_); | 528 EXPECT_EQ(1U, success_callback_count_); |
510 } | 529 } |
511 | 530 |
512 } // namespace chromeos | 531 } // namespace chromeos |
OLD | NEW |