1 // Copyright 2014 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_MEDIA_TRANSPORT_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_
12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/bluetooth_media_transport_client.h"
16 #include "dbus/object_path.h"
20 class CHROMEOS_EXPORT FakeBluetoothMediaTransportClient
21 : public BluetoothMediaTransportClient
{
23 struct Properties
: public BluetoothMediaTransportClient::Properties
{
24 explicit Properties(const PropertyChangedCallback
& callback
);
25 ~Properties() override
;
27 void Get(dbus::PropertyBase
* property
,
28 dbus::PropertySet::GetCallback callback
) override
;
29 void GetAll() override
;
30 void Set(dbus::PropertyBase
* property
,
31 dbus::PropertySet::SetCallback callback
) override
;
34 // The default path of the transport object.
35 static const char kTransportPath
[];
37 // The default properties including device, codec, configuration, state, delay
38 // and volume, owned by a fake media transport object we emulate.
39 static const char kTransportDevicePath
[];
40 static const uint8_t kTransportCodec
;
41 static const std::vector
<uint8_t> kTransportConfiguration
;
42 static const uint16_t kTransportDelay
;
43 static const uint16_t kTransportVolume
;
45 FakeBluetoothMediaTransportClient();
46 ~FakeBluetoothMediaTransportClient() override
;
48 // DBusClient override.
49 void Init(dbus::Bus
* bus
) override
;
51 // BluetoothMediaTransportClient override.
52 void AddObserver(Observer
* observer
) override
;
53 void RemoveObserver(Observer
* observer
) override
;
54 Properties
* GetProperties(const dbus::ObjectPath
& object_path
) override
;
55 void Acquire(const dbus::ObjectPath
& object_path
,
56 const AcquireCallback
& callback
,
57 const ErrorCallback
& error_callback
) override
;
58 void TryAcquire(const dbus::ObjectPath
& object_path
,
59 const AcquireCallback
& callback
,
60 const ErrorCallback
& error_callback
) override
;
61 void Release(const dbus::ObjectPath
& object_path
,
62 const base::Closure
& callback
,
63 const ErrorCallback
& error_callback
) override
;
65 // Makes the transport valid/invalid for a given media endpoint path. The
66 // transport object is assigned to the given endpoint if valid is true, false
68 void SetValid(const dbus::ObjectPath
& endpoint_path
, bool valid
);
71 // Property callback passed while a Properties structure is created.
72 void OnPropertyChanged(const std::string
& property_name
);
74 // The path of the media transport object.
75 dbus::ObjectPath object_path_
;
77 // Indicates whether endpoints are assigned with the transport object.
78 std::map
<dbus::ObjectPath
, bool> endpoints_
;
80 // The fake property set of the media transport object.
81 scoped_ptr
<Properties
> properties_
;
83 ObserverList
<BluetoothMediaTransportClient::Observer
> observers_
;
85 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient
);
88 } // namespace chromeos
90 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_