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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 const std::string kDefaultDeviceId; | 38 const std::string kDefaultDeviceId; |
39 const std::string kNonDefaultDeviceId("valid-nondefault-device-id"); | 39 const std::string kNonDefaultDeviceId("valid-nondefault-device-id"); |
40 const std::string kUnauthorizedDeviceId("unauthorized-device-id"); | 40 const std::string kUnauthorizedDeviceId("unauthorized-device-id"); |
41 const url::Origin kDefaultSecurityOrigin; | 41 const url::Origin kDefaultSecurityOrigin; |
42 | 42 |
43 class MockRenderCallback : public AudioRendererSink::RenderCallback { | 43 class MockRenderCallback : public AudioRendererSink::RenderCallback { |
44 public: | 44 public: |
45 MockRenderCallback() {} | 45 MockRenderCallback() {} |
46 virtual ~MockRenderCallback() {} | 46 virtual ~MockRenderCallback() {} |
47 | 47 |
48 MOCK_METHOD2(Render, int(AudioBus* dest, int audio_delay_milliseconds)); | 48 MOCK_METHOD3(Render, |
| 49 int(AudioBus* dest, |
| 50 uint32_t audio_delay_milliseconds, |
| 51 uint32_t frames_skipped)); |
49 MOCK_METHOD0(OnRenderError, void()); | 52 MOCK_METHOD0(OnRenderError, void()); |
50 }; | 53 }; |
51 | 54 |
52 class MockAudioOutputIPC : public AudioOutputIPC { | 55 class MockAudioOutputIPC : public AudioOutputIPC { |
53 public: | 56 public: |
54 MockAudioOutputIPC() {} | 57 MockAudioOutputIPC() {} |
55 virtual ~MockAudioOutputIPC() {} | 58 virtual ~MockAudioOutputIPC() {} |
56 | 59 |
57 MOCK_METHOD4(RequestDeviceAuthorization, | 60 MOCK_METHOD4(RequestDeviceAuthorization, |
58 void(AudioOutputIPCDelegate* delegate, | 61 void(AudioOutputIPCDelegate* delegate, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 .WillOnce(SendPendingBytes(&browser_socket_, kMemorySize)); | 211 .WillOnce(SendPendingBytes(&browser_socket_, kMemorySize)); |
209 | 212 |
210 // We expect calls to our audio renderer callback, which returns the number | 213 // We expect calls to our audio renderer callback, which returns the number |
211 // of frames written to the memory section. | 214 // of frames written to the memory section. |
212 // Here's the second place where it gets hacky: There's no way for us to | 215 // Here's the second place where it gets hacky: There's no way for us to |
213 // know (without using a sleep loop!) when the AudioOutputDevice has finished | 216 // know (without using a sleep loop!) when the AudioOutputDevice has finished |
214 // writing the interleaved audio data into the shared memory section. | 217 // writing the interleaved audio data into the shared memory section. |
215 // So, for the sake of this test, we consider the call to Render a sign | 218 // So, for the sake of this test, we consider the call to Render a sign |
216 // of success and quit the loop. | 219 // of success and quit the loop. |
217 const int kNumberOfFramesToProcess = 0; | 220 const int kNumberOfFramesToProcess = 0; |
218 EXPECT_CALL(callback_, Render(_, _)) | 221 EXPECT_CALL(callback_, Render(_, _, _)) |
219 .WillOnce(DoAll( | 222 .WillOnce(DoAll(QuitLoop(io_loop_.task_runner()), |
220 QuitLoop(io_loop_.task_runner()), | 223 Return(kNumberOfFramesToProcess))); |
221 Return(kNumberOfFramesToProcess))); | |
222 } | 224 } |
223 | 225 |
224 void AudioOutputDeviceTest::WaitUntilRenderCallback() { | 226 void AudioOutputDeviceTest::WaitUntilRenderCallback() { |
225 // Don't hang the test if we never get the Render() callback. | 227 // Don't hang the test if we never get the Render() callback. |
226 io_loop_.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 228 io_loop_.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
227 TestTimeouts::action_timeout()); | 229 TestTimeouts::action_timeout()); |
228 io_loop_.Run(); | 230 io_loop_.Run(); |
229 } | 231 } |
230 | 232 |
231 void AudioOutputDeviceTest::StopAudioDevice() { | 233 void AudioOutputDeviceTest::StopAudioDevice() { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 309 |
308 TEST_P(AudioOutputDeviceTest, UnauthorizedDevice) { | 310 TEST_P(AudioOutputDeviceTest, UnauthorizedDevice) { |
309 SetDevice(kUnauthorizedDeviceId); | 311 SetDevice(kUnauthorizedDeviceId); |
310 StartAudioDevice(); | 312 StartAudioDevice(); |
311 StopAudioDevice(); | 313 StopAudioDevice(); |
312 } | 314 } |
313 | 315 |
314 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); | 316 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); |
315 | 317 |
316 } // namespace media. | 318 } // namespace media. |
OLD | NEW |