Chromium Code Reviews| 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" |
| 11 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 11 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
| 12 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" | 12 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" |
| 13 #include "device/bluetooth/bluetooth_adapter.h" | 13 #include "device/bluetooth/bluetooth_adapter.h" |
| 14 #include "device/bluetooth/bluetooth_adapter_chromeos.h" | 14 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
| 15 #include "device/bluetooth/bluetooth_adapter_factory.h" | 15 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 16 #include "device/bluetooth/bluetooth_adapter_profile_chromeos.h" | 16 #include "device/bluetooth/bluetooth_adapter_profile_chromeos.h" |
| 17 #include "device/bluetooth/bluetooth_uuid.h" | 17 #include "device/bluetooth/bluetooth_uuid.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 using device::BluetoothAdapter; | 20 using device::BluetoothAdapter; |
| 21 using device::BluetoothUUID; | 21 using device::BluetoothUUID; |
| 22 | 22 |
| 23 namespace { | |
| 24 | |
| 25 void DoNothingDBusErrorCallback(const std::string& error_name, | |
| 26 const std::string& error_message) { | |
| 27 } | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 31 namespace chromeos { | 23 namespace chromeos { |
| 32 | 24 |
| 33 class BluetoothAdapterProfileChromeOSTest : public testing::Test { | 25 class BluetoothAdapterProfileChromeOSTest : public testing::Test { |
| 34 public: | 26 public: |
| 35 BluetoothAdapterProfileChromeOSTest() | 27 BluetoothAdapterProfileChromeOSTest() |
| 36 : fake_delegate_paired_(FakeBluetoothDeviceClient::kPairedDevicePath), | 28 : success_callback_count_(0), |
| 29 error_callback_count_(0), | |
| 30 fake_delegate_paired_(FakeBluetoothDeviceClient::kPairedDevicePath), | |
| 37 fake_delegate_autopair_(FakeBluetoothDeviceClient::kLegacyAutopairPath), | 31 fake_delegate_autopair_(FakeBluetoothDeviceClient::kLegacyAutopairPath), |
| 38 fake_delegate_listen_(""), | 32 fake_delegate_listen_(""), |
| 39 profile_(nullptr), | 33 profile_user_ptr_(nullptr) {} |
| 40 success_callback_count_(0), | |
| 41 error_callback_count_(0) {} | |
| 42 | 34 |
| 43 void SetUp() override { | 35 void SetUp() override { |
| 44 scoped_ptr<DBusThreadManagerSetter> dbus_setter = | 36 scoped_ptr<DBusThreadManagerSetter> dbus_setter = |
| 45 DBusThreadManager::GetSetterForTesting(); | 37 DBusThreadManager::GetSetterForTesting(); |
| 46 | 38 |
| 47 dbus_setter->SetBluetoothAdapterClient( | 39 dbus_setter->SetBluetoothAdapterClient( |
| 48 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); | 40 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); |
| 49 dbus_setter->SetBluetoothAgentManagerClient( | 41 dbus_setter->SetBluetoothAgentManagerClient( |
| 50 scoped_ptr<BluetoothAgentManagerClient>( | 42 scoped_ptr<BluetoothAgentManagerClient>( |
| 51 new FakeBluetoothAgentManagerClient)); | 43 new FakeBluetoothAgentManagerClient)); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 63 ASSERT_TRUE(adapter_->IsInitialized()); | 55 ASSERT_TRUE(adapter_->IsInitialized()); |
| 64 ASSERT_TRUE(adapter_->IsPresent()); | 56 ASSERT_TRUE(adapter_->IsPresent()); |
| 65 | 57 |
| 66 // Turn on the adapter. | 58 // Turn on the adapter. |
| 67 adapter_->SetPowered(true, base::Bind(&base::DoNothing), | 59 adapter_->SetPowered(true, base::Bind(&base::DoNothing), |
| 68 base::Bind(&base::DoNothing)); | 60 base::Bind(&base::DoNothing)); |
| 69 ASSERT_TRUE(adapter_->IsPowered()); | 61 ASSERT_TRUE(adapter_->IsPowered()); |
| 70 } | 62 } |
| 71 | 63 |
| 72 void TearDown() override { | 64 void TearDown() override { |
| 65 profile_.reset(); | |
|
Ilya Sherman
2015/03/09 18:18:51
Are you calling this explicitly because the order
Marie Janssen
2015/03/09 18:38:40
Order is important here, the profile should be rel
| |
| 73 adapter_ = nullptr; | 66 adapter_ = nullptr; |
| 74 DBusThreadManager::Shutdown(); | 67 DBusThreadManager::Shutdown(); |
| 75 } | 68 } |
| 76 | 69 |
| 77 void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { | 70 void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { |
| 78 adapter_ = adapter; | 71 adapter_ = adapter; |
| 79 } | 72 } |
| 80 | 73 |
| 81 class FakeDelegate | 74 class FakeDelegate |
| 82 : public chromeos::BluetoothProfileServiceProvider::Delegate { | 75 : public chromeos::BluetoothProfileServiceProvider::Delegate { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 95 scoped_ptr<dbus::FileDescriptor> fd, | 88 scoped_ptr<dbus::FileDescriptor> fd, |
| 96 const BluetoothProfileServiceProvider::Delegate::Options& options, | 89 const BluetoothProfileServiceProvider::Delegate::Options& options, |
| 97 const ConfirmationCallback& callback) override { | 90 const ConfirmationCallback& callback) override { |
| 98 VLOG(1) << "connection for " << device_path.value() << " on " | 91 VLOG(1) << "connection for " << device_path.value() << " on " |
| 99 << device_path_.value(); | 92 << device_path_.value(); |
| 100 ++connections_; | 93 ++connections_; |
| 101 fd->CheckValidity(); | 94 fd->CheckValidity(); |
| 102 close(fd->TakeValue()); | 95 close(fd->TakeValue()); |
| 103 callback.Run(SUCCESS); | 96 callback.Run(SUCCESS); |
| 104 if (device_path_.value() != "") | 97 if (device_path_.value() != "") |
| 105 ASSERT_TRUE(device_path == device_path_); | 98 ASSERT_EQ(device_path_, device_path); |
| 106 } | 99 } |
| 107 | 100 |
| 108 void RequestDisconnection(const dbus::ObjectPath& device_path, | 101 void RequestDisconnection(const dbus::ObjectPath& device_path, |
| 109 const ConfirmationCallback& callback) override { | 102 const ConfirmationCallback& callback) override { |
| 110 VLOG(1) << "disconnect " << device_path.value(); | 103 VLOG(1) << "disconnect " << device_path.value(); |
| 111 ++disconnections_; | 104 ++disconnections_; |
| 112 } | 105 } |
| 113 | 106 |
| 114 void Cancel() override { | 107 void Cancel() override { |
| 115 VLOG(1) << "cancel"; | 108 VLOG(1) << "cancel"; |
| 116 // noop | 109 // noop |
| 117 } | 110 } |
| 118 | 111 |
| 119 unsigned int connections_; | 112 unsigned int connections_; |
| 120 unsigned int disconnections_; | 113 unsigned int disconnections_; |
| 121 dbus::ObjectPath device_path_; | 114 dbus::ObjectPath device_path_; |
| 122 }; | 115 }; |
| 123 | 116 |
| 124 FakeDelegate fake_delegate_paired_; | 117 void ProfileSuccessCallback( |
| 125 FakeDelegate fake_delegate_autopair_; | 118 scoped_ptr<BluetoothAdapterProfileChromeOS> profile) { |
| 126 FakeDelegate fake_delegate_listen_; | 119 profile_.swap(profile); |
| 120 ++success_callback_count_; | |
| 121 } | |
| 127 | 122 |
| 128 BluetoothAdapterProfileChromeOS* profile_; | 123 void ProfileUserSuccessCallback(BluetoothAdapterProfileChromeOS* profile) { |
| 124 profile_user_ptr_ = profile; | |
| 125 ++success_callback_count_; | |
| 126 } | |
| 127 | |
| 128 void MatchedProfileCallback(BluetoothAdapterProfileChromeOS* profile) { | |
| 129 VLOG(1) << "Matched Profile Callback"; | |
|
Ilya Sherman
2015/03/09 18:18:51
nit: You probably don't actually want log statemen
Marie Janssen
2015/03/09 18:38:40
Done.
| |
| 130 ASSERT_EQ(profile_user_ptr_, profile); | |
| 131 ++success_callback_count_; | |
| 132 } | |
| 129 | 133 |
| 130 void DBusConnectSuccessCallback() { ++success_callback_count_; } | 134 void DBusConnectSuccessCallback() { ++success_callback_count_; } |
| 131 | 135 |
| 132 void DBusErrorCallback(const std::string& error_name, | 136 void DBusErrorCallback(const std::string& error_name, |
| 133 const std::string& error_message) { | 137 const std::string& error_message) { |
| 134 VLOG(1) << "DBus Connect Error: " << error_name << " - " << error_message; | 138 VLOG(1) << "DBus Connect Error: " << error_name << " - " << error_message; |
| 135 ++error_callback_count_; | 139 ++error_callback_count_; |
| 136 } | 140 } |
| 137 | 141 |
| 142 void BasicErrorCallback(const std::string& error_message) { | |
| 143 VLOG(1) << "Error: " << error_message; | |
| 144 ++error_callback_count_; | |
| 145 } | |
| 146 | |
| 138 protected: | 147 protected: |
| 139 base::MessageLoop message_loop_; | 148 base::MessageLoop message_loop_; |
| 140 | 149 |
| 141 scoped_refptr<BluetoothAdapter> adapter_; | 150 scoped_refptr<BluetoothAdapter> adapter_; |
| 142 | 151 |
| 143 unsigned int success_callback_count_; | 152 unsigned int success_callback_count_; |
| 144 unsigned int error_callback_count_; | 153 unsigned int error_callback_count_; |
| 154 | |
| 155 FakeDelegate fake_delegate_paired_; | |
| 156 FakeDelegate fake_delegate_autopair_; | |
| 157 FakeDelegate fake_delegate_listen_; | |
| 158 | |
| 159 scoped_ptr<BluetoothAdapterProfileChromeOS> profile_; | |
| 160 BluetoothAdapterProfileChromeOS* profile_user_ptr_; | |
|
Ilya Sherman
2015/03/09 18:18:51
IMO, it would be nice to document these, to clarif
Marie Janssen
2015/03/09 18:38:40
Done.
| |
| 145 }; | 161 }; |
| 146 | 162 |
| 147 TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { | 163 TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { |
| 148 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | 164 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
| 149 BluetoothProfileManagerClient::Options options; | 165 BluetoothProfileManagerClient::Options options; |
| 150 | 166 |
| 151 options.require_authentication.reset(new bool(false)); | 167 options.require_authentication.reset(new bool(false)); |
| 152 | 168 |
| 153 profile_ = BluetoothAdapterProfileChromeOS::Register( | 169 BluetoothAdapterProfileChromeOS::Register( |
| 154 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options, | 170 uuid, options, |
| 155 base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback)); | 171 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, |
| 172 base::Unretained(this)), | |
| 173 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | |
| 174 base::Unretained(this))); | |
| 156 | 175 |
| 157 message_loop_.RunUntilIdle(); | 176 message_loop_.RunUntilIdle(); |
| 158 | 177 |
| 159 EXPECT_TRUE(profile_); | 178 EXPECT_TRUE(profile_); |
| 179 EXPECT_EQ(1U, success_callback_count_); | |
| 180 EXPECT_EQ(0U, error_callback_count_); | |
| 160 | 181 |
| 161 EXPECT_EQ(0U, profile_->DelegateCount()); | 182 EXPECT_EQ(0U, profile_->DelegateCount()); |
| 162 | 183 |
| 163 profile_->SetDelegate(fake_delegate_paired_.device_path_, | 184 profile_->SetDelegate(fake_delegate_paired_.device_path_, |
| 164 &fake_delegate_paired_); | 185 &fake_delegate_paired_); |
| 165 | 186 |
| 166 EXPECT_EQ(1U, profile_->DelegateCount()); | 187 EXPECT_EQ(1U, profile_->DelegateCount()); |
| 167 | 188 |
| 168 profile_->RemoveDelegate(fake_delegate_autopair_.device_path_, | 189 profile_->RemoveDelegate(fake_delegate_autopair_.device_path_, |
| 169 base::Bind(&base::DoNothing)); | 190 base::Bind(&base::DoNothing)); |
| 170 | 191 |
| 171 EXPECT_EQ(1U, profile_->DelegateCount()); | 192 EXPECT_EQ(1U, profile_->DelegateCount()); |
| 172 | 193 |
| 173 profile_->RemoveDelegate(fake_delegate_paired_.device_path_, | 194 profile_->RemoveDelegate(fake_delegate_paired_.device_path_, |
| 174 base::Bind(&base::DoNothing)); | 195 base::Bind(&base::DoNothing)); |
| 175 | 196 |
| 176 EXPECT_EQ(0U, profile_->DelegateCount()); | 197 EXPECT_EQ(0U, profile_->DelegateCount()); |
| 177 | |
| 178 delete profile_; | |
| 179 }; | 198 }; |
| 180 | 199 |
| 181 TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { | 200 TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { |
| 182 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | 201 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
| 183 BluetoothProfileManagerClient::Options options; | 202 BluetoothProfileManagerClient::Options options; |
| 184 | 203 |
| 185 options.require_authentication.reset(new bool(false)); | 204 options.require_authentication.reset(new bool(false)); |
| 186 | 205 |
| 187 profile_ = BluetoothAdapterProfileChromeOS::Register( | 206 BluetoothAdapterProfileChromeOS::Register( |
| 188 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options, | 207 uuid, options, |
| 189 base::Bind( | 208 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, |
| 190 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, | 209 base::Unretained(this)), |
| 191 base::Unretained(this)), | |
| 192 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 210 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
| 193 base::Unretained(this))); | 211 base::Unretained(this))); |
| 194 | 212 |
| 195 message_loop_.RunUntilIdle(); | 213 message_loop_.RunUntilIdle(); |
| 196 | 214 |
| 197 EXPECT_TRUE(profile_); | 215 EXPECT_TRUE(profile_); |
| 198 EXPECT_EQ(1U, success_callback_count_); | 216 EXPECT_EQ(1U, success_callback_count_); |
| 199 EXPECT_EQ(0U, error_callback_count_); | 217 EXPECT_EQ(0U, error_callback_count_); |
| 200 | 218 |
| 201 DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( | 219 DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( |
| 202 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), | 220 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), |
| 203 FakeBluetoothProfileManagerClient::kRfcommUuid, | 221 FakeBluetoothProfileManagerClient::kRfcommUuid, |
| 204 base::Bind( | 222 base::Bind( |
| 205 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, | 223 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, |
| 206 base::Unretained(this)), | 224 base::Unretained(this)), |
| 207 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 225 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
| 208 base::Unretained(this))); | 226 base::Unretained(this))); |
| 209 | 227 |
| 210 message_loop_.RunUntilIdle(); | 228 message_loop_.RunUntilIdle(); |
| 211 | 229 |
| 212 EXPECT_EQ(1U, success_callback_count_); | 230 EXPECT_EQ(1U, success_callback_count_); |
| 213 EXPECT_EQ(1U, error_callback_count_); | 231 EXPECT_EQ(1U, error_callback_count_); |
| 214 | 232 |
| 215 EXPECT_EQ(0U, fake_delegate_paired_.connections_); | 233 EXPECT_EQ(0U, fake_delegate_paired_.connections_); |
| 216 | |
| 217 delete profile_; | |
| 218 }; | 234 }; |
| 219 | 235 |
| 220 TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { | 236 TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { |
| 221 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | 237 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
| 222 BluetoothProfileManagerClient::Options options; | 238 BluetoothProfileManagerClient::Options options; |
| 223 | 239 |
| 224 options.require_authentication.reset(new bool(false)); | 240 options.require_authentication.reset(new bool(false)); |
| 225 | 241 |
| 226 profile_ = BluetoothAdapterProfileChromeOS::Register( | 242 BluetoothAdapterProfileChromeOS::Register( |
| 227 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options, | 243 uuid, options, |
| 228 base::Bind( | 244 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, |
| 229 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, | 245 base::Unretained(this)), |
| 230 base::Unretained(this)), | |
| 231 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 246 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
| 232 base::Unretained(this))); | 247 base::Unretained(this))); |
| 233 | 248 |
| 234 message_loop_.RunUntilIdle(); | 249 message_loop_.RunUntilIdle(); |
| 235 | 250 |
| 236 ASSERT_TRUE(profile_); | 251 ASSERT_TRUE(profile_); |
| 252 ASSERT_EQ(1U, success_callback_count_); | |
| 253 ASSERT_EQ(0U, error_callback_count_); | |
| 237 | 254 |
| 238 profile_->SetDelegate(fake_delegate_paired_.device_path_, | 255 profile_->SetDelegate(fake_delegate_paired_.device_path_, |
| 239 &fake_delegate_paired_); | 256 &fake_delegate_paired_); |
| 240 profile_->SetDelegate(fake_delegate_autopair_.device_path_, | 257 profile_->SetDelegate(fake_delegate_autopair_.device_path_, |
| 241 &fake_delegate_autopair_); | 258 &fake_delegate_autopair_); |
| 242 profile_->SetDelegate(fake_delegate_listen_.device_path_, | 259 profile_->SetDelegate(fake_delegate_listen_.device_path_, |
| 243 &fake_delegate_listen_); | 260 &fake_delegate_listen_); |
| 244 | 261 |
| 245 DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( | 262 DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( |
| 246 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), | 263 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 base::Unretained(this)), | 300 base::Unretained(this)), |
| 284 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 301 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
| 285 base::Unretained(this))); | 302 base::Unretained(this))); |
| 286 | 303 |
| 287 message_loop_.RunUntilIdle(); | 304 message_loop_.RunUntilIdle(); |
| 288 | 305 |
| 289 EXPECT_EQ(4U, success_callback_count_); | 306 EXPECT_EQ(4U, success_callback_count_); |
| 290 EXPECT_EQ(0U, error_callback_count_); | 307 EXPECT_EQ(0U, error_callback_count_); |
| 291 | 308 |
| 292 EXPECT_EQ(1U, fake_delegate_listen_.connections_); | 309 EXPECT_EQ(1U, fake_delegate_listen_.connections_); |
| 310 }; | |
| 293 | 311 |
| 294 delete profile_; | 312 TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { |
| 313 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | |
| 314 BluetoothProfileManagerClient::Options options; | |
| 315 BluetoothAdapterChromeOS* adapter = | |
| 316 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); | |
| 317 | |
| 318 options.require_authentication.reset(new bool(false)); | |
| 319 | |
| 320 success_callback_count_ = 0; | |
| 321 error_callback_count_ = 0; | |
| 322 | |
| 323 adapter->UseProfile( | |
| 324 uuid, fake_delegate_paired_.device_path_, options, &fake_delegate_paired_, | |
| 325 base::Bind( | |
| 326 &BluetoothAdapterProfileChromeOSTest::ProfileUserSuccessCallback, | |
| 327 base::Unretained(this)), | |
| 328 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, | |
| 329 base::Unretained(this))); | |
| 330 | |
| 331 adapter->UseProfile( | |
| 332 uuid, fake_delegate_autopair_.device_path_, options, | |
| 333 &fake_delegate_autopair_, | |
| 334 base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback, | |
| 335 base::Unretained(this)), | |
| 336 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, | |
| 337 base::Unretained(this))); | |
| 338 | |
| 339 message_loop_.RunUntilIdle(); | |
| 340 | |
| 341 EXPECT_TRUE(profile_user_ptr_); | |
| 342 EXPECT_EQ(2U, success_callback_count_); | |
| 343 EXPECT_EQ(0U, error_callback_count_); | |
| 344 | |
| 345 adapter->ReleaseProfile(fake_delegate_paired_.device_path_, | |
| 346 profile_user_ptr_); | |
| 347 adapter->ReleaseProfile(fake_delegate_autopair_.device_path_, | |
| 348 profile_user_ptr_); | |
| 349 | |
| 350 message_loop_.RunUntilIdle(); | |
| 351 }; | |
| 352 | |
| 353 TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { | |
| 354 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kUnregisterableUuid); | |
| 355 BluetoothProfileManagerClient::Options options; | |
| 356 BluetoothAdapterChromeOS* adapter = | |
| 357 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); | |
| 358 | |
| 359 options.require_authentication.reset(new bool(false)); | |
| 360 | |
| 361 success_callback_count_ = 0; | |
| 362 error_callback_count_ = 0; | |
| 363 | |
| 364 adapter->UseProfile( | |
| 365 uuid, fake_delegate_paired_.device_path_, options, &fake_delegate_paired_, | |
| 366 base::Bind( | |
| 367 &BluetoothAdapterProfileChromeOSTest::ProfileUserSuccessCallback, | |
| 368 base::Unretained(this)), | |
| 369 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, | |
| 370 base::Unretained(this))); | |
| 371 | |
| 372 adapter->UseProfile( | |
| 373 uuid, fake_delegate_autopair_.device_path_, options, | |
| 374 &fake_delegate_autopair_, | |
| 375 base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback, | |
| 376 base::Unretained(this)), | |
| 377 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, | |
| 378 base::Unretained(this))); | |
| 379 | |
| 380 message_loop_.RunUntilIdle(); | |
| 381 | |
| 382 EXPECT_FALSE(profile_user_ptr_); | |
| 383 EXPECT_EQ(0U, success_callback_count_); | |
| 384 EXPECT_EQ(2U, error_callback_count_); | |
| 295 }; | 385 }; |
| 296 | 386 |
| 297 } // namespace chromeos | 387 } // namespace chromeos |
| OLD | NEW |