| 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 "content/renderer/media/media_stream_video_capturer_source.h" | 5 #include "content/renderer/media/media_stream_video_capturer_source.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 void InitWithDeviceInfo(const StreamDeviceInfo& device_info) { | 76 void InitWithDeviceInfo(const StreamDeviceInfo& device_info) { |
| 77 std::unique_ptr<MockVideoCapturerSource> delegate( | 77 std::unique_ptr<MockVideoCapturerSource> delegate( |
| 78 new MockVideoCapturerSource()); | 78 new MockVideoCapturerSource()); |
| 79 delegate_ = delegate.get(); | 79 delegate_ = delegate.get(); |
| 80 source_ = new MediaStreamVideoCapturerSource( | 80 source_ = new MediaStreamVideoCapturerSource( |
| 81 base::Bind(&MediaStreamVideoCapturerSourceTest::OnSourceStopped, | 81 base::Bind(&MediaStreamVideoCapturerSourceTest::OnSourceStopped, |
| 82 base::Unretained(this)), | 82 base::Unretained(this)), |
| 83 std::move(delegate)); | 83 std::move(delegate)); |
| 84 source_->SetDeviceInfo(device_info); | 84 source_->SetDeviceInfo(device_info); |
| 85 | 85 |
| 86 webkit_source_.initialize(base::UTF8ToUTF16("dummy_source_id"), | 86 webkit_source_.initialize(blink::WebString::fromASCII("dummy_source_id"), |
| 87 blink::WebMediaStreamSource::TypeVideo, | 87 blink::WebMediaStreamSource::TypeVideo, |
| 88 base::UTF8ToUTF16("dummy_source_name"), | 88 blink::WebString::fromASCII("dummy_source_name"), |
| 89 false /* remote */); | 89 false /* remote */); |
| 90 webkit_source_.setExtraData(source_); | 90 webkit_source_.setExtraData(source_); |
| 91 webkit_source_id_ = webkit_source_.id(); | 91 webkit_source_id_ = webkit_source_.id(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 MockConstraintFactory* constraint_factory() { return &constraint_factory_; } | 94 MockConstraintFactory* constraint_factory() { return &constraint_factory_; } |
| 95 | 95 |
| 96 blink::WebMediaStreamTrack StartSource() { | 96 blink::WebMediaStreamTrack StartSource() { |
| 97 bool enabled = true; | 97 bool enabled = true; |
| 98 // CreateVideoTrack will trigger OnConstraintsApplied. | 98 // CreateVideoTrack will trigger OnConstraintsApplied. |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 } | 291 } |
| 292 | 292 |
| 293 TEST_F(MediaStreamVideoCapturerSourceTest, Ended) { | 293 TEST_F(MediaStreamVideoCapturerSourceTest, Ended) { |
| 294 std::unique_ptr<MockVideoCapturerSource> delegate( | 294 std::unique_ptr<MockVideoCapturerSource> delegate( |
| 295 new MockVideoCapturerSource()); | 295 new MockVideoCapturerSource()); |
| 296 delegate_ = delegate.get(); | 296 delegate_ = delegate.get(); |
| 297 source_ = new MediaStreamVideoCapturerSource( | 297 source_ = new MediaStreamVideoCapturerSource( |
| 298 base::Bind(&MediaStreamVideoCapturerSourceTest::OnSourceStopped, | 298 base::Bind(&MediaStreamVideoCapturerSourceTest::OnSourceStopped, |
| 299 base::Unretained(this)), | 299 base::Unretained(this)), |
| 300 std::move(delegate)); | 300 std::move(delegate)); |
| 301 webkit_source_.initialize(base::UTF8ToUTF16("dummy_source_id"), | 301 webkit_source_.initialize(blink::WebString::fromASCII("dummy_source_id"), |
| 302 blink::WebMediaStreamSource::TypeVideo, | 302 blink::WebMediaStreamSource::TypeVideo, |
| 303 base::UTF8ToUTF16("dummy_source_name"), | 303 blink::WebString::fromASCII("dummy_source_name"), |
| 304 false /* remote */); | 304 false /* remote */); |
| 305 webkit_source_.setExtraData(source_); | 305 webkit_source_.setExtraData(source_); |
| 306 webkit_source_id_ = webkit_source_.id(); | 306 webkit_source_id_ = webkit_source_.id(); |
| 307 | 307 |
| 308 InSequence s; | 308 InSequence s; |
| 309 EXPECT_CALL(mock_delegate(), GetCurrentSupportedFormats(_, _, _, _)); | 309 EXPECT_CALL(mock_delegate(), GetCurrentSupportedFormats(_, _, _, _)); |
| 310 EXPECT_CALL(mock_delegate(), StartCapture(_, _, _)); | 310 EXPECT_CALL(mock_delegate(), StartCapture(_, _, _)); |
| 311 blink::WebMediaStreamTrack track = StartSource(); | 311 blink::WebMediaStreamTrack track = StartSource(); |
| 312 base::RunLoop().RunUntilIdle(); | 312 base::RunLoop().RunUntilIdle(); |
| 313 | 313 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 run_loop.Run(); | 396 run_loop.Run(); |
| 397 fake_sink.DisconnectFromTrack(); | 397 fake_sink.DisconnectFromTrack(); |
| 398 EXPECT_EQ(reference_capture_time, capture_time); | 398 EXPECT_EQ(reference_capture_time, capture_time); |
| 399 double metadata_value; | 399 double metadata_value; |
| 400 EXPECT_TRUE(metadata.GetDouble(media::VideoFrameMetadata::FRAME_RATE, | 400 EXPECT_TRUE(metadata.GetDouble(media::VideoFrameMetadata::FRAME_RATE, |
| 401 &metadata_value)); | 401 &metadata_value)); |
| 402 EXPECT_EQ(30.0, metadata_value); | 402 EXPECT_EQ(30.0, metadata_value); |
| 403 } | 403 } |
| 404 | 404 |
| 405 } // namespace content | 405 } // namespace content |
| OLD | NEW |