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(); |
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 { |
83 public: | 76 public: |
84 FakeDelegate(std::string device_path) : connections_(0) { | 77 FakeDelegate(std::string device_path) : connections_(0) { |
85 device_path_ = dbus::ObjectPath(device_path); | 78 device_path_ = dbus::ObjectPath(device_path); |
86 } | 79 } |
87 | 80 |
88 // BluetoothProfileServiceProvider::Delegate: | 81 // BluetoothProfileServiceProvider::Delegate: |
89 void Released() override { | 82 void Released() override { |
90 // noop | 83 // noop |
91 } | 84 } |
92 | 85 |
93 void NewConnection( | 86 void NewConnection( |
94 const dbus::ObjectPath& device_path, | 87 const dbus::ObjectPath& device_path, |
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 " | |
99 << device_path_.value(); | |
100 ++connections_; | 91 ++connections_; |
101 fd->CheckValidity(); | 92 fd->CheckValidity(); |
102 close(fd->TakeValue()); | 93 close(fd->TakeValue()); |
103 callback.Run(SUCCESS); | 94 callback.Run(SUCCESS); |
104 if (device_path_.value() != "") | 95 if (device_path_.value() != "") |
105 ASSERT_TRUE(device_path == device_path_); | 96 ASSERT_EQ(device_path_, device_path); |
106 } | 97 } |
107 | 98 |
108 void RequestDisconnection(const dbus::ObjectPath& device_path, | 99 void RequestDisconnection(const dbus::ObjectPath& device_path, |
109 const ConfirmationCallback& callback) override { | 100 const ConfirmationCallback& callback) override { |
110 VLOG(1) << "disconnect " << device_path.value(); | |
111 ++disconnections_; | 101 ++disconnections_; |
112 } | 102 } |
113 | 103 |
114 void Cancel() override { | 104 void Cancel() override { |
115 VLOG(1) << "cancel"; | |
116 // noop | 105 // noop |
117 } | 106 } |
118 | 107 |
119 unsigned int connections_; | 108 unsigned int connections_; |
120 unsigned int disconnections_; | 109 unsigned int disconnections_; |
121 dbus::ObjectPath device_path_; | 110 dbus::ObjectPath device_path_; |
122 }; | 111 }; |
123 | 112 |
124 FakeDelegate fake_delegate_paired_; | 113 void ProfileSuccessCallback( |
125 FakeDelegate fake_delegate_autopair_; | 114 scoped_ptr<BluetoothAdapterProfileChromeOS> profile) { |
126 FakeDelegate fake_delegate_listen_; | 115 profile_.swap(profile); |
| 116 ++success_callback_count_; |
| 117 } |
127 | 118 |
128 BluetoothAdapterProfileChromeOS* profile_; | 119 void ProfileUserSuccessCallback(BluetoothAdapterProfileChromeOS* profile) { |
| 120 profile_user_ptr_ = profile; |
| 121 ++success_callback_count_; |
| 122 } |
| 123 |
| 124 void MatchedProfileCallback(BluetoothAdapterProfileChromeOS* profile) { |
| 125 ASSERT_EQ(profile_user_ptr_, profile); |
| 126 ++success_callback_count_; |
| 127 } |
129 | 128 |
130 void DBusConnectSuccessCallback() { ++success_callback_count_; } | 129 void DBusConnectSuccessCallback() { ++success_callback_count_; } |
131 | 130 |
132 void DBusErrorCallback(const std::string& error_name, | 131 void DBusErrorCallback(const std::string& error_name, |
133 const std::string& error_message) { | 132 const std::string& error_message) { |
134 VLOG(1) << "DBus Connect Error: " << error_name << " - " << error_message; | |
135 ++error_callback_count_; | 133 ++error_callback_count_; |
136 } | 134 } |
137 | 135 |
| 136 void BasicErrorCallback(const std::string& error_message) { |
| 137 ++error_callback_count_; |
| 138 } |
| 139 |
138 protected: | 140 protected: |
139 base::MessageLoop message_loop_; | 141 base::MessageLoop message_loop_; |
140 | 142 |
141 scoped_refptr<BluetoothAdapter> adapter_; | 143 scoped_refptr<BluetoothAdapter> adapter_; |
142 | 144 |
143 unsigned int success_callback_count_; | 145 unsigned int success_callback_count_; |
144 unsigned int error_callback_count_; | 146 unsigned int error_callback_count_; |
| 147 |
| 148 FakeDelegate fake_delegate_paired_; |
| 149 FakeDelegate fake_delegate_autopair_; |
| 150 FakeDelegate fake_delegate_listen_; |
| 151 |
| 152 scoped_ptr<BluetoothAdapterProfileChromeOS> profile_; |
| 153 |
| 154 // unowned pointer as expected to be used by clients of |
| 155 // BluetoothAdapterChromeOS::UseProfile like BluetoothSocketChromeOS |
| 156 BluetoothAdapterProfileChromeOS* profile_user_ptr_; |
145 }; | 157 }; |
146 | 158 |
147 TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { | 159 TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { |
148 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | 160 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
149 BluetoothProfileManagerClient::Options options; | 161 BluetoothProfileManagerClient::Options options; |
150 | 162 |
151 options.require_authentication.reset(new bool(false)); | 163 options.require_authentication.reset(new bool(false)); |
152 | 164 |
153 profile_ = BluetoothAdapterProfileChromeOS::Register( | 165 BluetoothAdapterProfileChromeOS::Register( |
154 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options, | 166 uuid, options, |
155 base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback)); | 167 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, |
| 168 base::Unretained(this)), |
| 169 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
| 170 base::Unretained(this))); |
156 | 171 |
157 message_loop_.RunUntilIdle(); | 172 message_loop_.RunUntilIdle(); |
158 | 173 |
159 EXPECT_TRUE(profile_); | 174 EXPECT_TRUE(profile_); |
| 175 EXPECT_EQ(1U, success_callback_count_); |
| 176 EXPECT_EQ(0U, error_callback_count_); |
160 | 177 |
161 EXPECT_EQ(0U, profile_->DelegateCount()); | 178 EXPECT_EQ(0U, profile_->DelegateCount()); |
162 | 179 |
163 profile_->SetDelegate(fake_delegate_paired_.device_path_, | 180 profile_->SetDelegate(fake_delegate_paired_.device_path_, |
164 &fake_delegate_paired_); | 181 &fake_delegate_paired_); |
165 | 182 |
166 EXPECT_EQ(1U, profile_->DelegateCount()); | 183 EXPECT_EQ(1U, profile_->DelegateCount()); |
167 | 184 |
168 profile_->RemoveDelegate(fake_delegate_autopair_.device_path_, | 185 profile_->RemoveDelegate(fake_delegate_autopair_.device_path_, |
169 base::Bind(&base::DoNothing)); | 186 base::Bind(&base::DoNothing)); |
170 | 187 |
171 EXPECT_EQ(1U, profile_->DelegateCount()); | 188 EXPECT_EQ(1U, profile_->DelegateCount()); |
172 | 189 |
173 profile_->RemoveDelegate(fake_delegate_paired_.device_path_, | 190 profile_->RemoveDelegate(fake_delegate_paired_.device_path_, |
174 base::Bind(&base::DoNothing)); | 191 base::Bind(&base::DoNothing)); |
175 | 192 |
176 EXPECT_EQ(0U, profile_->DelegateCount()); | 193 EXPECT_EQ(0U, profile_->DelegateCount()); |
177 | |
178 delete profile_; | |
179 }; | 194 }; |
180 | 195 |
181 TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { | 196 TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { |
182 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | 197 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
183 BluetoothProfileManagerClient::Options options; | 198 BluetoothProfileManagerClient::Options options; |
184 | 199 |
185 options.require_authentication.reset(new bool(false)); | 200 options.require_authentication.reset(new bool(false)); |
186 | 201 |
187 profile_ = BluetoothAdapterProfileChromeOS::Register( | 202 BluetoothAdapterProfileChromeOS::Register( |
188 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options, | 203 uuid, options, |
189 base::Bind( | 204 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, |
190 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, | 205 base::Unretained(this)), |
191 base::Unretained(this)), | |
192 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 206 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
193 base::Unretained(this))); | 207 base::Unretained(this))); |
194 | 208 |
195 message_loop_.RunUntilIdle(); | 209 message_loop_.RunUntilIdle(); |
196 | 210 |
197 EXPECT_TRUE(profile_); | 211 EXPECT_TRUE(profile_); |
198 EXPECT_EQ(1U, success_callback_count_); | 212 EXPECT_EQ(1U, success_callback_count_); |
199 EXPECT_EQ(0U, error_callback_count_); | 213 EXPECT_EQ(0U, error_callback_count_); |
200 | 214 |
201 DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( | 215 DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( |
202 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), | 216 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), |
203 FakeBluetoothProfileManagerClient::kRfcommUuid, | 217 FakeBluetoothProfileManagerClient::kRfcommUuid, |
204 base::Bind( | 218 base::Bind( |
205 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, | 219 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, |
206 base::Unretained(this)), | 220 base::Unretained(this)), |
207 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 221 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
208 base::Unretained(this))); | 222 base::Unretained(this))); |
209 | 223 |
210 message_loop_.RunUntilIdle(); | 224 message_loop_.RunUntilIdle(); |
211 | 225 |
212 EXPECT_EQ(1U, success_callback_count_); | 226 EXPECT_EQ(1U, success_callback_count_); |
213 EXPECT_EQ(1U, error_callback_count_); | 227 EXPECT_EQ(1U, error_callback_count_); |
214 | 228 |
215 EXPECT_EQ(0U, fake_delegate_paired_.connections_); | 229 EXPECT_EQ(0U, fake_delegate_paired_.connections_); |
216 | |
217 delete profile_; | |
218 }; | 230 }; |
219 | 231 |
220 TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { | 232 TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { |
221 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); | 233 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
222 BluetoothProfileManagerClient::Options options; | 234 BluetoothProfileManagerClient::Options options; |
223 | 235 |
224 options.require_authentication.reset(new bool(false)); | 236 options.require_authentication.reset(new bool(false)); |
225 | 237 |
226 profile_ = BluetoothAdapterProfileChromeOS::Register( | 238 BluetoothAdapterProfileChromeOS::Register( |
227 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options, | 239 uuid, options, |
228 base::Bind( | 240 base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, |
229 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, | 241 base::Unretained(this)), |
230 base::Unretained(this)), | |
231 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 242 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
232 base::Unretained(this))); | 243 base::Unretained(this))); |
233 | 244 |
234 message_loop_.RunUntilIdle(); | 245 message_loop_.RunUntilIdle(); |
235 | 246 |
236 ASSERT_TRUE(profile_); | 247 ASSERT_TRUE(profile_); |
| 248 ASSERT_EQ(1U, success_callback_count_); |
| 249 ASSERT_EQ(0U, error_callback_count_); |
237 | 250 |
238 profile_->SetDelegate(fake_delegate_paired_.device_path_, | 251 profile_->SetDelegate(fake_delegate_paired_.device_path_, |
239 &fake_delegate_paired_); | 252 &fake_delegate_paired_); |
240 profile_->SetDelegate(fake_delegate_autopair_.device_path_, | 253 profile_->SetDelegate(fake_delegate_autopair_.device_path_, |
241 &fake_delegate_autopair_); | 254 &fake_delegate_autopair_); |
242 profile_->SetDelegate(fake_delegate_listen_.device_path_, | 255 profile_->SetDelegate(fake_delegate_listen_.device_path_, |
243 &fake_delegate_listen_); | 256 &fake_delegate_listen_); |
244 | 257 |
245 DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( | 258 DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( |
246 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), | 259 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 base::Unretained(this)), | 296 base::Unretained(this)), |
284 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, | 297 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, |
285 base::Unretained(this))); | 298 base::Unretained(this))); |
286 | 299 |
287 message_loop_.RunUntilIdle(); | 300 message_loop_.RunUntilIdle(); |
288 | 301 |
289 EXPECT_EQ(4U, success_callback_count_); | 302 EXPECT_EQ(4U, success_callback_count_); |
290 EXPECT_EQ(0U, error_callback_count_); | 303 EXPECT_EQ(0U, error_callback_count_); |
291 | 304 |
292 EXPECT_EQ(1U, fake_delegate_listen_.connections_); | 305 EXPECT_EQ(1U, fake_delegate_listen_.connections_); |
| 306 }; |
293 | 307 |
294 delete profile_; | 308 TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { |
| 309 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); |
| 310 BluetoothProfileManagerClient::Options options; |
| 311 BluetoothAdapterChromeOS* adapter = |
| 312 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); |
| 313 |
| 314 options.require_authentication.reset(new bool(false)); |
| 315 |
| 316 success_callback_count_ = 0; |
| 317 error_callback_count_ = 0; |
| 318 |
| 319 adapter->UseProfile( |
| 320 uuid, fake_delegate_paired_.device_path_, options, &fake_delegate_paired_, |
| 321 base::Bind( |
| 322 &BluetoothAdapterProfileChromeOSTest::ProfileUserSuccessCallback, |
| 323 base::Unretained(this)), |
| 324 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, |
| 325 base::Unretained(this))); |
| 326 |
| 327 adapter->UseProfile( |
| 328 uuid, fake_delegate_autopair_.device_path_, options, |
| 329 &fake_delegate_autopair_, |
| 330 base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback, |
| 331 base::Unretained(this)), |
| 332 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, |
| 333 base::Unretained(this))); |
| 334 |
| 335 message_loop_.RunUntilIdle(); |
| 336 |
| 337 EXPECT_TRUE(profile_user_ptr_); |
| 338 EXPECT_EQ(2U, success_callback_count_); |
| 339 EXPECT_EQ(0U, error_callback_count_); |
| 340 |
| 341 adapter->ReleaseProfile(fake_delegate_paired_.device_path_, |
| 342 profile_user_ptr_); |
| 343 adapter->ReleaseProfile(fake_delegate_autopair_.device_path_, |
| 344 profile_user_ptr_); |
| 345 |
| 346 message_loop_.RunUntilIdle(); |
| 347 }; |
| 348 |
| 349 TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { |
| 350 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kUnregisterableUuid); |
| 351 BluetoothProfileManagerClient::Options options; |
| 352 BluetoothAdapterChromeOS* adapter = |
| 353 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); |
| 354 |
| 355 options.require_authentication.reset(new bool(false)); |
| 356 |
| 357 success_callback_count_ = 0; |
| 358 error_callback_count_ = 0; |
| 359 |
| 360 adapter->UseProfile( |
| 361 uuid, fake_delegate_paired_.device_path_, options, &fake_delegate_paired_, |
| 362 base::Bind( |
| 363 &BluetoothAdapterProfileChromeOSTest::ProfileUserSuccessCallback, |
| 364 base::Unretained(this)), |
| 365 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, |
| 366 base::Unretained(this))); |
| 367 |
| 368 adapter->UseProfile( |
| 369 uuid, fake_delegate_autopair_.device_path_, options, |
| 370 &fake_delegate_autopair_, |
| 371 base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback, |
| 372 base::Unretained(this)), |
| 373 base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, |
| 374 base::Unretained(this))); |
| 375 |
| 376 message_loop_.RunUntilIdle(); |
| 377 |
| 378 EXPECT_FALSE(profile_user_ptr_); |
| 379 EXPECT_EQ(0U, success_callback_count_); |
| 380 EXPECT_EQ(2U, error_callback_count_); |
295 }; | 381 }; |
296 | 382 |
297 } // namespace chromeos | 383 } // namespace chromeos |
OLD | NEW |