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