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/macros.h" | 8 #include "base/macros.h" |
9 #include "media/audio/audio_manager.h" | 9 #include "media/audio/audio_manager.h" |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 | 12 |
13 // This class is a simple mock around AudioManager, used exclusively for tests, | 13 // This class is a simple mock around AudioManager, used exclusively for tests, |
14 // which avoids to use the actual (system and platform dependent) AudioManager. | 14 // which avoids to use the actual (system and platform dependent) AudioManager. |
15 // Some bots does not have input devices, thus using the actual AudioManager | 15 // Some bots does not have input devices, thus using the actual AudioManager |
16 // would causing failures on classes which expect that. | 16 // would causing failures on classes which expect that. |
17 class MockAudioManager : public media::AudioManager { | 17 class MockAudioManager : public AudioManager { |
18 public: | 18 public: |
19 explicit MockAudioManager( | 19 explicit MockAudioManager( |
20 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 20 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
21 | 21 |
22 bool HasAudioOutputDevices() override; | 22 bool HasAudioOutputDevices() override; |
23 | 23 |
24 bool HasAudioInputDevices() override; | 24 bool HasAudioInputDevices() override; |
25 | 25 |
26 base::string16 GetAudioInputDeviceModel() override; | 26 base::string16 GetAudioInputDeviceModel() override; |
27 | 27 |
28 void ShowAudioInputSettings() override; | 28 void ShowAudioInputSettings() override; |
29 | 29 |
30 void GetAudioInputDeviceDescriptions( | 30 void GetAudioInputDeviceDescriptions( |
31 media::AudioDeviceDescriptions* device_descriptions) override; | 31 media::AudioDeviceDescriptions* device_descriptions) override; |
32 | 32 |
33 void GetAudioOutputDeviceDescriptions( | 33 void GetAudioOutputDeviceDescriptions( |
34 media::AudioDeviceDescriptions* device_descriptions) override; | 34 media::AudioDeviceDescriptions* device_descriptions) override; |
35 | 35 |
36 media::AudioOutputStream* MakeAudioOutputStream( | 36 AudioOutputStream* MakeAudioOutputStream( |
37 const media::AudioParameters& params, | 37 const media::AudioParameters& params, |
38 const std::string& device_id, | 38 const std::string& device_id, |
39 const LogCallback& log_callback) override; | 39 const LogCallback& log_callback) override; |
40 | 40 |
41 media::AudioOutputStream* MakeAudioOutputStreamProxy( | 41 AudioOutputStream* MakeAudioOutputStreamProxy( |
42 const media::AudioParameters& params, | 42 const media::AudioParameters& params, |
43 const std::string& device_id) override; | 43 const std::string& device_id) override; |
44 | 44 |
45 media::AudioInputStream* MakeAudioInputStream( | 45 AudioInputStream* MakeAudioInputStream( |
46 const media::AudioParameters& params, | 46 const media::AudioParameters& params, |
47 const std::string& device_id, | 47 const std::string& device_id, |
48 const LogCallback& log_callback) override; | 48 const LogCallback& log_callback) override; |
49 | 49 |
50 void AddOutputDeviceChangeListener(AudioDeviceListener* listener) override; | 50 void AddOutputDeviceChangeListener(AudioDeviceListener* listener) override; |
51 void RemoveOutputDeviceChangeListener(AudioDeviceListener* listener) override; | 51 void RemoveOutputDeviceChangeListener(AudioDeviceListener* listener) override; |
52 | 52 |
53 AudioParameters GetDefaultOutputStreamParameters() override; | 53 AudioParameters GetDefaultOutputStreamParameters() override; |
54 AudioParameters GetOutputStreamParameters( | 54 AudioParameters GetOutputStreamParameters( |
55 const std::string& device_id) override; | 55 const std::string& device_id) override; |
56 AudioParameters GetInputStreamParameters( | 56 AudioParameters GetInputStreamParameters( |
57 const std::string& device_id) override; | 57 const std::string& device_id) override; |
58 std::string GetAssociatedOutputDeviceID( | 58 std::string GetAssociatedOutputDeviceID( |
59 const std::string& input_device_id) override; | 59 const std::string& input_device_id) override; |
60 | 60 |
61 std::unique_ptr<AudioLog> CreateAudioLog( | 61 std::unique_ptr<AudioLog> CreateAudioLog( |
62 AudioLogFactory::AudioComponent component) override; | 62 AudioLogFactory::AudioComponent component) override; |
63 | 63 |
64 const char* GetName() override; | 64 const char* GetName() override; |
65 | 65 |
| 66 // Setters to emulate desired in-test behavior. |
| 67 void SetInputStreamParameters(const AudioParameters& input_params); |
| 68 void SetHasInputDevices(bool has_input_devices); |
| 69 |
66 protected: | 70 protected: |
67 ~MockAudioManager() override; | 71 ~MockAudioManager() override; |
68 | 72 |
69 private: | 73 private: |
| 74 AudioParameters input_params_; |
| 75 bool has_input_devices_ = true; |
| 76 |
70 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); | 77 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); |
71 }; | 78 }; |
72 | 79 |
73 } // namespace media. | 80 } // namespace media. |
74 | 81 |
75 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ | 82 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ |
OLD | NEW |