OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "chromeos/chromeos_export.h" | |
14 #include "chromeos/dbus/bluetooth_gatt_manager_client.h" | |
15 #include "dbus/object_path.h" | 13 #include "dbus/object_path.h" |
| 14 #include "device/bluetooth/bluetooth_export.h" |
| 15 #include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" |
16 | 16 |
17 namespace chromeos { | 17 namespace bluez { |
18 | 18 |
19 class FakeBluetoothGattCharacteristicServiceProvider; | 19 class FakeBluetoothGattCharacteristicServiceProvider; |
20 class FakeBluetoothGattDescriptorServiceProvider; | 20 class FakeBluetoothGattDescriptorServiceProvider; |
21 class FakeBluetoothGattServiceServiceProvider; | 21 class FakeBluetoothGattServiceServiceProvider; |
22 | 22 |
23 // FakeBluetoothGattManagerClient simulates the behavior of the Bluetooth | 23 // FakeBluetoothGattManagerClient simulates the behavior of the Bluetooth |
24 // daemon's GATT manager object and is used both in test cases in place of a | 24 // daemon's GATT manager object and is used both in test cases in place of a |
25 // mock and on the Linux desktop. | 25 // mock and on the Linux desktop. |
26 class CHROMEOS_EXPORT FakeBluetoothGattManagerClient | 26 class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattManagerClient |
27 : public BluetoothGattManagerClient { | 27 : public BluetoothGattManagerClient { |
28 public: | 28 public: |
29 FakeBluetoothGattManagerClient(); | 29 FakeBluetoothGattManagerClient(); |
30 ~FakeBluetoothGattManagerClient() override; | 30 ~FakeBluetoothGattManagerClient() override; |
31 | 31 |
32 // DBusClient override. | 32 // DBusClient override. |
33 void Init(dbus::Bus* bus) override; | 33 void Init(dbus::Bus* bus) override; |
34 | 34 |
35 // BluetoothGattManagerClient overrides. | 35 // BluetoothGattManagerClient overrides. |
36 void RegisterService(const dbus::ObjectPath& service_path, | 36 void RegisterService(const dbus::ObjectPath& service_path, |
(...skipping 16 matching lines...) Expand all Loading... |
53 | 53 |
54 void UnregisterServiceServiceProvider( | 54 void UnregisterServiceServiceProvider( |
55 FakeBluetoothGattServiceServiceProvider* provider); | 55 FakeBluetoothGattServiceServiceProvider* provider); |
56 void UnregisterCharacteristicServiceProvider( | 56 void UnregisterCharacteristicServiceProvider( |
57 FakeBluetoothGattCharacteristicServiceProvider* provider); | 57 FakeBluetoothGattCharacteristicServiceProvider* provider); |
58 void UnregisterDescriptorServiceProvider( | 58 void UnregisterDescriptorServiceProvider( |
59 FakeBluetoothGattDescriptorServiceProvider* provider); | 59 FakeBluetoothGattDescriptorServiceProvider* provider); |
60 | 60 |
61 // Return a pointer to the service provider that corresponds to the object | 61 // Return a pointer to the service provider that corresponds to the object |
62 // path |object_path| if it exists. | 62 // path |object_path| if it exists. |
63 FakeBluetoothGattServiceServiceProvider* | 63 FakeBluetoothGattServiceServiceProvider* GetServiceServiceProvider( |
64 GetServiceServiceProvider(const dbus::ObjectPath& object_path) const; | 64 const dbus::ObjectPath& object_path) const; |
65 FakeBluetoothGattCharacteristicServiceProvider* | 65 FakeBluetoothGattCharacteristicServiceProvider* |
66 GetCharacteristicServiceProvider( | 66 GetCharacteristicServiceProvider(const dbus::ObjectPath& object_path) const; |
67 const dbus::ObjectPath& object_path) const; | 67 FakeBluetoothGattDescriptorServiceProvider* GetDescriptorServiceProvider( |
68 FakeBluetoothGattDescriptorServiceProvider* | 68 const dbus::ObjectPath& object_path) const; |
69 GetDescriptorServiceProvider(const dbus::ObjectPath& object_path) const; | |
70 | 69 |
71 // Returns true, if a GATT service with object path |object_path| was | 70 // Returns true, if a GATT service with object path |object_path| was |
72 // registered with the GATT manager using RegisterService. | 71 // registered with the GATT manager using RegisterService. |
73 bool IsServiceRegistered(const dbus::ObjectPath& object_path) const; | 72 bool IsServiceRegistered(const dbus::ObjectPath& object_path) const; |
74 | 73 |
75 private: | 74 private: |
76 // Mappings for GATT service, characteristic, and descriptor service | 75 // Mappings for GATT service, characteristic, and descriptor service |
77 // providers. The fake GATT manager stores references to all instances | 76 // providers. The fake GATT manager stores references to all instances |
78 // created so that they can be obtained by tests. | 77 // created so that they can be obtained by tests. |
79 typedef std::map< | 78 typedef std::map<dbus::ObjectPath, |
80 dbus::ObjectPath, FakeBluetoothGattCharacteristicServiceProvider*> | 79 FakeBluetoothGattCharacteristicServiceProvider*> |
81 CharacteristicMap; | 80 CharacteristicMap; |
82 typedef std::map< | 81 typedef std::map<dbus::ObjectPath, |
83 dbus::ObjectPath, FakeBluetoothGattDescriptorServiceProvider*> | 82 FakeBluetoothGattDescriptorServiceProvider*> DescriptorMap; |
84 DescriptorMap; | |
85 | 83 |
86 // The mapping for services is from object paths to pairs of boolean and | 84 // The mapping for services is from object paths to pairs of boolean and |
87 // service provider pointer, where the boolean denotes whether or not the | 85 // service provider pointer, where the boolean denotes whether or not the |
88 // service is already registered. | 86 // service is already registered. |
89 typedef std::pair<bool, FakeBluetoothGattServiceServiceProvider*> | 87 typedef std::pair<bool, FakeBluetoothGattServiceServiceProvider*> |
90 ServiceProvider; | 88 ServiceProvider; |
91 typedef std::map<dbus::ObjectPath, ServiceProvider> ServiceMap; | 89 typedef std::map<dbus::ObjectPath, ServiceProvider> ServiceMap; |
92 | 90 |
93 ServiceMap service_map_; | 91 ServiceMap service_map_; |
94 CharacteristicMap characteristic_map_; | 92 CharacteristicMap characteristic_map_; |
95 DescriptorMap descriptor_map_; | 93 DescriptorMap descriptor_map_; |
96 | 94 |
97 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattManagerClient); | 95 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattManagerClient); |
98 }; | 96 }; |
99 | 97 |
100 } // namespace chromeos | 98 } // namespace bluez |
101 | 99 |
102 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ | 100 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ |
OLD | NEW |