OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/dbus/mock_bluetooth_adapter_client.h" | 5 #include "chromeos/dbus/mock_bluetooth_adapter_client.h" |
6 #include "chromeos/dbus/mock_bluetooth_manager_client.h" | 6 #include "chromeos/dbus/mock_bluetooth_manager_client.h" |
7 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 7 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
8 #include "dbus/object_path.h" | 8 #include "dbus/object_path.h" |
9 #include "device/bluetooth/bluetooth_adapter.h" | 9 #include "device/bluetooth/bluetooth_adapter.h" |
10 #include "device/bluetooth/bluetooth_adapter_chromeos.h" | 10 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 MockBluetoothAdapter::Observer adapter_observer; | 123 MockBluetoothAdapter::Observer adapter_observer; |
124 adapter_->AddObserver(&adapter_observer); | 124 adapter_->AddObserver(&adapter_observer); |
125 | 125 |
126 EXPECT_CALL(adapter_observer, AdapterPresentChanged(adapter_.get(), true)) | 126 EXPECT_CALL(adapter_observer, AdapterPresentChanged(adapter_.get(), true)) |
127 .Times(1); | 127 .Times(1); |
128 | 128 |
129 adapter_callback.Run(adapter_path, true); | 129 adapter_callback.Run(adapter_path, true); |
130 | 130 |
131 // Adapter should be present with the given address. | 131 // Adapter should be present with the given address. |
132 EXPECT_TRUE(adapter_->IsPresent()); | 132 EXPECT_TRUE(adapter_->IsPresent()); |
133 EXPECT_EQ(adapter_address, adapter_->address()); | 133 EXPECT_EQ(adapter_address, adapter_->GetAddress()); |
134 } | 134 } |
135 | 135 |
136 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterWithoutAddress) { | 136 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterWithoutAddress) { |
137 const dbus::ObjectPath adapter_path("/fake/hci0"); | 137 const dbus::ObjectPath adapter_path("/fake/hci0"); |
138 const std::string adapter_address = "CA:FE:4A:C0:FE:FE"; | 138 const std::string adapter_address = "CA:FE:4A:C0:FE:FE"; |
139 | 139 |
140 // Create the default adapter instance; | 140 // Create the default adapter instance; |
141 // BluetoothManagerClient::DefaultAdapter will be called once, passing | 141 // BluetoothManagerClient::DefaultAdapter will be called once, passing |
142 // a callback to obtain the adapter path. | 142 // a callback to obtain the adapter path. |
143 BluetoothManagerClient::AdapterCallback adapter_callback; | 143 BluetoothManagerClient::AdapterCallback adapter_callback; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 BluetoothAdapterChromeOS* adapter_chromeos = | 179 BluetoothAdapterChromeOS* adapter_chromeos = |
180 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); | 180 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); |
181 | 181 |
182 static_cast<BluetoothAdapterClient::Observer*>(adapter_chromeos) | 182 static_cast<BluetoothAdapterClient::Observer*>(adapter_chromeos) |
183 ->AdapterPropertyChanged(adapter_path, | 183 ->AdapterPropertyChanged(adapter_path, |
184 adapter_properties.address.name()); | 184 adapter_properties.address.name()); |
185 | 185 |
186 // Adapter should be present with the given address. | 186 // Adapter should be present with the given address. |
187 EXPECT_TRUE(adapter_->IsPresent()); | 187 EXPECT_TRUE(adapter_->IsPresent()); |
188 EXPECT_EQ(adapter_address, adapter_->address()); | 188 EXPECT_EQ(adapter_address, adapter_->GetAddress()); |
189 } | 189 } |
190 | 190 |
191 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterBecomesPresentWithAddress) { | 191 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterBecomesPresentWithAddress) { |
192 const dbus::ObjectPath adapter_path("/fake/hci0"); | 192 const dbus::ObjectPath adapter_path("/fake/hci0"); |
193 const std::string adapter_address = "CA:FE:4A:C0:FE:FE"; | 193 const std::string adapter_address = "CA:FE:4A:C0:FE:FE"; |
194 | 194 |
195 // Create the default adapter instance; | 195 // Create the default adapter instance; |
196 // BluetoothManagerClient::DefaultAdapter will be called once, passing | 196 // BluetoothManagerClient::DefaultAdapter will be called once, passing |
197 // a callback to obtain the adapter path. | 197 // a callback to obtain the adapter path. |
198 BluetoothManagerClient::AdapterCallback adapter_callback; | 198 BluetoothManagerClient::AdapterCallback adapter_callback; |
(...skipping 24 matching lines...) Expand all Loading... |
223 .Times(1); | 223 .Times(1); |
224 | 224 |
225 BluetoothAdapterChromeOS* adapter_chromeos = | 225 BluetoothAdapterChromeOS* adapter_chromeos = |
226 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); | 226 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); |
227 | 227 |
228 static_cast<BluetoothManagerClient::Observer*>(adapter_chromeos) | 228 static_cast<BluetoothManagerClient::Observer*>(adapter_chromeos) |
229 ->DefaultAdapterChanged(adapter_path); | 229 ->DefaultAdapterChanged(adapter_path); |
230 | 230 |
231 // Adapter should be present with the new address. | 231 // Adapter should be present with the new address. |
232 EXPECT_TRUE(adapter_->IsPresent()); | 232 EXPECT_TRUE(adapter_->IsPresent()); |
233 EXPECT_EQ(adapter_address, adapter_->address()); | 233 EXPECT_EQ(adapter_address, adapter_->GetAddress()); |
234 } | 234 } |
235 | 235 |
236 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterReplacedWithAddress) { | 236 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterReplacedWithAddress) { |
237 const dbus::ObjectPath initial_adapter_path("/fake/hci0"); | 237 const dbus::ObjectPath initial_adapter_path("/fake/hci0"); |
238 const dbus::ObjectPath new_adapter_path("/fake/hci1"); | 238 const dbus::ObjectPath new_adapter_path("/fake/hci1"); |
239 const std::string initial_adapter_address = "CA:FE:4A:C0:FE:FE"; | 239 const std::string initial_adapter_address = "CA:FE:4A:C0:FE:FE"; |
240 const std::string new_adapter_address = "BA:C0:11:CO:FE:FE"; | 240 const std::string new_adapter_address = "BA:C0:11:CO:FE:FE"; |
241 | 241 |
242 // Create the default adapter instance; | 242 // Create the default adapter instance; |
243 // BluetoothManagerClient::DefaultAdapter will be called once, passing | 243 // BluetoothManagerClient::DefaultAdapter will be called once, passing |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 .Times(1); | 282 .Times(1); |
283 | 283 |
284 BluetoothAdapterChromeOS* adapter_chromeos = | 284 BluetoothAdapterChromeOS* adapter_chromeos = |
285 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); | 285 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); |
286 | 286 |
287 static_cast<BluetoothManagerClient::Observer*>(adapter_chromeos) | 287 static_cast<BluetoothManagerClient::Observer*>(adapter_chromeos) |
288 ->DefaultAdapterChanged(new_adapter_path); | 288 ->DefaultAdapterChanged(new_adapter_path); |
289 | 289 |
290 // Adapter should be present with the new address. | 290 // Adapter should be present with the new address. |
291 EXPECT_TRUE(adapter_->IsPresent()); | 291 EXPECT_TRUE(adapter_->IsPresent()); |
292 EXPECT_EQ(new_adapter_address, adapter_->address()); | 292 EXPECT_EQ(new_adapter_address, adapter_->GetAddress()); |
293 } | 293 } |
294 | 294 |
295 TEST_F(BluetoothAdapterChromeOSTest, | 295 TEST_F(BluetoothAdapterChromeOSTest, |
296 DefaultAdapterBecomesPresentWithoutAddress) { | 296 DefaultAdapterBecomesPresentWithoutAddress) { |
297 const dbus::ObjectPath adapter_path("/fake/hci0"); | 297 const dbus::ObjectPath adapter_path("/fake/hci0"); |
298 const std::string adapter_address = "CA:FE:4A:C0:FE:FE"; | 298 const std::string adapter_address = "CA:FE:4A:C0:FE:FE"; |
299 | 299 |
300 // Create the default adapter instance; | 300 // Create the default adapter instance; |
301 // BluetoothManagerClient::DefaultAdapter will be called once, passing | 301 // BluetoothManagerClient::DefaultAdapter will be called once, passing |
302 // a callback to obtain the adapter path. | 302 // a callback to obtain the adapter path. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 341 |
342 EXPECT_CALL(adapter_observer, AdapterPresentChanged(adapter_.get(), true)) | 342 EXPECT_CALL(adapter_observer, AdapterPresentChanged(adapter_.get(), true)) |
343 .Times(1); | 343 .Times(1); |
344 | 344 |
345 static_cast<BluetoothAdapterClient::Observer*>(adapter_chromeos) | 345 static_cast<BluetoothAdapterClient::Observer*>(adapter_chromeos) |
346 ->AdapterPropertyChanged(adapter_path, | 346 ->AdapterPropertyChanged(adapter_path, |
347 adapter_properties.address.name()); | 347 adapter_properties.address.name()); |
348 | 348 |
349 // Adapter should be present with the new address. | 349 // Adapter should be present with the new address. |
350 EXPECT_TRUE(adapter_->IsPresent()); | 350 EXPECT_TRUE(adapter_->IsPresent()); |
351 EXPECT_EQ(adapter_address, adapter_->address()); | 351 EXPECT_EQ(adapter_address, adapter_->GetAddress()); |
352 } | 352 } |
353 | 353 |
354 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterReplacedWithoutAddress) { | 354 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterReplacedWithoutAddress) { |
355 const dbus::ObjectPath initial_adapter_path("/fake/hci0"); | 355 const dbus::ObjectPath initial_adapter_path("/fake/hci0"); |
356 const dbus::ObjectPath new_adapter_path("/fake/hci1"); | 356 const dbus::ObjectPath new_adapter_path("/fake/hci1"); |
357 const std::string initial_adapter_address = "CA:FE:4A:C0:FE:FE"; | 357 const std::string initial_adapter_address = "CA:FE:4A:C0:FE:FE"; |
358 const std::string new_adapter_address = "BA:C0:11:CO:FE:FE"; | 358 const std::string new_adapter_address = "BA:C0:11:CO:FE:FE"; |
359 | 359 |
360 // Create the default adapter instance; | 360 // Create the default adapter instance; |
361 // BluetoothManagerClient::DefaultAdapter will be called once, passing | 361 // BluetoothManagerClient::DefaultAdapter will be called once, passing |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 410 |
411 EXPECT_CALL(adapter_observer, AdapterPresentChanged(adapter_.get(), true)) | 411 EXPECT_CALL(adapter_observer, AdapterPresentChanged(adapter_.get(), true)) |
412 .Times(1); | 412 .Times(1); |
413 | 413 |
414 static_cast<BluetoothAdapterClient::Observer*>(adapter_chromeos) | 414 static_cast<BluetoothAdapterClient::Observer*>(adapter_chromeos) |
415 ->AdapterPropertyChanged(new_adapter_path, | 415 ->AdapterPropertyChanged(new_adapter_path, |
416 new_adapter_properties.address.name()); | 416 new_adapter_properties.address.name()); |
417 | 417 |
418 // Adapter should be present with the new address. | 418 // Adapter should be present with the new address. |
419 EXPECT_TRUE(adapter_->IsPresent()); | 419 EXPECT_TRUE(adapter_->IsPresent()); |
420 EXPECT_EQ(new_adapter_address, adapter_->address()); | 420 EXPECT_EQ(new_adapter_address, adapter_->GetAddress()); |
421 } | 421 } |
422 | 422 |
423 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterRemoved) { | 423 TEST_F(BluetoothAdapterChromeOSTest, DefaultAdapterRemoved) { |
424 const dbus::ObjectPath adapter_path("/fake/hci0"); | 424 const dbus::ObjectPath adapter_path("/fake/hci0"); |
425 const std::string adapter_address = "CA:FE:4A:C0:FE:FE"; | 425 const std::string adapter_address = "CA:FE:4A:C0:FE:FE"; |
426 | 426 |
427 // Create the default adapter instance; | 427 // Create the default adapter instance; |
428 // BluetoothManagerClient::DefaultAdapter will be called once, passing | 428 // BluetoothManagerClient::DefaultAdapter will be called once, passing |
429 // a callback to obtain the adapter path. | 429 // a callback to obtain the adapter path. |
430 BluetoothManagerClient::AdapterCallback adapter_callback; | 430 BluetoothManagerClient::AdapterCallback adapter_callback; |
(...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2217 base::Unretained(this))); | 2217 base::Unretained(this))); |
2218 | 2218 |
2219 // Return to indicate success. | 2219 // Return to indicate success. |
2220 stop_discovery_callback.Run(adapter_path, true); | 2220 stop_discovery_callback.Run(adapter_path, true); |
2221 | 2221 |
2222 EXPECT_TRUE(callback_called_); | 2222 EXPECT_TRUE(callback_called_); |
2223 EXPECT_FALSE(error_callback_called_); | 2223 EXPECT_FALSE(error_callback_called_); |
2224 } | 2224 } |
2225 | 2225 |
2226 } // namespace chromeos | 2226 } // namespace chromeos |
OLD | NEW |