| 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 { | |
| 22 public: | |
| 23 void operator()(const MockAudioManager* instance) const; | |
| 24 }; | |
| 25 | |
| 26 using UniquePtr = std::unique_ptr<MockAudioManager, Deleter>; | |
| 27 using GetDeviceDescriptionsCallback = | 21 using GetDeviceDescriptionsCallback = |
| 28 base::RepeatingCallback<void(AudioDeviceDescriptions*)>; | 22 base::RepeatingCallback<void(AudioDeviceDescriptions*)>; |
| 29 | 23 |
| 30 explicit MockAudioManager( | 24 explicit MockAudioManager( |
| 31 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 25 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 26 ~MockAudioManager() override; |
| 27 |
| 28 void Shutdown() override; |
| 32 | 29 |
| 33 bool HasAudioOutputDevices() override; | 30 bool HasAudioOutputDevices() override; |
| 34 | 31 |
| 35 bool HasAudioInputDevices() override; | 32 bool HasAudioInputDevices() override; |
| 36 | 33 |
| 37 base::string16 GetAudioInputDeviceModel() override; | 34 base::string16 GetAudioInputDeviceModel() override; |
| 38 | 35 |
| 39 void ShowAudioInputSettings() override; | 36 void ShowAudioInputSettings() override; |
| 40 | 37 |
| 41 void GetAudioInputDeviceDescriptions( | 38 void GetAudioInputDeviceDescriptions( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 void SetInputStreamParameters(const AudioParameters& params); | 81 void SetInputStreamParameters(const AudioParameters& params); |
| 85 void SetOutputStreamParameters(const AudioParameters& params); | 82 void SetOutputStreamParameters(const AudioParameters& params); |
| 86 void SetDefaultOutputStreamParameters(const AudioParameters& params); | 83 void SetDefaultOutputStreamParameters(const AudioParameters& params); |
| 87 void SetHasInputDevices(bool has_input_devices); | 84 void SetHasInputDevices(bool has_input_devices); |
| 88 void SetHasOutputDevices(bool has_output_devices); | 85 void SetHasOutputDevices(bool has_output_devices); |
| 89 void SetInputDeviceDescriptionsCallback( | 86 void SetInputDeviceDescriptionsCallback( |
| 90 GetDeviceDescriptionsCallback callback); | 87 GetDeviceDescriptionsCallback callback); |
| 91 void SetOutputDeviceDescriptionsCallback( | 88 void SetOutputDeviceDescriptionsCallback( |
| 92 GetDeviceDescriptionsCallback callback); | 89 GetDeviceDescriptionsCallback callback); |
| 93 | 90 |
| 94 protected: | |
| 95 ~MockAudioManager() override; | |
| 96 | |
| 97 private: | 91 private: |
| 98 friend class base::DeleteHelper<MockAudioManager>; | |
| 99 | |
| 100 AudioParameters input_params_; | 92 AudioParameters input_params_; |
| 101 AudioParameters output_params_; | 93 AudioParameters output_params_; |
| 102 AudioParameters default_output_params_; | 94 AudioParameters default_output_params_; |
| 103 bool has_input_devices_ = true; | 95 bool has_input_devices_ = true; |
| 104 bool has_output_devices_ = true; | 96 bool has_output_devices_ = true; |
| 105 GetDeviceDescriptionsCallback get_input_device_descriptions_cb_; | 97 GetDeviceDescriptionsCallback get_input_device_descriptions_cb_; |
| 106 GetDeviceDescriptionsCallback get_output_device_descriptions_cb_; | 98 GetDeviceDescriptionsCallback get_output_device_descriptions_cb_; |
| 107 | 99 |
| 108 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); | 100 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); |
| 109 }; | 101 }; |
| 110 | 102 |
| 111 } // namespace media. | 103 } // namespace media. |
| 112 | 104 |
| 113 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ | 105 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ |
| OLD | NEW |