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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 InSequence s; | 424 InSequence s; |
425 base::RunLoop run_loop; | 425 base::RunLoop run_loop; |
426 EXPECT_CALL(*host_.get(), | 426 EXPECT_CALL(*host_.get(), |
427 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)); | 427 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)); |
428 media::VideoCaptureParams params; | 428 media::VideoCaptureParams params; |
429 params.requested_format = media::VideoCaptureFormat( | 429 params.requested_format = media::VideoCaptureFormat( |
430 gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420); | 430 gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420); |
431 host_->OnStartCapture(kDeviceId, opened_session_id_, params); | 431 host_->OnStartCapture(kDeviceId, opened_session_id_, params); |
432 host_->OnStopCapture(kDeviceId); | 432 host_->OnStopCapture(kDeviceId); |
433 run_loop.RunUntilIdle(); | 433 run_loop.RunUntilIdle(); |
| 434 WaitForVideoDeviceThread(); |
434 } | 435 } |
435 | 436 |
436 #ifdef DUMP_VIDEO | 437 #ifdef DUMP_VIDEO |
437 void CaptureAndDumpVideo(int width, int height, int frame_rate) { | 438 void CaptureAndDumpVideo(int width, int height, int frame_rate) { |
438 InSequence s; | 439 InSequence s; |
439 EXPECT_CALL(*host_.get(), OnNewBufferCreated(kDeviceId, _, _, _)) | 440 EXPECT_CALL(*host_.get(), OnNewBufferCreated(kDeviceId, _, _, _)) |
440 .Times(AnyNumber()).WillRepeatedly(Return()); | 441 .Times(AnyNumber()).WillRepeatedly(Return()); |
441 | 442 |
442 base::RunLoop run_loop; | 443 base::RunLoop run_loop; |
443 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _, _)) | 444 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _, _)) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 void SimulateError() { | 487 void SimulateError() { |
487 // Expect a change state to error state sent through IPC. | 488 // Expect a change state to error state sent through IPC. |
488 EXPECT_CALL(*host_.get(), | 489 EXPECT_CALL(*host_.get(), |
489 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_ERROR)).Times(1); | 490 OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_ERROR)).Times(1); |
490 VideoCaptureControllerID id(kDeviceId); | 491 VideoCaptureControllerID id(kDeviceId); |
491 host_->OnError(id); | 492 host_->OnError(id); |
492 // Wait for the error callback. | 493 // Wait for the error callback. |
493 base::RunLoop().RunUntilIdle(); | 494 base::RunLoop().RunUntilIdle(); |
494 } | 495 } |
495 | 496 |
| 497 void WaitForVideoDeviceThread() { |
| 498 base::RunLoop run_loop; |
| 499 media_stream_manager_->video_capture_manager()->device_task_runner() |
| 500 ->PostTaskAndReply( |
| 501 FROM_HERE, |
| 502 base::Bind(&base::DoNothing), |
| 503 run_loop.QuitClosure()); |
| 504 run_loop.Run(); |
| 505 } |
| 506 |
496 scoped_refptr<MockVideoCaptureHost> host_; | 507 scoped_refptr<MockVideoCaptureHost> host_; |
497 | 508 |
498 private: | 509 private: |
499 StrictMock<MockMediaStreamRequester> stream_requester_; | 510 StrictMock<MockMediaStreamRequester> stream_requester_; |
500 scoped_ptr<media::AudioManager> audio_manager_; | 511 scoped_ptr<media::AudioManager> audio_manager_; |
501 scoped_ptr<MediaStreamManager> media_stream_manager_; | 512 scoped_ptr<MediaStreamManager> media_stream_manager_; |
502 content::TestBrowserThreadBundle thread_bundle_; | 513 content::TestBrowserThreadBundle thread_bundle_; |
503 content::TestBrowserContext browser_context_; | 514 content::TestBrowserContext browser_context_; |
504 content::TestContentBrowserClient browser_client_; | 515 content::TestContentBrowserClient browser_client_; |
505 scoped_refptr<base::MessageLoopProxy> message_loop_; | 516 scoped_refptr<base::MessageLoopProxy> message_loop_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 #ifdef DUMP_VIDEO | 561 #ifdef DUMP_VIDEO |
551 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { | 562 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { |
552 CaptureAndDumpVideo(640, 480, 30); | 563 CaptureAndDumpVideo(640, 480, 30); |
553 } | 564 } |
554 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { | 565 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { |
555 CaptureAndDumpVideo(1280, 720, 30); | 566 CaptureAndDumpVideo(1280, 720, 30); |
556 } | 567 } |
557 #endif | 568 #endif |
558 | 569 |
559 } // namespace content | 570 } // namespace content |
OLD | NEW |