| 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 "components/proximity_auth/ble/bluetooth_low_energy_connection.h" | 5 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/test/test_simple_task_runner.h" | 18 #include "base/test/test_simple_task_runner.h" |
| 19 #include "components/cryptauth/remote_device.h" |
| 19 #include "components/proximity_auth/ble/bluetooth_low_energy_characteristics_fin
der.h" | 20 #include "components/proximity_auth/ble/bluetooth_low_energy_characteristics_fin
der.h" |
| 20 #include "components/proximity_auth/bluetooth_throttler.h" | 21 #include "components/proximity_auth/bluetooth_throttler.h" |
| 21 #include "components/proximity_auth/connection_finder.h" | 22 #include "components/proximity_auth/connection_finder.h" |
| 22 #include "components/proximity_auth/proximity_auth_test_util.h" | 23 #include "components/proximity_auth/proximity_auth_test_util.h" |
| 23 #include "components/proximity_auth/remote_device.h" | |
| 24 #include "components/proximity_auth/wire_message.h" | 24 #include "components/proximity_auth/wire_message.h" |
| 25 #include "device/bluetooth/bluetooth_adapter_factory.h" | 25 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 26 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 26 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 27 #include "device/bluetooth/bluetooth_uuid.h" | 27 #include "device/bluetooth/bluetooth_uuid.h" |
| 28 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 28 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
| 29 #include "device/bluetooth/test/mock_bluetooth_device.h" | 29 #include "device/bluetooth/test/mock_bluetooth_device.h" |
| 30 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" | 30 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" |
| 31 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" | 31 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" |
| 32 #include "device/bluetooth/test/mock_bluetooth_gatt_connection.h" | 32 #include "device/bluetooth/test/mock_bluetooth_gatt_connection.h" |
| 33 #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h" | 33 #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 MockBluetoothLowEnergyCharacteristicsFinder() {} | 80 MockBluetoothLowEnergyCharacteristicsFinder() {} |
| 81 ~MockBluetoothLowEnergyCharacteristicsFinder() override {} | 81 ~MockBluetoothLowEnergyCharacteristicsFinder() override {} |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 DISALLOW_COPY_AND_ASSIGN(MockBluetoothLowEnergyCharacteristicsFinder); | 84 DISALLOW_COPY_AND_ASSIGN(MockBluetoothLowEnergyCharacteristicsFinder); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 class MockBluetoothLowEnergyConnection : public BluetoothLowEnergyConnection { | 87 class MockBluetoothLowEnergyConnection : public BluetoothLowEnergyConnection { |
| 88 public: | 88 public: |
| 89 MockBluetoothLowEnergyConnection( | 89 MockBluetoothLowEnergyConnection( |
| 90 const RemoteDevice& remote_device, | 90 const cryptauth::RemoteDevice& remote_device, |
| 91 scoped_refptr<device::BluetoothAdapter> adapter, | 91 scoped_refptr<device::BluetoothAdapter> adapter, |
| 92 const device::BluetoothUUID remote_service_uuid, | 92 const device::BluetoothUUID remote_service_uuid, |
| 93 BluetoothThrottler* bluetooth_throttler, | 93 BluetoothThrottler* bluetooth_throttler, |
| 94 int max_number_of_write_attempts) | 94 int max_number_of_write_attempts) |
| 95 : BluetoothLowEnergyConnection(remote_device, | 95 : BluetoothLowEnergyConnection(remote_device, |
| 96 adapter, | 96 adapter, |
| 97 remote_service_uuid, | 97 remote_service_uuid, |
| 98 bluetooth_throttler, | 98 bluetooth_throttler, |
| 99 max_number_of_write_attempts) {} | 99 max_number_of_write_attempts) {} |
| 100 | 100 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 std::vector<uint8_t> bytes(4, 0); | 347 std::vector<uint8_t> bytes(4, 0); |
| 348 bytes[0] = static_cast<uint8_t>(value); | 348 bytes[0] = static_cast<uint8_t>(value); |
| 349 bytes[1] = static_cast<uint8_t>(value >> 8); | 349 bytes[1] = static_cast<uint8_t>(value >> 8); |
| 350 bytes[2] = static_cast<uint8_t>(value >> 16); | 350 bytes[2] = static_cast<uint8_t>(value >> 16); |
| 351 bytes[3] = static_cast<uint8_t>(value >> 24); | 351 bytes[3] = static_cast<uint8_t>(value >> 24); |
| 352 return bytes; | 352 return bytes; |
| 353 } | 353 } |
| 354 | 354 |
| 355 protected: | 355 protected: |
| 356 scoped_refptr<device::MockBluetoothAdapter> adapter_; | 356 scoped_refptr<device::MockBluetoothAdapter> adapter_; |
| 357 RemoteDevice remote_device_; | 357 cryptauth::RemoteDevice remote_device_; |
| 358 device::BluetoothUUID service_uuid_; | 358 device::BluetoothUUID service_uuid_; |
| 359 device::BluetoothUUID to_peripheral_char_uuid_; | 359 device::BluetoothUUID to_peripheral_char_uuid_; |
| 360 device::BluetoothUUID from_peripheral_char_uuid_; | 360 device::BluetoothUUID from_peripheral_char_uuid_; |
| 361 std::unique_ptr<device::MockBluetoothDevice> device_; | 361 std::unique_ptr<device::MockBluetoothDevice> device_; |
| 362 std::unique_ptr<device::MockBluetoothGattService> service_; | 362 std::unique_ptr<device::MockBluetoothGattService> service_; |
| 363 std::unique_ptr<device::MockBluetoothGattCharacteristic> to_peripheral_char_; | 363 std::unique_ptr<device::MockBluetoothGattCharacteristic> to_peripheral_char_; |
| 364 std::unique_ptr<device::MockBluetoothGattCharacteristic> | 364 std::unique_ptr<device::MockBluetoothGattCharacteristic> |
| 365 from_peripheral_char_; | 365 from_peripheral_char_; |
| 366 std::vector<uint8_t> last_value_written_on_to_peripheral_char_; | 366 std::vector<uint8_t> last_value_written_on_to_peripheral_char_; |
| 367 device::MockBluetoothGattNotifySession* notify_session_alias_; | 367 device::MockBluetoothGattNotifySession* notify_session_alias_; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 create_gatt_connection_success_callback_.Run( | 694 create_gatt_connection_success_callback_.Run( |
| 695 base::MakeUnique<NiceMock<device::MockBluetoothGattConnection>>( | 695 base::MakeUnique<NiceMock<device::MockBluetoothGattConnection>>( |
| 696 adapter_, kTestRemoteDeviceBluetoothAddress)); | 696 adapter_, kTestRemoteDeviceBluetoothAddress)); |
| 697 | 697 |
| 698 CharacteristicsFound(connection.get()); | 698 CharacteristicsFound(connection.get()); |
| 699 NotifySessionStarted(connection.get()); | 699 NotifySessionStarted(connection.get()); |
| 700 ResponseSignalReceived(connection.get()); | 700 ResponseSignalReceived(connection.get()); |
| 701 } | 701 } |
| 702 | 702 |
| 703 } // namespace proximity_auth | 703 } // namespace proximity_auth |
| OLD | NEW |