Index: device/bluetooth/test/fake_peripheral.h |
diff --git a/device/bluetooth/test/fake_peripheral.h b/device/bluetooth/test/fake_peripheral.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..decfe31a531c9b3874d6ef038cc2417c24d602b0 |
--- /dev/null |
+++ b/device/bluetooth/test/fake_peripheral.h |
@@ -0,0 +1,89 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+#ifndef DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
+#define DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |
+ |
+#include <string> |
+ |
+#include "base/compiler_specific.h" |
+#include "base/macros.h" |
+#include "base/optional.h" |
+#include "device/bluetooth/bluetooth_device.h" |
+#include "device/bluetooth/test/fake_central.h" |
+ |
+namespace bluetooth { |
+ |
+// Implements device::BluetoothDevice. Meant to be used by FakeCentral |
+// to keep track of the peripheral's state and attributes. |
+class FakePeripheral : public device::BluetoothDevice { |
+ public: |
+ FakePeripheral(FakeCentral* fake_central, |
+ const std::string& address, |
+ const std::string& name); |
+ ~FakePeripheral() override; |
+ |
+ // Set it to indicate if the Peripheral is connected or not. |
+ void SetGattConnected(bool gatt_connected); |
+ |
+ // BluetoothDevice overrides: |
+ uint32_t GetBluetoothClass() const override; |
+#if defined(OS_CHROMEOS) || defined(OS_LINUX) |
+ device::BluetoothTransport GetType() const override; |
+#endif |
+ std::string GetIdentifier() const override; |
+ std::string GetAddress() const override; |
+ VendorIDSource GetVendorIDSource() const override; |
+ uint16_t GetVendorID() const override; |
+ uint16_t GetProductID() const override; |
+ uint16_t GetDeviceID() const override; |
+ uint16_t GetAppearance() const override; |
+ base::Optional<std::string> GetName() const override; |
+ base::string16 GetNameForDisplay() const override; |
+ bool IsPaired() const override; |
+ bool IsConnected() const override; |
+ bool IsGattConnected() const override; |
+ bool IsConnectable() const override; |
+ bool IsConnecting() const override; |
+ UUIDSet GetUUIDs() const override; |
+ bool ExpectingPinCode() const override; |
+ bool ExpectingPasskey() const override; |
+ bool ExpectingConfirmation() const override; |
+ void GetConnectionInfo(const ConnectionInfoCallback& callback) override; |
+ void Connect(PairingDelegate* pairing_delegate, |
+ const base::Closure& callback, |
+ const ConnectErrorCallback& error_callback) override; |
+ void SetPinCode(const std::string& pincode) override; |
+ void SetPasskey(uint32_t passkey) override; |
+ void ConfirmPairing() override; |
+ void RejectPairing() override; |
+ void CancelPairing() override; |
+ void Disconnect(const base::Closure& callback, |
+ const ErrorCallback& error_callback) override; |
+ void Forget(const base::Closure& callback, |
+ const ErrorCallback& error_callback) override; |
+ void ConnectToService( |
+ const device::BluetoothUUID& uuid, |
+ const ConnectToServiceCallback& callback, |
+ const ConnectToServiceErrorCallback& error_callback) override; |
+ void ConnectToServiceInsecurely( |
+ const device::BluetoothUUID& uuid, |
+ const ConnectToServiceCallback& callback, |
+ const ConnectToServiceErrorCallback& error_callback) override; |
+ |
+ protected: |
+ void CreateGattConnectionImpl() override; |
+ void DisconnectGatt() override; |
+ |
+ private: |
+ const std::string address_; |
+ const std::string id_; |
+ base::Optional<std::string> name_; |
+ bool gatt_connected_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FakePeripheral); |
+}; |
+ |
+} // namespace bluetooth |
+ |
+#endif // DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_ |