| Index: device/bluetooth/bluetooth_socket_chromeos_unittest.cc
|
| diff --git a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc b/device/bluetooth/bluetooth_socket_chromeos_unittest.cc
|
| index 1a4aa96853b9937e6bcf82ae6a04dd853112ebc7..79d43ae8bb5f25d5cd67d181ba018614a8c4d18e 100644
|
| --- a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc
|
| +++ b/device/bluetooth/bluetooth_socket_chromeos_unittest.cc
|
| @@ -12,6 +12,7 @@
|
| #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h"
|
| #include "chromeos/dbus/fake_bluetooth_input_client.h"
|
| #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h"
|
| +#include "chromeos/dbus/fake_bluetooth_profile_service_provider.h"
|
| #include "device/bluetooth/bluetooth_adapter.h"
|
| #include "device/bluetooth/bluetooth_adapter_chromeos.h"
|
| #include "device/bluetooth/bluetooth_adapter_factory.h"
|
| @@ -144,6 +145,9 @@ class BluetoothSocketChromeOSTest : public testing::Test {
|
| void CreateServiceSuccessCallback(scoped_refptr<BluetoothSocket> socket) {
|
| ++success_callback_count_;
|
| last_socket_ = socket;
|
| +
|
| + if (message_loop_.is_running())
|
| + message_loop_.Quit();
|
| }
|
|
|
| void AcceptSuccessCallback(const BluetoothDevice* device,
|
| @@ -187,7 +191,6 @@ TEST_F(BluetoothSocketChromeOSTest, Connect) {
|
| base::Unretained(this)),
|
| base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback,
|
| base::Unretained(this)));
|
| -
|
| message_loop_.Run();
|
|
|
| EXPECT_EQ(1U, success_callback_count_);
|
| @@ -297,6 +300,8 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) {
|
| base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback,
|
| base::Unretained(this)));
|
|
|
| + message_loop_.Run();
|
| +
|
| EXPECT_EQ(1U, success_callback_count_);
|
| EXPECT_EQ(0U, error_callback_count_);
|
| EXPECT_TRUE(last_socket_.get() != NULL);
|
| @@ -325,6 +330,8 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) {
|
| base::Bind(&base::DoNothing),
|
| base::Bind(&DoNothingDBusErrorCallback));
|
|
|
| + message_loop_.RunUntilIdle();
|
| +
|
| server_socket->Accept(
|
| base::Bind(&BluetoothSocketChromeOSTest::AcceptSuccessCallback,
|
| base::Unretained(this)),
|
| @@ -363,6 +370,8 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) {
|
| base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback,
|
| base::Unretained(this)));
|
|
|
| + message_loop_.RunUntilIdle();
|
| +
|
| fake_bluetooth_device_client->ConnectProfile(
|
| static_cast<BluetoothDeviceChromeOS*>(device)->object_path(),
|
| FakeBluetoothProfileManagerClient::kRfcommUuid,
|
| @@ -398,6 +407,8 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) {
|
| base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback,
|
| base::Unretained(this)));
|
|
|
| + message_loop_.RunUntilIdle();
|
| +
|
| EXPECT_EQ(1U, success_callback_count_);
|
| }
|
|
|
| @@ -416,6 +427,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) {
|
| base::Unretained(this)),
|
| base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback,
|
| base::Unretained(this)));
|
| + message_loop_.Run();
|
|
|
| EXPECT_EQ(1U, success_callback_count_);
|
| EXPECT_EQ(0U, error_callback_count_);
|
| @@ -439,6 +451,8 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) {
|
| // Make the adapter visible. This should register a profile.
|
| fake_bluetooth_adapter_client->SetVisible(true);
|
|
|
| + message_loop_.RunUntilIdle();
|
| +
|
| profile_service_provider =
|
| fake_bluetooth_profile_manager_client->GetProfileServiceProvider(
|
| FakeBluetoothProfileManagerClient::kRfcommUuid);
|
| @@ -449,6 +463,8 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) {
|
| base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback,
|
| base::Unretained(this)));
|
|
|
| + message_loop_.RunUntilIdle();
|
| +
|
| EXPECT_EQ(1U, success_callback_count_);
|
| }
|
|
|
| @@ -465,6 +481,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) {
|
| base::Unretained(this)),
|
| base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback,
|
| base::Unretained(this)));
|
| + message_loop_.Run();
|
|
|
| EXPECT_EQ(1U, success_callback_count_);
|
| EXPECT_EQ(0U, error_callback_count_);
|
| @@ -488,14 +505,14 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) {
|
| // Make the adapter invisible, and fiddle with the profile fake to unregister
|
| // the profile since this doesn't happen automatically.
|
| fake_bluetooth_adapter_client->SetVisible(false);
|
| - fake_bluetooth_profile_manager_client->UnregisterProfile(
|
| - static_cast<BluetoothSocketChromeOS*>(socket.get())->object_path(),
|
| - base::Bind(&base::DoNothing),
|
| - base::Bind(&DoNothingDBusErrorCallback));
|
| +
|
| + message_loop_.RunUntilIdle();
|
|
|
| // Then make the adapter visible again. This should re-register the profile.
|
| fake_bluetooth_adapter_client->SetVisible(true);
|
|
|
| + message_loop_.RunUntilIdle();
|
| +
|
| profile_service_provider =
|
| fake_bluetooth_profile_manager_client->GetProfileServiceProvider(
|
| FakeBluetoothProfileManagerClient::kRfcommUuid);
|
| @@ -506,6 +523,8 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) {
|
| base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback,
|
| base::Unretained(this)));
|
|
|
| + message_loop_.RunUntilIdle();
|
| +
|
| EXPECT_EQ(1U, success_callback_count_);
|
| }
|
|
|
|
|