fake_bluetooth_profile_manager_client.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_PROFILE_MANAGER_CLIENT_H_
  5. #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_
  6. #include <map>
  7. #include <string>
  8. #include "base/bind.h"
  9. #include "base/callback.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_profile_manager_client.h"
  14. namespace bluez {
  15. class FakeBluetoothProfileServiceProvider;
  16. // FakeBluetoothProfileManagerClient simulates the behavior of the Bluetooth
  17. // Daemon's profile manager object and is used both in test cases in place of a
  18. // mock and on the Linux desktop.
  19. class DEVICE_BLUETOOTH_EXPORT FakeBluetoothProfileManagerClient
  20. : public BluetoothProfileManagerClient {
  21. public:
  22. FakeBluetoothProfileManagerClient();
  23. ~FakeBluetoothProfileManagerClient() override;
  24. // BluetoothProfileManagerClient overrides
  25. void Init(dbus::Bus* bus, const std::string& bluetooth_service_name) override;
  26. void RegisterProfile(const dbus::ObjectPath& profile_path,
  27. const std::string& uuid,
  28. const Options& options,
  29. base::OnceClosure callback,
  30. ErrorCallback error_callback) override;
  31. void UnregisterProfile(const dbus::ObjectPath& profile_path,
  32. base::OnceClosure callback,
  33. ErrorCallback error_callback) override;
  34. // Register, unregister and retrieve pointers to profile server providers.
  35. void RegisterProfileServiceProvider(
  36. FakeBluetoothProfileServiceProvider* service_provider);
  37. void UnregisterProfileServiceProvider(
  38. FakeBluetoothProfileServiceProvider* service_provider);
  39. FakeBluetoothProfileServiceProvider* GetProfileServiceProvider(
  40. const std::string& uuid);
  41. // UUIDs recognised for testing.
  42. static const char kL2capUuid[];
  43. static const char kRfcommUuid[];
  44. static const char kUnregisterableUuid[];
  45. private:
  46. // Map of a D-Bus object path to the FakeBluetoothProfileServiceProvider
  47. // registered for it; maintained by RegisterProfileServiceProvider() and
  48. // UnregisterProfileServiceProvicer() called by the constructor and
  49. // destructor of FakeBluetoothProfileServiceProvider.
  50. typedef std::map<dbus::ObjectPath, FakeBluetoothProfileServiceProvider*>
  51. ServiceProviderMap;
  52. ServiceProviderMap service_provider_map_;
  53. // Map of Profile UUID to the D-Bus object path of the service provider
  54. // in |service_provider_map_|. Maintained by RegisterProfile() and
  55. // UnregisterProfile() in response to BluetoothProfile methods.
  56. typedef std::map<std::string, dbus::ObjectPath> ProfileMap;
  57. ProfileMap profile_map_;
  58. };
  59. } // namespace bluez
  60. #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_