fake_bluetooth_le_advertisement_service_provider.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2015 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_DBUS_FAKE_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_
  5. #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_
  6. #include "base/bind.h"
  7. #include "base/callback.h"
  8. #include "base/memory/raw_ptr.h"
  9. #include "dbus/object_path.h"
  10. #include "device/bluetooth/bluetooth_export.h"
  11. #include "device/bluetooth/dbus/bluetooth_le_advertisement_service_provider.h"
  12. namespace bluez {
  13. // FakeBluetoothAdvertisementServiceProvider simulates the behavior of a local
  14. // Bluetooth agent object and is used both in test cases in place of a
  15. // mock and on the Linux desktop.
  16. class DEVICE_BLUETOOTH_EXPORT FakeBluetoothLEAdvertisementServiceProvider
  17. : public BluetoothLEAdvertisementServiceProvider {
  18. public:
  19. FakeBluetoothLEAdvertisementServiceProvider(
  20. const dbus::ObjectPath& object_path,
  21. Delegate* delegate);
  22. FakeBluetoothLEAdvertisementServiceProvider(
  23. const FakeBluetoothLEAdvertisementServiceProvider&) = delete;
  24. FakeBluetoothLEAdvertisementServiceProvider& operator=(
  25. const FakeBluetoothLEAdvertisementServiceProvider&) = delete;
  26. ~FakeBluetoothLEAdvertisementServiceProvider() override;
  27. // Each of these calls the equivalent
  28. // BluetoothAdvertisementServiceProvider::Delegate method on the object passed
  29. // on construction.
  30. void Release();
  31. const dbus::ObjectPath& object_path() { return object_path_; }
  32. private:
  33. friend class FakeBluetoothLEAdvertisingManagerClient;
  34. // All incoming method calls are passed on to the Delegate and a callback
  35. // passed to generate the reply. |delegate_| is generally the object that
  36. // owns this one, and must outlive it.
  37. raw_ptr<Delegate> delegate_;
  38. };
  39. } // namespace bluez
  40. #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_