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