| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 MOCK_METHOD1(Callback, void(OutputDeviceStatus result)); | 76 MOCK_METHOD1(Callback, void(OutputDeviceStatus result)); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 ACTION_P2(SendPendingBytes, socket, pending_bytes) { | 79 ACTION_P2(SendPendingBytes, socket, pending_bytes) { |
| 80 socket->Send(&pending_bytes, sizeof(pending_bytes)); | 80 socket->Send(&pending_bytes, sizeof(pending_bytes)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Used to terminate a loop from a different thread than the loop belongs to. | 83 // Used to terminate a loop from a different thread than the loop belongs to. |
| 84 // |task_runner| should be a SingleThreadTaskRunner. | 84 // |task_runner| should be a SingleThreadTaskRunner. |
| 85 ACTION_P(QuitLoop, task_runner) { | 85 ACTION_P(QuitLoop, task_runner) { |
| 86 task_runner->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 86 task_runner->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace. | 89 } // namespace. |
| 90 | 90 |
| 91 class AudioOutputDeviceTest | 91 class AudioOutputDeviceTest |
| 92 : public testing::Test, | 92 : public testing::Test, |
| 93 public testing::WithParamInterface<bool> { | 93 public testing::WithParamInterface<bool> { |
| 94 public: | 94 public: |
| 95 AudioOutputDeviceTest(); | 95 AudioOutputDeviceTest(); |
| 96 ~AudioOutputDeviceTest(); | 96 ~AudioOutputDeviceTest(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // of success and quit the loop. | 227 // of success and quit the loop. |
| 228 const int kNumberOfFramesToProcess = 0; | 228 const int kNumberOfFramesToProcess = 0; |
| 229 EXPECT_CALL(callback_, Render(_, _)) | 229 EXPECT_CALL(callback_, Render(_, _)) |
| 230 .WillOnce(DoAll( | 230 .WillOnce(DoAll( |
| 231 QuitLoop(io_loop_.task_runner()), | 231 QuitLoop(io_loop_.task_runner()), |
| 232 Return(kNumberOfFramesToProcess))); | 232 Return(kNumberOfFramesToProcess))); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void AudioOutputDeviceTest::WaitUntilRenderCallback() { | 235 void AudioOutputDeviceTest::WaitUntilRenderCallback() { |
| 236 // Don't hang the test if we never get the Render() callback. | 236 // Don't hang the test if we never get the Render() callback. |
| 237 io_loop_.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), | 237 io_loop_.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 238 TestTimeouts::action_timeout()); | 238 TestTimeouts::action_timeout()); |
| 239 io_loop_.Run(); | 239 io_loop_.Run(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void AudioOutputDeviceTest::StopAudioDevice() { | 242 void AudioOutputDeviceTest::StopAudioDevice() { |
| 243 if (device_status_ == OUTPUT_DEVICE_STATUS_OK) | 243 if (device_status_ == OUTPUT_DEVICE_STATUS_OK) |
| 244 EXPECT_CALL(*audio_output_ipc_, CloseStream()); | 244 EXPECT_CALL(*audio_output_ipc_, CloseStream()); |
| 245 | 245 |
| 246 audio_device_->Stop(); | 246 audio_device_->Stop(); |
| 247 io_loop_.RunUntilIdle(); | 247 io_loop_.RunUntilIdle(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 341 |
| 342 TEST_P(AudioOutputDeviceTest, UnauthorizedDevice) { | 342 TEST_P(AudioOutputDeviceTest, UnauthorizedDevice) { |
| 343 SetDevice(kUnauthorizedDeviceId); | 343 SetDevice(kUnauthorizedDeviceId); |
| 344 StartAudioDevice(); | 344 StartAudioDevice(); |
| 345 StopAudioDevice(); | 345 StopAudioDevice(); |
| 346 } | 346 } |
| 347 | 347 |
| 348 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); | 348 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); |
| 349 | 349 |
| 350 } // namespace media. | 350 } // namespace media. |
| OLD | NEW |