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 "components/proximity_auth/ble/bluetooth_low_energy_weave_client_connec
tion.h" | 5 #include "components/proximity_auth/ble/bluetooth_low_energy_weave_client_connec
tion.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/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/test/test_simple_task_runner.h" | 16 #include "base/test/test_simple_task_runner.h" |
| 17 #include "components/cryptauth/remote_device.h" |
17 #include "components/proximity_auth/bluetooth_throttler.h" | 18 #include "components/proximity_auth/bluetooth_throttler.h" |
18 #include "components/proximity_auth/connection_finder.h" | 19 #include "components/proximity_auth/connection_finder.h" |
19 #include "components/proximity_auth/connection_observer.h" | 20 #include "components/proximity_auth/connection_observer.h" |
20 #include "components/proximity_auth/proximity_auth_test_util.h" | 21 #include "components/proximity_auth/proximity_auth_test_util.h" |
21 #include "components/proximity_auth/remote_device.h" | |
22 #include "components/proximity_auth/wire_message.h" | 22 #include "components/proximity_auth/wire_message.h" |
23 #include "device/bluetooth/bluetooth_adapter_factory.h" | 23 #include "device/bluetooth/bluetooth_adapter_factory.h" |
24 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 24 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
25 #include "device/bluetooth/test/mock_bluetooth_device.h" | 25 #include "device/bluetooth/test/mock_bluetooth_device.h" |
26 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" | 26 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" |
27 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" | 27 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" |
28 #include "device/bluetooth/test/mock_bluetooth_gatt_connection.h" | 28 #include "device/bluetooth/test/mock_bluetooth_gatt_connection.h" |
29 #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h" | 29 #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h" |
30 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 most_recent_instance_); | 294 most_recent_instance_); |
295 } | 295 } |
296 | 296 |
297 MockBluetoothLowEnergyWeavePacketReceiver* most_recent_instance_; | 297 MockBluetoothLowEnergyWeavePacketReceiver* most_recent_instance_; |
298 }; | 298 }; |
299 | 299 |
300 class TestBluetoothLowEnergyWeaveClientConnection | 300 class TestBluetoothLowEnergyWeaveClientConnection |
301 : public BluetoothLowEnergyWeaveClientConnection { | 301 : public BluetoothLowEnergyWeaveClientConnection { |
302 public: | 302 public: |
303 TestBluetoothLowEnergyWeaveClientConnection( | 303 TestBluetoothLowEnergyWeaveClientConnection( |
304 const RemoteDevice& remote_device, | 304 const cryptauth::RemoteDevice& remote_device, |
305 scoped_refptr<device::BluetoothAdapter> adapter, | 305 scoped_refptr<device::BluetoothAdapter> adapter, |
306 const device::BluetoothUUID remote_service_uuid, | 306 const device::BluetoothUUID remote_service_uuid, |
307 BluetoothThrottler* bluetooth_throttler, | 307 BluetoothThrottler* bluetooth_throttler, |
308 int max_number_of_write_attempts) | 308 int max_number_of_write_attempts) |
309 : BluetoothLowEnergyWeaveClientConnection(remote_device, | 309 : BluetoothLowEnergyWeaveClientConnection(remote_device, |
310 adapter, | 310 adapter, |
311 remote_service_uuid, | 311 remote_service_uuid, |
312 bluetooth_throttler, | 312 bluetooth_throttler, |
313 max_number_of_write_attempts) {} | 313 max_number_of_write_attempts) {} |
314 | 314 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 } | 572 } |
573 | 573 |
574 void RunWriteCharacteristicSuccessCallback() { | 574 void RunWriteCharacteristicSuccessCallback() { |
575 EXPECT_FALSE(write_remote_characteristic_error_callback_.is_null()); | 575 EXPECT_FALSE(write_remote_characteristic_error_callback_.is_null()); |
576 ASSERT_FALSE(write_remote_characteristic_success_callback_.is_null()); | 576 ASSERT_FALSE(write_remote_characteristic_success_callback_.is_null()); |
577 write_remote_characteristic_success_callback_.Run(); | 577 write_remote_characteristic_success_callback_.Run(); |
578 } | 578 } |
579 | 579 |
580 protected: | 580 protected: |
581 scoped_refptr<device::MockBluetoothAdapter> adapter_; | 581 scoped_refptr<device::MockBluetoothAdapter> adapter_; |
582 RemoteDevice remote_device_; | 582 cryptauth::RemoteDevice remote_device_; |
583 device::BluetoothUUID service_uuid_; | 583 device::BluetoothUUID service_uuid_; |
584 device::BluetoothUUID tx_characteristic_uuid_; | 584 device::BluetoothUUID tx_characteristic_uuid_; |
585 device::BluetoothUUID rx_characteristic_uuid_; | 585 device::BluetoothUUID rx_characteristic_uuid_; |
586 std::unique_ptr<device::MockBluetoothDevice> device_; | 586 std::unique_ptr<device::MockBluetoothDevice> device_; |
587 std::unique_ptr<device::MockBluetoothGattService> service_; | 587 std::unique_ptr<device::MockBluetoothGattService> service_; |
588 std::unique_ptr<device::MockBluetoothGattCharacteristic> tx_characteristic_; | 588 std::unique_ptr<device::MockBluetoothGattCharacteristic> tx_characteristic_; |
589 std::unique_ptr<device::MockBluetoothGattCharacteristic> rx_characteristic_; | 589 std::unique_ptr<device::MockBluetoothGattCharacteristic> rx_characteristic_; |
590 std::vector<uint8_t> last_value_written_on_tx_characteristic_; | 590 std::vector<uint8_t> last_value_written_on_tx_characteristic_; |
591 device::MockBluetoothGattNotifySession* notify_session_alias_; | 591 device::MockBluetoothGattNotifySession* notify_session_alias_; |
592 std::unique_ptr<MockBluetoothThrottler> bluetooth_throttler_; | 592 std::unique_ptr<MockBluetoothThrottler> bluetooth_throttler_; |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 adapter_, kTestRemoteDeviceBluetoothAddress)); | 1040 adapter_, kTestRemoteDeviceBluetoothAddress)); |
1041 | 1041 |
1042 CharacteristicsFound(connection.get()); | 1042 CharacteristicsFound(connection.get()); |
1043 NotifySessionStarted(connection.get()); | 1043 NotifySessionStarted(connection.get()); |
1044 ConnectionResponseReceived(connection.get(), kDefaultMaxPacketSize); | 1044 ConnectionResponseReceived(connection.get(), kDefaultMaxPacketSize); |
1045 } | 1045 } |
1046 | 1046 |
1047 } // namespace weave | 1047 } // namespace weave |
1048 | 1048 |
1049 } // namespace proximity_auth | 1049 } // namespace proximity_auth |
OLD | NEW |