Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: device/bluetooth/bluetooth_chromeos_unittest.cc

Issue 933823003: bluetooth: Modify DCHECK to conditionals in several BluetoothAdapterChromeOS methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/memory/scoped_vector.h" 5 #include "base/memory/scoped_vector.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.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_gatt_service_client.h" 12 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h"
13 #include "chromeos/dbus/fake_bluetooth_input_client.h" 13 #include "chromeos/dbus/fake_bluetooth_input_client.h"
14 #include "dbus/object_path.h" 14 #include "dbus/object_path.h"
15 #include "device/bluetooth/bluetooth_adapter.h" 15 #include "device/bluetooth/bluetooth_adapter.h"
16 #include "device/bluetooth/bluetooth_adapter_chromeos.h" 16 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
17 #include "device/bluetooth/bluetooth_adapter_factory.h" 17 #include "device/bluetooth/bluetooth_adapter_factory.h"
18 #include "device/bluetooth/bluetooth_device.h" 18 #include "device/bluetooth/bluetooth_device.h"
19 #include "device/bluetooth/bluetooth_device_chromeos.h" 19 #include "device/bluetooth/bluetooth_device_chromeos.h"
20 #include "device/bluetooth/bluetooth_discovery_session.h" 20 #include "device/bluetooth/bluetooth_discovery_session.h"
21 #include "device/bluetooth/bluetooth_pairing_chromeos.h" 21 #include "device/bluetooth/bluetooth_pairing_chromeos.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 #include "third_party/cros_system_api/dbus/service_constants.h" 23 #include "third_party/cros_system_api/dbus/service_constants.h"
24 24
25 using device::BluetoothAdapter; 25 using device::BluetoothAdapter;
26 using device::BluetoothAdapterFactory; 26 using device::BluetoothAdapterFactory;
27 using device::BluetoothAudioSink;
27 using device::BluetoothDevice; 28 using device::BluetoothDevice;
28 using device::BluetoothDiscoverySession; 29 using device::BluetoothDiscoverySession;
29 using device::BluetoothUUID; 30 using device::BluetoothUUID;
30 31
31 namespace chromeos { 32 namespace chromeos {
32 33
33 namespace { 34 namespace {
34 35
35 class TestObserver : public BluetoothAdapter::Observer { 36 class TestObserver : public BluetoothAdapter::Observer {
36 public: 37 public:
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 scoped_refptr<BluetoothAdapter> adapter_; 140 scoped_refptr<BluetoothAdapter> adapter_;
140 }; 141 };
141 142
142 // Callback for BluetoothDevice::GetConnectionInfo() that simply saves the 143 // Callback for BluetoothDevice::GetConnectionInfo() that simply saves the
143 // connection info to the bound argument. 144 // connection info to the bound argument.
144 void SaveConnectionInfo(BluetoothDevice::ConnectionInfo* out, 145 void SaveConnectionInfo(BluetoothDevice::ConnectionInfo* out,
145 const BluetoothDevice::ConnectionInfo& conn_info) { 146 const BluetoothDevice::ConnectionInfo& conn_info) {
146 *out = conn_info; 147 *out = conn_info;
147 }; 148 };
148 149
150 class FakeBluetoothProfileServiceProviderDelegate
151 : public chromeos::BluetoothProfileServiceProvider::Delegate {
152 public:
153 FakeBluetoothProfileServiceProviderDelegate() {}
154
155 // BluetoothProfileServiceProvider::Delegate:
156 void Released() override {}
157
158 void NewConnection(const dbus::ObjectPath&,
159 scoped_ptr<dbus::FileDescriptor>,
160 const BluetoothProfileServiceProvider::Delegate::Options&,
161 const ConfirmationCallback&) override {}
162
163 void RequestDisconnection(const dbus::ObjectPath&,
164 const ConfirmationCallback&) override {}
165
166 void Cancel() override {}
167 };
168
149 } // namespace 169 } // namespace
150 170
151 class TestPairingDelegate : public BluetoothDevice::PairingDelegate { 171 class TestPairingDelegate : public BluetoothDevice::PairingDelegate {
152 public: 172 public:
153 TestPairingDelegate() 173 TestPairingDelegate()
154 : call_count_(0), 174 : call_count_(0),
155 request_pincode_count_(0), 175 request_pincode_count_(0),
156 request_passkey_count_(0), 176 request_passkey_count_(0),
157 display_pincode_count_(0), 177 display_pincode_count_(0),
158 display_passkey_count_(0), 178 display_passkey_count_(0),
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 QuitMessageLoop(); 311 QuitMessageLoop();
292 } 312 }
293 313
294 void DiscoverySessionCallback( 314 void DiscoverySessionCallback(
295 scoped_ptr<BluetoothDiscoverySession> discovery_session) { 315 scoped_ptr<BluetoothDiscoverySession> discovery_session) {
296 ++callback_count_; 316 ++callback_count_;
297 discovery_sessions_.push_back(discovery_session.release()); 317 discovery_sessions_.push_back(discovery_session.release());
298 QuitMessageLoop(); 318 QuitMessageLoop();
299 } 319 }
300 320
321 void AudioSinkAcquiredCallback(scoped_refptr<BluetoothAudioSink>) {
322 ++callback_count_;
323 QuitMessageLoop();
324 }
325
326 void ProfileRegisteredCallback(BluetoothAdapterProfileChromeOS*) {
327 ++callback_count_;
328 QuitMessageLoop();
329 }
330
301 void ErrorCallback() { 331 void ErrorCallback() {
302 ++error_callback_count_; 332 ++error_callback_count_;
303 QuitMessageLoop(); 333 QuitMessageLoop();
304 } 334 }
305 335
306 void DBusErrorCallback(const std::string& error_name, 336 void DBusErrorCallback(const std::string& error_name,
307 const std::string& error_message) { 337 const std::string& error_message) {
308 ++error_callback_count_; 338 ++error_callback_count_;
309 last_client_error_ = error_name; 339 last_client_error_ = error_name;
310 QuitMessageLoop(); 340 QuitMessageLoop();
311 } 341 }
312 342
313 void ConnectErrorCallback(BluetoothDevice::ConnectErrorCode error) { 343 void ConnectErrorCallback(BluetoothDevice::ConnectErrorCode error) {
314 ++error_callback_count_; 344 ++error_callback_count_;
315 last_connect_error_ = error; 345 last_connect_error_ = error;
316 } 346 }
317 347
348 void AudioSinkErrorCallback(BluetoothAudioSink::ErrorCode) {
349 ++error_callback_count_;
350 QuitMessageLoop();
351 }
352
353 void ErrorCompletionCallback(const std::string& error_message) {
354 ++error_callback_count_;
355 QuitMessageLoop();
356 }
357
318 // Call to fill the adapter_ member with a BluetoothAdapter instance. 358 // Call to fill the adapter_ member with a BluetoothAdapter instance.
319 void GetAdapter() { 359 void GetAdapter() {
320 adapter_ = new BluetoothAdapterChromeOS(); 360 adapter_ = new BluetoothAdapterChromeOS();
321 ASSERT_TRUE(adapter_.get() != NULL); 361 ASSERT_TRUE(adapter_.get() != NULL);
322 ASSERT_TRUE(adapter_->IsInitialized()); 362 ASSERT_TRUE(adapter_->IsInitialized());
323 } 363 }
324 364
325 // Run a discovery phase until the named device is detected, or if the named 365 // Run a discovery phase until the named device is detected, or if the named
326 // device is not created, the discovery process ends without finding it. 366 // device is not created, the discovery process ends without finding it.
327 // 367 //
(...skipping 2981 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); 3349 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4);
3310 BluetoothDevice::ConnectionInfo conn_info; 3350 BluetoothDevice::ConnectionInfo conn_info;
3311 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); 3351 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info));
3312 EXPECT_EQ(-10, conn_info.rssi); 3352 EXPECT_EQ(-10, conn_info.rssi);
3313 EXPECT_EQ(3, conn_info.transmit_power); 3353 EXPECT_EQ(3, conn_info.transmit_power);
3314 EXPECT_EQ(4, conn_info.max_transmit_power); 3354 EXPECT_EQ(4, conn_info.max_transmit_power);
3315 } 3355 }
3316 3356
3317 // Verifies Shutdown shuts down the adapter as expected. 3357 // Verifies Shutdown shuts down the adapter as expected.
3318 TEST_F(BluetoothChromeOSTest, Shutdown) { 3358 TEST_F(BluetoothChromeOSTest, Shutdown) {
3319 // Set up and adapter, power, discoverable, start discovery. 3359 // Set up adapter. Set powered & discoverable, start discovery.
3320 GetAdapter(); 3360 GetAdapter();
3321 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, 3361 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback,
3322 base::Unretained(this)), 3362 base::Unretained(this)),
3323 base::Bind(&BluetoothChromeOSTest::ErrorCallback, 3363 base::Bind(&BluetoothChromeOSTest::ErrorCallback,
3324 base::Unretained(this))); 3364 base::Unretained(this)));
3325 adapter_->SetDiscoverable(true, base::Bind(&BluetoothChromeOSTest::Callback, 3365 adapter_->SetDiscoverable(true, base::Bind(&BluetoothChromeOSTest::Callback,
3326 base::Unretained(this)), 3366 base::Unretained(this)),
3327 base::Bind(&BluetoothChromeOSTest::ErrorCallback, 3367 base::Bind(&BluetoothChromeOSTest::ErrorCallback,
3328 base::Unretained(this))); 3368 base::Unretained(this)));
3329 adapter_->StartDiscoverySession( 3369 adapter_->StartDiscoverySession(
3330 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, 3370 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback,
3331 base::Unretained(this)), 3371 base::Unretained(this)),
3332 base::Bind(&BluetoothChromeOSTest::ErrorCallback, 3372 base::Bind(&BluetoothChromeOSTest::ErrorCallback,
3333 base::Unretained(this))); 3373 base::Unretained(this)));
3334 base::MessageLoop::current()->Run(); 3374 base::MessageLoop::current()->Run();
3335 ASSERT_EQ(3, callback_count_); 3375 ASSERT_EQ(3, callback_count_);
3336 ASSERT_EQ(0, error_callback_count_); 3376 ASSERT_EQ(0, error_callback_count_);
3337 callback_count_ = 0; 3377 callback_count_ = 0;
3338 3378
3379 TestPairingDelegate pairing_delegate;
3380 adapter_->AddPairingDelegate(
3381 &pairing_delegate, BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH);
3382
3339 // Validate running adapter state. 3383 // Validate running adapter state.
3340 EXPECT_NE("", adapter_->GetAddress()); 3384 EXPECT_NE("", adapter_->GetAddress());
3341 EXPECT_NE("", adapter_->GetName()); 3385 EXPECT_NE("", adapter_->GetName());
3342 EXPECT_TRUE(adapter_->IsInitialized()); 3386 EXPECT_TRUE(adapter_->IsInitialized());
3343 EXPECT_TRUE(adapter_->IsPresent()); 3387 EXPECT_TRUE(adapter_->IsPresent());
3344 EXPECT_TRUE(adapter_->IsPowered()); 3388 EXPECT_TRUE(adapter_->IsPowered());
3345 EXPECT_TRUE(adapter_->IsDiscoverable()); 3389 EXPECT_TRUE(adapter_->IsDiscoverable());
3346 EXPECT_TRUE(adapter_->IsDiscovering()); 3390 EXPECT_TRUE(adapter_->IsDiscovering());
3347 EXPECT_EQ(2U, adapter_->GetDevices().size()); 3391 EXPECT_EQ(2U, adapter_->GetDevices().size());
3348 EXPECT_NE(nullptr, adapter_->GetDevice( 3392 EXPECT_NE(nullptr, adapter_->GetDevice(
3349 FakeBluetoothDeviceClient::kPairedDeviceAddress)); 3393 FakeBluetoothDeviceClient::kPairedDeviceAddress));
3350 EXPECT_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>( 3394 EXPECT_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>(
3351 adapter_.get())->object_path()); 3395 adapter_.get())->object_path());
3352 3396
3353 // Shutdown 3397 // Shutdown
3354 static_cast<BluetoothAdapterChromeOS*>(adapter_.get())->Shutdown(); 3398 adapter_->Shutdown();
3355 3399
3356 // Validate post shutdown state. 3400 // Validate post shutdown state by calling all BluetoothAdapterChromeOS
3401 // members, in declaration order:
3402
3403 adapter_->Shutdown();
3404 // DeleteOnCorrectThread omitted as we don't want to delete in this test.
3405 {
3406 TestObserver observer(adapter_); // Calls AddObserver
3407 } // TestObserver::~TestObserver calls RemoveObserver.
3357 EXPECT_EQ("", adapter_->GetAddress()); 3408 EXPECT_EQ("", adapter_->GetAddress());
3358 EXPECT_EQ("", adapter_->GetName()); 3409 EXPECT_EQ("", adapter_->GetName());
3410
3411 adapter_->SetName(
3412 "", base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)),
3413 base::Bind(&BluetoothChromeOSTest::ErrorCallback,
3414 base::Unretained(this)));
3415 EXPECT_EQ(0, callback_count_);
3416 EXPECT_EQ(1, error_callback_count_) << "SetName error";
3417 error_callback_count_ = 0;
3418
3359 EXPECT_TRUE(adapter_->IsInitialized()); 3419 EXPECT_TRUE(adapter_->IsInitialized());
3360 EXPECT_FALSE(adapter_->IsPresent()); 3420 EXPECT_FALSE(adapter_->IsPresent());
3361 EXPECT_FALSE(adapter_->IsPowered()); 3421 EXPECT_FALSE(adapter_->IsPowered());
3362 EXPECT_FALSE(adapter_->IsDiscoverable());
3363 EXPECT_FALSE(adapter_->IsDiscovering());
3364 EXPECT_EQ(0U, adapter_->GetDevices().size());
3365 EXPECT_EQ(nullptr, adapter_->GetDevice(
3366 FakeBluetoothDeviceClient::kPairedDeviceAddress));
3367 EXPECT_EQ(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>(
3368 adapter_.get())->object_path());
3369 3422
3370 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, 3423 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback,
3371 base::Unretained(this)), 3424 base::Unretained(this)),
3372 base::Bind(&BluetoothChromeOSTest::ErrorCallback, 3425 base::Bind(&BluetoothChromeOSTest::ErrorCallback,
3373 base::Unretained(this))); 3426 base::Unretained(this)));
3427 EXPECT_EQ(0, callback_count_);
3428 EXPECT_EQ(1, error_callback_count_) << "SetPowered error";
3429 error_callback_count_ = 0;
3430
3431 EXPECT_FALSE(adapter_->IsDiscoverable());
3432
3374 adapter_->SetDiscoverable(true, base::Bind(&BluetoothChromeOSTest::Callback, 3433 adapter_->SetDiscoverable(true, base::Bind(&BluetoothChromeOSTest::Callback,
3375 base::Unretained(this)), 3434 base::Unretained(this)),
3376 base::Bind(&BluetoothChromeOSTest::ErrorCallback, 3435 base::Bind(&BluetoothChromeOSTest::ErrorCallback,
3377 base::Unretained(this))); 3436 base::Unretained(this)));
3437 EXPECT_EQ(0, callback_count_);
3438 EXPECT_EQ(1, error_callback_count_) << "SetDiscoverable error";
3439 error_callback_count_ = 0;
3440
3441 EXPECT_FALSE(adapter_->IsDiscovering());
3442 // CreateRfcommService will DCHECK after Shutdown().
3443 // CreateL2capService will DCHECK after Shutdown().
3444
3445 BluetoothAudioSink::Options audio_sink_options;
3446 adapter_->RegisterAudioSink(
3447 audio_sink_options,
3448 base::Bind(&BluetoothChromeOSTest::AudioSinkAcquiredCallback,
3449 base::Unretained(this)),
3450 base::Bind(&BluetoothChromeOSTest::AudioSinkErrorCallback,
3451 base::Unretained(this)));
3452 EXPECT_EQ(0, callback_count_);
3453 EXPECT_EQ(1, error_callback_count_) << "RegisterAudioSink error";
3454 error_callback_count_ = 0;
3455
3456 BluetoothAdapterChromeOS* adapter_chrome_os =
3457 static_cast<BluetoothAdapterChromeOS*>(adapter_.get());
3458 EXPECT_EQ(NULL, adapter_chrome_os->GetDeviceWithPath(dbus::ObjectPath("")));
3459
3460 // Notify methods presume objects exist that are owned by the adapter and
3461 // destroyed in Shutdown(). Mocks are not attempted here that won't exist,
3462 // as verified below by EXPECT_EQ(0U, adapter_->GetDevices().size());
3463 // NotifyDeviceChanged
3464 // NotifyGattServiceAdded
3465 // NotifyGattServiceRemoved
3466 // NotifyGattServiceChanged
3467 // NotifyGattDiscoveryComplete
3468 // NotifyGattCharacteristicAdded
3469 // NotifyGattCharacteristicRemoved
3470 // NotifyGattDescriptorAdded
3471 // NotifyGattDescriptorRemoved
3472 // NotifyGattCharacteristicValueChanged
3473 // NotifyGattDescriptorValueChanged
3474
3475 EXPECT_EQ(dbus::ObjectPath(""), adapter_chrome_os->object_path());
3476
3477 FakeBluetoothProfileServiceProviderDelegate profile_delegate;
3478 adapter_chrome_os->UseProfile(
3479 BluetoothUUID(), dbus::ObjectPath(""),
3480 BluetoothProfileManagerClient::Options(), &profile_delegate,
3481 base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback,
3482 base::Unretained(this)),
3483 base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback,
3484 base::Unretained(this)));
3485 EXPECT_EQ(0, callback_count_) << "UseProfile error";
3486 EXPECT_EQ(0, error_callback_count_) << "UseProfile error";
3487 error_callback_count_ = 0;
3488
3489 adapter_chrome_os->ReleaseProfile(BluetoothUUID());
3490
3491 // Protected and private methods:
3492
3493 adapter_chrome_os->RemovePairingDelegateInternal(&pairing_delegate);
3494
3495 // BluetoothAdapterClient::Observer methods omitted, dbus will be shutdown.
3496 // BluetoothDeviceClient::Observer methods omitted, dbus will be shutdown.
3497 // BluetoothInputClient::Observer methods omitted, dbus will be shutdown.
3498 // BluetoothAgentServiceProvider::Delegate omitted, dbus will be shutdown,
3499 // with the exception of Released.
3500 adapter_chrome_os->Released();
3501
3502 adapter_chrome_os->OnRegisterAgent();
3503 adapter_chrome_os->OnRegisterAgentError("", "");
3504 adapter_chrome_os->OnRequestDefaultAgent();
3505 adapter_chrome_os->OnRequestDefaultAgentError("", "");
3506
3507 scoped_refptr<device::BluetoothAudioSink> audio_sink;
3508 adapter_chrome_os->OnRegisterAudioSink(
3509 base::Bind(&BluetoothChromeOSTest::AudioSinkAcquiredCallback,
3510 base::Unretained(this)),
3511 audio_sink);
3512 EXPECT_EQ(0, callback_count_);
3513 EXPECT_EQ(0, error_callback_count_) << "RegisterAudioSink error";
3514
3515 // GetPairing will DCHECK after Shutdown().
3516 // SetAdapter will DCHECK after Shutdown().
3517 // SetDefaultAdapterName will DCHECK after Shutdown().
3518 // RemoveAdapter will DCHECK after Shutdown().
3519 adapter_chrome_os->PoweredChanged(false);
3520 adapter_chrome_os->DiscoverableChanged(false);
3521 adapter_chrome_os->DiscoveringChanged(false);
3522 adapter_chrome_os->PresentChanged(false);
3523
3524 adapter_chrome_os->OnSetDiscoverable(
3525 base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)),
3526 base::Bind(&BluetoothChromeOSTest::ErrorCallback, base::Unretained(this)),
3527 true);
3528 EXPECT_EQ(0, callback_count_) << "OnSetDiscoverable error";
3529 EXPECT_EQ(1, error_callback_count_) << "OnSetDiscoverable error";
3530 error_callback_count_ = 0;
3531
3532 adapter_chrome_os->OnPropertyChangeCompleted(
3533 base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)),
3534 base::Bind(&BluetoothChromeOSTest::ErrorCallback, base::Unretained(this)),
3535 true);
3536 EXPECT_EQ(0, callback_count_) << "OnPropertyChangeCompleted error";
3537 EXPECT_EQ(1, error_callback_count_) << "OnPropertyChangeCompleted error";
3538 error_callback_count_ = 0;
3539
3540 adapter_chrome_os->AddDiscoverySession(
3541 base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)),
3542 base::Bind(&BluetoothChromeOSTest::ErrorCallback,
3543 base::Unretained(this)));
3544 EXPECT_EQ(0, callback_count_) << "AddDiscoverySession error";
3545 EXPECT_EQ(1, error_callback_count_) << "AddDiscoverySession error";
3546 error_callback_count_ = 0;
3547
3548 adapter_chrome_os->RemoveDiscoverySession(
3549 base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)),
3550 base::Bind(&BluetoothChromeOSTest::ErrorCallback,
3551 base::Unretained(this)));
3552 EXPECT_EQ(0, callback_count_) << "RemoveDiscoverySession error";
3553 EXPECT_EQ(1, error_callback_count_) << "RemoveDiscoverySession error";
3554 error_callback_count_ = 0;
3555
3556 // OnStartDiscovery will DCHECK after Shutdown().
3557
3558 adapter_chrome_os->OnStartDiscoveryError(
3559 base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)),
3560 base::Bind(&BluetoothChromeOSTest::ErrorCallback, base::Unretained(this)),
3561 "", "");
3562 EXPECT_EQ(0, callback_count_) << "OnStartDiscoveryError error";
3563 EXPECT_EQ(1, error_callback_count_) << "OnStartDiscoveryError error";
3564 error_callback_count_ = 0;
3565
3566 // OnStopDiscovery will fail after Shutdown().
3567
3568 adapter_chrome_os->OnStopDiscoveryError(
3569 base::Bind(&BluetoothChromeOSTest::ErrorCallback, base::Unretained(this)),
3570 "", "");
3571 EXPECT_EQ(0, callback_count_) << "OnStopDiscoveryError error";
3572 EXPECT_EQ(1, error_callback_count_) << "OnStopDiscoveryError error";
3573 error_callback_count_ = 0;
3574
3575 // OnRegisterProfile omitted, dbus will be shutdown.
3576 // SetProfileDelegate omitted, dbus will be shutdown.
3577 // OnRegisterProfileError omitted, dbus will be shutdown.
3578
3579 adapter_chrome_os->ProcessQueuedDiscoveryRequests();
3580
3581 // From BluetoothAdapater:
3582
3378 adapter_->StartDiscoverySession( 3583 adapter_->StartDiscoverySession(
3379 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, 3584 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback,
3380 base::Unretained(this)), 3585 base::Unretained(this)),
3381 base::Bind(&BluetoothChromeOSTest::ErrorCallback, 3586 base::Bind(&BluetoothChromeOSTest::ErrorCallback,
3382 base::Unretained(this))); 3587 base::Unretained(this)));
3383 ASSERT_EQ(0, callback_count_); 3588 EXPECT_EQ(0, callback_count_) << "StartDiscoverySession error";
3384 ASSERT_EQ(3, error_callback_count_); 3589 EXPECT_EQ(1, error_callback_count_) << "StartDiscoverySession error";
3590 error_callback_count_ = 0;
3591
3592 EXPECT_EQ(0U, adapter_->GetDevices().size());
3593 EXPECT_EQ(nullptr, adapter_->GetDevice(
3594 FakeBluetoothDeviceClient::kPairedDeviceAddress));
3595 TestPairingDelegate pairing_delegate2;
3596 adapter_->AddPairingDelegate(
3597 &pairing_delegate2, BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH);
3598 adapter_->RemovePairingDelegate(&pairing_delegate2);
3385 } 3599 }
3386 3600
3387 } // namespace chromeos 3601 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698