| 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; |
| 34 | 28 |
| 35 AudioOutputStream* MakeAudioOutputStream( | 29 AudioOutputStream* MakeAudioOutputStream( |
| 36 const media::AudioParameters& params, | 30 const media::AudioParameters& params, |
| 37 const std::string& device_id, | 31 const std::string& device_id, |
| 38 const LogCallback& log_callback) override; | 32 const LogCallback& log_callback) override; |
| 39 | 33 |
| 40 AudioOutputStream* MakeAudioOutputStreamProxy( | 34 AudioOutputStream* MakeAudioOutputStreamProxy( |
| 41 const media::AudioParameters& params, | 35 const media::AudioParameters& params, |
| 42 const std::string& device_id) override; | 36 const std::string& device_id) override; |
| 43 | 37 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 67 void SetHasInputDevices(bool has_input_devices); | 61 void SetHasInputDevices(bool has_input_devices); |
| 68 void SetHasOutputDevices(bool has_output_devices); | 62 void SetHasOutputDevices(bool has_output_devices); |
| 69 void SetInputDeviceDescriptionsCallback( | 63 void SetInputDeviceDescriptionsCallback( |
| 70 GetDeviceDescriptionsCallback callback); | 64 GetDeviceDescriptionsCallback callback); |
| 71 void SetOutputDeviceDescriptionsCallback( | 65 void SetOutputDeviceDescriptionsCallback( |
| 72 GetDeviceDescriptionsCallback callback); | 66 GetDeviceDescriptionsCallback callback); |
| 73 void SetAssociatedOutputDeviceIDCallback( | 67 void SetAssociatedOutputDeviceIDCallback( |
| 74 GetAssociatedOutputDeviceIDCallback callback); | 68 GetAssociatedOutputDeviceIDCallback callback); |
| 75 | 69 |
| 76 protected: | 70 protected: |
| 77 ~MockAudioManager() override; | 71 void ShutdownOnAudioThread() override; |
| 78 | 72 |
| 79 bool HasAudioOutputDevices() override; | 73 bool HasAudioOutputDevices() override; |
| 80 | 74 |
| 81 bool HasAudioInputDevices() override; | 75 bool HasAudioInputDevices() override; |
| 82 | 76 |
| 83 base::string16 GetAudioInputDeviceModel() override; | 77 base::string16 GetAudioInputDeviceModel() override; |
| 84 | 78 |
| 85 void ShowAudioInputSettings() override; | 79 void ShowAudioInputSettings() override; |
| 86 | 80 |
| 87 void GetAudioInputDeviceDescriptions( | 81 void GetAudioInputDeviceDescriptions( |
| 88 media::AudioDeviceDescriptions* device_descriptions) override; | 82 media::AudioDeviceDescriptions* device_descriptions) override; |
| 89 | 83 |
| 90 void GetAudioOutputDeviceDescriptions( | 84 void GetAudioOutputDeviceDescriptions( |
| 91 media::AudioDeviceDescriptions* device_descriptions) override; | 85 media::AudioDeviceDescriptions* device_descriptions) override; |
| 92 | 86 |
| 93 AudioParameters GetDefaultOutputStreamParameters() override; | 87 AudioParameters GetDefaultOutputStreamParameters() override; |
| 94 AudioParameters GetOutputStreamParameters( | 88 AudioParameters GetOutputStreamParameters( |
| 95 const std::string& device_id) override; | 89 const std::string& device_id) override; |
| 96 AudioParameters GetInputStreamParameters( | 90 AudioParameters GetInputStreamParameters( |
| 97 const std::string& device_id) override; | 91 const std::string& device_id) override; |
| 98 std::string GetAssociatedOutputDeviceID( | 92 std::string GetAssociatedOutputDeviceID( |
| 99 const std::string& input_device_id) override; | 93 const std::string& input_device_id) override; |
| 100 | 94 |
| 101 private: | 95 private: |
| 102 friend class base::DeleteHelper<MockAudioManager>; | |
| 103 | |
| 104 AudioParameters input_params_; | 96 AudioParameters input_params_; |
| 105 AudioParameters output_params_; | 97 AudioParameters output_params_; |
| 106 AudioParameters default_output_params_; | 98 AudioParameters default_output_params_; |
| 107 bool has_input_devices_ = true; | 99 bool has_input_devices_ = true; |
| 108 bool has_output_devices_ = true; | 100 bool has_output_devices_ = true; |
| 109 GetDeviceDescriptionsCallback get_input_device_descriptions_cb_; | 101 GetDeviceDescriptionsCallback get_input_device_descriptions_cb_; |
| 110 GetDeviceDescriptionsCallback get_output_device_descriptions_cb_; | 102 GetDeviceDescriptionsCallback get_output_device_descriptions_cb_; |
| 111 GetAssociatedOutputDeviceIDCallback get_associated_output_device_id_cb_; | 103 GetAssociatedOutputDeviceIDCallback get_associated_output_device_id_cb_; |
| 112 | 104 |
| 113 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); | 105 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); |
| 114 }; | 106 }; |
| 115 | 107 |
| 116 } // namespace media. | 108 } // namespace media. |
| 117 | 109 |
| 118 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ | 110 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ |
| OLD | NEW |