| 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 "media/audio/audio_manager.h" | 8 #include "media/audio/audio_manager.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| 11 | 11 |
| 12 // This class is a simple mock around AudioManager, used exclusively for tests, | 12 // This class is a simple mock around AudioManager, used exclusively for tests, |
| 13 // which has the following purposes: | 13 // which has the following purposes: |
| 14 // 1) Avoids to use the actual (system and platform dependent) AudioManager. | 14 // 1) 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 // 2) Allows the mock audio events to be dispatched on an arbitrary thread, | 17 // 2) Allows the mock audio events to be dispatched on an arbitrary thread, |
| 18 // rather than forcing them on the audio thread, easing their handling in | 18 // rather than forcing them on the audio thread, easing their handling in |
| 19 // browser tests (Note: sharing a thread can cause deadlocks on production | 19 // browser tests (Note: sharing a thread can cause deadlocks on production |
| 20 // classes if WaitableEvents or any other form of lock is used for | 20 // classes if WaitableEvents or any other form of lock is used for |
| 21 // synchronization purposes). | 21 // synchronization purposes). |
| 22 class MockAudioManager : public media::AudioManager { | 22 class MockAudioManager : public media::AudioManager { |
| 23 public: | 23 public: |
| 24 explicit MockAudioManager( | 24 explicit MockAudioManager( |
| 25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 26 | 26 |
| 27 virtual bool HasAudioOutputDevices() override; | 27 bool HasAudioOutputDevices() override; |
| 28 | 28 |
| 29 virtual bool HasAudioInputDevices() override; | 29 bool HasAudioInputDevices() override; |
| 30 | 30 |
| 31 virtual base::string16 GetAudioInputDeviceModel() override; | 31 base::string16 GetAudioInputDeviceModel() override; |
| 32 | 32 |
| 33 virtual void ShowAudioInputSettings() override; | 33 void ShowAudioInputSettings() override; |
| 34 | 34 |
| 35 virtual void GetAudioInputDeviceNames( | 35 void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) override; |
| 36 |
| 37 void GetAudioOutputDeviceNames( |
| 36 media::AudioDeviceNames* device_names) override; | 38 media::AudioDeviceNames* device_names) override; |
| 37 | 39 |
| 38 virtual void GetAudioOutputDeviceNames( | 40 media::AudioOutputStream* MakeAudioOutputStream( |
| 39 media::AudioDeviceNames* device_names) override; | |
| 40 | |
| 41 virtual media::AudioOutputStream* MakeAudioOutputStream( | |
| 42 const media::AudioParameters& params, | 41 const media::AudioParameters& params, |
| 43 const std::string& device_id) override; | 42 const std::string& device_id) override; |
| 44 | 43 |
| 45 virtual media::AudioOutputStream* MakeAudioOutputStreamProxy( | 44 media::AudioOutputStream* MakeAudioOutputStreamProxy( |
| 46 const media::AudioParameters& params, | 45 const media::AudioParameters& params, |
| 47 const std::string& device_id) override; | 46 const std::string& device_id) override; |
| 48 | 47 |
| 49 virtual media::AudioInputStream* MakeAudioInputStream( | 48 media::AudioInputStream* MakeAudioInputStream( |
| 50 const media::AudioParameters& params, | 49 const media::AudioParameters& params, |
| 51 const std::string& device_id) override; | 50 const std::string& device_id) override; |
| 52 | 51 |
| 53 virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override; | 52 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override; |
| 54 virtual scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() | 53 scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() override; |
| 55 override; | |
| 56 | 54 |
| 57 virtual void AddOutputDeviceChangeListener( | 55 void AddOutputDeviceChangeListener(AudioDeviceListener* listener) override; |
| 58 AudioDeviceListener* listener) override; | 56 void RemoveOutputDeviceChangeListener(AudioDeviceListener* listener) override; |
| 59 virtual void RemoveOutputDeviceChangeListener( | |
| 60 AudioDeviceListener* listener) override; | |
| 61 | 57 |
| 62 virtual AudioParameters GetDefaultOutputStreamParameters() override; | 58 AudioParameters GetDefaultOutputStreamParameters() override; |
| 63 virtual AudioParameters GetOutputStreamParameters( | 59 AudioParameters GetOutputStreamParameters( |
| 64 const std::string& device_id) override; | 60 const std::string& device_id) override; |
| 65 virtual AudioParameters GetInputStreamParameters( | 61 AudioParameters GetInputStreamParameters( |
| 66 const std::string& device_id) override; | 62 const std::string& device_id) override; |
| 67 virtual std::string GetAssociatedOutputDeviceID( | 63 std::string GetAssociatedOutputDeviceID( |
| 68 const std::string& input_device_id) override; | 64 const std::string& input_device_id) override; |
| 69 | 65 |
| 70 virtual scoped_ptr<AudioLog> CreateAudioLog( | 66 scoped_ptr<AudioLog> CreateAudioLog( |
| 71 AudioLogFactory::AudioComponent component) override; | 67 AudioLogFactory::AudioComponent component) override; |
| 72 | 68 |
| 73 virtual void SetHasKeyboardMic() override; | 69 void SetHasKeyboardMic() override; |
| 74 | 70 |
| 75 protected: | 71 protected: |
| 76 virtual ~MockAudioManager(); | 72 ~MockAudioManager() override; |
| 77 | 73 |
| 78 private: | 74 private: |
| 79 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 75 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 80 | 76 |
| 81 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); | 77 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); |
| 82 }; | 78 }; |
| 83 | 79 |
| 84 } // namespace media. | 80 } // namespace media. |
| 85 | 81 |
| 86 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ | 82 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ |
| OLD | NEW |