OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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_DEVICE_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/containers/scoped_ptr_map.h" | 13 #include "base/containers/scoped_ptr_map.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
16 #include "chromeos/dbus/bluetooth_agent_service_provider.h" | |
17 #include "chromeos/dbus/bluetooth_device_client.h" | |
18 #include "chromeos/dbus/bluetooth_profile_service_provider.h" | |
19 #include "dbus/object_path.h" | 16 #include "dbus/object_path.h" |
20 #include "dbus/property.h" | 17 #include "dbus/property.h" |
| 18 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" |
| 19 #include "device/bluetooth/dbus/bluetooth_device_client.h" |
| 20 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" |
21 | 21 |
22 namespace chromeos { | 22 namespace bluez { |
23 | 23 |
24 // FakeBluetoothDeviceClient simulates the behavior of the Bluetooth Daemon | 24 // FakeBluetoothDeviceClient simulates the behavior of the Bluetooth Daemon |
25 // device objects and is used both in test cases in place of a mock and on | 25 // device objects and is used both in test cases in place of a mock and on |
26 // the Linux desktop. | 26 // the Linux desktop. |
27 class CHROMEOS_EXPORT FakeBluetoothDeviceClient | 27 class CHROMEOS_EXPORT FakeBluetoothDeviceClient : public BluetoothDeviceClient { |
28 : public BluetoothDeviceClient { | |
29 public: | 28 public: |
30 struct Properties : public BluetoothDeviceClient::Properties { | 29 struct Properties : public BluetoothDeviceClient::Properties { |
31 explicit Properties(const PropertyChangedCallback & callback); | 30 explicit Properties(const PropertyChangedCallback& callback); |
32 ~Properties() override; | 31 ~Properties() override; |
33 | 32 |
34 // dbus::PropertySet override | 33 // dbus::PropertySet override |
35 void Get(dbus::PropertyBase* property, | 34 void Get(dbus::PropertyBase* property, |
36 dbus::PropertySet::GetCallback callback) override; | 35 dbus::PropertySet::GetCallback callback) override; |
37 void GetAll() override; | 36 void GetAll() override; |
38 void Set(dbus::PropertyBase* property, | 37 void Set(dbus::PropertyBase* property, |
39 dbus::PropertySet::SetCallback callback) override; | 38 dbus::PropertySet::SetCallback callback) override; |
40 }; | 39 }; |
41 | 40 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 static const uint32 kPairedUnconnectableDeviceClass; | 229 static const uint32 kPairedUnconnectableDeviceClass; |
231 | 230 |
232 private: | 231 private: |
233 // Property callback passed when we create Properties* structures. | 232 // Property callback passed when we create Properties* structures. |
234 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 233 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
235 const std::string& property_name); | 234 const std::string& property_name); |
236 | 235 |
237 void DiscoverySimulationTimer(); | 236 void DiscoverySimulationTimer(); |
238 void IncomingPairingSimulationTimer(); | 237 void IncomingPairingSimulationTimer(); |
239 | 238 |
240 void CompleteSimulatedPairing( | 239 void CompleteSimulatedPairing(const dbus::ObjectPath& object_path, |
241 const dbus::ObjectPath& object_path, | 240 const base::Closure& callback, |
242 const base::Closure& callback, | 241 const ErrorCallback& error_callback); |
243 const ErrorCallback& error_callback); | 242 void TimeoutSimulatedPairing(const dbus::ObjectPath& object_path, |
244 void TimeoutSimulatedPairing( | 243 const ErrorCallback& error_callback); |
245 const dbus::ObjectPath& object_path, | 244 void CancelSimulatedPairing(const dbus::ObjectPath& object_path, |
246 const ErrorCallback& error_callback); | 245 const ErrorCallback& error_callback); |
247 void CancelSimulatedPairing( | 246 void RejectSimulatedPairing(const dbus::ObjectPath& object_path, |
248 const dbus::ObjectPath& object_path, | 247 const ErrorCallback& error_callback); |
249 const ErrorCallback& error_callback); | 248 void FailSimulatedPairing(const dbus::ObjectPath& object_path, |
250 void RejectSimulatedPairing( | 249 const ErrorCallback& error_callback); |
251 const dbus::ObjectPath& object_path, | 250 void AddInputDeviceIfNeeded(const dbus::ObjectPath& object_path, |
252 const ErrorCallback& error_callback); | 251 Properties* properties); |
253 void FailSimulatedPairing( | |
254 const dbus::ObjectPath& object_path, | |
255 const ErrorCallback& error_callback); | |
256 void AddInputDeviceIfNeeded( | |
257 const dbus::ObjectPath& object_path, | |
258 Properties* properties); | |
259 | 252 |
260 // Updates the inquiry RSSI property of fake device with object path | 253 // Updates the inquiry RSSI property of fake device with object path |
261 // |object_path| to |rssi|, if the fake device exists. | 254 // |object_path| to |rssi|, if the fake device exists. |
262 void UpdateDeviceRSSI(const dbus::ObjectPath& object_path, int16 rssi); | 255 void UpdateDeviceRSSI(const dbus::ObjectPath& object_path, int16 rssi); |
263 | 256 |
264 void PinCodeCallback( | 257 void PinCodeCallback(const dbus::ObjectPath& object_path, |
265 const dbus::ObjectPath& object_path, | 258 const base::Closure& callback, |
266 const base::Closure& callback, | 259 const ErrorCallback& error_callback, |
267 const ErrorCallback& error_callback, | 260 BluetoothAgentServiceProvider::Delegate::Status status, |
268 BluetoothAgentServiceProvider::Delegate::Status status, | 261 const std::string& pincode); |
269 const std::string& pincode); | 262 void PasskeyCallback(const dbus::ObjectPath& object_path, |
270 void PasskeyCallback( | 263 const base::Closure& callback, |
271 const dbus::ObjectPath& object_path, | 264 const ErrorCallback& error_callback, |
272 const base::Closure& callback, | 265 BluetoothAgentServiceProvider::Delegate::Status status, |
273 const ErrorCallback& error_callback, | 266 uint32 passkey); |
274 BluetoothAgentServiceProvider::Delegate::Status status, | |
275 uint32 passkey); | |
276 void ConfirmationCallback( | 267 void ConfirmationCallback( |
277 const dbus::ObjectPath& object_path, | 268 const dbus::ObjectPath& object_path, |
278 const base::Closure& callback, | 269 const base::Closure& callback, |
279 const ErrorCallback& error_callback, | 270 const ErrorCallback& error_callback, |
280 BluetoothAgentServiceProvider::Delegate::Status status); | 271 BluetoothAgentServiceProvider::Delegate::Status status); |
281 void SimulateKeypress( | 272 void SimulateKeypress(uint16 entered, |
282 uint16 entered, | 273 const dbus::ObjectPath& object_path, |
283 const dbus::ObjectPath& object_path, | 274 const base::Closure& callback, |
284 const base::Closure& callback, | 275 const ErrorCallback& error_callback); |
285 const ErrorCallback& error_callback); | |
286 | 276 |
287 void ConnectionCallback( | 277 void ConnectionCallback( |
288 const dbus::ObjectPath& object_path, | 278 const dbus::ObjectPath& object_path, |
289 const base::Closure& callback, | 279 const base::Closure& callback, |
290 const ErrorCallback& error_callback, | 280 const ErrorCallback& error_callback, |
291 BluetoothProfileServiceProvider::Delegate::Status status); | 281 BluetoothProfileServiceProvider::Delegate::Status status); |
292 void DisconnectionCallback( | 282 void DisconnectionCallback( |
293 const dbus::ObjectPath& object_path, | 283 const dbus::ObjectPath& object_path, |
294 const base::Closure& callback, | 284 const base::Closure& callback, |
295 const ErrorCallback& error_callback, | 285 const ErrorCallback& error_callback, |
(...skipping 17 matching lines...) Expand all Loading... |
313 int simulation_interval_ms_; | 303 int simulation_interval_ms_; |
314 uint32_t discovery_simulation_step_; | 304 uint32_t discovery_simulation_step_; |
315 uint32_t incoming_pairing_simulation_step_; | 305 uint32_t incoming_pairing_simulation_step_; |
316 bool pairing_cancelled_; | 306 bool pairing_cancelled_; |
317 | 307 |
318 int16 connection_rssi_; | 308 int16 connection_rssi_; |
319 int16 transmit_power_; | 309 int16 transmit_power_; |
320 int16 max_transmit_power_; | 310 int16 max_transmit_power_; |
321 }; | 311 }; |
322 | 312 |
323 } // namespace chromeos | 313 } // namespace bluez |
324 | 314 |
325 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ | 315 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ |
OLD | NEW |