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..2092e0e2cfad850faab142ff4b803a0a53bc5262 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 |
Ben Chan
2015/02/12 21:17:44
there is already a // static above
Miao
2015/02/12 22:54:06
Done.
|
+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; |
+ return; |
+ } |
+ 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 |