Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromeos / dbus / fake_bluetooth_adapter_client.h
blob987fc6fcaa54dfa756c36aff5c337453f8c38f80
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;
57 void SetDiscoveryFilter(const dbus::ObjectPath& object_path,
58 const DiscoveryFilter& discovery_filter,
59 const base::Closure& callback,
60 const ErrorCallback& error_callback) override;
62 // Sets the current simulation timeout interval.
63 void SetSimulationIntervalMs(int interval_ms);
65 // Returns current discovery filter in use by this adapter.
66 DiscoveryFilter* GetDiscoveryFilter();
68 // Make SetDiscoveryFilter fail when called next time.
69 void MakeSetDiscoveryFilterFail();
71 // Mark the adapter and second adapter as visible or invisible.
72 void SetVisible(bool visible);
73 void SetSecondVisible(bool visible);
75 // Object path, name and addresses of the adapters we emulate.
76 static const char kAdapterPath[];
77 static const char kAdapterName[];
78 static const char kAdapterAddress[];
80 static const char kSecondAdapterPath[];
81 static const char kSecondAdapterName[];
82 static const char kSecondAdapterAddress[];
84 private:
85 // Property callback passed when we create Properties* structures.
86 void OnPropertyChanged(const std::string& property_name);
88 // Posts the delayed task represented by |callback| onto the current
89 // message loop to be executed after |simulation_interval_ms_| milliseconds.
90 void PostDelayedTask(const base::Closure& callback);
92 // List of observers interested in event notifications from us.
93 base::ObserverList<Observer> observers_;
95 // Static properties we return.
96 scoped_ptr<Properties> properties_;
97 scoped_ptr<Properties> second_properties_;
99 // Whether the adapter and second adapter should be visible or not.
100 bool visible_;
101 bool second_visible_;
103 // Number of times we've been asked to discover.
104 int discovering_count_;
106 // Current discovery filter
107 scoped_ptr<DiscoveryFilter> discovery_filter_;
109 // When set, next call to SetDiscoveryFilter would fail.
110 bool set_discovery_filter_should_fail_;
112 // Current timeout interval used when posting delayed tasks.
113 int simulation_interval_ms_;
116 } // namespace chromeos
118 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_