| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 void WaitForEnumeration(base::RunLoop* loop, | 176 void WaitForEnumeration(base::RunLoop* loop, |
| 177 const AudioOutputDeviceEnumeration& e) { | 177 const AudioOutputDeviceEnumeration& e) { |
| 178 loop->Quit(); | 178 loop->Quit(); |
| 179 } | 179 } |
| 180 } // namespace | 180 } // namespace |
| 181 | 181 |
| 182 class AudioRendererHostTest : public testing::Test { | 182 class AudioRendererHostTest : public testing::Test { |
| 183 public: | 183 public: |
| 184 AudioRendererHostTest() { | 184 AudioRendererHostTest() { |
| 185 audio_manager_.reset(media::AudioManager::CreateForTesting()); | 185 audio_manager_ = media::AudioManager::CreateForTesting( |
| 186 base::ThreadTaskRunnerHandle::Get()); |
| 186 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 187 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 187 switches::kUseFakeDeviceForMediaStream); | 188 switches::kUseFakeDeviceForMediaStream); |
| 188 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 189 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
| 189 | 190 |
| 190 // Enable caching to make enumerations run in a single thread | 191 // Enable caching to make enumerations run in a single thread |
| 191 media_stream_manager_->audio_output_device_enumerator()->SetCachePolicy( | 192 media_stream_manager_->audio_output_device_enumerator()->SetCachePolicy( |
| 192 AudioOutputDeviceEnumerator::CACHE_POLICY_MANUAL_INVALIDATION); | 193 AudioOutputDeviceEnumerator::CACHE_POLICY_MANUAL_INVALIDATION); |
| 193 base::RunLoop().RunUntilIdle(); | 194 base::RunLoop().RunUntilIdle(); |
| 194 base::RunLoop run_loop; | 195 base::RunLoop run_loop; |
| 195 media_stream_manager_->audio_output_device_enumerator()->Enumerate( | 196 media_stream_manager_->audio_output_device_enumerator()->Enumerate( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 audio_manager_->GetTaskRunner()->PostTask( | 317 audio_manager_->GetTaskRunner()->PostTask( |
| 317 FROM_HERE, media::BindToCurrentLoop(run_loop.QuitClosure())); | 318 FROM_HERE, media::BindToCurrentLoop(run_loop.QuitClosure())); |
| 318 run_loop.Run(); | 319 run_loop.Run(); |
| 319 } | 320 } |
| 320 | 321 |
| 321 private: | 322 private: |
| 322 // MediaStreamManager uses a DestructionObserver, so it must outlive the | 323 // MediaStreamManager uses a DestructionObserver, so it must outlive the |
| 323 // TestBrowserThreadBundle. | 324 // TestBrowserThreadBundle. |
| 324 scoped_ptr<MediaStreamManager> media_stream_manager_; | 325 scoped_ptr<MediaStreamManager> media_stream_manager_; |
| 325 TestBrowserThreadBundle thread_bundle_; | 326 TestBrowserThreadBundle thread_bundle_; |
| 326 scoped_ptr<media::AudioManager> audio_manager_; | 327 media::ScopedAudioManagerPtr audio_manager_; |
| 327 MockAudioMirroringManager mirroring_manager_; | 328 MockAudioMirroringManager mirroring_manager_; |
| 328 scoped_refptr<MockAudioRendererHost> host_; | 329 scoped_refptr<MockAudioRendererHost> host_; |
| 329 | 330 |
| 330 DISALLOW_COPY_AND_ASSIGN(AudioRendererHostTest); | 331 DISALLOW_COPY_AND_ASSIGN(AudioRendererHostTest); |
| 331 }; | 332 }; |
| 332 | 333 |
| 333 TEST_F(AudioRendererHostTest, CreateAndClose) { | 334 TEST_F(AudioRendererHostTest, CreateAndClose) { |
| 334 Create(); | 335 Create(); |
| 335 Close(); | 336 Close(); |
| 336 } | 337 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 402 } |
| 402 | 403 |
| 403 TEST_F(AudioRendererHostTest, CreateInvalidDevice) { | 404 TEST_F(AudioRendererHostTest, CreateInvalidDevice) { |
| 404 Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin))); | 405 Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin))); |
| 405 Close(); | 406 Close(); |
| 406 } | 407 } |
| 407 | 408 |
| 408 // TODO(hclam): Add tests for data conversation in low latency mode. | 409 // TODO(hclam): Add tests for data conversation in low latency mode. |
| 409 | 410 |
| 410 } // namespace content | 411 } // namespace content |
| OLD | NEW |