[email protected] | 896619e | 2013-04-18 04:41:42 | [diff] [blame] | 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_PROFILE_MANAGER_CLIENT_H_ |
| 6 | #define CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ |
| 7 | |
[email protected] | e882d2c | 2013-05-09 03:49:18 | [diff] [blame] | 8 | #include <map> |
| 9 | #include <string> |
| 10 | |
[email protected] | 896619e | 2013-04-18 04:41:42 | [diff] [blame] | 11 | #include "base/bind.h" |
| 12 | #include "base/callback.h" |
| 13 | #include "base/observer_list.h" |
| 14 | #include "chromeos/chromeos_export.h" |
[email protected] | 627f4f4 | 2013-06-12 14:47:32 | [diff] [blame] | 15 | #include "chromeos/dbus/bluetooth_profile_manager_client.h" |
[email protected] | 896619e | 2013-04-18 04:41:42 | [diff] [blame] | 16 | #include "dbus/object_path.h" |
| 17 | #include "dbus/property.h" |
| 18 | |
| 19 | namespace chromeos { |
| 20 | |
[email protected] | e882d2c | 2013-05-09 03:49:18 | [diff] [blame] | 21 | class FakeBluetoothProfileServiceProvider; |
| 22 | |
[email protected] | 896619e | 2013-04-18 04:41:42 | [diff] [blame] | 23 | // FakeBluetoothProfileManagerClient simulates the behavior of the Bluetooth |
| 24 | // Daemon's profile manager object and is used both in test cases in place of a |
| 25 | // mock and on the Linux desktop. |
| 26 | class CHROMEOS_EXPORT FakeBluetoothProfileManagerClient |
[email protected] | 627f4f4 | 2013-06-12 14:47:32 | [diff] [blame] | 27 | : public BluetoothProfileManagerClient { |
[email protected] | 896619e | 2013-04-18 04:41:42 | [diff] [blame] | 28 | public: |
| 29 | FakeBluetoothProfileManagerClient(); |
dcheng | 0280cb6 | 2015-01-16 07:37:50 | [diff] [blame] | 30 | ~FakeBluetoothProfileManagerClient() override; |
[email protected] | 896619e | 2013-04-18 04:41:42 | [diff] [blame] | 31 | |
[email protected] | c5fd536 | 2013-08-27 12:23:04 | [diff] [blame] | 32 | // BluetoothProfileManagerClient overrides |
dcheng | 0280cb6 | 2015-01-16 07:37:50 | [diff] [blame] | 33 | void Init(dbus::Bus* bus) override; |
| 34 | void RegisterProfile(const dbus::ObjectPath& profile_path, |
| 35 | const std::string& uuid, |
| 36 | const Options& options, |
| 37 | const base::Closure& callback, |
| 38 | const ErrorCallback& error_callback) override; |
| 39 | void UnregisterProfile(const dbus::ObjectPath& profile_path, |
| 40 | const base::Closure& callback, |
| 41 | const ErrorCallback& error_callback) override; |
[email protected] | e882d2c | 2013-05-09 03:49:18 | [diff] [blame] | 42 | |
| 43 | // Register, unregister and retrieve pointers to profile server providers. |
| 44 | void RegisterProfileServiceProvider( |
| 45 | FakeBluetoothProfileServiceProvider* service_provider); |
| 46 | void UnregisterProfileServiceProvider( |
| 47 | FakeBluetoothProfileServiceProvider* service_provider); |
| 48 | FakeBluetoothProfileServiceProvider* GetProfileServiceProvider( |
| 49 | const std::string& uuid); |
| 50 | |
| 51 | // UUIDs recognised for testing. |
| 52 | static const char kL2capUuid[]; |
| 53 | static const char kRfcommUuid[]; |
jamuraa | 202fef4 | 2015-03-09 20:20:22 | [diff] [blame] | 54 | static const char kUnregisterableUuid[]; |
[email protected] | e882d2c | 2013-05-09 03:49:18 | [diff] [blame] | 55 | |
| 56 | private: |
| 57 | // Map of a D-Bus object path to the FakeBluetoothProfileServiceProvider |
| 58 | // registered for it; maintained by RegisterProfileServiceProvider() and |
| 59 | // UnregisterProfileServiceProvicer() called by the constructor and |
| 60 | // destructor of FakeBluetoothProfileServiceProvider. |
| 61 | typedef std::map<dbus::ObjectPath, FakeBluetoothProfileServiceProvider*> |
| 62 | ServiceProviderMap; |
| 63 | ServiceProviderMap service_provider_map_; |
| 64 | |
| 65 | // Map of Profile UUID to the D-Bus object path of the service provider |
| 66 | // in |service_provider_map_|. Maintained by RegisterProfile() and |
| 67 | // UnregisterProfile() in response to BluetoothProfile methods. |
| 68 | typedef std::map<std::string, dbus::ObjectPath> ProfileMap; |
| 69 | ProfileMap profile_map_; |
[email protected] | 896619e | 2013-04-18 04:41:42 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } // namespace chromeos |
| 73 | |
[email protected] | 435605a | 2013-04-23 16:45:42 | [diff] [blame] | 74 | #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ |