OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "media/audio/audio_system_impl.h" | 5 #include "media/audio/audio_system_impl.h" |
6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // which means AudioSystem reply containing device parameters is already | 118 // which means AudioSystem reply containing device parameters is already |
119 // queued on the main thread. | 119 // queued on the main thread. |
120 event.RunAndWait(); | 120 event.RunAndWait(); |
121 base::RunLoop().RunUntilIdle(); | 121 base::RunLoop().RunUntilIdle(); |
122 } | 122 } |
123 | 123 |
124 // Mocks to verify that AudioSystem replied with an expected callback. | 124 // Mocks to verify that AudioSystem replied with an expected callback. |
125 MOCK_METHOD0(AudioParametersReceived, void(void)); | 125 MOCK_METHOD0(AudioParametersReceived, void(void)); |
126 MOCK_METHOD1(HasInputDevicesCallback, void(bool)); | 126 MOCK_METHOD1(HasInputDevicesCallback, void(bool)); |
127 MOCK_METHOD0(DeviceDescriptionsReceived, void(void)); | 127 MOCK_METHOD0(DeviceDescriptionsReceived, void(void)); |
| 128 MOCK_METHOD1(AssociatedOutputDeviceIDReceived, void(const std::string&)); |
128 | 129 |
129 protected: | 130 protected: |
130 base::MessageLoop message_loop_; | 131 base::MessageLoop message_loop_; |
131 base::ThreadChecker thread_checker_; | 132 base::ThreadChecker thread_checker_; |
132 bool use_audio_thread_; | 133 bool use_audio_thread_; |
133 base::Thread audio_thread_; | 134 base::Thread audio_thread_; |
134 MockAudioManager::UniquePtr audio_manager_; | 135 MockAudioManager::UniquePtr audio_manager_; |
135 std::unique_ptr<media::AudioSystem> audio_system_; | 136 AudioSystem::UniquePtr audio_system_; |
136 AudioParameters input_params_; | 137 AudioParameters input_params_; |
137 AudioParameters output_params_; | 138 AudioParameters output_params_; |
138 AudioParameters default_output_params_; | 139 AudioParameters default_output_params_; |
139 AudioDeviceDescriptions input_device_descriptions_; | 140 AudioDeviceDescriptions input_device_descriptions_; |
140 AudioDeviceDescriptions output_device_descriptions_; | 141 AudioDeviceDescriptions output_device_descriptions_; |
141 }; | 142 }; |
142 | 143 |
143 TEST_P(AudioSystemImplTest, GetInputStreamParameters) { | 144 TEST_P(AudioSystemImplTest, GetInputStreamParameters) { |
144 EXPECT_CALL(*this, AudioParametersReceived()); | 145 EXPECT_CALL(*this, AudioParametersReceived()); |
145 audio_system_->GetInputStreamParameters( | 146 audio_system_->GetInputStreamParameters( |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 EXPECT_EQ(2, static_cast<int>(output_device_descriptions_.size())); | 262 EXPECT_EQ(2, static_cast<int>(output_device_descriptions_.size())); |
262 EXPECT_EQ(1, static_cast<int>(input_device_descriptions_.size())); | 263 EXPECT_EQ(1, static_cast<int>(input_device_descriptions_.size())); |
263 EXPECT_CALL(*this, DeviceDescriptionsReceived()); | 264 EXPECT_CALL(*this, DeviceDescriptionsReceived()); |
264 audio_system_->GetDeviceDescriptions( | 265 audio_system_->GetDeviceDescriptions( |
265 base::Bind(&AudioSystemImplTest::OnGetDeviceDescriptions, | 266 base::Bind(&AudioSystemImplTest::OnGetDeviceDescriptions, |
266 base::Unretained(this), output_device_descriptions_), | 267 base::Unretained(this), output_device_descriptions_), |
267 false); | 268 false); |
268 WaitForCallback(); | 269 WaitForCallback(); |
269 } | 270 } |
270 | 271 |
| 272 TEST_P(AudioSystemImplTest, GetAssociatedOutputDeviceID) { |
| 273 const std::string associated_id("associated_id"); |
| 274 audio_manager_->SetAssociatedOutputDeviceIDCallback( |
| 275 base::Bind([](const std::string& result, |
| 276 const std::string&) -> std::string { return result; }, |
| 277 associated_id)); |
| 278 |
| 279 EXPECT_CALL(*this, AssociatedOutputDeviceIDReceived(associated_id)); |
| 280 |
| 281 audio_system_->GetAssociatedOutputDeviceID( |
| 282 std::string(), |
| 283 base::Bind(&AudioSystemImplTest::AssociatedOutputDeviceIDReceived, |
| 284 base::Unretained(this))); |
| 285 WaitForCallback(); |
| 286 } |
| 287 |
271 INSTANTIATE_TEST_CASE_P(, AudioSystemImplTest, testing::Values(false, true)); | 288 INSTANTIATE_TEST_CASE_P(, AudioSystemImplTest, testing::Values(false, true)); |
272 | 289 |
273 } // namespace media | 290 } // namespace media |
OLD | NEW |