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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
13 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
15 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
16 #include "base/sync_socket.h" | 17 #include "base/sync_socket.h" |
17 #include "base/task_runner.h" | 18 #include "base/task_runner.h" |
18 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
19 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
20 #include "media/audio/audio_output_device.h" | 21 #include "media/audio/audio_output_device.h" |
21 #include "media/audio/sample_rates.h" | 22 #include "media/audio/sample_rates.h" |
22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 CHANNEL_LAYOUT_STEREO, 48000, 16, 1024); | 134 CHANNEL_LAYOUT_STEREO, 48000, 16, 1024); |
134 SetDevice(kDefaultDeviceId); | 135 SetDevice(kDefaultDeviceId); |
135 } | 136 } |
136 | 137 |
137 AudioOutputDeviceTest::~AudioOutputDeviceTest() { | 138 AudioOutputDeviceTest::~AudioOutputDeviceTest() { |
138 audio_device_ = NULL; | 139 audio_device_ = NULL; |
139 } | 140 } |
140 | 141 |
141 void AudioOutputDeviceTest::SetDevice(const std::string& device_id) { | 142 void AudioOutputDeviceTest::SetDevice(const std::string& device_id) { |
142 audio_output_ipc_ = new MockAudioOutputIPC(); | 143 audio_output_ipc_ = new MockAudioOutputIPC(); |
143 audio_device_ = new AudioOutputDevice( | 144 audio_device_ = new AudioOutputDevice(base::WrapUnique(audio_output_ipc_), |
144 scoped_ptr<AudioOutputIPC>(audio_output_ipc_), io_loop_.task_runner(), 0, | 145 io_loop_.task_runner(), 0, device_id, |
145 device_id, url::Origin()); | 146 url::Origin()); |
146 EXPECT_CALL(*audio_output_ipc_, | 147 EXPECT_CALL(*audio_output_ipc_, |
147 RequestDeviceAuthorization(audio_device_.get(), 0, device_id, _)); | 148 RequestDeviceAuthorization(audio_device_.get(), 0, device_id, _)); |
148 audio_device_->RequestDeviceAuthorization(); | 149 audio_device_->RequestDeviceAuthorization(); |
149 io_loop_.RunUntilIdle(); | 150 io_loop_.RunUntilIdle(); |
150 | 151 |
151 // Simulate response from browser | 152 // Simulate response from browser |
152 OutputDeviceStatus device_status = | 153 OutputDeviceStatus device_status = |
153 (device_id == kUnauthorizedDeviceId) | 154 (device_id == kUnauthorizedDeviceId) |
154 ? OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED | 155 ? OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED |
155 : OUTPUT_DEVICE_STATUS_OK; | 156 : OUTPUT_DEVICE_STATUS_OK; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 314 |
314 TEST_P(AudioOutputDeviceTest, UnauthorizedDevice) { | 315 TEST_P(AudioOutputDeviceTest, UnauthorizedDevice) { |
315 SetDevice(kUnauthorizedDeviceId); | 316 SetDevice(kUnauthorizedDeviceId); |
316 StartAudioDevice(); | 317 StartAudioDevice(); |
317 StopAudioDevice(); | 318 StopAudioDevice(); |
318 } | 319 } |
319 | 320 |
320 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); | 321 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); |
321 | 322 |
322 } // namespace media. | 323 } // namespace media. |
OLD | NEW |