| 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 "content/browser/renderer_host/media/audio_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 void WaitForEnumeration(base::RunLoop* loop, | 181 void WaitForEnumeration(base::RunLoop* loop, |
| 182 const AudioOutputDeviceEnumeration& e) { | 182 const AudioOutputDeviceEnumeration& e) { |
| 183 loop->Quit(); | 183 loop->Quit(); |
| 184 } | 184 } |
| 185 } // namespace | 185 } // namespace |
| 186 | 186 |
| 187 class AudioRendererHostTest : public testing::Test { | 187 class AudioRendererHostTest : public testing::Test { |
| 188 public: | 188 public: |
| 189 AudioRendererHostTest() { | 189 AudioRendererHostTest() { |
| 190 audio_manager_.reset(media::AudioManager::CreateForTesting()); | 190 audio_manager_ = media::AudioManager::CreateForTesting( |
| 191 base::ThreadTaskRunnerHandle::Get()); |
| 191 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 192 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 192 switches::kUseFakeDeviceForMediaStream); | 193 switches::kUseFakeDeviceForMediaStream); |
| 193 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 194 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
| 194 | 195 |
| 195 // Enable caching to make enumerations run in a single thread | 196 // Enable caching to make enumerations run in a single thread |
| 196 media_stream_manager_->audio_output_device_enumerator()->SetCachePolicy( | 197 media_stream_manager_->audio_output_device_enumerator()->SetCachePolicy( |
| 197 AudioOutputDeviceEnumerator::CACHE_POLICY_MANUAL_INVALIDATION); | 198 AudioOutputDeviceEnumerator::CACHE_POLICY_MANUAL_INVALIDATION); |
| 198 base::RunLoop().RunUntilIdle(); | 199 base::RunLoop().RunUntilIdle(); |
| 199 base::RunLoop run_loop; | 200 base::RunLoop run_loop; |
| 200 media_stream_manager_->audio_output_device_enumerator()->Enumerate( | 201 media_stream_manager_->audio_output_device_enumerator()->Enumerate( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 audio_manager_->GetTaskRunner()->PostTask( | 322 audio_manager_->GetTaskRunner()->PostTask( |
| 322 FROM_HERE, media::BindToCurrentLoop(run_loop.QuitClosure())); | 323 FROM_HERE, media::BindToCurrentLoop(run_loop.QuitClosure())); |
| 323 run_loop.Run(); | 324 run_loop.Run(); |
| 324 } | 325 } |
| 325 | 326 |
| 326 private: | 327 private: |
| 327 // MediaStreamManager uses a DestructionObserver, so it must outlive the | 328 // MediaStreamManager uses a DestructionObserver, so it must outlive the |
| 328 // TestBrowserThreadBundle. | 329 // TestBrowserThreadBundle. |
| 329 std::unique_ptr<MediaStreamManager> media_stream_manager_; | 330 std::unique_ptr<MediaStreamManager> media_stream_manager_; |
| 330 TestBrowserThreadBundle thread_bundle_; | 331 TestBrowserThreadBundle thread_bundle_; |
| 331 std::unique_ptr<media::AudioManager> audio_manager_; | 332 media::ScopedAudioManagerPtr audio_manager_; |
| 332 MockAudioMirroringManager mirroring_manager_; | 333 MockAudioMirroringManager mirroring_manager_; |
| 333 scoped_refptr<MockAudioRendererHost> host_; | 334 scoped_refptr<MockAudioRendererHost> host_; |
| 334 | 335 |
| 335 DISALLOW_COPY_AND_ASSIGN(AudioRendererHostTest); | 336 DISALLOW_COPY_AND_ASSIGN(AudioRendererHostTest); |
| 336 }; | 337 }; |
| 337 | 338 |
| 338 TEST_F(AudioRendererHostTest, CreateAndClose) { | 339 TEST_F(AudioRendererHostTest, CreateAndClose) { |
| 339 Create(); | 340 Create(); |
| 340 Close(); | 341 Close(); |
| 341 } | 342 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 } | 407 } |
| 407 | 408 |
| 408 TEST_F(AudioRendererHostTest, CreateInvalidDevice) { | 409 TEST_F(AudioRendererHostTest, CreateInvalidDevice) { |
| 409 Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin))); | 410 Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin))); |
| 410 Close(); | 411 Close(); |
| 411 } | 412 } |
| 412 | 413 |
| 413 // TODO(hclam): Add tests for data conversation in low latency mode. | 414 // TODO(hclam): Add tests for data conversation in low latency mode. |
| 414 | 415 |
| 415 } // namespace content | 416 } // namespace content |
| OLD | NEW |