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