| 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_INPUT_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "chromeos/chromeos_export.h" | 10 #include "chromeos/chromeos_export.h" |
| 11 #include "chromeos/dbus/bluetooth_input_client.h" | |
| 12 #include "dbus/object_path.h" | 11 #include "dbus/object_path.h" |
| 13 #include "dbus/property.h" | 12 #include "dbus/property.h" |
| 13 #include "device/bluetooth/dbus/bluetooth_input_client.h" |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace bluez { |
| 16 | 16 |
| 17 // FakeBluetoothInputClient simulates the behavior of the Bluetooth Daemon | 17 // FakeBluetoothInputClient simulates the behavior of the Bluetooth Daemon |
| 18 // input device objects and is used both in test cases in place of a mock and on | 18 // input device objects and is used both in test cases in place of a mock and on |
| 19 // the Linux desktop. | 19 // the Linux desktop. |
| 20 class CHROMEOS_EXPORT FakeBluetoothInputClient | 20 class CHROMEOS_EXPORT FakeBluetoothInputClient : public BluetoothInputClient { |
| 21 : public BluetoothInputClient { | |
| 22 public: | 21 public: |
| 23 struct Properties : public BluetoothInputClient::Properties { | 22 struct Properties : public BluetoothInputClient::Properties { |
| 24 explicit Properties(const PropertyChangedCallback & callback); | 23 explicit Properties(const PropertyChangedCallback& callback); |
| 25 ~Properties() override; | 24 ~Properties() override; |
| 26 | 25 |
| 27 // dbus::PropertySet override | 26 // dbus::PropertySet override |
| 28 void Get(dbus::PropertyBase* property, | 27 void Get(dbus::PropertyBase* property, |
| 29 dbus::PropertySet::GetCallback callback) override; | 28 dbus::PropertySet::GetCallback callback) override; |
| 30 void GetAll() override; | 29 void GetAll() override; |
| 31 void Set(dbus::PropertyBase* property, | 30 void Set(dbus::PropertyBase* property, |
| 32 dbus::PropertySet::SetCallback callback) override; | 31 dbus::PropertySet::SetCallback callback) override; |
| 33 }; | 32 }; |
| 34 | 33 |
| 35 FakeBluetoothInputClient(); | 34 FakeBluetoothInputClient(); |
| 36 ~FakeBluetoothInputClient() override; | 35 ~FakeBluetoothInputClient() override; |
| 37 | 36 |
| 38 // BluetoothInputClient overrides | 37 // BluetoothInputClient overrides |
| 39 void Init(dbus::Bus* bus) override; | 38 void Init(dbus::Bus* bus) override; |
| 40 void AddObserver(Observer* observer) override; | 39 void AddObserver(Observer* observer) override; |
| 41 void RemoveObserver(Observer* observer) override; | 40 void RemoveObserver(Observer* observer) override; |
| 42 Properties* GetProperties(const dbus::ObjectPath& object_path) override; | 41 Properties* GetProperties(const dbus::ObjectPath& object_path) override; |
| 43 | 42 |
| 44 // Simulate device addition/removal | 43 // Simulate device addition/removal |
| 45 void AddInputDevice(const dbus::ObjectPath& object_path); | 44 void AddInputDevice(const dbus::ObjectPath& object_path); |
| 46 void RemoveInputDevice(const dbus::ObjectPath& object_path); | 45 void RemoveInputDevice(const dbus::ObjectPath& object_path); |
| 47 | 46 |
| 48 private: | 47 private: |
| 49 // Property callback passed when we create Properties* structures. | 48 // Property callback passed when we create Properties* structures. |
| 50 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 49 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
| 51 const std::string& property_name); | 50 const std::string& property_name); |
| 52 | 51 |
| 53 // Static properties we return. | 52 // Static properties we return. |
| 54 typedef std::map<const dbus::ObjectPath, Properties *> PropertiesMap; | 53 typedef std::map<const dbus::ObjectPath, Properties*> PropertiesMap; |
| 55 PropertiesMap properties_map_; | 54 PropertiesMap properties_map_; |
| 56 | 55 |
| 57 // List of observers interested in event notifications from us. | 56 // List of observers interested in event notifications from us. |
| 58 base::ObserverList<Observer> observers_; | 57 base::ObserverList<Observer> observers_; |
| 59 | 58 |
| 60 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothInputClient); | 59 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothInputClient); |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 } // namespace chromeos | 62 } // namespace bluez |
| 64 | 63 |
| 65 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ | 64 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ |
| OLD | NEW |