Chromium Code Reviews| 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. | |
|
scheib
2017/05/09 23:33:54
... UUIDs that are returned by GetUUIDs.
ortuno
2017/05/10 06:32:50
Done.
| |
| 31 void SetServiceUUIDs(UUIDSet service_uuids); | |
| 32 | |
| 30 // BluetoothDevice overrides: | 33 // BluetoothDevice overrides: |
| 31 uint32_t GetBluetoothClass() const override; | 34 uint32_t GetBluetoothClass() const override; |
| 32 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 35 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
| 33 device::BluetoothTransport GetType() const override; | 36 device::BluetoothTransport GetType() const override; |
| 34 #endif | 37 #endif |
| 35 std::string GetIdentifier() const override; | 38 std::string GetIdentifier() const override; |
| 36 std::string GetAddress() const override; | 39 std::string GetAddress() const override; |
| 37 VendorIDSource GetVendorIDSource() const override; | 40 VendorIDSource GetVendorIDSource() const override; |
| 38 uint16_t GetVendorID() const override; | 41 uint16_t GetVendorID() const override; |
| 39 uint16_t GetProductID() const override; | 42 uint16_t GetProductID() const override; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 const ConnectToServiceErrorCallback& error_callback) override; | 76 const ConnectToServiceErrorCallback& error_callback) override; |
| 74 | 77 |
| 75 protected: | 78 protected: |
| 76 void CreateGattConnectionImpl() override; | 79 void CreateGattConnectionImpl() override; |
| 77 void DisconnectGatt() override; | 80 void DisconnectGatt() override; |
| 78 | 81 |
| 79 private: | 82 private: |
| 80 const std::string address_; | 83 const std::string address_; |
| 81 base::Optional<std::string> name_; | 84 base::Optional<std::string> name_; |
| 82 bool gatt_connected_; | 85 bool gatt_connected_; |
| 86 UUIDSet service_uuids_; | |
| 83 | 87 |
| 84 DISALLOW_COPY_AND_ASSIGN(FakePeripheral); | 88 DISALLOW_COPY_AND_ASSIGN(FakePeripheral); |
| 85 }; | 89 }; |
| 86 | 90 |
| 87 } // namespace bluetooth | 91 } // namespace bluetooth |
| 88 | 92 |
| 89 #endif // DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ | 93 #endif // DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
| OLD | NEW |