Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / media / audio / mock_audio_manager.h
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
10 namespace 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).
22 class MockAudioManager : public media::AudioManager {
23  public:
24   explicit MockAudioManager(
25       const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
26
27   virtual bool HasAudioOutputDevices() OVERRIDE;
28
29   virtual bool HasAudioInputDevices() OVERRIDE;
30
31   virtual base::string16 GetAudioInputDeviceModel() OVERRIDE;
32
33   virtual void ShowAudioInputSettings() OVERRIDE;
34
35   virtual void GetAudioInputDeviceNames(
36       media::AudioDeviceNames* device_names) OVERRIDE;
37
38   virtual void GetAudioOutputDeviceNames(
39       media::AudioDeviceNames* device_names) OVERRIDE;
40
41   virtual media::AudioOutputStream* MakeAudioOutputStream(
42       const media::AudioParameters& params,
43       const std::string& device_id,
44       const std::string& input_device_id) OVERRIDE;
45
46   virtual media::AudioOutputStream* MakeAudioOutputStreamProxy(
47       const media::AudioParameters& params,
48       const std::string& device_id,
49       const std::string& input_device_id) OVERRIDE;
50
51   virtual media::AudioInputStream* MakeAudioInputStream(
52       const media::AudioParameters& params,
53       const std::string& device_id) OVERRIDE;
54
55   virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() OVERRIDE;
56   virtual scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner()
57       OVERRIDE;
58
59   virtual void AddOutputDeviceChangeListener(
60       AudioDeviceListener* listener) OVERRIDE;
61   virtual void RemoveOutputDeviceChangeListener(
62       AudioDeviceListener* listener) OVERRIDE;
63
64   virtual AudioParameters GetDefaultOutputStreamParameters() OVERRIDE;
65   virtual AudioParameters GetOutputStreamParameters(
66       const std::string& device_id) OVERRIDE;
67   virtual AudioParameters GetInputStreamParameters(
68       const std::string& device_id) OVERRIDE;
69   virtual std::string GetAssociatedOutputDeviceID(
70       const std::string& input_device_id) OVERRIDE;
71
72   virtual scoped_ptr<AudioLog> CreateAudioLog(
73       AudioLogFactory::AudioComponent component) OVERRIDE;
74
75   virtual void FixWedgedAudio() OVERRIDE;
76
77  protected:
78   virtual ~MockAudioManager();
79
80  private:
81   scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
82
83   DISALLOW_COPY_AND_ASSIGN(MockAudioManager);
84 };
85
86 }  // namespace media.
87
88 #endif  // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_