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

Unified Diff: chromeos/dbus/fake_bluetooth_media_transport_client.cc

Issue 910023002: device/bluetooth:Implement BluetoothMediaEndpointServiceProvider delegate and media-related overrid… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Marked TransportProperties struct with DISALLOW_COPY_AND_ASSIGN. Created 5 years, 10 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_media_transport_client.cc
diff --git a/chromeos/dbus/fake_bluetooth_media_transport_client.cc b/chromeos/dbus/fake_bluetooth_media_transport_client.cc
index 1a48abbfb78d9dc5da3c6b61ba3c1cb527a562b9..5b8cf9b44a4c549c2d8d621f1f20ef10e54d77fc 100644
--- a/chromeos/dbus/fake_bluetooth_media_transport_client.cc
+++ b/chromeos/dbus/fake_bluetooth_media_transport_client.cc
@@ -4,6 +4,13 @@
#include "chromeos/dbus/fake_bluetooth_media_transport_client.h"
+#include "base/bind.h"
+#include "chromeos/dbus/bluetooth_media_client.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/fake_bluetooth_media_client.h"
+
+using dbus::ObjectPath;
+
namespace {
// TODO(mcchou): Remove this constants once it is in cros_system_api.
@@ -14,6 +21,20 @@ const char kNotImplemented[] = "org.bluez.NotImplemented";
namespace chromeos {
+// static
+const char FakeBluetoothMediaTransportClient::kTransportPath[] =
+ "/fake/hci0/dev_00_00_00_00_00_00/fd0";
+
+// static
+const char FakeBluetoothMediaTransportClient::kTransportDevicePath[] =
+ "/fake/hci0/dev_00_00_00_00_00_00";
+const uint8_t FakeBluetoothMediaTransportClient::kTransportCodec = 0x00;
+const std::vector<uint8_t>
+ FakeBluetoothMediaTransportClient::kTransportConfiguration = {
+ 0x21, 0x15, 0x33, 0x2C};
+const uint16_t FakeBluetoothMediaTransportClient::kTransportDelay = 5;
+const uint16_t FakeBluetoothMediaTransportClient::kTransportVolume = 10;
+
FakeBluetoothMediaTransportClient::Properties::Properties(
const PropertyChangedCallback& callback)
: BluetoothMediaTransportClient::Properties(
@@ -45,7 +66,23 @@ void FakeBluetoothMediaTransportClient::Properties::Set(
callback.Run(false);
}
-FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient() {
+FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient()
+ : object_path_(ObjectPath(kTransportPath)) {
+ // TODO(mcchou): Multiple endpoints are sharing one property set for now.
+ // Add property sets accordingly to separate the
+ // MediaTransportPropertiesChanged events for different endpoints.
+
+ // Sets fake property set with default values.
+ properties_.reset(new Properties(
+ base::Bind(&FakeBluetoothMediaTransportClient::OnPropertyChanged,
+ base::Unretained(this))));
+ properties_->device.ReplaceValue(ObjectPath(kTransportDevicePath));
+ properties_->uuid.ReplaceValue(BluetoothMediaClient::kBluetoothAudioSinkUUID);
+ properties_->codec.ReplaceValue(kTransportCodec);
+ properties_->configuration.ReplaceValue(kTransportConfiguration);
+ properties_->state.ReplaceValue(BluetoothMediaTransportClient::kStateIdle);
+ properties_->delay.ReplaceValue(kTransportDelay);
+ properties_->volume.ReplaceValue(kTransportVolume);
}
FakeBluetoothMediaTransportClient::~FakeBluetoothMediaTransportClient() {
@@ -69,29 +106,51 @@ void FakeBluetoothMediaTransportClient::RemoveObserver(
FakeBluetoothMediaTransportClient::Properties*
FakeBluetoothMediaTransportClient::GetProperties(
- const dbus::ObjectPath& object_path) {
+ const ObjectPath& object_path) {
return nullptr;
}
void FakeBluetoothMediaTransportClient::Acquire(
- const dbus::ObjectPath& object_path,
+ const ObjectPath& object_path,
const AcquireCallback& callback,
const ErrorCallback& error_callback) {
error_callback.Run(kNotImplemented, "");
}
void FakeBluetoothMediaTransportClient::TryAcquire(
- const dbus::ObjectPath& object_path,
+ const ObjectPath& object_path,
const AcquireCallback& callback,
const ErrorCallback& error_callback) {
error_callback.Run(kNotImplemented, "");
}
void FakeBluetoothMediaTransportClient::Release(
- const dbus::ObjectPath& object_path,
+ const ObjectPath& object_path,
const base::Closure& callback,
const ErrorCallback& error_callback) {
error_callback.Run(kNotImplemented, "");
}
+void FakeBluetoothMediaTransportClient::SetValid(
+ const ObjectPath& endpoint_path,
+ bool valid) {
+ if (valid) {
+ endpoints_[endpoint_path] = valid;
armansito 2015/02/12 05:20:44 nit: early return.
Miao 2015/02/12 19:08:03 Done.
+ } else {
+ endpoints_.erase(endpoint_path);
+
+ // TODO(mcchou): Since there is only one transport path, all observers will
+ // be notified. Shades irrelevant observers.
+
+ // Notifies observers about the state change of the transport.
+ FOR_EACH_OBSERVER(BluetoothMediaTransportClient::Observer, observers_,
+ MediaTransportRemoved(object_path_));
+ }
+}
+
+void FakeBluetoothMediaTransportClient::OnPropertyChanged(
+ const std::string& property_name) {
+ VLOG(1) << "Property " << property_name << " changed";
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698