| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_DBUS_FAKE_CRAS_AUDIO_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_CRAS_AUDIO_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_FAKE_CRAS_AUDIO_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_CRAS_AUDIO_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "base/macros.h" |
| 8 #include "chromeos/chromeos_export.h" | 11 #include "chromeos/chromeos_export.h" |
| 9 #include "chromeos/dbus/cras_audio_client.h" | 12 #include "chromeos/dbus/cras_audio_client.h" |
| 10 | 13 |
| 11 namespace chromeos { | 14 namespace chromeos { |
| 12 | 15 |
| 13 class CrasAudioHandlerTest; | 16 class CrasAudioHandlerTest; |
| 14 | 17 |
| 15 // The CrasAudioClient implementation used on Linux desktop. | 18 // The CrasAudioClient implementation used on Linux desktop. |
| 16 class CHROMEOS_EXPORT FakeCrasAudioClient : public CrasAudioClient { | 19 class CHROMEOS_EXPORT FakeCrasAudioClient : public CrasAudioClient { |
| 17 public: | 20 public: |
| 18 FakeCrasAudioClient(); | 21 FakeCrasAudioClient(); |
| 19 ~FakeCrasAudioClient() override; | 22 ~FakeCrasAudioClient() override; |
| 20 | 23 |
| 21 // CrasAudioClient overrides: | 24 // CrasAudioClient overrides: |
| 22 void Init(dbus::Bus* bus) override; | 25 void Init(dbus::Bus* bus) override; |
| 23 void AddObserver(Observer* observer) override; | 26 void AddObserver(Observer* observer) override; |
| 24 void RemoveObserver(Observer* observer) override; | 27 void RemoveObserver(Observer* observer) override; |
| 25 bool HasObserver(const Observer* observer) const override; | 28 bool HasObserver(const Observer* observer) const override; |
| 26 void GetVolumeState(const GetVolumeStateCallback& callback) override; | 29 void GetVolumeState(const GetVolumeStateCallback& callback) override; |
| 27 void GetNodes(const GetNodesCallback& callback, | 30 void GetNodes(const GetNodesCallback& callback, |
| 28 const ErrorCallback& error_callback) override; | 31 const ErrorCallback& error_callback) override; |
| 29 void SetOutputNodeVolume(uint64 node_id, int32 volume) override; | 32 void SetOutputNodeVolume(uint64_t node_id, int32_t volume) override; |
| 30 void SetOutputUserMute(bool mute_on) override; | 33 void SetOutputUserMute(bool mute_on) override; |
| 31 void SetInputNodeGain(uint64 node_id, int32 gain) override; | 34 void SetInputNodeGain(uint64_t node_id, int32_t gain) override; |
| 32 void SetInputMute(bool mute_on) override; | 35 void SetInputMute(bool mute_on) override; |
| 33 void SetActiveOutputNode(uint64 node_id) override; | 36 void SetActiveOutputNode(uint64_t node_id) override; |
| 34 void SetActiveInputNode(uint64 node_id) override; | 37 void SetActiveInputNode(uint64_t node_id) override; |
| 35 void AddActiveInputNode(uint64 node_id) override; | 38 void AddActiveInputNode(uint64_t node_id) override; |
| 36 void RemoveActiveInputNode(uint64 node_id) override; | 39 void RemoveActiveInputNode(uint64_t node_id) override; |
| 37 void AddActiveOutputNode(uint64 node_id) override; | 40 void AddActiveOutputNode(uint64_t node_id) override; |
| 38 void RemoveActiveOutputNode(uint64 node_id) override; | 41 void RemoveActiveOutputNode(uint64_t node_id) override; |
| 39 void SwapLeftRight(uint64 node_id, bool swap) override; | 42 void SwapLeftRight(uint64_t node_id, bool swap) override; |
| 40 | 43 |
| 41 // Modifies an AudioNode from |node_list_| based on |audio_node.id|. | 44 // Modifies an AudioNode from |node_list_| based on |audio_node.id|. |
| 42 // if the |audio_node.id| cannot be found in list, Add an | 45 // if the |audio_node.id| cannot be found in list, Add an |
| 43 // AudioNode to |node_list_| | 46 // AudioNode to |node_list_| |
| 44 void InsertAudioNodeToList(const AudioNode& audio_node); | 47 void InsertAudioNodeToList(const AudioNode& audio_node); |
| 45 | 48 |
| 46 // Removes an AudioNode from |node_list_| based on |node_id|. | 49 // Removes an AudioNode from |node_list_| based on |node_id|. |
| 47 void RemoveAudioNodeFromList(const uint64& node_id); | 50 void RemoveAudioNodeFromList(const uint64_t& node_id); |
| 48 | 51 |
| 49 // Updates |node_list_| to contain |audio_nodes|. | 52 // Updates |node_list_| to contain |audio_nodes|. |
| 50 void SetAudioNodesForTesting(const AudioNodeList& audio_nodes); | 53 void SetAudioNodesForTesting(const AudioNodeList& audio_nodes); |
| 51 | 54 |
| 52 // Calls SetAudioNodesForTesting() and additionally notifies |observers_|. | 55 // Calls SetAudioNodesForTesting() and additionally notifies |observers_|. |
| 53 void SetAudioNodesAndNotifyObserversForTesting( | 56 void SetAudioNodesAndNotifyObserversForTesting( |
| 54 const AudioNodeList& new_nodes); | 57 const AudioNodeList& new_nodes); |
| 55 | 58 |
| 56 const AudioNodeList& node_list() const { return node_list_; } | 59 const AudioNodeList& node_list() const { return node_list_; } |
| 57 const uint64& active_input_node_id() const { return active_input_node_id_; } | 60 const uint64_t& active_input_node_id() const { return active_input_node_id_; } |
| 58 const uint64& active_output_node_id() const { return active_output_node_id_; } | 61 const uint64_t& active_output_node_id() const { |
| 62 return active_output_node_id_; |
| 63 } |
| 59 | 64 |
| 60 private: | 65 private: |
| 61 // Find a node in the list based on the id. | 66 // Find a node in the list based on the id. |
| 62 AudioNodeList::iterator FindNode(uint64 node_id); | 67 AudioNodeList::iterator FindNode(uint64_t node_id); |
| 63 | 68 |
| 64 VolumeState volume_state_; | 69 VolumeState volume_state_; |
| 65 AudioNodeList node_list_; | 70 AudioNodeList node_list_; |
| 66 uint64 active_input_node_id_; | 71 uint64_t active_input_node_id_; |
| 67 uint64 active_output_node_id_; | 72 uint64_t active_output_node_id_; |
| 68 base::ObserverList<Observer> observers_; | 73 base::ObserverList<Observer> observers_; |
| 69 | 74 |
| 70 DISALLOW_COPY_AND_ASSIGN(FakeCrasAudioClient); | 75 DISALLOW_COPY_AND_ASSIGN(FakeCrasAudioClient); |
| 71 }; | 76 }; |
| 72 | 77 |
| 73 } // namespace chromeos | 78 } // namespace chromeos |
| 74 | 79 |
| 75 #endif // CHROMEOS_DBUS_FAKE_CRAS_AUDIO_CLIENT_H_ | 80 #endif // CHROMEOS_DBUS_FAKE_CRAS_AUDIO_CLIENT_H_ |
| OLD | NEW |