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" |
11 #include "base/optional.h" | 11 #include "base/optional.h" |
12 #include "device/bluetooth/bluetooth_device.h" | 12 #include "device/bluetooth/bluetooth_device.h" |
13 #include "device/bluetooth/test/fake_central.h" | 13 #include "device/bluetooth/test/fake_central.h" |
14 | 14 |
15 namespace bluetooth { | 15 namespace bluetooth { |
16 | 16 |
17 // Implements device::BluetoothDevice. Meant to be used by FakeCentral | 17 // Implements device::BluetoothDevice. Meant to be used by FakeCentral |
18 // to keep track of the peripheral's state and attributes. | 18 // to keep track of the peripheral's state and attributes. |
19 class FakePeripheral : public device::BluetoothDevice { | 19 class FakePeripheral : public device::BluetoothDevice { |
20 public: | 20 public: |
21 FakePeripheral(FakeCentral* fake_central, const std::string& address); | 21 FakePeripheral(FakeCentral* fake_central, const std::string& address); |
22 ~FakePeripheral() override; | 22 ~FakePeripheral() override; |
23 | 23 |
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 |
| 31 // BluetoothDevice::GetUUIDs(). |
| 32 void SetServiceUUIDs(UUIDSet service_uuids); |
| 33 |
30 // BluetoothDevice overrides: | 34 // BluetoothDevice overrides: |
31 uint32_t GetBluetoothClass() const override; | 35 uint32_t GetBluetoothClass() const override; |
32 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 36 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
33 device::BluetoothTransport GetType() const override; | 37 device::BluetoothTransport GetType() const override; |
34 #endif | 38 #endif |
35 std::string GetIdentifier() const override; | 39 std::string GetIdentifier() const override; |
36 std::string GetAddress() const override; | 40 std::string GetAddress() const override; |
37 VendorIDSource GetVendorIDSource() const override; | 41 VendorIDSource GetVendorIDSource() const override; |
38 uint16_t GetVendorID() const override; | 42 uint16_t GetVendorID() const override; |
39 uint16_t GetProductID() const override; | 43 uint16_t GetProductID() const override; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 const ConnectToServiceErrorCallback& error_callback) override; | 77 const ConnectToServiceErrorCallback& error_callback) override; |
74 | 78 |
75 protected: | 79 protected: |
76 void CreateGattConnectionImpl() override; | 80 void CreateGattConnectionImpl() override; |
77 void DisconnectGatt() override; | 81 void DisconnectGatt() override; |
78 | 82 |
79 private: | 83 private: |
80 const std::string address_; | 84 const std::string address_; |
81 base::Optional<std::string> name_; | 85 base::Optional<std::string> name_; |
82 bool gatt_connected_; | 86 bool gatt_connected_; |
| 87 UUIDSet service_uuids_; |
83 | 88 |
84 DISALLOW_COPY_AND_ASSIGN(FakePeripheral); | 89 DISALLOW_COPY_AND_ASSIGN(FakePeripheral); |
85 }; | 90 }; |
86 | 91 |
87 } // namespace bluetooth | 92 } // namespace bluetooth |
88 | 93 |
89 #endif // DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ | 94 #endif // DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
OLD | NEW |