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/cryptauth/ble/bluetooth_low_energy_weave_client_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/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" |
(...skipping 14 matching lines...) Expand all Loading... |
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" |
32 | 32 |
33 using testing::_; | 33 using testing::_; |
34 using testing::AtLeast; | 34 using testing::AtLeast; |
35 using testing::NiceMock; | 35 using testing::NiceMock; |
36 using testing::Return; | 36 using testing::Return; |
37 using testing::StrictMock; | 37 using testing::StrictMock; |
38 using testing::SaveArg; | 38 using testing::SaveArg; |
39 | 39 |
40 namespace proximity_auth { | 40 namespace cryptauth { |
41 namespace { | 41 namespace { |
42 | 42 |
43 class MockBluetoothThrottler : public BluetoothThrottler { | 43 class MockBluetoothThrottler : public BluetoothThrottler { |
44 public: | 44 public: |
45 MockBluetoothThrottler() {} | 45 MockBluetoothThrottler() {} |
46 ~MockBluetoothThrottler() override {} | 46 ~MockBluetoothThrottler() override {} |
47 | 47 |
48 MOCK_CONST_METHOD0(GetDelay, base::TimeDelta()); | 48 MOCK_CONST_METHOD0(GetDelay, base::TimeDelta()); |
49 MOCK_METHOD1(OnConnection, void(Connection* connection)); | 49 MOCK_METHOD1(OnConnection, void(Connection* connection)); |
50 | 50 |
(...skipping 13 matching lines...) Expand all Loading... |
64 | 64 |
65 class MockConnectionObserver : public ConnectionObserver { | 65 class MockConnectionObserver : public ConnectionObserver { |
66 public: | 66 public: |
67 MockConnectionObserver() : num_send_completed_(0) {} | 67 MockConnectionObserver() : num_send_completed_(0) {} |
68 | 68 |
69 void OnConnectionStatusChanged(Connection* connection, | 69 void OnConnectionStatusChanged(Connection* connection, |
70 Connection::Status old_status, | 70 Connection::Status old_status, |
71 Connection::Status new_status) override {} | 71 Connection::Status new_status) override {} |
72 | 72 |
73 void OnMessageReceived(const Connection& connection, | 73 void OnMessageReceived(const Connection& connection, |
74 const WireMessage& message) override {} | 74 const proximity_auth::WireMessage& message) override {} |
75 | 75 |
76 void OnSendCompleted(const Connection& conenction, | 76 void OnSendCompleted(const Connection& conenction, |
77 const WireMessage& message, | 77 const proximity_auth::WireMessage& message, |
78 bool success) override { | 78 bool success) override { |
79 last_deserialized_message_ = message.payload(); | 79 last_deserialized_message_ = message.payload(); |
80 last_send_success_ = success; | 80 last_send_success_ = success; |
81 num_send_completed_++; | 81 num_send_completed_++; |
82 } | 82 } |
83 | 83 |
84 std::string GetLastDeserializedMessage() { | 84 std::string GetLastDeserializedMessage() { |
85 return last_deserialized_message_; | 85 return last_deserialized_message_; |
86 } | 86 } |
87 | 87 |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_; |
593 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 593 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
594 base::MessageLoop message_loop_; | 594 base::MessageLoop message_loop_; |
595 WireMessage last_completed_wire_message_; | 595 proximity_auth::WireMessage last_completed_wire_message_; |
596 bool last_wire_message_success_; | 596 bool last_wire_message_success_; |
597 std::shared_ptr<MockBluetoothLowEnergyWeavePacketGeneratorFactory> | 597 std::shared_ptr<MockBluetoothLowEnergyWeavePacketGeneratorFactory> |
598 generator_factory_; | 598 generator_factory_; |
599 std::shared_ptr<MockBluetoothLowEnergyWeavePacketReceiverFactory> | 599 std::shared_ptr<MockBluetoothLowEnergyWeavePacketReceiverFactory> |
600 receiver_factory_; | 600 receiver_factory_; |
601 MockConnectionObserver connection_observer_; | 601 MockConnectionObserver connection_observer_; |
602 | 602 |
603 // Callbacks | 603 // Callbacks |
604 device::BluetoothDevice::GattConnectionCallback | 604 device::BluetoothDevice::GattConnectionCallback |
605 create_gatt_connection_success_callback_; | 605 create_gatt_connection_success_callback_; |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 base::MakeUnique<NiceMock<device::MockBluetoothGattConnection>>( | 1039 base::MakeUnique<NiceMock<device::MockBluetoothGattConnection>>( |
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 cryptauth |
OLD | NEW |