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/video_capture_host.h" | 5 #include "content/browser/renderer_host/media/video_capture_host.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 opened_session_id_(kInvalidMediaCaptureSessionId) {} | 267 opened_session_id_(kInvalidMediaCaptureSessionId) {} |
268 | 268 |
269 void SetUp() override { | 269 void SetUp() override { |
270 SetBrowserClientForTesting(&browser_client_); | 270 SetBrowserClientForTesting(&browser_client_); |
271 | 271 |
272 #if defined(OS_CHROMEOS) | 272 #if defined(OS_CHROMEOS) |
273 chromeos::CrasAudioHandler::InitializeForTesting(); | 273 chromeos::CrasAudioHandler::InitializeForTesting(); |
274 #endif | 274 #endif |
275 | 275 |
276 // Create our own MediaStreamManager. | 276 // Create our own MediaStreamManager. |
277 audio_manager_.reset(media::AudioManager::CreateForTesting()); | 277 audio_manager_ = media::AudioManager::CreateForTesting(task_runner_); |
278 #ifndef TEST_REAL_CAPTURE_DEVICE | 278 #ifndef TEST_REAL_CAPTURE_DEVICE |
279 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 279 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
280 switches::kUseFakeDeviceForMediaStream); | 280 switches::kUseFakeDeviceForMediaStream); |
281 #endif | 281 #endif |
282 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 282 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
283 media_stream_manager_->UseFakeUIForTests( | 283 media_stream_manager_->UseFakeUIForTests( |
284 std::unique_ptr<FakeMediaStreamUIProxy>()); | 284 std::unique_ptr<FakeMediaStreamUIProxy>()); |
285 | 285 |
286 // Create a Host and connect it to a simulated IPC channel. | 286 // Create a Host and connect it to a simulated IPC channel. |
287 host_ = new MockVideoCaptureHost(media_stream_manager_.get()); | 287 host_ = new MockVideoCaptureHost(media_stream_manager_.get()); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 ->PostTaskAndReply( | 476 ->PostTaskAndReply( |
477 FROM_HERE, | 477 FROM_HERE, |
478 base::Bind(&base::DoNothing), | 478 base::Bind(&base::DoNothing), |
479 run_loop.QuitClosure()); | 479 run_loop.QuitClosure()); |
480 run_loop.Run(); | 480 run_loop.Run(); |
481 } | 481 } |
482 | 482 |
483 scoped_refptr<MockVideoCaptureHost> host_; | 483 scoped_refptr<MockVideoCaptureHost> host_; |
484 | 484 |
485 private: | 485 private: |
| 486 // media_stream_manager_ needs to outlive thread_bundle_ because it is a |
| 487 // MessageLoop::DestructionObserver. audio_manager_ needs to outlive |
| 488 // thread_bundle_ because it uses the underlying message loop. |
486 StrictMock<MockMediaStreamRequester> stream_requester_; | 489 StrictMock<MockMediaStreamRequester> stream_requester_; |
487 std::unique_ptr<media::AudioManager> audio_manager_; | |
488 std::unique_ptr<MediaStreamManager> media_stream_manager_; | 490 std::unique_ptr<MediaStreamManager> media_stream_manager_; |
489 content::TestBrowserThreadBundle thread_bundle_; | 491 content::TestBrowserThreadBundle thread_bundle_; |
| 492 media::ScopedAudioManagerPtr audio_manager_; |
490 content::TestBrowserContext browser_context_; | 493 content::TestBrowserContext browser_context_; |
491 content::TestContentBrowserClient browser_client_; | 494 content::TestContentBrowserClient browser_client_; |
492 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 495 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
493 int opened_session_id_; | 496 int opened_session_id_; |
494 std::string opened_device_label_; | 497 std::string opened_device_label_; |
495 | 498 |
496 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHostTest); | 499 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHostTest); |
497 }; | 500 }; |
498 | 501 |
499 TEST_F(VideoCaptureHostTest, CloseSessionWithoutStopping) { | 502 TEST_F(VideoCaptureHostTest, CloseSessionWithoutStopping) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 #ifdef DUMP_VIDEO | 540 #ifdef DUMP_VIDEO |
538 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { | 541 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { |
539 CaptureAndDumpVideo(640, 480, 30); | 542 CaptureAndDumpVideo(640, 480, 30); |
540 } | 543 } |
541 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { | 544 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { |
542 CaptureAndDumpVideo(1280, 720, 30); | 545 CaptureAndDumpVideo(1280, 720, 30); |
543 } | 546 } |
544 #endif | 547 #endif |
545 | 548 |
546 } // namespace content | 549 } // namespace content |
OLD | NEW |