| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 blink::WebMediaStreamTrack CreateTrackAndStartSource( | 72 blink::WebMediaStreamTrack CreateTrackAndStartSource( |
| 73 const blink::WebMediaConstraints& constraints, | 73 const blink::WebMediaConstraints& constraints, |
| 74 int expected_width, | 74 int expected_width, |
| 75 int expected_height, | 75 int expected_height, |
| 76 int expected_frame_rate) { | 76 int expected_frame_rate) { |
| 77 blink::WebMediaStreamTrack track = CreateTrack("123", constraints); | 77 blink::WebMediaStreamTrack track = CreateTrack("123", constraints); |
| 78 | 78 |
| 79 mock_source_->CompleteGetSupportedFormats(); | 79 mock_source_->CompleteGetSupportedFormats(); |
| 80 const media::VideoCaptureParams& format = mock_source()->start_params(); | 80 const media::VideoCaptureFormat& format = mock_source()->start_format(); |
| 81 EXPECT_EQ(expected_width, format.requested_format.frame_size.width()); | 81 EXPECT_EQ(expected_width, format.frame_size.width()); |
| 82 EXPECT_EQ(expected_height, format.requested_format.frame_size.height()); | 82 EXPECT_EQ(expected_height, format.frame_size.height()); |
| 83 EXPECT_EQ(expected_frame_rate, format.requested_format.frame_rate); | 83 EXPECT_EQ(expected_frame_rate, format.frame_rate); |
| 84 | 84 |
| 85 EXPECT_EQ(0, NumberOfSuccessConstraintsCallbacks()); | 85 EXPECT_EQ(0, NumberOfSuccessConstraintsCallbacks()); |
| 86 mock_source_->StartMockedSource(); | 86 mock_source_->StartMockedSource(); |
| 87 // Once the source has started successfully we expect that the | 87 // Once the source has started successfully we expect that the |
| 88 // ConstraintsCallback in MediaStreamSource::AddTrack completes. | 88 // ConstraintsCallback in MediaStreamSource::AddTrack completes. |
| 89 EXPECT_EQ(1, NumberOfSuccessConstraintsCallbacks()); | 89 EXPECT_EQ(1, NumberOfSuccessConstraintsCallbacks()); |
| 90 return track; | 90 return track; |
| 91 } | 91 } |
| 92 | 92 |
| 93 int NumberOfSuccessConstraintsCallbacks() const { | 93 int NumberOfSuccessConstraintsCallbacks() const { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 417 |
| 418 // Test that the source ignores an optional aspect ratio that is higher than | 418 // Test that the source ignores an optional aspect ratio that is higher than |
| 419 // supported. | 419 // supported. |
| 420 TEST_F(MediaStreamVideoSourceTest, OptionalAspectRatioTooHigh) { | 420 TEST_F(MediaStreamVideoSourceTest, OptionalAspectRatioTooHigh) { |
| 421 MockMediaConstraintFactory factory; | 421 MockMediaConstraintFactory factory; |
| 422 factory.AddOptional(MediaStreamVideoSource::kMinAspectRatio, 2); | 422 factory.AddOptional(MediaStreamVideoSource::kMinAspectRatio, 2); |
| 423 blink::WebMediaStreamTrack track = CreateTrack( | 423 blink::WebMediaStreamTrack track = CreateTrack( |
| 424 "123", factory.CreateWebMediaConstraints()); | 424 "123", factory.CreateWebMediaConstraints()); |
| 425 mock_source()->CompleteGetSupportedFormats(); | 425 mock_source()->CompleteGetSupportedFormats(); |
| 426 | 426 |
| 427 const media::VideoCaptureParams& params = mock_source()->start_params(); | 427 const media::VideoCaptureFormat& format = mock_source()->start_format(); |
| 428 double aspect_ratio = | 428 double aspect_ratio = |
| 429 static_cast<double>(params.requested_format.frame_size.width()) / | 429 static_cast<double>(format.frame_size.width()) / |
| 430 params.requested_format.frame_size.height(); | 430 format.frame_size.height(); |
| 431 EXPECT_LT(aspect_ratio, 2); | 431 EXPECT_LT(aspect_ratio, 2); |
| 432 } | 432 } |
| 433 | 433 |
| 434 // Test that the source starts video with the default resolution if the | 434 // Test that the source starts video with the default resolution if the |
| 435 // that is the only supported. | 435 // that is the only supported. |
| 436 TEST_F(MediaStreamVideoSourceTest, DefaultCapability) { | 436 TEST_F(MediaStreamVideoSourceTest, DefaultCapability) { |
| 437 media::VideoCaptureFormats formats; | 437 media::VideoCaptureFormats formats; |
| 438 formats.push_back(media::VideoCaptureFormat( | 438 formats.push_back(media::VideoCaptureFormat( |
| 439 gfx::Size(MediaStreamVideoSource::kDefaultWidth, | 439 gfx::Size(MediaStreamVideoSource::kDefaultWidth, |
| 440 MediaStreamVideoSource::kDefaultHeight), | 440 MediaStreamVideoSource::kDefaultHeight), |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 run_loop2.Run(); | 781 run_loop2.Run(); |
| 782 | 782 |
| 783 EXPECT_EQ(muted_state, false); | 783 EXPECT_EQ(muted_state, false); |
| 784 EXPECT_EQ(track.source().readyState(), | 784 EXPECT_EQ(track.source().readyState(), |
| 785 blink::WebMediaStreamSource::ReadyStateLive); | 785 blink::WebMediaStreamSource::ReadyStateLive); |
| 786 | 786 |
| 787 MediaStreamVideoSink::RemoveFromVideoTrack(&sink, track); | 787 MediaStreamVideoSink::RemoveFromVideoTrack(&sink, track); |
| 788 } | 788 } |
| 789 | 789 |
| 790 } // namespace content | 790 } // namespace content |
| OLD | NEW |