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