Index: content/renderer/media/media_stream_video_source_unittest.cc |
diff --git a/content/renderer/media/media_stream_video_source_unittest.cc b/content/renderer/media/media_stream_video_source_unittest.cc |
index 1060b04ad260d89e50e86d01f7f989a4a48668da..dfafbf125e3e73b8df41ebe6bc6cc9dce7519051 100644 |
--- a/content/renderer/media/media_stream_video_source_unittest.cc |
+++ b/content/renderer/media/media_stream_video_source_unittest.cc |
@@ -64,8 +64,6 @@ class MediaStreamVideoSourceTest |
formats.push_back(media::VideoCaptureFormat( |
gfx::Size(640, 480), 30, media::PIXEL_FORMAT_I420)); |
formats.push_back(media::VideoCaptureFormat( |
- gfx::Size(640, 400), 30, media::PIXEL_FORMAT_I420)); |
- formats.push_back(media::VideoCaptureFormat( |
gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420)); |
formats.push_back(media::VideoCaptureFormat( |
gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420)); |
@@ -130,6 +128,34 @@ class MediaStreamVideoSourceTest |
MockMediaStreamVideoSource* mock_source() { return mock_source_; } |
+ // Test that the source crop to the requested max width and |
Jói
2014/02/27 14:52:25
source crop -> source crops
perkj_chrome
2014/03/01 12:32:59
Done.
|
+ // height even though the camera delivers a larger frame. |
+ // TODO(perkj): Frame resolution should be verified in MediaStreamVideoTrack |
+ // and not in the adapter. |
+ void TestSourceCroppFrame(int capture_w, |
Jói
2014/02/27 14:52:25
TestSourceCroppFrame -> TestSourceCropFrame
perkj_chrome
2014/03/01 12:32:59
Done.
|
+ int capture_h, |
+ const blink::WebMediaConstraints& constraints, |
+ int extpected_h, |
+ int expected_w) { |
+ // Expect the source to start capture with the supported resolution. |
+ CreateTrackAndStartSource(constraints, capture_w, capture_h , 30); |
+ |
+ ASSERT_TRUE(mock_source()->GetAdapter()); |
+ MockVideoSource* adapter = static_cast<MockVideoSource*>( |
+ mock_source()->GetAdapter()); |
+ EXPECT_EQ(0, adapter->GetFrameNum()); |
+ |
+ scoped_refptr<media::VideoFrame> frame = |
+ media::VideoFrame::CreateBlackFrame(gfx::Size(capture_w, capture_h)); |
+ mock_source()->DeliverVideoFrame(frame); |
+ EXPECT_EQ(1, adapter->GetFrameNum()); |
+ |
+ // Expect the delivered frame to be cropped. |
+ EXPECT_EQ(extpected_h, adapter->GetLastFrameWidth()); |
+ EXPECT_EQ(expected_w, adapter->GetLastFrameHeight()); |
+ } |
+ |
+ |
private: |
void OnConstraintsApplied(MediaStreamSource* source, bool success) { |
ASSERT_EQ(source, webkit_source_.extraData()); |
@@ -352,5 +378,38 @@ TEST_F(MediaStreamVideoSourceTest, AdapterReceiveVideoFrame) { |
adapter->GetLastFrameHeight()); |
} |
+// Test that the source crop to the requested max width and |
+// height even though the camera delivers a larger frame. |
+TEST_F(MediaStreamVideoSourceTest, DeliverCroppedVideoFrameOptional640360) { |
+ ConstraintsFactory factory; |
+ factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 640); |
+ factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 360); |
+ TestSourceCroppFrame(640, 480, factory.CreateConstraints(), 640, 360); |
+} |
+ |
+TEST_F(MediaStreamVideoSourceTest, DeliverCroppedVideoFrameMandatory640360) { |
+ ConstraintsFactory factory; |
+ factory.AddMandatory(MediaStreamVideoSource::kMaxWidth, 640); |
+ factory.AddMandatory(MediaStreamVideoSource::kMaxHeight, 360); |
+ TestSourceCroppFrame(640, 480, factory.CreateConstraints(), 640, 360); |
+} |
+ |
+// Test that the source crop to the requested max width and |
+// height even though the requested frame has odd size. |
+TEST_F(MediaStreamVideoSourceTest, DeliverCroppedVideoFrame637359) { |
+ ConstraintsFactory factory; |
+ factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 637); |
+ factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 359); |
+ TestSourceCroppFrame(640, 480, factory.CreateConstraints(), 637, 359); |
+} |
+ |
+TEST_F(MediaStreamVideoSourceTest, DeliverSmallerSizeWhenToLargeMax) { |
Jói
2014/02/27 14:52:25
WhenToLargeMax -> WhenTooLargeMax
perkj_chrome
2014/03/01 12:32:59
Done.
|
+ ConstraintsFactory factory; |
+ factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 1920); |
+ factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 1080); |
+ factory.AddOptional(MediaStreamVideoSource::kMinWidth, 1280); |
+ factory.AddOptional(MediaStreamVideoSource::kMinHeight, 720); |
+ TestSourceCroppFrame(1280, 720, factory.CreateConstraints(), 1280, 720); |
+} |
} // namespace content |