Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host_unittest.cc

Issue 1901583005: Revert of Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_ = media::AudioManager::CreateForTesting( 190 audio_manager_.reset(media::AudioManager::CreateForTesting());
191 base::ThreadTaskRunnerHandle::Get());
192 base::CommandLine::ForCurrentProcess()->AppendSwitch( 191 base::CommandLine::ForCurrentProcess()->AppendSwitch(
193 switches::kUseFakeDeviceForMediaStream); 192 switches::kUseFakeDeviceForMediaStream);
194 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); 193 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
195 194
196 // Enable caching to make enumerations run in a single thread 195 // Enable caching to make enumerations run in a single thread
197 media_stream_manager_->audio_output_device_enumerator()->SetCachePolicy( 196 media_stream_manager_->audio_output_device_enumerator()->SetCachePolicy(
198 AudioOutputDeviceEnumerator::CACHE_POLICY_MANUAL_INVALIDATION); 197 AudioOutputDeviceEnumerator::CACHE_POLICY_MANUAL_INVALIDATION);
199 base::RunLoop().RunUntilIdle(); 198 base::RunLoop().RunUntilIdle();
200 base::RunLoop run_loop; 199 base::RunLoop run_loop;
201 media_stream_manager_->audio_output_device_enumerator()->Enumerate( 200 media_stream_manager_->audio_output_device_enumerator()->Enumerate(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 audio_manager_->GetTaskRunner()->PostTask( 321 audio_manager_->GetTaskRunner()->PostTask(
323 FROM_HERE, media::BindToCurrentLoop(run_loop.QuitClosure())); 322 FROM_HERE, media::BindToCurrentLoop(run_loop.QuitClosure()));
324 run_loop.Run(); 323 run_loop.Run();
325 } 324 }
326 325
327 private: 326 private:
328 // MediaStreamManager uses a DestructionObserver, so it must outlive the 327 // MediaStreamManager uses a DestructionObserver, so it must outlive the
329 // TestBrowserThreadBundle. 328 // TestBrowserThreadBundle.
330 std::unique_ptr<MediaStreamManager> media_stream_manager_; 329 std::unique_ptr<MediaStreamManager> media_stream_manager_;
331 TestBrowserThreadBundle thread_bundle_; 330 TestBrowserThreadBundle thread_bundle_;
332 media::ScopedAudioManagerPtr audio_manager_; 331 std::unique_ptr<media::AudioManager> audio_manager_;
333 MockAudioMirroringManager mirroring_manager_; 332 MockAudioMirroringManager mirroring_manager_;
334 scoped_refptr<MockAudioRendererHost> host_; 333 scoped_refptr<MockAudioRendererHost> host_;
335 334
336 DISALLOW_COPY_AND_ASSIGN(AudioRendererHostTest); 335 DISALLOW_COPY_AND_ASSIGN(AudioRendererHostTest);
337 }; 336 };
338 337
339 TEST_F(AudioRendererHostTest, CreateAndClose) { 338 TEST_F(AudioRendererHostTest, CreateAndClose) {
340 Create(); 339 Create();
341 Close(); 340 Close();
342 } 341 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 406 }
408 407
409 TEST_F(AudioRendererHostTest, CreateInvalidDevice) { 408 TEST_F(AudioRendererHostTest, CreateInvalidDevice) {
410 Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin))); 409 Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin)));
411 Close(); 410 Close();
412 } 411 }
413 412
414 // TODO(hclam): Add tests for data conversation in low latency mode. 413 // TODO(hclam): Add tests for data conversation in low latency mode.
415 414
416 } // namespace content 415 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698