| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "chromeos/dbus/bluetooth_profile_service_provider.h" | 7 #include "chromeos/dbus/bluetooth_profile_service_provider.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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 profile_->RemoveDelegate(fake_delegate_autopair_.device_path_, | 185 profile_->RemoveDelegate(fake_delegate_autopair_.device_path_, |
| 186 base::Bind(&base::DoNothing)); | 186 base::Bind(&base::DoNothing)); |
| 187 | 187 |
| 188 EXPECT_EQ(1U, profile_->DelegateCount()); | 188 EXPECT_EQ(1U, profile_->DelegateCount()); |
| 189 | 189 |
| 190 profile_->RemoveDelegate(fake_delegate_paired_.device_path_, | 190 profile_->RemoveDelegate(fake_delegate_paired_.device_path_, |
| 191 base::Bind(&base::DoNothing)); | 191 base::Bind(&base::DoNothing)); |
| 192 | 192 |
| 193 EXPECT_EQ(0U, profile_->DelegateCount()); | 193 EXPECT_EQ(0U, profile_->DelegateCount()); |
| 194 }; | 194 } |
| 195 | 195 |
| 196 TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { | 196 TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { |
| 197 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | 197 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
| 198 BluetoothProfileManagerClient::Options options; | 198 BluetoothProfileManagerClient::Options options; |
| 199 | 199 |
| 200 options.require_authentication.reset(new bool(false)); | 200 options.require_authentication.reset(new bool(false)); |
| 201 | 201 |
| 202 BluetoothAdapterProfileChromeOS::Register( | 202 BluetoothAdapterProfileChromeOS::Register( |
| 203 uuid, options, | 203 uuid, options, |
| 204 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, | 204 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 220 base::Unretained(this)), | 220 base::Unretained(this)), |
| 221 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 221 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
| 222 base::Unretained(this))); | 222 base::Unretained(this))); |
| 223 | 223 |
| 224 message_loop_.RunUntilIdle(); | 224 message_loop_.RunUntilIdle(); |
| 225 | 225 |
| 226 EXPECT_EQ(1U, success_callback_count_); | 226 EXPECT_EQ(1U, success_callback_count_); |
| 227 EXPECT_EQ(1U, error_callback_count_); | 227 EXPECT_EQ(1U, error_callback_count_); |
| 228 | 228 |
| 229 EXPECT_EQ(0U, fake_delegate_paired_.connections_); | 229 EXPECT_EQ(0U, fake_delegate_paired_.connections_); |
| 230 }; | 230 } |
| 231 | 231 |
| 232 TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { | 232 TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { |
| 233 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | 233 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
| 234 BluetoothProfileManagerClient::Options options; | 234 BluetoothProfileManagerClient::Options options; |
| 235 | 235 |
| 236 options.require_authentication.reset(new bool(false)); | 236 options.require_authentication.reset(new bool(false)); |
| 237 | 237 |
| 238 BluetoothAdapterProfileChromeOS::Register( | 238 BluetoothAdapterProfileChromeOS::Register( |
| 239 uuid, options, | 239 uuid, options, |
| 240 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, | 240 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 base::Unretained(this)), | 296 base::Unretained(this)), |
| 297 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 297 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
| 298 base::Unretained(this))); | 298 base::Unretained(this))); |
| 299 | 299 |
| 300 message_loop_.RunUntilIdle(); | 300 message_loop_.RunUntilIdle(); |
| 301 | 301 |
| 302 EXPECT_EQ(4U, success_callback_count_); | 302 EXPECT_EQ(4U, success_callback_count_); |
| 303 EXPECT_EQ(0U, error_callback_count_); | 303 EXPECT_EQ(0U, error_callback_count_); |
| 304 | 304 |
| 305 EXPECT_EQ(1U, fake_delegate_listen_.connections_); | 305 EXPECT_EQ(1U, fake_delegate_listen_.connections_); |
| 306 }; | 306 } |
| 307 | 307 |
| 308 TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { | 308 TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { |
| 309 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | 309 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
| 310 BluetoothProfileManagerClient::Options options; | 310 BluetoothProfileManagerClient::Options options; |
| 311 BluetoothAdapterChromeOS* adapter = | 311 BluetoothAdapterChromeOS* adapter = |
| 312 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); | 312 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); |
| 313 | 313 |
| 314 options.require_authentication.reset(new bool(false)); | 314 options.require_authentication.reset(new bool(false)); |
| 315 | 315 |
| 316 success_callback_count_ = 0; | 316 success_callback_count_ = 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 337 EXPECT_TRUE(profile_user_ptr_); | 337 EXPECT_TRUE(profile_user_ptr_); |
| 338 EXPECT_EQ(2U, success_callback_count_); | 338 EXPECT_EQ(2U, success_callback_count_); |
| 339 EXPECT_EQ(0U, error_callback_count_); | 339 EXPECT_EQ(0U, error_callback_count_); |
| 340 | 340 |
| 341 adapter->ReleaseProfile(fake_delegate_paired_.device_path_, | 341 adapter->ReleaseProfile(fake_delegate_paired_.device_path_, |
| 342 profile_user_ptr_); | 342 profile_user_ptr_); |
| 343 adapter->ReleaseProfile(fake_delegate_autopair_.device_path_, | 343 adapter->ReleaseProfile(fake_delegate_autopair_.device_path_, |
| 344 profile_user_ptr_); | 344 profile_user_ptr_); |
| 345 | 345 |
| 346 message_loop_.RunUntilIdle(); | 346 message_loop_.RunUntilIdle(); |
| 347 }; | 347 } |
| 348 | 348 |
| 349 TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { | 349 TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { |
| 350 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kUnregisterableUuid); | 350 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kUnregisterableUuid); |
| 351 BluetoothProfileManagerClient::Options options; | 351 BluetoothProfileManagerClient::Options options; |
| 352 BluetoothAdapterChromeOS* adapter = | 352 BluetoothAdapterChromeOS* adapter = |
| 353 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); | 353 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); |
| 354 | 354 |
| 355 options.require_authentication.reset(new bool(false)); | 355 options.require_authentication.reset(new bool(false)); |
| 356 | 356 |
| 357 success_callback_count_ = 0; | 357 success_callback_count_ = 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 371 base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback, | 371 base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback, |
| 372 base::Unretained(this)), | 372 base::Unretained(this)), |
| 373 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, | 373 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, |
| 374 base::Unretained(this))); | 374 base::Unretained(this))); |
| 375 | 375 |
| 376 message_loop_.RunUntilIdle(); | 376 message_loop_.RunUntilIdle(); |
| 377 | 377 |
| 378 EXPECT_FALSE(profile_user_ptr_); | 378 EXPECT_FALSE(profile_user_ptr_); |
| 379 EXPECT_EQ(0U, success_callback_count_); | 379 EXPECT_EQ(0U, success_callback_count_); |
| 380 EXPECT_EQ(2U, error_callback_count_); | 380 EXPECT_EQ(2U, error_callback_count_); |
| 381 }; | 381 } |
| 382 | 382 |
| 383 } // namespace chromeos | 383 } // namespace chromeos |
| OLD | NEW |