OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 int NumberOfSuccessConstraintsCallbacks() const { | 87 int NumberOfSuccessConstraintsCallbacks() const { |
88 return number_of_successful_constraints_applied_; | 88 return number_of_successful_constraints_applied_; |
89 } | 89 } |
90 | 90 |
91 int NumberOfFailedConstraintsCallbacks() const { | 91 int NumberOfFailedConstraintsCallbacks() const { |
92 return number_of_failed_constraints_applied_; | 92 return number_of_failed_constraints_applied_; |
93 } | 93 } |
94 | 94 |
95 MockMediaStreamVideoSource* mock_source() { return mock_source_; } | 95 MockMediaStreamVideoSource* mock_source() { return mock_source_; } |
96 | 96 |
97 // Test that the source crops to the requested max width and | 97 // Test that the source crops/scales to the requested width and |
98 // height even though the camera delivers a larger frame. | 98 // height even though the camera delivers a larger frame. |
99 void TestSourceCropFrame(int capture_width, | 99 void TestSourceCropFrame(int capture_width, |
100 int capture_height, | 100 int capture_height, |
101 const blink::WebMediaConstraints& constraints, | 101 const blink::WebMediaConstraints& constraints, |
102 int expected_width, | 102 int expected_width, |
103 int expected_height) { | 103 int expected_height) { |
104 // Expect the source to start capture with the supported resolution. | 104 // Expect the source to start capture with the supported resolution. |
105 blink::WebMediaStreamTrack track = | 105 blink::WebMediaStreamTrack track = |
106 CreateTrackAndStartSource(constraints, capture_width, capture_height, | 106 CreateTrackAndStartSource(constraints, capture_width, capture_height, |
107 30); | 107 30); |
(...skipping 15 matching lines...) Expand all Loading... |
123 base::RunLoop run_loop; | 123 base::RunLoop run_loop; |
124 base::Closure quit_closure = run_loop.QuitClosure(); | 124 base::Closure quit_closure = run_loop.QuitClosure(); |
125 EXPECT_CALL(*sink, OnVideoFrame()).WillOnce( | 125 EXPECT_CALL(*sink, OnVideoFrame()).WillOnce( |
126 RunClosure(quit_closure)); | 126 RunClosure(quit_closure)); |
127 scoped_refptr<media::VideoFrame> frame = | 127 scoped_refptr<media::VideoFrame> frame = |
128 media::VideoFrame::CreateBlackFrame(gfx::Size(width, height)); | 128 media::VideoFrame::CreateBlackFrame(gfx::Size(width, height)); |
129 mock_source()->DeliverVideoFrame(frame); | 129 mock_source()->DeliverVideoFrame(frame); |
130 run_loop.Run(); | 130 run_loop.Run(); |
131 } | 131 } |
132 | 132 |
| 133 void DeliverVideoFrameAndWaitForTwoRenderers( |
| 134 int width, |
| 135 int height, |
| 136 MockMediaStreamVideoSink* sink1, |
| 137 MockMediaStreamVideoSink* sink2) { |
| 138 base::RunLoop run_loop; |
| 139 base::Closure quit_closure = run_loop.QuitClosure(); |
| 140 EXPECT_CALL(*sink1, OnVideoFrame()); |
| 141 EXPECT_CALL(*sink2, OnVideoFrame()).WillOnce( |
| 142 RunClosure(quit_closure)); |
| 143 scoped_refptr<media::VideoFrame> frame = |
| 144 media::VideoFrame::CreateBlackFrame(gfx::Size(width, height)); |
| 145 mock_source()->DeliverVideoFrame(frame); |
| 146 run_loop.Run(); |
| 147 } |
| 148 |
| 149 void TestTwoTracksWithDifferentConstraints( |
| 150 const blink::WebMediaConstraints& constraints1, |
| 151 const blink::WebMediaConstraints& constraints2, |
| 152 int capture_width, |
| 153 int capture_height, |
| 154 int expected_width1, |
| 155 int expected_height1, |
| 156 int expected_width2, |
| 157 int expected_height2) { |
| 158 blink::WebMediaStreamTrack track1 = |
| 159 CreateTrackAndStartSource(constraints1, capture_width, capture_height, |
| 160 MediaStreamVideoSource::kDefaultFrameRate); |
| 161 |
| 162 blink::WebMediaStreamTrack track2 = |
| 163 CreateTrack("dummy", constraints2); |
| 164 |
| 165 MockMediaStreamVideoSink sink1; |
| 166 MediaStreamVideoSink::AddToVideoTrack(&sink1, sink1.GetDeliverFrameCB(), |
| 167 track1); |
| 168 EXPECT_EQ(0, sink1.number_of_frames()); |
| 169 |
| 170 MockMediaStreamVideoSink sink2; |
| 171 MediaStreamVideoSink::AddToVideoTrack(&sink2, sink2.GetDeliverFrameCB(), |
| 172 track2); |
| 173 EXPECT_EQ(0, sink2.number_of_frames()); |
| 174 |
| 175 DeliverVideoFrameAndWaitForTwoRenderers(capture_width, |
| 176 capture_height, |
| 177 &sink1, |
| 178 &sink2); |
| 179 |
| 180 EXPECT_EQ(1, sink1.number_of_frames()); |
| 181 EXPECT_EQ(expected_width1, sink1.frame_size().width()); |
| 182 EXPECT_EQ(expected_height1, sink1.frame_size().height()); |
| 183 |
| 184 EXPECT_EQ(1, sink2.number_of_frames()); |
| 185 EXPECT_EQ(expected_width2, sink2.frame_size().width()); |
| 186 EXPECT_EQ(expected_height2, sink2.frame_size().height()); |
| 187 |
| 188 MediaStreamVideoSink::RemoveFromVideoTrack(&sink1, track1); |
| 189 MediaStreamVideoSink::RemoveFromVideoTrack(&sink2, track2); |
| 190 } |
133 | 191 |
134 void ReleaseTrackAndSourceOnAddTrackCallback( | 192 void ReleaseTrackAndSourceOnAddTrackCallback( |
135 const blink::WebMediaStreamTrack& track_to_release) { | 193 const blink::WebMediaStreamTrack& track_to_release) { |
136 track_to_release_ = track_to_release; | 194 track_to_release_ = track_to_release; |
137 } | 195 } |
138 | 196 |
139 private: | 197 private: |
140 void OnConstraintsApplied(MediaStreamSource* source, bool success) { | 198 void OnConstraintsApplied(MediaStreamSource* source, bool success) { |
141 ASSERT_EQ(source, webkit_source_.extraData()); | 199 ASSERT_EQ(source, webkit_source_.extraData()); |
142 | 200 |
143 if (success) | 201 if (success) |
144 ++number_of_successful_constraints_applied_; | 202 ++number_of_successful_constraints_applied_; |
145 else | 203 else |
146 ++number_of_failed_constraints_applied_; | 204 ++number_of_failed_constraints_applied_; |
147 | 205 |
148 if (!track_to_release_.isNull()) { | 206 if (!track_to_release_.isNull()) { |
149 mock_source_ = NULL; | 207 mock_source_ = NULL; |
150 webkit_source_.reset(); | 208 webkit_source_.reset(); |
151 track_to_release_.reset(); | 209 track_to_release_.reset(); |
152 } | 210 } |
153 } | 211 } |
| 212 base::MessageLoopForUI message_loop_; |
154 scoped_ptr<ChildProcess> child_process_; | 213 scoped_ptr<ChildProcess> child_process_; |
155 base::MessageLoopForUI message_loop_; | |
156 blink::WebMediaStreamTrack track_to_release_; | 214 blink::WebMediaStreamTrack track_to_release_; |
157 int number_of_successful_constraints_applied_; | 215 int number_of_successful_constraints_applied_; |
158 int number_of_failed_constraints_applied_; | 216 int number_of_failed_constraints_applied_; |
159 blink::WebMediaStreamSource webkit_source_; | 217 blink::WebMediaStreamSource webkit_source_; |
160 // |mock_source_| is owned by |webkit_source_|. | 218 // |mock_source_| is owned by |webkit_source_|. |
161 MockMediaStreamVideoSource* mock_source_; | 219 MockMediaStreamVideoSource* mock_source_; |
162 }; | 220 }; |
163 | 221 |
164 TEST_F(MediaStreamVideoSourceTest, AddTrackAndStartSource) { | 222 TEST_F(MediaStreamVideoSourceTest, AddTrackAndStartSource) { |
165 blink::WebMediaConstraints constraints; | 223 blink::WebMediaConstraints constraints; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // require it even if an optional constraint request a higher resolution | 297 // require it even if an optional constraint request a higher resolution |
240 // that don't have this aspect ratio. | 298 // that don't have this aspect ratio. |
241 TEST_F(MediaStreamVideoSourceTest, MandatoryAspectRatio4To3) { | 299 TEST_F(MediaStreamVideoSourceTest, MandatoryAspectRatio4To3) { |
242 MockMediaConstraintFactory factory; | 300 MockMediaConstraintFactory factory; |
243 factory.AddMandatory(MediaStreamVideoSource::kMinWidth, 640); | 301 factory.AddMandatory(MediaStreamVideoSource::kMinWidth, 640); |
244 factory.AddMandatory(MediaStreamVideoSource::kMinHeight, 480); | 302 factory.AddMandatory(MediaStreamVideoSource::kMinHeight, 480); |
245 factory.AddMandatory(MediaStreamVideoSource::kMaxAspectRatio, | 303 factory.AddMandatory(MediaStreamVideoSource::kMaxAspectRatio, |
246 640.0 / 480); | 304 640.0 / 480); |
247 factory.AddOptional(MediaStreamVideoSource::kMinWidth, 1280); | 305 factory.AddOptional(MediaStreamVideoSource::kMinWidth, 1280); |
248 | 306 |
249 CreateTrackAndStartSource(factory.CreateWebMediaConstraints(), 640, 480, 30); | 307 TestSourceCropFrame(1280, 720, |
| 308 factory.CreateWebMediaConstraints(), 960, 720); |
250 } | 309 } |
251 | 310 |
252 // Test that AddTrack fail if the mandatory aspect ratio | 311 // Test that AddTrack succeeds if the mandatory min aspect ratio it set to 2. |
253 // is set higher than supported. | 312 TEST_F(MediaStreamVideoSourceTest, MandatoryAspectRatio2) { |
254 TEST_F(MediaStreamVideoSourceTest, MandatoryAspectRatioTooHigh) { | |
255 MockMediaConstraintFactory factory; | 313 MockMediaConstraintFactory factory; |
256 factory.AddMandatory(MediaStreamVideoSource::kMinAspectRatio, 2); | 314 factory.AddMandatory(MediaStreamVideoSource::kMinAspectRatio, 2); |
| 315 |
| 316 TestSourceCropFrame(MediaStreamVideoSource::kDefaultWidth, |
| 317 MediaStreamVideoSource::kDefaultHeight, |
| 318 factory.CreateWebMediaConstraints(), 640, 320); |
| 319 } |
| 320 |
| 321 TEST_F(MediaStreamVideoSourceTest, MinAspectRatioLargerThanMaxAspectRatio) { |
| 322 MockMediaConstraintFactory factory; |
| 323 factory.AddMandatory(MediaStreamVideoSource::kMinAspectRatio, 2); |
| 324 factory.AddMandatory(MediaStreamVideoSource::kMaxAspectRatio, 1); |
257 blink::WebMediaStreamTrack track = CreateTrack( | 325 blink::WebMediaStreamTrack track = CreateTrack( |
258 "123", factory.CreateWebMediaConstraints()); | 326 "123", factory.CreateWebMediaConstraints()); |
259 mock_source()->CompleteGetSupportedFormats(); | 327 mock_source()->CompleteGetSupportedFormats(); |
| 328 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); |
| 329 } |
| 330 |
| 331 TEST_F(MediaStreamVideoSourceTest, MaxAspectRatioZero) { |
| 332 MockMediaConstraintFactory factory; |
| 333 factory.AddOptional(MediaStreamVideoSource::kMaxAspectRatio, 0); |
| 334 blink::WebMediaStreamTrack track = CreateTrack( |
| 335 "123", factory.CreateWebMediaConstraints()); |
| 336 mock_source()->CompleteGetSupportedFormats(); |
| 337 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); |
| 338 } |
| 339 |
| 340 TEST_F(MediaStreamVideoSourceTest, MinWidthLargerThanMaxWidth) { |
| 341 MockMediaConstraintFactory factory; |
| 342 factory.AddMandatory(MediaStreamVideoSource::kMinWidth, 640); |
| 343 factory.AddMandatory(MediaStreamVideoSource::kMaxWidth, 320); |
| 344 blink::WebMediaStreamTrack track = CreateTrack( |
| 345 "123", factory.CreateWebMediaConstraints()); |
| 346 mock_source()->CompleteGetSupportedFormats(); |
| 347 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); |
| 348 } |
| 349 |
| 350 TEST_F(MediaStreamVideoSourceTest, MinHeightLargerThanMaxHeight) { |
| 351 MockMediaConstraintFactory factory; |
| 352 factory.AddMandatory(MediaStreamVideoSource::kMinHeight, 480); |
| 353 factory.AddMandatory(MediaStreamVideoSource::kMaxHeight, 360); |
| 354 blink::WebMediaStreamTrack track = CreateTrack( |
| 355 "123", factory.CreateWebMediaConstraints()); |
| 356 mock_source()->CompleteGetSupportedFormats(); |
260 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); | 357 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); |
261 } | 358 } |
262 | 359 |
263 // Test that its safe to release the last reference of a blink track and the | 360 // Test that its safe to release the last reference of a blink track and the |
264 // source during the callback if adding a track succeeds. | 361 // source during the callback if adding a track succeeds. |
265 TEST_F(MediaStreamVideoSourceTest, ReleaseTrackAndSourceOnSuccessCallBack) { | 362 TEST_F(MediaStreamVideoSourceTest, ReleaseTrackAndSourceOnSuccessCallBack) { |
266 MockMediaConstraintFactory factory; | 363 MockMediaConstraintFactory factory; |
267 { | 364 { |
268 blink::WebMediaStreamTrack track = | 365 blink::WebMediaStreamTrack track = |
269 CreateTrack("123", factory.CreateWebMediaConstraints()); | 366 CreateTrack("123", factory.CreateWebMediaConstraints()); |
270 ReleaseTrackAndSourceOnAddTrackCallback(track); | 367 ReleaseTrackAndSourceOnAddTrackCallback(track); |
271 } | 368 } |
272 mock_source()->CompleteGetSupportedFormats(); | 369 mock_source()->CompleteGetSupportedFormats(); |
273 mock_source()->StartMockedSource(); | 370 mock_source()->StartMockedSource(); |
274 EXPECT_EQ(1, NumberOfSuccessConstraintsCallbacks()); | 371 EXPECT_EQ(1, NumberOfSuccessConstraintsCallbacks()); |
275 } | 372 } |
276 | 373 |
277 // Test that its safe to release the last reference of a blink track and the | 374 // Test that its safe to release the last reference of a blink track and the |
278 // source during the callback if adding a track fails. | 375 // source during the callback if adding a track fails. |
279 TEST_F(MediaStreamVideoSourceTest, ReleaseTrackAndSourceOnFailureCallBack) { | 376 TEST_F(MediaStreamVideoSourceTest, ReleaseTrackAndSourceOnFailureCallBack) { |
280 MockMediaConstraintFactory factory; | 377 MockMediaConstraintFactory factory; |
281 factory.AddMandatory(MediaStreamVideoSource::kMinAspectRatio, 2); | 378 factory.AddMandatory(MediaStreamVideoSource::kMinWidth, 99999); |
282 { | 379 { |
283 blink::WebMediaStreamTrack track = | 380 blink::WebMediaStreamTrack track = |
284 CreateTrack("123", factory.CreateWebMediaConstraints()); | 381 CreateTrack("123", factory.CreateWebMediaConstraints()); |
285 ReleaseTrackAndSourceOnAddTrackCallback(track); | 382 ReleaseTrackAndSourceOnAddTrackCallback(track); |
286 } | 383 } |
287 mock_source()->CompleteGetSupportedFormats(); | 384 mock_source()->CompleteGetSupportedFormats(); |
288 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); | 385 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); |
289 } | 386 } |
290 | 387 |
291 // Test that the source ignores an optional aspect ratio that is higher than | 388 // Test that the source ignores an optional aspect ratio that is higher than |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 495 |
399 // Test that the source crops to the requested max width and | 496 // Test that the source crops to the requested max width and |
400 // height even though the requested frame has odd size. | 497 // height even though the requested frame has odd size. |
401 TEST_F(MediaStreamVideoSourceTest, DeliverCroppedVideoFrame637359) { | 498 TEST_F(MediaStreamVideoSourceTest, DeliverCroppedVideoFrame637359) { |
402 MockMediaConstraintFactory factory; | 499 MockMediaConstraintFactory factory; |
403 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 637); | 500 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 637); |
404 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 359); | 501 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 359); |
405 TestSourceCropFrame(640, 480, factory.CreateWebMediaConstraints(), 637, 359); | 502 TestSourceCropFrame(640, 480, factory.CreateWebMediaConstraints(), 637, 359); |
406 } | 503 } |
407 | 504 |
| 505 TEST_F(MediaStreamVideoSourceTest, DeliverCroppedVideoFrame320320) { |
| 506 MockMediaConstraintFactory factory; |
| 507 factory.AddMandatory(MediaStreamVideoSource::kMaxWidth, 320); |
| 508 factory.AddMandatory(MediaStreamVideoSource::kMaxHeight, 320); |
| 509 factory.AddMandatory(MediaStreamVideoSource::kMinHeight, 320); |
| 510 factory.AddMandatory(MediaStreamVideoSource::kMinWidth, 320); |
| 511 TestSourceCropFrame(640, 480, factory.CreateWebMediaConstraints(), 320, 320); |
| 512 } |
| 513 |
408 TEST_F(MediaStreamVideoSourceTest, DeliverSmallerSizeWhenTooLargeMax) { | 514 TEST_F(MediaStreamVideoSourceTest, DeliverSmallerSizeWhenTooLargeMax) { |
409 MockMediaConstraintFactory factory; | 515 MockMediaConstraintFactory factory; |
410 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 1920); | 516 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 1920); |
411 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 1080); | 517 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 1080); |
412 factory.AddOptional(MediaStreamVideoSource::kMinWidth, 1280); | 518 factory.AddOptional(MediaStreamVideoSource::kMinWidth, 1280); |
413 factory.AddOptional(MediaStreamVideoSource::kMinHeight, 720); | 519 factory.AddOptional(MediaStreamVideoSource::kMinHeight, 720); |
414 TestSourceCropFrame(1280, 720, factory.CreateWebMediaConstraints(), | 520 TestSourceCropFrame(1280, 720, factory.CreateWebMediaConstraints(), |
415 1280, 720); | 521 1280, 720); |
416 } | 522 } |
417 | 523 |
| 524 TEST_F(MediaStreamVideoSourceTest, TwoTracksWithVGAAndWVGA) { |
| 525 MockMediaConstraintFactory factory1; |
| 526 factory1.AddOptional(MediaStreamVideoSource::kMaxWidth, 640); |
| 527 factory1.AddOptional(MediaStreamVideoSource::kMaxHeight, 480); |
| 528 |
| 529 MockMediaConstraintFactory factory2; |
| 530 factory2.AddOptional(MediaStreamVideoSource::kMaxHeight, 360); |
| 531 |
| 532 TestTwoTracksWithDifferentConstraints(factory1.CreateWebMediaConstraints(), |
| 533 factory2.CreateWebMediaConstraints(), |
| 534 640, 480, |
| 535 640, 480, |
| 536 640, 360); |
| 537 } |
| 538 |
| 539 TEST_F(MediaStreamVideoSourceTest, TwoTracksWith720AndWVGA) { |
| 540 MockMediaConstraintFactory factory1; |
| 541 factory1.AddOptional(MediaStreamVideoSource::kMinWidth, 1280); |
| 542 factory1.AddOptional(MediaStreamVideoSource::kMinHeight, 720); |
| 543 |
| 544 |
| 545 MockMediaConstraintFactory factory2; |
| 546 factory2.AddMandatory(MediaStreamVideoSource::kMaxWidth, 640); |
| 547 factory2.AddMandatory(MediaStreamVideoSource::kMaxHeight, 360); |
| 548 |
| 549 TestTwoTracksWithDifferentConstraints(factory1.CreateWebMediaConstraints(), |
| 550 factory2.CreateWebMediaConstraints(), |
| 551 1280, 720, |
| 552 1280, 720, |
| 553 640, 360); |
| 554 } |
| 555 |
| 556 TEST_F(MediaStreamVideoSourceTest, TwoTracksWith720AndW700H700) { |
| 557 MockMediaConstraintFactory factory1; |
| 558 factory1.AddOptional(MediaStreamVideoSource::kMinWidth, 1280); |
| 559 factory1.AddOptional(MediaStreamVideoSource::kMinHeight, 720); |
| 560 |
| 561 MockMediaConstraintFactory factory2; |
| 562 factory2.AddMandatory(MediaStreamVideoSource::kMaxWidth, 700); |
| 563 factory2.AddMandatory(MediaStreamVideoSource::kMaxHeight, 700); |
| 564 |
| 565 TestTwoTracksWithDifferentConstraints(factory1.CreateWebMediaConstraints(), |
| 566 factory2.CreateWebMediaConstraints(), |
| 567 1280, 720, |
| 568 1280, 720, |
| 569 700, 700); |
| 570 } |
| 571 |
| 572 TEST_F(MediaStreamVideoSourceTest, TwoTracksWith720AndMaxAspectRatio4To3) { |
| 573 MockMediaConstraintFactory factory1; |
| 574 factory1.AddOptional(MediaStreamVideoSource::kMinWidth, 1280); |
| 575 factory1.AddOptional(MediaStreamVideoSource::kMinHeight, 720); |
| 576 |
| 577 MockMediaConstraintFactory factory2; |
| 578 factory2.AddMandatory(MediaStreamVideoSource::kMaxAspectRatio, 640.0 / 480); |
| 579 |
| 580 TestTwoTracksWithDifferentConstraints(factory1.CreateWebMediaConstraints(), |
| 581 factory2.CreateWebMediaConstraints(), |
| 582 1280, 720, |
| 583 1280, 720, |
| 584 960, 720); |
| 585 } |
| 586 |
| 587 TEST_F(MediaStreamVideoSourceTest, TwoTracksWithVgaAndMinAspectRatio) { |
| 588 MockMediaConstraintFactory factory1; |
| 589 factory1.AddOptional(MediaStreamVideoSource::kMaxWidth, 640); |
| 590 factory1.AddOptional(MediaStreamVideoSource::kMaxHeight, 480); |
| 591 |
| 592 MockMediaConstraintFactory factory2; |
| 593 factory2.AddMandatory(MediaStreamVideoSource::kMinAspectRatio, 640.0 / 360); |
| 594 |
| 595 TestTwoTracksWithDifferentConstraints(factory1.CreateWebMediaConstraints(), |
| 596 factory2.CreateWebMediaConstraints(), |
| 597 640, 480, |
| 598 640, 480, |
| 599 640, 360); |
| 600 } |
| 601 |
418 // Test that a source can change the frame resolution on the fly and that | 602 // Test that a source can change the frame resolution on the fly and that |
419 // tracks sinks get the new frame size unless constraints force the frame to be | 603 // tracks sinks get the new frame size unless constraints force the frame to be |
420 // cropped. | 604 // cropped. |
421 TEST_F(MediaStreamVideoSourceTest, SourceChangeFrameSize) { | 605 TEST_F(MediaStreamVideoSourceTest, SourceChangeFrameSize) { |
422 MockMediaConstraintFactory factory; | 606 MockMediaConstraintFactory factory; |
423 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 800); | 607 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 800); |
424 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 700); | 608 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 700); |
425 | 609 |
426 // Expect the source to start capture with the supported resolution. | 610 // Expect the source to start capture with the supported resolution. |
427 blink::WebMediaStreamTrack track = | 611 blink::WebMediaStreamTrack track = |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( | 656 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( |
473 MediaStreamVideoSource::kMaxAspectRatio)); | 657 MediaStreamVideoSource::kMaxAspectRatio)); |
474 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( | 658 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( |
475 MediaStreamVideoSource::kMinAspectRatio)); | 659 MediaStreamVideoSource::kMinAspectRatio)); |
476 | 660 |
477 EXPECT_FALSE(MediaStreamVideoSource::IsConstraintSupported( | 661 EXPECT_FALSE(MediaStreamVideoSource::IsConstraintSupported( |
478 "something unsupported")); | 662 "something unsupported")); |
479 } | 663 } |
480 | 664 |
481 } // namespace content | 665 } // namespace content |
OLD | NEW |