| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 BluetoothRemoteGattDescriptor* descriptor = | 232 BluetoothRemoteGattDescriptor* descriptor = |
| 233 characteristic->GetDescriptors()[0]; | 233 characteristic->GetDescriptors()[0]; |
| 234 EXPECT_EQ( | 234 EXPECT_EQ( |
| 235 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid(), | 235 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid(), |
| 236 descriptor->GetUUID()); | 236 descriptor->GetUUID()); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { | 239 void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { |
| 240 adapter_ = adapter; | 240 adapter_ = adapter; |
| 241 if (base::MessageLoop::current() && | 241 if (base::RunLoop::IsRunningOnCurrentThread()) |
| 242 base::MessageLoop::current()->is_running()) { | |
| 243 base::MessageLoop::current()->QuitWhenIdle(); | 242 base::MessageLoop::current()->QuitWhenIdle(); |
| 244 } | |
| 245 } | 243 } |
| 246 | 244 |
| 247 void SuccessCallback() { ++success_callback_count_; } | 245 void SuccessCallback() { ++success_callback_count_; } |
| 248 | 246 |
| 249 void ValueCallback(const std::vector<uint8_t>& value) { | 247 void ValueCallback(const std::vector<uint8_t>& value) { |
| 250 ++success_callback_count_; | 248 ++success_callback_count_; |
| 251 last_read_value_ = value; | 249 last_read_value_ = value; |
| 252 } | 250 } |
| 253 | 251 |
| 254 void GattConnectionCallback(std::unique_ptr<BluetoothGattConnection> conn) { | 252 void GattConnectionCallback(std::unique_ptr<BluetoothGattConnection> conn) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 274 const std::string& error_message) { | 272 const std::string& error_message) { |
| 275 ++error_callback_count_; | 273 ++error_callback_count_; |
| 276 } | 274 } |
| 277 | 275 |
| 278 void ConnectErrorCallback(BluetoothDevice::ConnectErrorCode error) { | 276 void ConnectErrorCallback(BluetoothDevice::ConnectErrorCode error) { |
| 279 ++error_callback_count_; | 277 ++error_callback_count_; |
| 280 } | 278 } |
| 281 | 279 |
| 282 protected: | 280 protected: |
| 283 void QuitMessageLoop() { | 281 void QuitMessageLoop() { |
| 284 if (base::MessageLoop::current() && | 282 if (base::RunLoop::IsRunningOnCurrentThread()) |
| 285 base::MessageLoop::current()->is_running()) | |
| 286 base::MessageLoop::current()->QuitWhenIdle(); | 283 base::MessageLoop::current()->QuitWhenIdle(); |
| 287 } | 284 } |
| 288 | 285 |
| 289 base::MessageLoop message_loop_; | 286 base::MessageLoop message_loop_; |
| 290 | 287 |
| 291 bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_; | 288 bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_; |
| 292 bluez::FakeBluetoothGattServiceClient* fake_bluetooth_gatt_service_client_; | 289 bluez::FakeBluetoothGattServiceClient* fake_bluetooth_gatt_service_client_; |
| 293 bluez::FakeBluetoothGattCharacteristicClient* | 290 bluez::FakeBluetoothGattCharacteristicClient* |
| 294 fake_bluetooth_gatt_characteristic_client_; | 291 fake_bluetooth_gatt_characteristic_client_; |
| 295 bluez::FakeBluetoothGattDescriptorClient* | 292 bluez::FakeBluetoothGattDescriptorClient* |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 | 1633 |
| 1637 EXPECT_EQ(1, success_callback_count_); | 1634 EXPECT_EQ(1, success_callback_count_); |
| 1638 EXPECT_EQ(0, error_callback_count_); | 1635 EXPECT_EQ(0, error_callback_count_); |
| 1639 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); | 1636 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); |
| 1640 EXPECT_TRUE(characteristic->IsNotifying()); | 1637 EXPECT_TRUE(characteristic->IsNotifying()); |
| 1641 EXPECT_EQ(1U, update_sessions_.size()); | 1638 EXPECT_EQ(1U, update_sessions_.size()); |
| 1642 EXPECT_TRUE(update_sessions_[0]->IsActive()); | 1639 EXPECT_TRUE(update_sessions_[0]->IsActive()); |
| 1643 } | 1640 } |
| 1644 | 1641 |
| 1645 } // namespace bluez | 1642 } // namespace bluez |
| OLD | NEW |