| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 TEST_F(MediaStreamVideoSourceTest, MandatoryMinVgaOptional720P) { | 307 TEST_F(MediaStreamVideoSourceTest, MandatoryMinVgaOptional720P) { |
| 308 MockConstraintFactory factory; | 308 MockConstraintFactory factory; |
| 309 factory.basic().width.setMin(640); | 309 factory.basic().width.setMin(640); |
| 310 factory.basic().height.setMin(480); | 310 factory.basic().height.setMin(480); |
| 311 factory.AddAdvanced().width.setMin(1280); | 311 factory.AddAdvanced().width.setMin(1280); |
| 312 factory.AddAdvanced().aspectRatio.setMin(1280.0 / 720); | 312 factory.AddAdvanced().aspectRatio.setMin(1280.0 / 720); |
| 313 | 313 |
| 314 CreateTrackAndStartSource(factory.CreateWebMediaConstraints(), 1280, 720, 30); | 314 CreateTrackAndStartSource(factory.CreateWebMediaConstraints(), 1280, 720, 30); |
| 315 } | 315 } |
| 316 | 316 |
| 317 // Test that the capture output is 720P if the camera supports it and the |
| 318 // mandatory constraint is exactly width 1280. |
| 319 TEST_F(MediaStreamVideoSourceTest, MandatoryExact720P) { |
| 320 MockConstraintFactory factory; |
| 321 factory.basic().width.setExact(1280); |
| 322 CreateTrackAndStartSource(factory.CreateWebMediaConstraints(), 1280, 720, 30); |
| 323 } |
| 324 |
| 317 // Test that the capture output have aspect ratio 4:3 if a mandatory constraint | 325 // Test that the capture output have aspect ratio 4:3 if a mandatory constraint |
| 318 // require it even if an optional constraint request a higher resolution | 326 // require it even if an optional constraint request a higher resolution |
| 319 // that don't have this aspect ratio. | 327 // that don't have this aspect ratio. |
| 320 TEST_F(MediaStreamVideoSourceTest, MandatoryAspectRatio4To3) { | 328 TEST_F(MediaStreamVideoSourceTest, MandatoryAspectRatio4To3) { |
| 321 MockConstraintFactory factory; | 329 MockConstraintFactory factory; |
| 322 factory.basic().width.setMin(640); | 330 factory.basic().width.setMin(640); |
| 323 factory.basic().height.setMin(480); | 331 factory.basic().height.setMin(480); |
| 324 factory.basic().aspectRatio.setMax(640.0 / 480); | 332 factory.basic().aspectRatio.setMax(640.0 / 480); |
| 325 factory.AddAdvanced().width.setMin(1280); | 333 factory.AddAdvanced().width.setMin(1280); |
| 326 | 334 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 blink::WebMediaStreamTrack track = CreateTrack( | 374 blink::WebMediaStreamTrack track = CreateTrack( |
| 367 "123", factory.CreateWebMediaConstraints()); | 375 "123", factory.CreateWebMediaConstraints()); |
| 368 mock_source()->CompleteGetSupportedFormats(); | 376 mock_source()->CompleteGetSupportedFormats(); |
| 369 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); | 377 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); |
| 370 } | 378 } |
| 371 | 379 |
| 372 TEST_F(MediaStreamVideoSourceTest, MinFrameRateLargerThanMaxFrameRate) { | 380 TEST_F(MediaStreamVideoSourceTest, MinFrameRateLargerThanMaxFrameRate) { |
| 373 MockConstraintFactory factory; | 381 MockConstraintFactory factory; |
| 374 factory.basic().frameRate.setMin(25); | 382 factory.basic().frameRate.setMin(25); |
| 375 factory.basic().frameRate.setMax(15); | 383 factory.basic().frameRate.setMax(15); |
| 376 blink::WebMediaStreamTrack track = CreateTrack( | 384 blink::WebMediaStreamTrack track = |
| 377 "123", factory.CreateWebMediaConstraints()); | 385 CreateTrack("123", factory.CreateWebMediaConstraints()); |
| 378 mock_source()->CompleteGetSupportedFormats(); | 386 mock_source()->CompleteGetSupportedFormats(); |
| 379 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); | 387 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); |
| 380 } | 388 } |
| 389 |
| 390 TEST_F(MediaStreamVideoSourceTest, ExactWidthNotSupported) { |
| 391 MockConstraintFactory factory; |
| 392 factory.basic().width.setExact(12000); |
| 393 blink::WebMediaStreamTrack track = |
| 394 CreateTrack("123", factory.CreateWebMediaConstraints()); |
| 395 mock_source()->CompleteGetSupportedFormats(); |
| 396 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); |
| 397 } |
| 398 |
| 399 TEST_F(MediaStreamVideoSourceTest, MinWidthNotSupported) { |
| 400 MockConstraintFactory factory; |
| 401 factory.basic().width.setMin(12000); |
| 402 blink::WebMediaStreamTrack track = |
| 403 CreateTrack("123", factory.CreateWebMediaConstraints()); |
| 404 mock_source()->CompleteGetSupportedFormats(); |
| 405 EXPECT_EQ(1, NumberOfFailedConstraintsCallbacks()); |
| 406 } |
| 381 | 407 |
| 382 // Test that its safe to release the last reference of a blink track and the | 408 // Test that its safe to release the last reference of a blink track and the |
| 383 // source during the callback if adding a track succeeds. | 409 // source during the callback if adding a track succeeds. |
| 384 TEST_F(MediaStreamVideoSourceTest, ReleaseTrackAndSourceOnSuccessCallBack) { | 410 TEST_F(MediaStreamVideoSourceTest, ReleaseTrackAndSourceOnSuccessCallBack) { |
| 385 MockConstraintFactory factory; | 411 MockConstraintFactory factory; |
| 386 { | 412 { |
| 387 blink::WebMediaStreamTrack track = | 413 blink::WebMediaStreamTrack track = |
| 388 CreateTrack("123", factory.CreateWebMediaConstraints()); | 414 CreateTrack("123", factory.CreateWebMediaConstraints()); |
| 389 ReleaseTrackAndSourceOnAddTrackCallback(track); | 415 ReleaseTrackAndSourceOnAddTrackCallback(track); |
| 390 } | 416 } |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 run_loop2.Run(); | 776 run_loop2.Run(); |
| 751 | 777 |
| 752 EXPECT_EQ(muted_state, false); | 778 EXPECT_EQ(muted_state, false); |
| 753 EXPECT_EQ(track.source().getReadyState(), | 779 EXPECT_EQ(track.source().getReadyState(), |
| 754 blink::WebMediaStreamSource::ReadyStateLive); | 780 blink::WebMediaStreamSource::ReadyStateLive); |
| 755 | 781 |
| 756 sink.DisconnectFromTrack(); | 782 sink.DisconnectFromTrack(); |
| 757 } | 783 } |
| 758 | 784 |
| 759 } // namespace content | 785 } // namespace content |
| OLD | NEW |