diff options
author | jamuraa <jamuraa@chromium.org> | 2015-06-25 14:55:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-25 21:56:20 +0000 |
commit | 512c2f57f0dbcb312ee5aa79451568f7a8233a02 (patch) | |
tree | dc83d0244157b88fb1a2ad2ff38e9ad000ad590c /device/bluetooth | |
parent | 917fac73b0b046b774ea10fa76074d7397568f8d (diff) | |
download | chromium_src-512c2f57f0dbcb312ee5aa79451568f7a8233a02.zip chromium_src-512c2f57f0dbcb312ee5aa79451568f7a8233a02.tar.gz chromium_src-512c2f57f0dbcb312ee5aa79451568f7a8233a02.tar.bz2 |
Submission for C++ Readability
Some files have had minor comments changes made, others just an added newline at the end for git to allow adding.
BUG=None
Review URL: https://codereview.chromium.org/1124883004
Cr-Commit-Position: refs/heads/master@{#336270}
Diffstat (limited to 'device/bluetooth')
-rw-r--r-- | device/bluetooth/bluetooth_adapter_chromeos.cc | 57 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_adapter_chromeos.h | 10 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_adapter_profile_chromeos.h | 5 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc | 10 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_chromeos_unittest.cc | 161 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_device_chromeos.h | 7 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_socket_chromeos.cc | 10 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_socket_chromeos.h | 2 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_socket_chromeos_unittest.cc | 64 |
9 files changed, 176 insertions, 150 deletions
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc index a521c8f..9ba2cbd 100644 --- a/device/bluetooth/bluetooth_adapter_chromeos.cc +++ b/device/bluetooth/bluetooth_adapter_chromeos.cc @@ -67,7 +67,7 @@ base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter( return chromeos::BluetoothAdapterChromeOS::CreateAdapter(); } -} +} // namespace device namespace chromeos { @@ -87,7 +87,7 @@ void BluetoothAdapterChromeOS::Shutdown() { if (IsPresent()) RemoveAdapter(); // Also deletes devices_. DCHECK(devices_.empty()); - // profiles_ should be empty because all BluetoothSockets have been signaled + // profiles_ is empty because all BluetoothSockets have been notified // that this adapter is disappearing. DCHECK(profiles_.empty()); @@ -324,9 +324,8 @@ void BluetoothAdapterChromeOS::RegisterAdvertisement( void BluetoothAdapterChromeOS::RemovePairingDelegateInternal( BluetoothDevice::PairingDelegate* pairing_delegate) { - // Before removing a pairing delegate make sure that there aren't any devices - // currently using it; if there are, clear the pairing context which will - // make any responses no-ops. + // Check if any device is using the pairing delegate. + // If so, clear the pairing context which will make any responses no-ops. for (DevicesMap::iterator iter = devices_.begin(); iter != devices_.end(); ++iter) { BluetoothDeviceChromeOS* device_chromeos = @@ -362,12 +361,13 @@ void BluetoothAdapterChromeOS::AdapterPropertyChanged( DBusThreadManager::Get()->GetBluetoothAdapterClient()-> GetProperties(object_path_); - if (property_name == properties->powered.name()) + if (property_name == properties->powered.name()) { PoweredChanged(properties->powered.value()); - else if (property_name == properties->discoverable.name()) + } else if (property_name == properties->discoverable.name()) { DiscoverableChanged(properties->discoverable.value()); - else if (property_name == properties->discovering.name()) + } else if (property_name == properties->discovering.name()) { DiscoveringChanged(properties->discovering.value()); + } } void BluetoothAdapterChromeOS::DeviceAdded( @@ -429,14 +429,16 @@ void BluetoothAdapterChromeOS::DevicePropertyChanged( property_name == properties->connected.name() || property_name == properties->uuids.name() || property_name == properties->rssi.name() || - property_name == properties->tx_power.name()) + property_name == properties->tx_power.name()) { NotifyDeviceChanged(device_chromeos); + } // When a device becomes paired, mark it as trusted so that the user does // not need to approve every incoming connection if (property_name == properties->paired.name() && - properties->paired.value() && !properties->trusted.value()) + properties->paired.value() && !properties->trusted.value()) { device_chromeos->SetTrusted(); + } // UMA connection counting if (property_name == properties->connected.name()) { @@ -473,9 +475,9 @@ void BluetoothAdapterChromeOS::InputPropertyChanged( // Properties structure can be removed, which triggers a change in the // BluetoothDevice::IsConnectable() property, as does a change in the // actual reconnect_mode property. - if (!properties || - property_name == properties->reconnect_mode.name()) + if (!properties || property_name == properties->reconnect_mode.name()) { NotifyDeviceChanged(device_chromeos); + } } void BluetoothAdapterChromeOS::Released() { @@ -673,7 +675,7 @@ BluetoothDeviceChromeOS* BluetoothAdapterChromeOS::GetDeviceWithPath( const dbus::ObjectPath& object_path) { if (!IsPresent()) - return NULL; + return nullptr; for (DevicesMap::iterator iter = devices_.begin(); iter != devices_.end(); ++iter) { @@ -683,7 +685,7 @@ BluetoothAdapterChromeOS::GetDeviceWithPath( return device_chromeos; } - return NULL; + return nullptr; } BluetoothPairingChromeOS* BluetoothAdapterChromeOS::GetPairing( @@ -693,7 +695,7 @@ BluetoothPairingChromeOS* BluetoothAdapterChromeOS::GetPairing( if (!device_chromeos) { LOG(WARNING) << "Pairing Agent request for unknown device: " << object_path.value(); - return NULL; + return nullptr; } BluetoothPairingChromeOS* pairing = device_chromeos->GetPairing(); @@ -704,7 +706,7 @@ BluetoothPairingChromeOS* BluetoothAdapterChromeOS::GetPairing( // pairing request that should use our best default delegate (if we have one). BluetoothDevice::PairingDelegate* pairing_delegate = DefaultPairingDelegate(); if (!pairing_delegate) - return NULL; + return nullptr; return device_chromeos->BeginPairing(pairing_delegate); } @@ -813,8 +815,8 @@ void BluetoothAdapterChromeOS::DiscoveringChanged( // If the adapter stopped discovery due to a reason other than a request by // us, reset the count to 0. VLOG(1) << "Discovering changed: " << discovering; - if (!discovering && !discovery_request_pending_ - && num_discovery_sessions_ > 0) { + if (!discovering && !discovery_request_pending_ && + num_discovery_sessions_ > 0) { VLOG(1) << "Marking sessions as inactive."; num_discovery_sessions_ = 0; MarkDiscoverySessionsAsInactive(); @@ -830,6 +832,7 @@ void BluetoothAdapterChromeOS::PresentChanged(bool present) { void BluetoothAdapterChromeOS::NotifyDeviceChanged( BluetoothDeviceChromeOS* device) { + DCHECK(device); DCHECK(device->adapter_ == this); FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, @@ -1078,10 +1081,11 @@ void BluetoothAdapterChromeOS::OnPropertyChangeCompleted( const base::Closure& callback, const ErrorCallback& error_callback, bool success) { - if (IsPresent() && success) + if (IsPresent() && success) { callback.Run(); - else + } else { error_callback.Run(); + } } void BluetoothAdapterChromeOS::AddDiscoverySession( @@ -1131,8 +1135,9 @@ void BluetoothAdapterChromeOS::AddDiscoverySession( base::Bind(&BluetoothAdapterChromeOS::OnPreSetDiscoveryFilterError, weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); return; - } else + } else { current_filter_.reset(); + } // This is the first request to start device discovery. discovery_request_pending_ = true; @@ -1276,10 +1281,11 @@ void BluetoothAdapterChromeOS::OnStartDiscovery( DCHECK_EQ(num_discovery_sessions_, 0); discovery_request_pending_ = false; num_discovery_sessions_++; - if (IsPresent()) + if (IsPresent()) { callback.Run(); - else + } else { error_callback.Run(); + } // Try to add a new discovery session for each queued request. ProcessQueuedDiscoveryRequests(); @@ -1383,10 +1389,11 @@ void BluetoothAdapterChromeOS::OnSetDiscoveryFilter( const ErrorCallback& error_callback) { // Report success on the original request and increment the count. VLOG(1) << __func__; - if (IsPresent()) + if (IsPresent()) { callback.Run(); - else + } else { error_callback.Run(); + } } void BluetoothAdapterChromeOS::OnSetDiscoveryFilterError( diff --git a/device/bluetooth/bluetooth_adapter_chromeos.h b/device/bluetooth/bluetooth_adapter_chromeos.h index 13942d8..0775c1a 100644 --- a/device/bluetooth/bluetooth_adapter_chromeos.h +++ b/device/bluetooth/bluetooth_adapter_chromeos.h @@ -46,6 +46,12 @@ class BluetoothRemoteGattServiceChromeOS; // The BluetoothAdapterChromeOS class implements BluetoothAdapter for the // Chrome OS platform. // +// All methods are called from the dbus origin / UI thread and are generally +// not assumed to be thread-safe. +// +// This class interacts with sockets using the BluetoothSocketThread to ensure +// single-threaded calls, and posts tasks to the UI thread. +// // Methods tolerate a shutdown scenario where BluetoothAdapterChromeOS::Shutdown // causes IsPresent to return false just before the dbus system is shutdown but // while references to the BluetoothAdapterChromeOS object still exists. @@ -109,8 +115,8 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS BluetoothDeviceChromeOS* GetDeviceWithPath( const dbus::ObjectPath& object_path); - // Announce to observers a change in device state that is not reflected by - // its D-Bus properties. + // Announces to observers a change in device state that is not reflected by + // its D-Bus properties. |device| is owned by the caller and cannot be NULL. void NotifyDeviceChanged(BluetoothDeviceChromeOS* device); // The following methods are used to send various GATT observer events to diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos.h b/device/bluetooth/bluetooth_adapter_profile_chromeos.h index fbbb9f6..85e2ffe 100644 --- a/device/bluetooth/bluetooth_adapter_profile_chromeos.h +++ b/device/bluetooth/bluetooth_adapter_profile_chromeos.h @@ -22,6 +22,9 @@ namespace chromeos { // Maintains a list of delegates which may serve the profile. // One delegate is allowed for each device. // +// This class is not thread-safe, but is only called from the dbus origin +// thread. +// // BluetoothAdapterProfileChromeOS objects are owned by the // BluetoothAdapterChromeOS and allocated through Register() class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS @@ -103,4 +106,4 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS } // namespace chromeos -#endif +#endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc b/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc index e690c9d..f5b96f8 100644 --- a/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc @@ -191,7 +191,7 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { base::Bind(&base::DoNothing)); EXPECT_EQ(0U, profile_->DelegateCount()); -}; +} TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); @@ -227,7 +227,7 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { EXPECT_EQ(1U, error_callback_count_); EXPECT_EQ(0U, fake_delegate_paired_.connections_); -}; +} TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); @@ -303,7 +303,7 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { EXPECT_EQ(0U, error_callback_count_); EXPECT_EQ(1U, fake_delegate_listen_.connections_); -}; +} TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); @@ -344,7 +344,7 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { profile_user_ptr_); message_loop_.RunUntilIdle(); -}; +} TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kUnregisterableUuid); @@ -378,6 +378,6 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { EXPECT_FALSE(profile_user_ptr_); EXPECT_EQ(0U, success_callback_count_); EXPECT_EQ(2U, error_callback_count_); -}; +} } // namespace chromeos diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_chromeos_unittest.cc index ad19d8b..47ef7fe 100644 --- a/device/bluetooth/bluetooth_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_chromeos_unittest.cc @@ -139,14 +139,15 @@ class TestPairingDelegate : public BluetoothDevice::PairingDelegate { uint32 last_entered_; std::string last_pincode_; - private: - // Some tests use a message loop since background processing is simulated; - // break out of those loops. - void QuitMessageLoop() { - if (base::MessageLoop::current() && - base::MessageLoop::current()->is_running()) - base::MessageLoop::current()->Quit(); - } + private: + // Some tests use a message loop since background processing is simulated; + // break out of those loops. + void QuitMessageLoop() { + if (base::MessageLoop::current() && + base::MessageLoop::current()->is_running()) { + base::MessageLoop::current()->Quit(); + } + } }; class BluetoothChromeOSTest : public testing::Test { @@ -194,7 +195,7 @@ class BluetoothChromeOSTest : public testing::Test { ASSERT_EQ(1, callback_count_); } discovery_sessions_.clear(); - adapter_ = NULL; + adapter_ = nullptr; DBusThreadManager::Shutdown(); } @@ -261,7 +262,7 @@ class BluetoothChromeOSTest : public testing::Test { // Call to fill the adapter_ member with a BluetoothAdapter instance. void GetAdapter() { adapter_ = new BluetoothAdapterChromeOS(); - ASSERT_TRUE(adapter_.get() != NULL); + ASSERT_TRUE(adapter_.get() != nullptr); ASSERT_TRUE(adapter_->IsInitialized()); } @@ -271,8 +272,8 @@ class BluetoothChromeOSTest : public testing::Test { // The correct behavior of discovery is tested by the "Discovery" test case // without using this function. void DiscoverDevice(const std::string& address) { - ASSERT_TRUE(adapter_.get() != NULL); - ASSERT_TRUE(base::MessageLoop::current() != NULL); + ASSERT_TRUE(adapter_.get() != nullptr); + ASSERT_TRUE(base::MessageLoop::current() != nullptr); fake_bluetooth_device_client_->SetSimulationIntervalMs(10); TestBluetoothAdapterObserver observer(adapter_); @@ -330,8 +331,9 @@ class BluetoothChromeOSTest : public testing::Test { // break out of those loops. void QuitMessageLoop() { if (base::MessageLoop::current() && - base::MessageLoop::current()->is_running()) + base::MessageLoop::current()->is_running()) { base::MessageLoop::current()->Quit(); + } } }; @@ -1398,7 +1400,7 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscovery) { ASSERT_EQ((size_t)1, discovery_sessions_.size()); ASSERT_FALSE(discovery_sessions_[0]->IsActive()); ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), - (BluetoothDiscoveryFilter*)NULL); + (BluetoothDiscoveryFilter*)nullptr); filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); EXPECT_EQ(nullptr, filter); @@ -1537,10 +1539,10 @@ TEST_F(BluetoothChromeOSTest, QueuedSetDiscoveryFilterBeforeStartDiscovery) { ASSERT_FALSE(adapter_->IsDiscovering()); ASSERT_FALSE(discovery_sessions_[0]->IsActive()); ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), - (BluetoothDiscoveryFilter*)NULL); + (BluetoothDiscoveryFilter*)nullptr); ASSERT_FALSE(discovery_sessions_[1]->IsActive()); ASSERT_EQ(discovery_sessions_[1]->GetDiscoveryFilter(), - (BluetoothDiscoveryFilter*)NULL); + (BluetoothDiscoveryFilter*)nullptr); filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); EXPECT_EQ(nullptr, filter); @@ -1641,7 +1643,7 @@ TEST_F(BluetoothChromeOSTest, ASSERT_FALSE(adapter_->IsDiscovering()); ASSERT_FALSE(discovery_sessions_[0]->IsActive()); ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), - (BluetoothDiscoveryFilter*)NULL); + (BluetoothDiscoveryFilter*)nullptr); filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); EXPECT_EQ(nullptr, filter); @@ -1675,9 +1677,9 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) { EXPECT_EQ(1, observer.discovering_changed_count()); observer.Reset(); - auto nullInstance = scoped_ptr<BluetoothDiscoveryFilter>(); - nullInstance.reset(); - ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), nullInstance.get()); + auto null_instance = scoped_ptr<BluetoothDiscoveryFilter>(); + null_instance.reset(); + ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), null_instance.get()); auto filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); EXPECT_EQ(nullptr, filter); @@ -1724,7 +1726,7 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) { ASSERT_EQ((size_t)1, discovery_sessions_.size()); ASSERT_FALSE(discovery_sessions_[0]->IsActive()); ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), - (BluetoothDiscoveryFilter*)NULL); + (BluetoothDiscoveryFilter*)nullptr); filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); EXPECT_EQ(nullptr, filter); @@ -2305,11 +2307,11 @@ TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kConnectUnpairableAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); // Connect the device so it becomes trusted and remembered. - device->Connect(NULL, GetCallback(), + device->Connect(nullptr, GetCallback(), base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, base::Unretained(this))); @@ -2340,7 +2342,7 @@ TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { // GetDevices shouldn't return the device either. device = adapter_->GetDevice( FakeBluetoothDeviceClient::kConnectUnpairableAddress); - EXPECT_FALSE(device != NULL); + EXPECT_FALSE(device != nullptr); } TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { @@ -2348,14 +2350,14 @@ TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kPairedDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_TRUE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); // Connect without a pairing delegate; since the device is already Paired // this should succeed and the device should become connected. - device->Connect(NULL, GetCallback(), + device->Connect(nullptr, GetCallback(), base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, base::Unretained(this))); @@ -2377,14 +2379,14 @@ TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kConnectUnpairableAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); // Connect without a pairing delegate; since the device does not require // pairing, this should succeed and the device should become connected. - device->Connect(NULL, GetCallback(), + device->Connect(nullptr, GetCallback(), base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, base::Unretained(this))); @@ -2417,10 +2419,10 @@ TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kPairedDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_TRUE(device->IsPaired()); - device->Connect(NULL, GetCallback(), + device->Connect(nullptr, GetCallback(), base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, base::Unretained(this))); @@ -2434,7 +2436,7 @@ TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { // anything to initiate the connection. TestBluetoothAdapterObserver observer(adapter_); - device->Connect(NULL, GetCallback(), + device->Connect(nullptr, GetCallback(), base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, base::Unretained(this))); @@ -2455,14 +2457,14 @@ TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kLegacyAutopairAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); // Connect without a pairing delegate; since the device requires pairing, // this should fail with an error. - device->Connect(NULL, GetCallback(), + device->Connect(nullptr, GetCallback(), base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, base::Unretained(this))); @@ -2481,10 +2483,10 @@ TEST_F(BluetoothChromeOSTest, DisconnectDevice) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kPairedDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_TRUE(device->IsPaired()); - device->Connect(NULL, GetCallback(), + device->Connect(nullptr, GetCallback(), base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, base::Unretained(this))); @@ -2515,7 +2517,7 @@ TEST_F(BluetoothChromeOSTest, DisconnectUnconnectedDevice) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kPairedDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_TRUE(device->IsPaired()); ASSERT_FALSE(device->IsConnected()); @@ -2543,7 +2545,7 @@ TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { // the daemon provides 0000 to the device for us. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kLegacyAutopairAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -2594,7 +2596,7 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { // Requires that we display a randomly generated PIN on the screen. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kDisplayPinCodeAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -2648,7 +2650,7 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { // and notifies us as it's typed in. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kDisplayPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -2668,7 +2670,7 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { EXPECT_TRUE(device->IsConnecting()); // One call to KeysEntered() for each key, including [enter]. - for(int i = 1; i <= 7; ++i) { + for (int i = 1; i <= 7; ++i) { message_loop_.Run(); EXPECT_EQ(2 + i, pairing_delegate.call_count_); @@ -2722,7 +2724,7 @@ TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { // Requires that the user enters a PIN for them. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPinCodeAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -2776,7 +2778,7 @@ TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { // Requests that we confirm a displayed passkey. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kConfirmPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -2828,7 +2830,7 @@ TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { // device that has a display, but doesn't use "just works" - maybe a car? BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -2879,7 +2881,7 @@ TEST_F(BluetoothChromeOSTest, PairJustWorks) { // interaction is required. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kJustWorksAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -2924,7 +2926,7 @@ TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kUnpairableDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -2959,7 +2961,7 @@ TEST_F(BluetoothChromeOSTest, PairingFails) { // The vanishing device times out during pairing BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kVanishingDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -2995,7 +2997,7 @@ TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { // it pairs, but then you can't make connections to it after. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3042,7 +3044,7 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { // Reject the pairing after we receive a request for the PIN code. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPinCodeAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3080,7 +3082,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { // Cancel the pairing after we receive a request for the PIN code. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPinCodeAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3118,7 +3120,7 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { // Reject the pairing after we receive a request for the passkey. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3156,7 +3158,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { // Cancel the pairing after we receive a request for the passkey. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3194,7 +3196,7 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { // Reject the pairing after we receive a request for passkey confirmation. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kConfirmPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3232,7 +3234,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { // Cancel the pairing after we receive a request for the passkey. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kConfirmPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3270,7 +3272,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { // Cancel the pairing while we're waiting for the remote host. BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kLegacyAutopairAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3314,7 +3316,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCode) { dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPinCodeAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3349,7 +3351,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCode) { // No pairing context should remain on the device. BluetoothDeviceChromeOS* device_chromeos = static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == NULL); + EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); } TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { @@ -3368,7 +3370,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kConfirmPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3404,7 +3406,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { // No pairing context should remain on the device. BluetoothDeviceChromeOS* device_chromeos = static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == NULL); + EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); } TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { @@ -3423,7 +3425,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3458,7 +3460,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { // No pairing context should remain on the device. BluetoothDeviceChromeOS* device_chromeos = static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == NULL); + EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); } TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { @@ -3478,7 +3480,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kJustWorksAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3513,7 +3515,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { // No pairing context should remain on the device. BluetoothDeviceChromeOS* device_chromeos = static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == NULL); + EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); } TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { @@ -3528,7 +3530,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPinCodeAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3552,7 +3554,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { // No pairing context should remain on the device. BluetoothDeviceChromeOS* device_chromeos = static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == NULL); + EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); } TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { @@ -3567,7 +3569,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kConfirmPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3591,7 +3593,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { // No pairing context should remain on the device. BluetoothDeviceChromeOS* device_chromeos = static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == NULL); + EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); } TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { @@ -3606,7 +3608,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3630,7 +3632,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { // No pairing context should remain on the device. BluetoothDeviceChromeOS* device_chromeos = static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == NULL); + EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); } TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { @@ -3645,7 +3647,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kJustWorksAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3669,7 +3671,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { // No pairing context should remain on the device. BluetoothDeviceChromeOS* device_chromeos = static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == NULL); + EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); } TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { @@ -3688,7 +3690,7 @@ TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kRequestPasskeyAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); @@ -3704,12 +3706,12 @@ TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { // A pairing context should now be set on the device. BluetoothDeviceChromeOS* device_chromeos = static_cast<BluetoothDeviceChromeOS*>(device); - ASSERT_TRUE(device_chromeos->GetPairing() != NULL); + ASSERT_TRUE(device_chromeos->GetPairing() != nullptr); // Removing the pairing delegate should remove that pairing context. adapter_->RemovePairingDelegate(&pairing_delegate); - EXPECT_TRUE(device_chromeos->GetPairing() == NULL); + EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); // Set the Passkey, this should now have no effect since the pairing has // been, in-effect, cancelled @@ -3733,8 +3735,8 @@ TEST_F(BluetoothChromeOSTest, DeviceId) { fake_bluetooth_device_client_->GetProperties( dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); - ASSERT_TRUE(device != NULL); - ASSERT_TRUE(properties != NULL); + ASSERT_TRUE(device != nullptr); + ASSERT_TRUE(properties != nullptr); // Valid USB IF-assigned identifier. ASSERT_EQ("usb:v05ACp030Dd0306", properties->modalias.value()); @@ -3798,7 +3800,7 @@ TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) { BluetoothDevice* device = adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); - device->Connect(NULL, GetCallback(), + device->Connect(nullptr, GetCallback(), base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_TRUE(device->IsConnected()); @@ -3894,7 +3896,8 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { BluetoothAdapterChromeOS* adapter_chrome_os = static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); - EXPECT_EQ(NULL, adapter_chrome_os->GetDeviceWithPath(dbus::ObjectPath(""))); + EXPECT_EQ(nullptr, + adapter_chrome_os->GetDeviceWithPath(dbus::ObjectPath(""))); // Notify methods presume objects exist that are owned by the adapter and // destroyed in Shutdown(). Mocks are not attempted here that won't exist, @@ -3913,7 +3916,7 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { EXPECT_EQ(dbus::ObjectPath(""), adapter_chrome_os->object_path()); - adapter_profile_ = NULL; + adapter_profile_ = nullptr; FakeBluetoothProfileServiceProviderDelegate profile_delegate; adapter_chrome_os->UseProfile( @@ -3989,7 +3992,7 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { // OnStopDiscovery tested in Shutdown_OnStopDiscovery // OnStopDiscoveryError tested in Shutdown_OnStopDiscoveryError - adapter_profile_ = NULL; + adapter_profile_ = nullptr; // OnRegisterProfile SetProfileDelegate, OnRegisterProfileError, require // UseProfile to be set first, do so again here just before calling them. diff --git a/device/bluetooth/bluetooth_device_chromeos.h b/device/bluetooth/bluetooth_device_chromeos.h index 94612d3..f937be7 100644 --- a/device/bluetooth/bluetooth_device_chromeos.h +++ b/device/bluetooth/bluetooth_device_chromeos.h @@ -28,6 +28,11 @@ class BluetoothPairingChromeOS; // The BluetoothDeviceChromeOS class implements BluetoothDevice for the // Chrome OS platform. +// +// This class is not thread-safe, but is only called from the UI thread. +// +// A socket thread is used to create sockets but posts all callbacks on the UI +// thread. class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS : public device::BluetoothDevice, public BluetoothGattServiceClient::Observer { @@ -94,7 +99,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS BluetoothAdapterChromeOS* adapter() const { return adapter_; } protected: - // BluetoothDevice override + // BluetoothDevice override std::string GetDeviceName() const override; private: diff --git a/device/bluetooth/bluetooth_socket_chromeos.cc b/device/bluetooth/bluetooth_socket_chromeos.cc index eb786f9..da15484 100644 --- a/device/bluetooth/bluetooth_socket_chromeos.cc +++ b/device/bluetooth/bluetooth_socket_chromeos.cc @@ -86,7 +86,7 @@ BluetoothSocketChromeOS::~BluetoothSocketChromeOS() { if (adapter_.get()) { adapter_->RemoveObserver(this); - adapter_ = NULL; + adapter_ = nullptr; } } @@ -168,7 +168,7 @@ void BluetoothSocketChromeOS::Close() { // DBusThreadManager during shutdown if that callback executes too late. if (adapter_.get()) { adapter_->RemoveObserver(this); - adapter_ = NULL; + adapter_ = nullptr; } if (!device_path_.value().empty()) { @@ -182,7 +182,7 @@ void BluetoothSocketChromeOS::Disconnect(const base::Closure& callback) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); if (profile_) - UnregisterProfile(); + UnregisterProfile(); if (!device_path_.value().empty()) { BluetoothSocketNet::Disconnect(callback); @@ -523,7 +523,7 @@ void BluetoothSocketChromeOS::OnNewConnection( accept_request_->error_callback.Run(kAcceptFailed); } - accept_request_.reset(NULL); + accept_request_.reset(nullptr); connection_request_queue_.pop(); callback.Run(status); @@ -535,7 +535,7 @@ void BluetoothSocketChromeOS::DoCloseListening() { if (accept_request_) { accept_request_->error_callback.Run( net::ErrorToString(net::ERR_CONNECTION_CLOSED)); - accept_request_.reset(NULL); + accept_request_.reset(nullptr); } while (connection_request_queue_.size() > 0) { diff --git a/device/bluetooth/bluetooth_socket_chromeos.h b/device/bluetooth/bluetooth_socket_chromeos.h index f836b21..98d4d02 100644 --- a/device/bluetooth/bluetooth_socket_chromeos.h +++ b/device/bluetooth/bluetooth_socket_chromeos.h @@ -31,6 +31,8 @@ class BluetoothAdapterProfileChromeOS; // The BluetoothSocketChromeOS class implements BluetoothSocket for the // Chrome OS platform. +// +// This class is not thread-safe, but is only called from the UI thread. class CHROMEOS_EXPORT BluetoothSocketChromeOS : public device::BluetoothSocketNet, public device::BluetoothAdapter::Observer, diff --git a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc b/device/bluetooth/bluetooth_socket_chromeos_unittest.cc index 7630167..697365d 100644 --- a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_socket_chromeos_unittest.cc @@ -76,7 +76,7 @@ class BluetoothSocketChromeOSTest : public testing::Test { device::BluetoothAdapterFactory::GetAdapter( base::Bind(&BluetoothSocketChromeOSTest::AdapterCallback, base::Unretained(this))); - ASSERT_TRUE(adapter_.get() != NULL); + ASSERT_TRUE(adapter_.get() != nullptr); ASSERT_TRUE(adapter_->IsInitialized()); ASSERT_TRUE(adapter_->IsPresent()); @@ -89,7 +89,7 @@ class BluetoothSocketChromeOSTest : public testing::Test { } void TearDown() override { - adapter_ = NULL; + adapter_ = nullptr; BluetoothSocketThread::CleanupForTesting(); DBusThreadManager::Shutdown(); } @@ -184,7 +184,7 @@ class BluetoothSocketChromeOSTest : public testing::Test { TEST_F(BluetoothSocketChromeOSTest, Connect) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kPairedDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); device->ConnectToService( BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), @@ -196,11 +196,11 @@ TEST_F(BluetoothSocketChromeOSTest, Connect) { EXPECT_EQ(1U, success_callback_count_); EXPECT_EQ(0U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() != NULL); + EXPECT_TRUE(last_socket_.get() != nullptr); // Take ownership of the socket for the remainder of the test. scoped_refptr<BluetoothSocket> socket = last_socket_; - last_socket_ = NULL; + last_socket_ = nullptr; success_callback_count_ = 0; error_callback_count_ = 0; @@ -235,18 +235,18 @@ TEST_F(BluetoothSocketChromeOSTest, Connect) { EXPECT_EQ(1U, success_callback_count_); EXPECT_EQ(0U, error_callback_count_); EXPECT_EQ(4, last_bytes_received_); - EXPECT_TRUE(last_io_buffer_.get() != NULL); + EXPECT_TRUE(last_io_buffer_.get() != nullptr); // Take ownership of the received buffer. scoped_refptr<net::IOBuffer> read_buffer = last_io_buffer_; - last_io_buffer_ = NULL; + last_io_buffer_ = nullptr; success_callback_count_ = 0; error_callback_count_ = 0; std::string data = std::string(read_buffer->data(), last_bytes_received_); EXPECT_EQ("test", data); - read_buffer = NULL; + read_buffer = nullptr; // Receive data again; the socket will have been closed, this should cause a // disconnected error to be returned via the error callback. @@ -305,11 +305,11 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { EXPECT_EQ(1U, success_callback_count_); EXPECT_EQ(0U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() != NULL); + EXPECT_TRUE(last_socket_.get() != nullptr); // Take ownership of the socket for the remainder of the test. scoped_refptr<BluetoothSocket> server_socket = last_socket_; - last_socket_ = NULL; + last_socket_ = nullptr; success_callback_count_ = 0; error_callback_count_ = 0; @@ -324,7 +324,7 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { DBusThreadManager::Get()->GetBluetoothDeviceClient()); BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kPairedDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); fake_bluetooth_device_client->ConnectProfile( static_cast<BluetoothDeviceChromeOS*>(device)->object_path(), FakeBluetoothProfileManagerClient::kRfcommUuid, @@ -343,11 +343,11 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { EXPECT_EQ(1U, success_callback_count_); EXPECT_EQ(0U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() != NULL); + EXPECT_TRUE(last_socket_.get() != nullptr); // Take ownership of the client socket for the remainder of the test. scoped_refptr<BluetoothSocket> client_socket = last_socket_; - last_socket_ = NULL; + last_socket_ = nullptr; success_callback_count_ = 0; error_callback_count_ = 0; @@ -359,7 +359,7 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { message_loop_.Run(); EXPECT_EQ(1U, success_callback_count_); - client_socket = NULL; + client_socket = nullptr; success_callback_count_ = 0; error_callback_count_ = 0; @@ -383,11 +383,11 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { EXPECT_EQ(1U, success_callback_count_); EXPECT_EQ(0U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() != NULL); + EXPECT_TRUE(last_socket_.get() != nullptr); // Take ownership of the client socket for the remainder of the test. client_socket = last_socket_; - last_socket_ = NULL; + last_socket_ = nullptr; success_callback_count_ = 0; error_callback_count_ = 0; @@ -399,7 +399,7 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { message_loop_.Run(); EXPECT_EQ(1U, success_callback_count_); - client_socket = NULL; + client_socket = nullptr; success_callback_count_ = 0; error_callback_count_ = 0; @@ -432,11 +432,11 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { EXPECT_EQ(1U, success_callback_count_); EXPECT_EQ(0U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() != NULL); + EXPECT_TRUE(last_socket_.get() != nullptr); // Take ownership of the socket for the remainder of the test. scoped_refptr<BluetoothSocket> socket = last_socket_; - last_socket_ = NULL; + last_socket_ = nullptr; success_callback_count_ = 0; error_callback_count_ = 0; @@ -447,7 +447,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { FakeBluetoothProfileServiceProvider* profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider( FakeBluetoothProfileManagerClient::kRfcommUuid); - EXPECT_TRUE(profile_service_provider == NULL); + EXPECT_TRUE(profile_service_provider == nullptr); // Make the adapter visible. This should register a profile. fake_bluetooth_adapter_client->SetVisible(true); @@ -457,7 +457,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider( FakeBluetoothProfileManagerClient::kRfcommUuid); - EXPECT_TRUE(profile_service_provider != NULL); + EXPECT_TRUE(profile_service_provider != nullptr); // Cleanup the socket. socket->Disconnect( @@ -486,11 +486,11 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { EXPECT_EQ(1U, success_callback_count_); EXPECT_EQ(0U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() != NULL); + EXPECT_TRUE(last_socket_.get() != nullptr); // Take ownership of the socket for the remainder of the test. scoped_refptr<BluetoothSocket> socket = last_socket_; - last_socket_ = NULL; + last_socket_ = nullptr; success_callback_count_ = 0; error_callback_count_ = 0; @@ -501,7 +501,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { FakeBluetoothProfileServiceProvider* profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider( FakeBluetoothProfileManagerClient::kRfcommUuid); - EXPECT_TRUE(profile_service_provider != NULL); + EXPECT_TRUE(profile_service_provider != nullptr); // Make the adapter invisible, and fiddle with the profile fake to unregister // the profile since this doesn't happen automatically. @@ -517,7 +517,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider( FakeBluetoothProfileManagerClient::kRfcommUuid); - EXPECT_TRUE(profile_service_provider != NULL); + EXPECT_TRUE(profile_service_provider != nullptr); // Cleanup the socket. socket->Disconnect( @@ -532,7 +532,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { BluetoothDevice* device = adapter_->GetDevice( FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress); - ASSERT_TRUE(device != NULL); + ASSERT_TRUE(device != nullptr); device->ConnectToService( BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), @@ -544,7 +544,7 @@ TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { EXPECT_EQ(0U, success_callback_count_); EXPECT_EQ(1U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() == NULL); + EXPECT_TRUE(last_socket_.get() == nullptr); device->ConnectToService( BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), @@ -556,7 +556,7 @@ TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { EXPECT_EQ(0U, success_callback_count_); EXPECT_EQ(2U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() == NULL); + EXPECT_TRUE(last_socket_.get() == nullptr); } TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { @@ -572,7 +572,7 @@ TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { EXPECT_EQ(1U, success_callback_count_); EXPECT_EQ(0U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() != NULL); + EXPECT_TRUE(last_socket_.get() != nullptr); // Take control of this socket. scoped_refptr<BluetoothSocket> server_socket; @@ -586,7 +586,7 @@ TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { server_socket->Close(); - server_socket = NULL; + server_socket = nullptr; message_loop_.RunUntilIdle(); @@ -605,7 +605,7 @@ TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { EXPECT_EQ(2U, success_callback_count_); EXPECT_EQ(1U, error_callback_count_); - EXPECT_TRUE(last_socket_.get() != NULL); + EXPECT_TRUE(last_socket_.get() != nullptr); // Take control of this socket. server_socket.swap(last_socket_); @@ -618,7 +618,7 @@ TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { server_socket->Close(); - server_socket = NULL; + server_socket = nullptr; message_loop_.RunUntilIdle(); |