fake_bluetooth_agent_service_provider.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright (c) 2013 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_AGENT_SERVICE_PROVIDER_H_
  5. #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_
  6. #include <stdint.h>
  7. #include "base/bind.h"
  8. #include "base/callback.h"
  9. #include "base/memory/raw_ptr.h"
  10. #include "dbus/object_path.h"
  11. #include "dbus/property.h"
  12. #include "device/bluetooth/bluetooth_export.h"
  13. #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h"
  14. namespace bluez {
  15. class FakeBluetoothAgentManagerClient;
  16. // FakeBluetoothAgentServiceProvider simulates the behavior of a local
  17. // Bluetooth agent object and is used both in test cases in place of a
  18. // mock and on the Linux desktop.
  19. class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAgentServiceProvider
  20. : public BluetoothAgentServiceProvider {
  21. public:
  22. FakeBluetoothAgentServiceProvider(const dbus::ObjectPath& object_path,
  23. Delegate* delegate);
  24. ~FakeBluetoothAgentServiceProvider() override;
  25. // Each of these calls the equivalent BluetoothAgentServiceProvider::Delegate
  26. // method on the object passed on construction.
  27. virtual void Release();
  28. virtual void RequestPinCode(const dbus::ObjectPath& device_path,
  29. Delegate::PinCodeCallback callback);
  30. virtual void DisplayPinCode(const dbus::ObjectPath& device_path,
  31. const std::string& pincode);
  32. virtual void RequestPasskey(const dbus::ObjectPath& device_path,
  33. Delegate::PasskeyCallback callback);
  34. virtual void DisplayPasskey(const dbus::ObjectPath& device_path,
  35. uint32_t passkey,
  36. int16_t entered);
  37. virtual void RequestConfirmation(const dbus::ObjectPath& device_path,
  38. uint32_t passkey,
  39. Delegate::ConfirmationCallback callback);
  40. virtual void RequestAuthorization(const dbus::ObjectPath& device_path,
  41. Delegate::ConfirmationCallback callback);
  42. virtual void AuthorizeService(const dbus::ObjectPath& device_path,
  43. const std::string& uuid,
  44. Delegate::ConfirmationCallback callback);
  45. virtual void Cancel();
  46. private:
  47. friend class FakeBluetoothAgentManagerClient;
  48. // D-Bus object path we are faking.
  49. dbus::ObjectPath object_path_;
  50. // All incoming method calls are passed on to the Delegate and a callback
  51. // passed to generate the reply. |delegate_| is generally the object that
  52. // owns this one, and must outlive it.
  53. raw_ptr<Delegate> delegate_;
  54. };
  55. } // namespace bluez
  56. #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_