[chromedriver] Drop support for M39 and add support for M42.
[chromium-blink-merge.git] / chromeos / dbus / fake_bluetooth_adapter_client.h
blob58f361d3b63778d288bb2839585f8ec44689d5ab
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.
5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_
8 #include <vector>
10 #include "base/bind.h"
11 #include "base/callback.h"
12 #include "base/observer_list.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/bluetooth_adapter_client.h"
15 #include "dbus/object_path.h"
16 #include "dbus/property.h"
18 namespace chromeos {
20 // FakeBluetoothAdapterClient simulates the behavior of the Bluetooth Daemon
21 // adapter objects and is used both in test cases in place of a mock and on
22 // the Linux desktop.
23 class CHROMEOS_EXPORT FakeBluetoothAdapterClient
24 : public BluetoothAdapterClient {
25 public:
26 struct Properties : public BluetoothAdapterClient::Properties {
27 explicit Properties(const PropertyChangedCallback& callback);
28 ~Properties() override;
30 // dbus::PropertySet override
31 void Get(dbus::PropertyBase* property,
32 dbus::PropertySet::GetCallback callback) override;
33 void GetAll() override;
34 void Set(dbus::PropertyBase* property,
35 dbus::PropertySet::SetCallback callback) override;
38 FakeBluetoothAdapterClient();
39 ~FakeBluetoothAdapterClient() override;
41 // BluetoothAdapterClient overrides
42 void Init(dbus::Bus* bus) override;
43 void AddObserver(Observer* observer) override;
44 void RemoveObserver(Observer* observer) override;
45 std::vector<dbus::ObjectPath> GetAdapters() override;
46 Properties* GetProperties(const dbus::ObjectPath& object_path) override;
47 void StartDiscovery(const dbus::ObjectPath& object_path,
48 const base::Closure& callback,
49 const ErrorCallback& error_callback) override;
50 void StopDiscovery(const dbus::ObjectPath& object_path,
51 const base::Closure& callback,
52 const ErrorCallback& error_callback) override;
53 void RemoveDevice(const dbus::ObjectPath& object_path,
54 const dbus::ObjectPath& device_path,
55 const base::Closure& callback,
56 const ErrorCallback& error_callback) override;
58 // Sets the current simulation timeout interval.
59 void SetSimulationIntervalMs(int interval_ms);
61 // Mark the adapter and second adapter as visible or invisible.
62 void SetVisible(bool visible);
63 void SetSecondVisible(bool visible);
65 // Object path, name and addresses of the adapters we emulate.
66 static const char kAdapterPath[];
67 static const char kAdapterName[];
68 static const char kAdapterAddress[];
70 static const char kSecondAdapterPath[];
71 static const char kSecondAdapterName[];
72 static const char kSecondAdapterAddress[];
74 private:
75 // Property callback passed when we create Properties* structures.
76 void OnPropertyChanged(const std::string& property_name);
78 // Posts the delayed task represented by |callback| onto the current
79 // message loop to be executed after |simulation_interval_ms_| milliseconds.
80 void PostDelayedTask(const base::Closure& callback);
82 // List of observers interested in event notifications from us.
83 ObserverList<Observer> observers_;
85 // Static properties we return.
86 scoped_ptr<Properties> properties_;
87 scoped_ptr<Properties> second_properties_;
89 // Whether the adapter and second adapter should be visible or not.
90 bool visible_;
91 bool second_visible_;
93 // Number of times we've been asked to discover.
94 int discovering_count_;
96 // Current timeout interval used when posting delayed tasks.
97 int simulation_interval_ms_;
100 } // namespace chromeos
102 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_