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 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 using base::SharedMemory; | 23 using base::SharedMemory; |
24 using base::SyncSocket; | 24 using base::SyncSocket; |
25 using testing::_; | 25 using testing::_; |
26 using testing::DoAll; | 26 using testing::DoAll; |
27 using testing::Invoke; | 27 using testing::Invoke; |
28 using testing::Return; | 28 using testing::Return; |
29 using testing::WithArgs; | 29 using testing::WithArgs; |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 // Derived from AudioDevice to gain access to the protected constructor. | |
34 class TestAudioDevice : public AudioDevice { | |
35 public: | |
36 explicit TestAudioDevice(const scoped_refptr<base::MessageLoopProxy>& io_loop) | |
37 : AudioDevice(io_loop) {} | |
38 | |
39 protected: | |
40 virtual ~TestAudioDevice() {} | |
41 }; | |
42 | |
43 class MockRenderCallback : public media::AudioRendererSink::RenderCallback { | 33 class MockRenderCallback : public media::AudioRendererSink::RenderCallback { |
44 public: | 34 public: |
45 MockRenderCallback() {} | 35 MockRenderCallback() {} |
46 virtual ~MockRenderCallback() {} | 36 virtual ~MockRenderCallback() {} |
47 | 37 |
48 MOCK_METHOD3(Render, int(const std::vector<float*>& audio_data, | 38 MOCK_METHOD3(Render, int(const std::vector<float*>& audio_data, |
49 int number_of_frames, | 39 int number_of_frames, |
50 int audio_delay_milliseconds)); | 40 int audio_delay_milliseconds)); |
51 MOCK_METHOD0(OnRenderError, void()); | 41 MOCK_METHOD0(OnRenderError, void()); |
52 }; | 42 }; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 ~AudioDeviceTest() {} | 128 ~AudioDeviceTest() {} |
139 | 129 |
140 virtual void SetUp() OVERRIDE { | 130 virtual void SetUp() OVERRIDE { |
141 // This sets a global audio_message_filter pointer. AudioDevice will pick | 131 // This sets a global audio_message_filter pointer. AudioDevice will pick |
142 // up a pointer to this variable via the static AudioMessageFilter::Get() | 132 // up a pointer to this variable via the static AudioMessageFilter::Get() |
143 // method. | 133 // method. |
144 audio_message_filter_ = new MockAudioMessageFilter(); | 134 audio_message_filter_ = new MockAudioMessageFilter(); |
145 } | 135 } |
146 | 136 |
147 AudioDevice* CreateAudioDevice() { | 137 AudioDevice* CreateAudioDevice() { |
148 return new TestAudioDevice(io_loop_.message_loop_proxy()); | 138 return new AudioDevice(audio_message_filter_, |
scherkus (not reviewing)
2012/07/23 22:57:51
fix indent (drop a_m_f_ to next line?)
tommi (sloooow) - chröme
2012/07/24 09:49:44
Done.
| |
139 io_loop_.message_loop_proxy()); | |
149 } | 140 } |
150 | 141 |
151 void set_stream_id(int stream_id) { stream_id_ = stream_id; } | 142 void set_stream_id(int stream_id) { stream_id_ = stream_id; } |
152 | 143 |
153 protected: | 144 protected: |
154 // Used to clean up TLS pointers that the test(s) will initialize. | 145 // Used to clean up TLS pointers that the test(s) will initialize. |
155 // Must remain the first member of this class. | 146 // Must remain the first member of this class. |
156 base::ShadowingAtExitManager at_exit_manager_; | 147 base::ShadowingAtExitManager at_exit_manager_; |
157 MessageLoopForIO io_loop_; | 148 MessageLoopForIO io_loop_; |
158 const media::AudioParameters default_audio_parameters_; | 149 const media::AudioParameters default_audio_parameters_; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 TestTimeouts::action_timeout()); | 258 TestTimeouts::action_timeout()); |
268 io_loop_.Run(); | 259 io_loop_.Run(); |
269 | 260 |
270 // Close the stream sequence. | 261 // Close the stream sequence. |
271 | 262 |
272 EXPECT_CALL(*audio_message_filter_, OnCloseStream(stream_id_)); | 263 EXPECT_CALL(*audio_message_filter_, OnCloseStream(stream_id_)); |
273 | 264 |
274 audio_device->Stop(); | 265 audio_device->Stop(); |
275 io_loop_.RunAllPending(); | 266 io_loop_.RunAllPending(); |
276 } | 267 } |
OLD | NEW |