OLD | NEW |
(Empty) | |
| 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 |
| 5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_ADVERTISEMENT_MANAGER_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_ADVERTISEMENT_MANAGER_CLIENT_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 |
| 11 #include "base/bind.h" |
| 12 #include "base/callback.h" |
| 13 #include "base/observer_list.h" |
| 14 #include "chromeos/chromeos_export.h" |
| 15 #include "chromeos/dbus/bluetooth_advertisement_manager_client.h" |
| 16 #include "dbus/object_path.h" |
| 17 #include "dbus/property.h" |
| 18 |
| 19 namespace chromeos { |
| 20 |
| 21 class FakeBluetoothAdvertisementServiceProvider; |
| 22 |
| 23 // FakeBluetoothAdvertisementManagerClient simulates the behavior of the |
| 24 // Bluetooth |
| 25 // Daemon's profile manager object and is used both in test cases in place of a |
| 26 // mock and on the Linux desktop. |
| 27 class CHROMEOS_EXPORT FakeBluetoothAdvertisementManagerClient |
| 28 : public BluetoothAdvertisementManagerClient { |
| 29 public: |
| 30 FakeBluetoothAdvertisementManagerClient(); |
| 31 ~FakeBluetoothAdvertisementManagerClient() override; |
| 32 |
| 33 // DBusClient overrides: |
| 34 void Init(dbus::Bus* bus) override {} |
| 35 |
| 36 // BluetoothAdvertisingManagerClient overrides: |
| 37 void RegisterAdvertisement(const dbus::ObjectPath& obj_path, |
| 38 const base::Closure& callback, |
| 39 const ErrorCallback& error_callback) override; |
| 40 |
| 41 // Unregisters an advertisement with the DBus object path |obj_path| with |
| 42 // BlueZ's advertisement manager. |
| 43 void UnregisterAdvertisement(const dbus::ObjectPath& profile_path, |
| 44 const base::Closure& callback, |
| 45 const ErrorCallback& error_callback) override; |
| 46 |
| 47 // Register, unregister and retrieve pointers to profile server providers. |
| 48 void RegisterAdvertisementServiceProvider( |
| 49 FakeBluetoothAdvertisementServiceProvider* service_provider); |
| 50 void UnregisterAdvertisementServiceProvider( |
| 51 FakeBluetoothAdvertisementServiceProvider* service_provider); |
| 52 FakeBluetoothAdvertisementServiceProvider* GetAdvertisementServiceProvider( |
| 53 const std::string& uuid); |
| 54 |
| 55 // UUIDs recognised for testing. |
| 56 static const char kL2capUuid[]; |
| 57 static const char kRfcommUuid[]; |
| 58 static const char kUnregisterableUuid[]; |
| 59 |
| 60 private: |
| 61 // Map of a D-Bus object path to the FakeBluetoothAdvertisementServiceProvider |
| 62 // registered for it; maintained by RegisterAdvertisementServiceProvider() and |
| 63 // UnregisterProfileServiceProvicer() called by the constructor and |
| 64 // destructor of FakeBluetoothAdvertisementServiceProvider. |
| 65 typedef std::map<dbus::ObjectPath, FakeBluetoothAdvertisementServiceProvider*> |
| 66 ServiceProviderMap; |
| 67 ServiceProviderMap service_provider_map_; |
| 68 |
| 69 std::string currently_registered_; |
| 70 |
| 71 // Map of Profile UUID to the D-Bus object path of the service provider |
| 72 // in |service_provider_map_|. Maintained by RegisterProfile() and |
| 73 // UnregisterProfile() in response to BluetoothProfile methods. |
| 74 typedef std::map<std::string, dbus::ObjectPath> ProfileMap; |
| 75 ProfileMap profile_map_; |
| 76 }; |
| 77 |
| 78 } // namespace chromeos |
| 79 |
| 80 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_ADVERTISEMENT_MANAGER_CLIENT_H_ |
OLD | NEW |