| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 AudioBus* dest, | 42 AudioBus* dest, |
| 43 int audio_delay_milliseconds)); | 43 int audio_delay_milliseconds)); |
| 44 MOCK_METHOD0(OnRenderError, void()); | 44 MOCK_METHOD0(OnRenderError, void()); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class MockAudioOutputIPC : public AudioOutputIPC { | 47 class MockAudioOutputIPC : public AudioOutputIPC { |
| 48 public: | 48 public: |
| 49 MockAudioOutputIPC() {} | 49 MockAudioOutputIPC() {} |
| 50 virtual ~MockAudioOutputIPC() {} | 50 virtual ~MockAudioOutputIPC() {} |
| 51 | 51 |
| 52 MOCK_METHOD2(CreateStream, void(AudioOutputIPCDelegate* delegate, | 52 MOCK_METHOD3(CreateStream, void(AudioOutputIPCDelegate* delegate, |
| 53 const AudioParameters& params)); | 53 const AudioParameters& params, |
| 54 int session_id)); |
| 54 MOCK_METHOD0(PlayStream, void()); | 55 MOCK_METHOD0(PlayStream, void()); |
| 55 MOCK_METHOD0(PauseStream, void()); | 56 MOCK_METHOD0(PauseStream, void()); |
| 56 MOCK_METHOD0(CloseStream, void()); | 57 MOCK_METHOD0(CloseStream, void()); |
| 57 MOCK_METHOD1(SetVolume, void(double volume)); | 58 MOCK_METHOD1(SetVolume, void(double volume)); |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 // Creates a copy of a SyncSocket handle that we can give to AudioOutputDevice. | 61 // Creates a copy of a SyncSocket handle that we can give to AudioOutputDevice. |
| 61 // On Windows this means duplicating the pipe handle so that AudioOutputDevice | 62 // On Windows this means duplicating the pipe handle so that AudioOutputDevice |
| 62 // can call CloseHandle() (since ownership has been transferred), but on other | 63 // can call CloseHandle() (since ownership has been transferred), but on other |
| 63 // platforms, we just copy the same socket handle since AudioOutputDevice on | 64 // platforms, we just copy the same socket handle since AudioOutputDevice on |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 io_loop_.RunUntilIdle(); | 163 io_loop_.RunUntilIdle(); |
| 163 } | 164 } |
| 164 | 165 |
| 165 AudioOutputDeviceTest::~AudioOutputDeviceTest() { | 166 AudioOutputDeviceTest::~AudioOutputDeviceTest() { |
| 166 audio_device_ = NULL; | 167 audio_device_ = NULL; |
| 167 } | 168 } |
| 168 | 169 |
| 169 void AudioOutputDeviceTest::StartAudioDevice() { | 170 void AudioOutputDeviceTest::StartAudioDevice() { |
| 170 audio_device_->Start(); | 171 audio_device_->Start(); |
| 171 | 172 |
| 172 EXPECT_CALL(*audio_output_ipc_, CreateStream(audio_device_.get(), _)); | 173 EXPECT_CALL(*audio_output_ipc_, CreateStream(audio_device_.get(), _, 0)); |
| 173 | 174 |
| 174 io_loop_.RunUntilIdle(); | 175 io_loop_.RunUntilIdle(); |
| 175 } | 176 } |
| 176 | 177 |
| 177 void AudioOutputDeviceTest::CreateStream() { | 178 void AudioOutputDeviceTest::CreateStream() { |
| 178 const int kMemorySize = CalculateMemorySize(); | 179 const int kMemorySize = CalculateMemorySize(); |
| 179 | 180 |
| 180 ASSERT_TRUE(shared_memory_.CreateAndMapAnonymous(kMemorySize)); | 181 ASSERT_TRUE(shared_memory_.CreateAndMapAnonymous(kMemorySize)); |
| 181 memset(shared_memory_.memory(), 0xff, kMemorySize); | 182 memset(shared_memory_.memory(), 0xff, kMemorySize); |
| 182 | 183 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 ExpectRenderCallback(); | 285 ExpectRenderCallback(); |
| 285 CreateStream(); | 286 CreateStream(); |
| 286 WaitUntilRenderCallback(); | 287 WaitUntilRenderCallback(); |
| 287 StopAudioDevice(); | 288 StopAudioDevice(); |
| 288 } | 289 } |
| 289 | 290 |
| 290 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); | 291 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); |
| 291 INSTANTIATE_TEST_CASE_P(RenderIO, AudioOutputDeviceTest, Values(true)); | 292 INSTANTIATE_TEST_CASE_P(RenderIO, AudioOutputDeviceTest, Values(true)); |
| 292 | 293 |
| 293 } // namespace media. | 294 } // namespace media. |
| OLD | NEW |