blob: a2aa62016559cbe1093b57f0ad0e9920a9d528c0 [file] [log] [blame]
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/callback.h"
#include "base/observer_list.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/bluetooth_input_client.h"
#include "dbus/object_path.h"
#include "dbus/property.h"
namespace chromeos {
// FakeBluetoothInputClient simulates the behavior of the Bluetooth Daemon
// input device objects and is used both in test cases in place of a mock and on
// the Linux desktop.
class CHROMEOS_EXPORT FakeBluetoothInputClient
: public BluetoothInputClient {
struct Properties : public BluetoothInputClient::Properties {
explicit Properties(const PropertyChangedCallback & callback);
virtual ~Properties();
// dbus::PropertySet override
virtual void Get(dbus::PropertyBase* property,
dbus::PropertySet::GetCallback callback) OVERRIDE;
virtual void GetAll() OVERRIDE;
virtual void Set(dbus::PropertyBase* property,
dbus::PropertySet::SetCallback callback) OVERRIDE;
virtual ~FakeBluetoothInputClient();
// BluetoothInputClient overrides
virtual void Init(dbus::Bus* bus) OVERRIDE;
virtual void AddObserver(Observer* observer) OVERRIDE;
virtual void RemoveObserver(Observer* observer) OVERRIDE;
virtual Properties* GetProperties(const dbus::ObjectPath& object_path)
// Simulate device addition/removal
void AddInputDevice(const dbus::ObjectPath& object_path);
void RemoveInputDevice(const dbus::ObjectPath& object_path);
// Property callback passed when we create Properties* structures.
void OnPropertyChanged(const dbus::ObjectPath& object_path,
const std::string& property_name);
// Static properties we return.
typedef std::map<const dbus::ObjectPath, Properties *> PropertiesMap;
PropertiesMap properties_map_;
// List of observers interested in event notifications from us.
ObserverList<Observer> observers_;
} // namespace chromeos