OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ | 4 #ifndef DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
5 #define DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ | 5 #define DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Changes the name of the device. | 24 // Changes the name of the device. |
25 void SetName(base::Optional<std::string> name); | 25 void SetName(base::Optional<std::string> name); |
26 | 26 |
27 // Set it to indicate if the Peripheral is connected or not. | 27 // Set it to indicate if the Peripheral is connected or not. |
28 void SetGattConnected(bool gatt_connected); | 28 void SetGattConnected(bool gatt_connected); |
29 | 29 |
30 // Updates the peripheral's UUIDs that are returned by | 30 // Updates the peripheral's UUIDs that are returned by |
31 // BluetoothDevice::GetUUIDs(). | 31 // BluetoothDevice::GetUUIDs(). |
32 void SetServiceUUIDs(UUIDSet service_uuids); | 32 void SetServiceUUIDs(UUIDSet service_uuids); |
33 | 33 |
| 34 // If |code| is kHCISuccess calls a pending success callback for |
| 35 // CreateGattConnection. Otherwise calls a pending error callback |
| 36 // with the ConnectErrorCode corresponding to |code|. |
| 37 void SimulateGATTConnectionResponse(uint16_t code); |
| 38 |
34 // BluetoothDevice overrides: | 39 // BluetoothDevice overrides: |
35 uint32_t GetBluetoothClass() const override; | 40 uint32_t GetBluetoothClass() const override; |
36 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 41 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
37 device::BluetoothTransport GetType() const override; | 42 device::BluetoothTransport GetType() const override; |
38 #endif | 43 #endif |
39 std::string GetIdentifier() const override; | 44 std::string GetIdentifier() const override; |
40 std::string GetAddress() const override; | 45 std::string GetAddress() const override; |
41 VendorIDSource GetVendorIDSource() const override; | 46 VendorIDSource GetVendorIDSource() const override; |
42 uint16_t GetVendorID() const override; | 47 uint16_t GetVendorID() const override; |
43 uint16_t GetProductID() const override; | 48 uint16_t GetProductID() const override; |
(...skipping 24 matching lines...) Expand all Loading... |
68 void Forget(const base::Closure& callback, | 73 void Forget(const base::Closure& callback, |
69 const ErrorCallback& error_callback) override; | 74 const ErrorCallback& error_callback) override; |
70 void ConnectToService( | 75 void ConnectToService( |
71 const device::BluetoothUUID& uuid, | 76 const device::BluetoothUUID& uuid, |
72 const ConnectToServiceCallback& callback, | 77 const ConnectToServiceCallback& callback, |
73 const ConnectToServiceErrorCallback& error_callback) override; | 78 const ConnectToServiceErrorCallback& error_callback) override; |
74 void ConnectToServiceInsecurely( | 79 void ConnectToServiceInsecurely( |
75 const device::BluetoothUUID& uuid, | 80 const device::BluetoothUUID& uuid, |
76 const ConnectToServiceCallback& callback, | 81 const ConnectToServiceCallback& callback, |
77 const ConnectToServiceErrorCallback& error_callback) override; | 82 const ConnectToServiceErrorCallback& error_callback) override; |
| 83 void CreateGattConnection( |
| 84 const GattConnectionCallback& callback, |
| 85 const ConnectErrorCallback& error_callback) override; |
78 | 86 |
79 protected: | 87 protected: |
80 void CreateGattConnectionImpl() override; | 88 void CreateGattConnectionImpl() override; |
81 void DisconnectGatt() override; | 89 void DisconnectGatt() override; |
82 | 90 |
83 private: | 91 private: |
84 const std::string address_; | 92 const std::string address_; |
85 base::Optional<std::string> name_; | 93 base::Optional<std::string> name_; |
86 bool gatt_connected_; | 94 bool gatt_connected_; |
87 UUIDSet service_uuids_; | 95 UUIDSet service_uuids_; |
88 | 96 |
| 97 using CreateGattConnectionCallbacks = |
| 98 std::pair<GattConnectionCallback, ConnectErrorCallback>; |
| 99 std::queue<CreateGattConnectionCallbacks> create_gatt_connection_callbacks_; |
| 100 |
89 DISALLOW_COPY_AND_ASSIGN(FakePeripheral); | 101 DISALLOW_COPY_AND_ASSIGN(FakePeripheral); |
90 }; | 102 }; |
91 | 103 |
92 } // namespace bluetooth | 104 } // namespace bluetooth |
93 | 105 |
94 #endif // DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ | 106 #endif // DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
OLD | NEW |