OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ | 5 #ifndef MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ |
6 #define MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ | 6 #define MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/sequenced_task_runner_helpers.h" | 10 #include "base/sequenced_task_runner_helpers.h" |
11 #include "media/audio/audio_manager.h" | 11 #include "media/audio/audio_manager.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 // This class is a simple mock around AudioManager, used exclusively for tests, | 15 // This class is a simple mock around AudioManager, used exclusively for tests, |
16 // which avoids to use the actual (system and platform dependent) AudioManager. | 16 // which avoids to use the actual (system and platform dependent) AudioManager. |
17 // Some bots does not have input devices, thus using the actual AudioManager | 17 // Some bots does not have input devices, thus using the actual AudioManager |
18 // would causing failures on classes which expect that. | 18 // would causing failures on classes which expect that. |
19 class MockAudioManager : public AudioManager { | 19 class MockAudioManager : public AudioManager { |
20 public: | 20 public: |
21 class Deleter { | 21 class Deleter { |
22 public: | 22 public: |
23 void operator()(const MockAudioManager* instance) const; | 23 void operator()(const MockAudioManager* instance) const; |
24 }; | 24 }; |
25 | 25 |
26 using UniquePtr = std::unique_ptr<MockAudioManager, Deleter>; | 26 using UniquePtr = std::unique_ptr<MockAudioManager, Deleter>; |
27 using GetDeviceDescriptionsCallback = | 27 using GetDeviceDescriptionsCallback = |
28 base::RepeatingCallback<void(AudioDeviceDescriptions*)>; | 28 base::RepeatingCallback<void(AudioDeviceDescriptions*)>; |
| 29 using GetAssociatedOutputDeviceIDCallback = |
| 30 base::RepeatingCallback<std::string(const std::string&)>; |
29 | 31 |
30 explicit MockAudioManager( | 32 explicit MockAudioManager( |
31 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 33 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
32 | 34 |
33 bool HasAudioOutputDevices() override; | 35 bool HasAudioOutputDevices() override; |
34 | 36 |
35 bool HasAudioInputDevices() override; | 37 bool HasAudioInputDevices() override; |
36 | 38 |
37 base::string16 GetAudioInputDeviceModel() override; | 39 base::string16 GetAudioInputDeviceModel() override; |
38 | 40 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // Setters to emulate desired in-test behavior. | 85 // Setters to emulate desired in-test behavior. |
84 void SetInputStreamParameters(const AudioParameters& params); | 86 void SetInputStreamParameters(const AudioParameters& params); |
85 void SetOutputStreamParameters(const AudioParameters& params); | 87 void SetOutputStreamParameters(const AudioParameters& params); |
86 void SetDefaultOutputStreamParameters(const AudioParameters& params); | 88 void SetDefaultOutputStreamParameters(const AudioParameters& params); |
87 void SetHasInputDevices(bool has_input_devices); | 89 void SetHasInputDevices(bool has_input_devices); |
88 void SetHasOutputDevices(bool has_output_devices); | 90 void SetHasOutputDevices(bool has_output_devices); |
89 void SetInputDeviceDescriptionsCallback( | 91 void SetInputDeviceDescriptionsCallback( |
90 GetDeviceDescriptionsCallback callback); | 92 GetDeviceDescriptionsCallback callback); |
91 void SetOutputDeviceDescriptionsCallback( | 93 void SetOutputDeviceDescriptionsCallback( |
92 GetDeviceDescriptionsCallback callback); | 94 GetDeviceDescriptionsCallback callback); |
| 95 void SetAssociatedOutputDeviceIDCallback( |
| 96 GetAssociatedOutputDeviceIDCallback callback); |
93 | 97 |
94 protected: | 98 protected: |
95 ~MockAudioManager() override; | 99 ~MockAudioManager() override; |
96 | 100 |
97 private: | 101 private: |
98 friend class base::DeleteHelper<MockAudioManager>; | 102 friend class base::DeleteHelper<MockAudioManager>; |
99 | 103 |
100 AudioParameters input_params_; | 104 AudioParameters input_params_; |
101 AudioParameters output_params_; | 105 AudioParameters output_params_; |
102 AudioParameters default_output_params_; | 106 AudioParameters default_output_params_; |
103 bool has_input_devices_ = true; | 107 bool has_input_devices_ = true; |
104 bool has_output_devices_ = true; | 108 bool has_output_devices_ = true; |
105 GetDeviceDescriptionsCallback get_input_device_descriptions_cb_; | 109 GetDeviceDescriptionsCallback get_input_device_descriptions_cb_; |
106 GetDeviceDescriptionsCallback get_output_device_descriptions_cb_; | 110 GetDeviceDescriptionsCallback get_output_device_descriptions_cb_; |
| 111 GetAssociatedOutputDeviceIDCallback get_associated_output_device_id_cb_; |
107 | 112 |
108 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); | 113 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); |
109 }; | 114 }; |
110 | 115 |
111 } // namespace media. | 116 } // namespace media. |
112 | 117 |
113 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ | 118 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ |
OLD | NEW |