Chromium Code Reviews| 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 // Unit test for VideoCaptureController. | 5 // Unit test for VideoCaptureController. |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 Mock::VerifyAndClearExpectations(client_a_.get()); | 625 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 626 | 626 |
| 627 // Second client connects after the error state. It also should get told of | 627 // Second client connects after the error state. It also should get told of |
| 628 // the error. | 628 // the error. |
| 629 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); | 629 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); |
| 630 controller_->AddClient( | 630 controller_->AddClient( |
| 631 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); | 631 route_id, client_b_.get(), base::kNullProcessHandle, 200, session_200); |
| 632 Mock::VerifyAndClearExpectations(client_b_.get()); | 632 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 633 } | 633 } |
| 634 | 634 |
| 635 // Exercise OnIncomingCapturedData() code path of VideoCaptureController | |
|
kbalazs
2014/12/04 17:00:30
Instead of comment please make the name of the tes
zhaoze.zhou
2014/12/04 19:01:42
All Done.
| |
| 636 TEST_F(VideoCaptureControllerTest, OnIncomingCapturedData) { | |
| 637 | |
| 638 for (int index = media::PIXEL_FORMAT_I420; index <= media::PIXEL_FORMAT_MAX; | |
|
kbalazs
2014/12/04 17:00:30
I would jut assign 0 first, it doesn't matter whic
| |
| 639 index++) { | |
| 640 media::VideoPixelFormat format; | |
| 641 format = static_cast<media::VideoPixelFormat>(index); | |
| 642 media::VideoCaptureParams session_100; | |
|
kbalazs
2014/12/04 17:00:30
100? Copy paste programming?
| |
| 643 session_100.requested_format = media::VideoCaptureFormat( | |
| 644 gfx::Size(320, 240), 30, format); | |
| 645 | |
| 646 gfx::Size capture_resolution(320,240); | |
|
kbalazs
2014/12/04 17:00:30
(320, 240)
^
|
SPACE!!!
| |
| 647 | |
| 648 // The device format needn't match the VideoCaptureParams (the camera can do | |
| 649 // what it wants). Pick something random. | |
| 650 media::VideoCaptureFormat device_format( | |
| 651 gfx::Size(10, 10), 25, media::PIXEL_FORMAT_RGB24); | |
| 652 | |
| 653 const VideoCaptureControllerID client_a_route_1(0x99); | |
|
kbalazs
2014/12/04 17:00:30
There is only one client, you can just name it cli
| |
| 654 | |
| 655 // add clients | |
| 656 controller_->AddClient(client_a_route_1, | |
| 657 client_a_.get(), | |
| 658 base::kNullProcessHandle, | |
| 659 100, | |
| 660 session_100); | |
| 661 ASSERT_EQ(1, controller_->GetClientCount()); | |
| 662 | |
| 663 // Now, simulate an incoming captured buffer from the capture device. | |
| 664 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer; | |
| 665 buffer = | |
| 666 device_->ReserveOutputBuffer(media::VideoFrame::I420, | |
| 667 capture_resolution); | |
| 668 ASSERT_TRUE(buffer.get()); | |
| 669 | |
| 670 // Captured a new video frame | |
| 671 device_->OnIncomingCapturedData( | |
| 672 (unsigned char*)buffer.get()->data(), | |
|
kbalazs
2014/12/04 17:00:30
C-style cast? should be static_cast
| |
| 673 buffer.get()->size(), | |
| 674 session_100.requested_format, | |
| 675 0, | |
| 676 base::TimeTicks()); | |
| 677 | |
| 678 base::RunLoop().RunUntilIdle(); | |
| 679 Mock::VerifyAndClearExpectations(client_a_.get()); | |
| 680 } | |
| 681 } | |
| 682 | |
| 635 } // namespace content | 683 } // namespace content |
| OLD | NEW |