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" |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // Cleanup the socket. | 521 // Cleanup the socket. |
522 socket->Disconnect( | 522 socket->Disconnect( |
523 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, | 523 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, |
524 base::Unretained(this))); | 524 base::Unretained(this))); |
525 | 525 |
526 message_loop_.RunUntilIdle(); | 526 message_loop_.RunUntilIdle(); |
527 | 527 |
528 EXPECT_EQ(1U, success_callback_count_); | 528 EXPECT_EQ(1U, success_callback_count_); |
529 } | 529 } |
530 | 530 |
| 531 TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { |
| 532 BluetoothDevice* device = adapter_->GetDevice( |
| 533 FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress); |
| 534 ASSERT_TRUE(device != NULL); |
| 535 |
| 536 device->ConnectToService( |
| 537 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), |
| 538 base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, |
| 539 base::Unretained(this)), |
| 540 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, |
| 541 base::Unretained(this))); |
| 542 message_loop_.Run(); |
| 543 |
| 544 EXPECT_EQ(0U, success_callback_count_); |
| 545 EXPECT_EQ(1U, error_callback_count_); |
| 546 EXPECT_TRUE(last_socket_.get() == NULL); |
| 547 |
| 548 device->ConnectToService( |
| 549 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), |
| 550 base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, |
| 551 base::Unretained(this)), |
| 552 base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, |
| 553 base::Unretained(this))); |
| 554 message_loop_.Run(); |
| 555 |
| 556 EXPECT_EQ(0U, success_callback_count_); |
| 557 EXPECT_EQ(2U, error_callback_count_); |
| 558 EXPECT_TRUE(last_socket_.get() == NULL); |
| 559 } |
| 560 |
531 } // namespace chromeos | 561 } // namespace chromeos |
OLD | NEW |