OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 #ifndef DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
| 5 #define DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" |
| 11 #include "base/optional.h" |
| 12 #include "device/bluetooth/bluetooth_device.h" |
| 13 #include "device/bluetooth/test/fake_central.h" |
| 14 |
| 15 namespace bluetooth { |
| 16 |
| 17 // Implements device::BluetoothDevice. Meant to be used by FakeCentral |
| 18 // to keep track of the peripheral's state and attributes. |
| 19 class FakePeripheral : public device::BluetoothDevice { |
| 20 public: |
| 21 FakePeripheral(FakeCentral* fake_central, |
| 22 const std::string& address, |
| 23 const std::string& name); |
| 24 ~FakePeripheral() override; |
| 25 |
| 26 // Set it to indicate if the Peripheral is connected or not. |
| 27 void SetGattConnected(bool gatt_connected); |
| 28 |
| 29 // BluetoothDevice overrides: |
| 30 uint32_t GetBluetoothClass() const override; |
| 31 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
| 32 device::BluetoothTransport GetType() const override; |
| 33 #endif |
| 34 std::string GetIdentifier() const override; |
| 35 std::string GetAddress() const override; |
| 36 VendorIDSource GetVendorIDSource() const override; |
| 37 uint16_t GetVendorID() const override; |
| 38 uint16_t GetProductID() const override; |
| 39 uint16_t GetDeviceID() const override; |
| 40 uint16_t GetAppearance() const override; |
| 41 base::Optional<std::string> GetName() const override; |
| 42 base::string16 GetNameForDisplay() const override; |
| 43 bool IsPaired() const override; |
| 44 bool IsConnected() const override; |
| 45 bool IsGattConnected() const override; |
| 46 bool IsConnectable() const override; |
| 47 bool IsConnecting() const override; |
| 48 UUIDSet GetUUIDs() const override; |
| 49 bool ExpectingPinCode() const override; |
| 50 bool ExpectingPasskey() const override; |
| 51 bool ExpectingConfirmation() const override; |
| 52 void GetConnectionInfo(const ConnectionInfoCallback& callback) override; |
| 53 void Connect(PairingDelegate* pairing_delegate, |
| 54 const base::Closure& callback, |
| 55 const ConnectErrorCallback& error_callback) override; |
| 56 void SetPinCode(const std::string& pincode) override; |
| 57 void SetPasskey(uint32_t passkey) override; |
| 58 void ConfirmPairing() override; |
| 59 void RejectPairing() override; |
| 60 void CancelPairing() override; |
| 61 void Disconnect(const base::Closure& callback, |
| 62 const ErrorCallback& error_callback) override; |
| 63 void Forget(const base::Closure& callback, |
| 64 const ErrorCallback& error_callback) override; |
| 65 void ConnectToService( |
| 66 const device::BluetoothUUID& uuid, |
| 67 const ConnectToServiceCallback& callback, |
| 68 const ConnectToServiceErrorCallback& error_callback) override; |
| 69 void ConnectToServiceInsecurely( |
| 70 const device::BluetoothUUID& uuid, |
| 71 const ConnectToServiceCallback& callback, |
| 72 const ConnectToServiceErrorCallback& error_callback) override; |
| 73 |
| 74 protected: |
| 75 void CreateGattConnectionImpl() override; |
| 76 void DisconnectGatt() override; |
| 77 |
| 78 private: |
| 79 const std::string address_; |
| 80 const std::string id_; |
| 81 base::Optional<std::string> name_; |
| 82 bool gatt_connected_; |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(FakePeripheral); |
| 85 }; |
| 86 |
| 87 } // namespace bluetooth |
| 88 |
| 89 #endif // DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
OLD | NEW |