| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 6 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| 7 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 7 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
| 8 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 8 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
| 9 #include "chromeos/dbus/fake_bluetooth_input_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_input_client.h" |
| 10 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 void Callback() { | 85 void Callback() { |
| 86 ++callback_count_; | 86 ++callback_count_; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void ErrorCallback() { | 89 void ErrorCallback() { |
| 90 ++error_callback_count_; | 90 ++error_callback_count_; |
| 91 | 91 |
| 92 message_loop_.Quit(); | 92 message_loop_.Quit(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void ConnectToProfileErrorCallback(const std::string error) { | |
| 96 ErrorCallback(); | |
| 97 } | |
| 98 | |
| 99 void ProfileCallback(BluetoothProfile* profile) { | 95 void ProfileCallback(BluetoothProfile* profile) { |
| 100 ++profile_callback_count_; | 96 ++profile_callback_count_; |
| 101 last_profile_ = profile; | 97 last_profile_ = profile; |
| 102 } | 98 } |
| 103 | 99 |
| 104 void ConnectionCallback(const BluetoothDevice *device, | 100 void ConnectionCallback(const BluetoothDevice *device, |
| 105 scoped_refptr<BluetoothSocket> socket) { | 101 scoped_refptr<BluetoothSocket> socket) { |
| 106 ++connection_callback_count_; | 102 ++connection_callback_count_; |
| 107 last_device_ = device; | 103 last_device_ = device; |
| 108 last_socket_ = socket; | 104 last_socket_ = socket; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // connection callback to be called with the device we passed and a new | 150 // connection callback to be called with the device we passed and a new |
| 155 // socket instance. | 151 // socket instance. |
| 156 BluetoothDevice* device = adapter_->GetDevice( | 152 BluetoothDevice* device = adapter_->GetDevice( |
| 157 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 153 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
| 158 ASSERT_TRUE(device != NULL); | 154 ASSERT_TRUE(device != NULL); |
| 159 | 155 |
| 160 device->ConnectToProfile( | 156 device->ConnectToProfile( |
| 161 profile, | 157 profile, |
| 162 base::Bind(&BluetoothProfileChromeOSTest::Callback, | 158 base::Bind(&BluetoothProfileChromeOSTest::Callback, |
| 163 base::Unretained(this)), | 159 base::Unretained(this)), |
| 164 base::Bind(&BluetoothProfileChromeOSTest::ConnectToProfileErrorCallback, | 160 base::Bind(&BluetoothProfileChromeOSTest::ErrorCallback, |
| 165 base::Unretained(this))); | 161 base::Unretained(this))); |
| 166 | 162 |
| 167 message_loop_.Run(); | 163 message_loop_.Run(); |
| 168 | 164 |
| 169 EXPECT_EQ(1U, callback_count_); | 165 EXPECT_EQ(1U, callback_count_); |
| 170 EXPECT_EQ(0U, error_callback_count_); | 166 EXPECT_EQ(0U, error_callback_count_); |
| 171 | 167 |
| 172 EXPECT_EQ(1U, connection_callback_count_); | 168 EXPECT_EQ(1U, connection_callback_count_); |
| 173 EXPECT_EQ(device, last_device_); | 169 EXPECT_EQ(device, last_device_); |
| 174 EXPECT_TRUE(last_socket_.get() != NULL); | 170 EXPECT_TRUE(last_socket_.get() != NULL); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // connection callback to be called with the device we passed and a new | 276 // connection callback to be called with the device we passed and a new |
| 281 // socket instance. | 277 // socket instance. |
| 282 BluetoothDevice* device = adapter_->GetDevice( | 278 BluetoothDevice* device = adapter_->GetDevice( |
| 283 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 279 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
| 284 ASSERT_TRUE(device != NULL); | 280 ASSERT_TRUE(device != NULL); |
| 285 | 281 |
| 286 device->ConnectToProfile( | 282 device->ConnectToProfile( |
| 287 profile, | 283 profile, |
| 288 base::Bind(&BluetoothProfileChromeOSTest::Callback, | 284 base::Bind(&BluetoothProfileChromeOSTest::Callback, |
| 289 base::Unretained(this)), | 285 base::Unretained(this)), |
| 290 base::Bind(&BluetoothProfileChromeOSTest::ConnectToProfileErrorCallback, | 286 base::Bind(&BluetoothProfileChromeOSTest::ErrorCallback, |
| 291 base::Unretained(this))); | 287 base::Unretained(this))); |
| 292 | 288 |
| 293 message_loop_.Run(); | 289 message_loop_.Run(); |
| 294 | 290 |
| 295 EXPECT_EQ(1U, callback_count_); | 291 EXPECT_EQ(1U, callback_count_); |
| 296 EXPECT_EQ(0U, error_callback_count_); | 292 EXPECT_EQ(0U, error_callback_count_); |
| 297 | 293 |
| 298 EXPECT_EQ(1U, connection_callback_count_); | 294 EXPECT_EQ(1U, connection_callback_count_); |
| 299 EXPECT_EQ(device, last_device_); | 295 EXPECT_EQ(device, last_device_); |
| 300 EXPECT_TRUE(last_socket_.get() != NULL); | 296 EXPECT_TRUE(last_socket_.get() != NULL); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 // Unregister the profile, make sure it's no longer registered. | 365 // Unregister the profile, make sure it's no longer registered. |
| 370 last_profile_->Unregister(); | 366 last_profile_->Unregister(); |
| 371 | 367 |
| 372 profile_service_provider = | 368 profile_service_provider = |
| 373 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( | 369 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( |
| 374 FakeBluetoothProfileManagerClient::kRfcommUuid); | 370 FakeBluetoothProfileManagerClient::kRfcommUuid); |
| 375 EXPECT_TRUE(profile_service_provider == NULL); | 371 EXPECT_TRUE(profile_service_provider == NULL); |
| 376 } | 372 } |
| 377 | 373 |
| 378 } // namespace chromeos | 374 } // namespace chromeos |
| OLD | NEW |