mock_audio_manager.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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 3// found in the LICENSE file. 4 5#ifndef MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 6#define MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 7 8#include "media/audio/audio_manager.h" 9 10namespace media { 11 12// This class is a simple mock around AudioManager, used exclusively for tests, 13// which has the following purposes: 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 16// would causing failures on classes which expect that. 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 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 21// synchronization purposes). 22class MockAudioManager : public media::AudioManager { 23 public: 24 explicit MockAudioManager(base::MessageLoopProxy* message_loop_proxy); 25 26 virtual bool HasAudioOutputDevices() OVERRIDE; 27 28 virtual bool HasAudioInputDevices() OVERRIDE; 29 30 virtual string16 GetAudioInputDeviceModel() OVERRIDE; 31 32 virtual bool CanShowAudioInputSettings() OVERRIDE; 33 34 virtual void ShowAudioInputSettings() OVERRIDE; 35 36 virtual void GetAudioInputDeviceNames( 37 media::AudioDeviceNames* device_names) OVERRIDE; 38 39 virtual media::AudioOutputStream* MakeAudioOutputStream( 40 const media::AudioParameters& params) OVERRIDE; 41 42 virtual media::AudioOutputStream* MakeAudioOutputStreamProxy( 43 const media::AudioParameters& params) OVERRIDE; 44 45 virtual media::AudioInputStream* MakeAudioInputStream( 46 const media::AudioParameters& params, 47 const std::string& device_id) OVERRIDE; 48 49 virtual bool IsRecordingInProcess() OVERRIDE; 50 51 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE; 52 53 virtual void AddOutputDeviceChangeListener( 54 AudioDeviceListener* listener) OVERRIDE; 55 virtual void RemoveOutputDeviceChangeListener( 56 AudioDeviceListener* listener) OVERRIDE; 57 58 private: 59 virtual ~MockAudioManager(); 60 61 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 62 63 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); 64}; 65 66} // namespace media. 67 68#endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 69