Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / media / audio / mock_audio_manager.h
blob3a0e9070094a97c22927e305057f7fa3cccbb237
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.
5 #ifndef MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_
6 #define MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_
8 #include "media/audio/audio_manager.h"
10 namespace media {
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).
22 class MockAudioManager : public media::AudioManager {
23 public:
24 explicit MockAudioManager(base::MessageLoopProxy* message_loop_proxy);
26 virtual bool HasAudioOutputDevices() OVERRIDE;
28 virtual bool HasAudioInputDevices() OVERRIDE;
30 virtual string16 GetAudioInputDeviceModel() OVERRIDE;
32 virtual void ShowAudioInputSettings() OVERRIDE;
34 virtual void GetAudioInputDeviceNames(
35 media::AudioDeviceNames* device_names) OVERRIDE;
37 virtual media::AudioOutputStream* MakeAudioOutputStream(
38 const media::AudioParameters& params) OVERRIDE;
40 virtual media::AudioOutputStream* MakeAudioOutputStreamProxy(
41 const media::AudioParameters& params) OVERRIDE;
43 virtual media::AudioInputStream* MakeAudioInputStream(
44 const media::AudioParameters& params,
45 const std::string& device_id) OVERRIDE;
47 virtual bool IsRecordingInProcess() OVERRIDE;
49 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE;
51 virtual void AddOutputDeviceChangeListener(
52 AudioDeviceListener* listener) OVERRIDE;
53 virtual void RemoveOutputDeviceChangeListener(
54 AudioDeviceListener* listener) OVERRIDE;
56 virtual AudioParameters GetDefaultOutputStreamParameters() OVERRIDE;
57 virtual AudioParameters GetInputStreamParameters(
58 const std::string& device_id) OVERRIDE;
60 private:
61 virtual ~MockAudioManager();
63 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
65 DISALLOW_COPY_AND_ASSIGN(MockAudioManager);
68 } // namespace media.
70 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_