Change blimp README to use Markdown.
[chromium-blink-merge.git] / media / audio / mock_audio_manager.h
blobdcae43b31be1dddc932c169e105341b69951c47e
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(
25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
27 bool HasAudioOutputDevices() override;
29 bool HasAudioInputDevices() override;
31 base::string16 GetAudioInputDeviceModel() override;
33 void ShowAudioInputSettings() override;
35 void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) override;
37 void GetAudioOutputDeviceNames(
38 media::AudioDeviceNames* device_names) override;
40 media::AudioOutputStream* MakeAudioOutputStream(
41 const media::AudioParameters& params,
42 const std::string& device_id) override;
44 media::AudioOutputStream* MakeAudioOutputStreamProxy(
45 const media::AudioParameters& params,
46 const std::string& device_id) override;
48 media::AudioInputStream* MakeAudioInputStream(
49 const media::AudioParameters& params,
50 const std::string& device_id) override;
52 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override;
53 scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() override;
55 void AddOutputDeviceChangeListener(AudioDeviceListener* listener) override;
56 void RemoveOutputDeviceChangeListener(AudioDeviceListener* listener) override;
58 AudioParameters GetDefaultOutputStreamParameters() override;
59 AudioParameters GetOutputStreamParameters(
60 const std::string& device_id) override;
61 AudioParameters GetInputStreamParameters(
62 const std::string& device_id) override;
63 std::string GetAssociatedOutputDeviceID(
64 const std::string& input_device_id) override;
66 scoped_ptr<AudioLog> CreateAudioLog(
67 AudioLogFactory::AudioComponent component) override;
69 void SetHasKeyboardMic() override;
71 protected:
72 ~MockAudioManager() override;
74 private:
75 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
77 DISALLOW_COPY_AND_ASSIGN(MockAudioManager);
80 } // namespace media.
82 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_