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 TEST_F(VideoCaptureControllerTest, CaptureAllVideoFormats) { | |
|
mcasas
2014/12/04 21:09:06
Suggest test name like: CaptureInEachVideoFormatIn
zhaoze.zhou
2014/12/04 21:54:16
Done.
| |
| 636 for (int format = 0; format <= media::PIXEL_FORMAT_MAX; format++) { | |
|
mcasas
2014/12/04 21:09:07
for (VideoPixelFormat format = 0; format < PIXEL_F
zhaoze.zhou
2014/12/04 21:54:16
for this, it will need to cast format to int when
mcasas
2014/12/04 23:11:53
Ah, true. Leave it then.
| |
| 637 media::VideoCaptureParams params; | |
| 638 params.requested_format = media::VideoCaptureFormat( | |
| 639 gfx::Size(320, 240), 30, media::VideoPixelFormat(format)); | |
| 640 | |
| 641 gfx::Size capture_resolution(320, 240); | |
|
mcasas
2014/12/04 21:09:06
const?
zhaoze.zhou
2014/12/04 21:54:16
Done.
| |
| 642 | |
| 643 const VideoCaptureControllerID route(0x99); | |
| 644 | |
| 645 // add clients | |
| 646 controller_->AddClient(route, | |
| 647 client_a_.get(), | |
| 648 base::kNullProcessHandle, | |
| 649 100, | |
| 650 params); | |
| 651 ASSERT_EQ(1, controller_->GetClientCount()); | |
| 652 | |
| 653 // Now, simulate an incoming captured buffer from the capture device. | |
| 654 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer; | |
| 655 buffer = | |
| 656 device_->ReserveOutputBuffer(media::VideoFrame::I420, | |
| 657 capture_resolution); | |
| 658 ASSERT_TRUE(buffer.get()); | |
| 659 | |
| 660 // Captured a new video frame | |
| 661 device_->OnIncomingCapturedData( | |
| 662 static_cast<unsigned char*>(buffer.get()->data()), | |
| 663 buffer.get()->size(), | |
| 664 params.requested_format, | |
| 665 0, | |
| 666 base::TimeTicks()); | |
| 667 | |
| 668 base::RunLoop().RunUntilIdle(); | |
| 669 Mock::VerifyAndClearExpectations(client_a_.get()); | |
| 670 } | |
| 671 } | |
| 672 | |
| 635 } // namespace content | 673 } // namespace content |
| OLD | NEW |