Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: chromeos/dbus/fake_bluetooth_adapter_client.h

Issue 13927010: Bluetooth: implement BlueZ 5 backend for Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/fake_bluetooth_adapter_client.h
diff --git a/chromeos/dbus/fake_bluetooth_adapter_client.h b/chromeos/dbus/fake_bluetooth_adapter_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..26b21ff5149d9412614c685821a429b074c3364d
--- /dev/null
+++ b/chromeos/dbus/fake_bluetooth_adapter_client.h
@@ -0,0 +1,93 @@
+// 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.
+
+#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_
+#define CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_
+
+#include <vector>
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/observer_list.h"
+#include "chromeos/chromeos_export.h"
+#include "chromeos/dbus/dbus_client_implementation_type.h"
+#include "chromeos/dbus/experimental_bluetooth_adapter_client.h"
+#include "dbus/object_path.h"
+#include "dbus/property.h"
+
+namespace chromeos {
+
+// FakeBluetoothAdapterClient simulates the behavior of the Bluetooth Daemon
+// adapter objects and is used both in test cases in place of a mock and on
+// the Linux desktop.
+class CHROMEOS_EXPORT FakeBluetoothAdapterClient
+ : public ExperimentalBluetoothAdapterClient {
+ public:
+ struct Properties : public ExperimentalBluetoothAdapterClient::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;
+ };
+
+ FakeBluetoothAdapterClient();
+ virtual ~FakeBluetoothAdapterClient();
+
+ // ExperimentalBluetoothAdapterClient override
+ virtual void AddObserver(Observer* observer) OVERRIDE;
+ virtual void RemoveObserver(Observer* observer) OVERRIDE;
+ virtual std::vector<dbus::ObjectPath> GetAdapters() OVERRIDE;
+ virtual Properties* GetProperties(const dbus::ObjectPath& object_path)
+ OVERRIDE;
+ virtual void StartDiscovery(const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE;
+ virtual void StopDiscovery(const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE;
+ virtual void RemoveDevice(const dbus::ObjectPath& object_path,
+ const dbus::ObjectPath& device_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE;
+
+ // Mark the adapter and second adapter as visible or invisible.
+ void SetVisible(bool visible);
+ void SetSecondVisible(bool visible);
+
+ // Object path, name and addresses of the adapters we emulate.
+ static const dbus::ObjectPath kAdapterPath;
+ static const char kAdapterName[];
+ static const char kAdapterAddress[];
+
+ static const dbus::ObjectPath kSecondAdapterPath;
+ static const char kSecondAdapterName[];
+ static const char kSecondAdapterAddress[];
+
+ private:
+ // Property callback passed when we create Properties* structures.
+ void OnPropertyChanged(const std::string& property_name);
+
+ // List of observers interested in event notifications from us.
+ ObserverList<Observer> observers_;
+
+ // Static properties we return.
+ scoped_ptr<Properties> properties_;
+ scoped_ptr<Properties> second_properties_;
+
+ // Whether the adapter and second adapter should be visible or not.
+ bool visible_;
+ bool second_visible_;
+
+ // Number of times we've been asked to discover.
+ int discovering_count_;
+};
+
+} // namespace chromeos
+
+#endif /* CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_ */

Powered by Google App Engine
This is Rietveld 408576698