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_CRAS_AUDIO_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_CRAS_AUDIO_CLIENT_H_
8 #include "chromeos/chromeos_export.h"
9 #include "chromeos/dbus/cras_audio_client.h"
13 class CrasAudioHandlerTest
;
15 // The CrasAudioClient implementation used on Linux desktop.
16 class CHROMEOS_EXPORT FakeCrasAudioClient
: public CrasAudioClient
{
18 FakeCrasAudioClient();
19 ~FakeCrasAudioClient() override
;
21 // CrasAudioClient overrides:
22 void Init(dbus::Bus
* bus
) override
;
23 void AddObserver(Observer
* observer
) override
;
24 void RemoveObserver(Observer
* observer
) override
;
25 bool HasObserver(const Observer
* observer
) const override
;
26 void GetVolumeState(const GetVolumeStateCallback
& callback
) override
;
27 void GetNodes(const GetNodesCallback
& callback
,
28 const ErrorCallback
& error_callback
) override
;
29 void SetOutputNodeVolume(uint64 node_id
, int32 volume
) override
;
30 void SetOutputUserMute(bool mute_on
) override
;
31 void SetInputNodeGain(uint64 node_id
, int32 gain
) override
;
32 void SetInputMute(bool mute_on
) override
;
33 void SetActiveOutputNode(uint64 node_id
) override
;
34 void SetActiveInputNode(uint64 node_id
) override
;
35 void AddActiveInputNode(uint64 node_id
) override
;
36 void RemoveActiveInputNode(uint64 node_id
) override
;
37 void AddActiveOutputNode(uint64 node_id
) override
;
38 void RemoveActiveOutputNode(uint64 node_id
) override
;
39 void SwapLeftRight(uint64 node_id
, bool swap
) override
;
41 // Modifies an AudioNode from |node_list_| based on |audio_node.id|.
42 // if the |audio_node.id| cannot be found in list, Add an
43 // AudioNode to |node_list_|
44 void InsertAudioNodeToList(const AudioNode
& audio_node
);
46 // Removes an AudioNode from |node_list_| based on |node_id|.
47 void RemoveAudioNodeFromList(const uint64
& node_id
);
49 // Updates |node_list_| to contain |audio_nodes|.
50 void SetAudioNodesForTesting(const AudioNodeList
& audio_nodes
);
52 // Calls SetAudioNodesForTesting() and additionally notifies |observers_|.
53 void SetAudioNodesAndNotifyObserversForTesting(
54 const AudioNodeList
& new_nodes
);
56 const AudioNodeList
& node_list() const { return node_list_
; }
57 const uint64
& active_input_node_id() const { return active_input_node_id_
; }
58 const uint64
& active_output_node_id() const { return active_output_node_id_
; }
61 // Find a node in the list based on the id.
62 AudioNodeList::iterator
FindNode(uint64 node_id
);
64 VolumeState volume_state_
;
65 AudioNodeList node_list_
;
66 uint64 active_input_node_id_
;
67 uint64 active_output_node_id_
;
68 base::ObserverList
<Observer
> observers_
;
70 DISALLOW_COPY_AND_ASSIGN(FakeCrasAudioClient
);
73 } // namespace chromeos
75 #endif // CHROMEOS_DBUS_FAKE_CRAS_AUDIO_CLIENT_H_