Chromium Code Reviews| Index: content/browser/renderer_host/media/video_capture_controller_unittest.cc |
| diff --git a/content/browser/renderer_host/media/video_capture_controller_unittest.cc b/content/browser/renderer_host/media/video_capture_controller_unittest.cc |
| index 091a288285c9aeab9d18aa385c8f34566f277929..294c36affcc67842745a23316dd03719acde9c57 100644 |
| --- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc |
| +++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc |
| @@ -632,4 +632,52 @@ TEST_F(VideoCaptureControllerTest, ErrorAfterDeviceCreation) { |
| Mock::VerifyAndClearExpectations(client_b_.get()); |
| } |
| +// 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.
|
| +TEST_F(VideoCaptureControllerTest, OnIncomingCapturedData) { |
| + |
| + 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
|
| + index++) { |
| + media::VideoPixelFormat format; |
| + format = static_cast<media::VideoPixelFormat>(index); |
| + media::VideoCaptureParams session_100; |
|
kbalazs
2014/12/04 17:00:30
100? Copy paste programming?
|
| + session_100.requested_format = media::VideoCaptureFormat( |
| + gfx::Size(320, 240), 30, format); |
| + |
| + gfx::Size capture_resolution(320,240); |
|
kbalazs
2014/12/04 17:00:30
(320, 240)
^
|
SPACE!!!
|
| + |
| + // The device format needn't match the VideoCaptureParams (the camera can do |
| + // what it wants). Pick something random. |
| + media::VideoCaptureFormat device_format( |
| + gfx::Size(10, 10), 25, media::PIXEL_FORMAT_RGB24); |
| + |
| + 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
|
| + |
| + // add clients |
| + controller_->AddClient(client_a_route_1, |
| + client_a_.get(), |
| + base::kNullProcessHandle, |
| + 100, |
| + session_100); |
| + ASSERT_EQ(1, controller_->GetClientCount()); |
| + |
| + // Now, simulate an incoming captured buffer from the capture device. |
| + scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer; |
| + buffer = |
| + device_->ReserveOutputBuffer(media::VideoFrame::I420, |
| + capture_resolution); |
| + ASSERT_TRUE(buffer.get()); |
| + |
| + // Captured a new video frame |
| + device_->OnIncomingCapturedData( |
| + (unsigned char*)buffer.get()->data(), |
|
kbalazs
2014/12/04 17:00:30
C-style cast? should be static_cast
|
| + buffer.get()->size(), |
| + session_100.requested_format, |
| + 0, |
| + base::TimeTicks()); |
| + |
| + base::RunLoop().RunUntilIdle(); |
| + Mock::VerifyAndClearExpectations(client_a_.get()); |
| + } |
| +} |
| + |
| } // namespace content |