| 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 18 matching lines...) Expand all Loading... |
| 29 namespace content { | 29 namespace content { |
| 30 | 30 |
| 31 class MockVideoCapturerSource : public media::VideoCapturerSource { | 31 class MockVideoCapturerSource : public media::VideoCapturerSource { |
| 32 public: | 32 public: |
| 33 MockVideoCapturerSource() { | 33 MockVideoCapturerSource() { |
| 34 ON_CALL(*this, GetCurrentSupportedFormats(_, _, _, _)) | 34 ON_CALL(*this, GetCurrentSupportedFormats(_, _, _, _)) |
| 35 .WillByDefault(WithArgs<3>( | 35 .WillByDefault(WithArgs<3>( |
| 36 Invoke(this, &MockVideoCapturerSource::EnumerateDeviceFormats))); | 36 Invoke(this, &MockVideoCapturerSource::EnumerateDeviceFormats))); |
| 37 } | 37 } |
| 38 | 38 |
| 39 MOCK_METHOD0(RequestRefreshFrame, void()); |
| 39 MOCK_METHOD4(GetCurrentSupportedFormats, | 40 MOCK_METHOD4(GetCurrentSupportedFormats, |
| 40 void(int max_requested_width, | 41 void(int max_requested_width, |
| 41 int max_requested_height, | 42 int max_requested_height, |
| 42 double max_requested_frame_rate, | 43 double max_requested_frame_rate, |
| 43 const VideoCaptureDeviceFormatsCB& callback)); | 44 const VideoCaptureDeviceFormatsCB& callback)); |
| 44 MOCK_METHOD3(StartCapture, | 45 MOCK_METHOD3(StartCapture, |
| 45 void(const media::VideoCaptureParams& params, | 46 void(const media::VideoCaptureParams& params, |
| 46 const VideoCaptureDeliverFrameCB& new_frame_callback, | 47 const VideoCaptureDeliverFrameCB& new_frame_callback, |
| 47 const RunningCallback& running_callback)); | 48 const RunningCallback& running_callback)); |
| 48 MOCK_METHOD0(StopCapture, void()); | 49 MOCK_METHOD0(StopCapture, void()); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 InitWithDeviceInfo(device_info); | 357 InitWithDeviceInfo(device_info); |
| 357 | 358 |
| 358 VideoCaptureDeliverFrameCB deliver_frame_cb; | 359 VideoCaptureDeliverFrameCB deliver_frame_cb; |
| 359 media::VideoCapturerSource::RunningCallback running_cb; | 360 media::VideoCapturerSource::RunningCallback running_cb; |
| 360 | 361 |
| 361 InSequence s; | 362 InSequence s; |
| 362 EXPECT_CALL(mock_delegate(), GetCurrentSupportedFormats(_, _, _, _)); | 363 EXPECT_CALL(mock_delegate(), GetCurrentSupportedFormats(_, _, _, _)); |
| 363 EXPECT_CALL(mock_delegate(), StartCapture(_, _, _)) | 364 EXPECT_CALL(mock_delegate(), StartCapture(_, _, _)) |
| 364 .WillOnce(testing::DoAll(testing::SaveArg<1>(&deliver_frame_cb), | 365 .WillOnce(testing::DoAll(testing::SaveArg<1>(&deliver_frame_cb), |
| 365 testing::SaveArg<2>(&running_cb))); | 366 testing::SaveArg<2>(&running_cb))); |
| 367 EXPECT_CALL(mock_delegate(), RequestRefreshFrame()); |
| 366 EXPECT_CALL(mock_delegate(), StopCapture()); | 368 EXPECT_CALL(mock_delegate(), StopCapture()); |
| 367 blink::WebMediaStreamTrack track = StartSource(); | 369 blink::WebMediaStreamTrack track = StartSource(); |
| 368 running_cb.Run(true); | 370 running_cb.Run(true); |
| 369 | 371 |
| 370 base::RunLoop run_loop; | 372 base::RunLoop run_loop; |
| 371 base::TimeTicks reference_capture_time = | 373 base::TimeTicks reference_capture_time = |
| 372 base::TimeTicks::FromInternalValue(60013); | 374 base::TimeTicks::FromInternalValue(60013); |
| 373 base::TimeTicks capture_time; | 375 base::TimeTicks capture_time; |
| 374 media::VideoFrameMetadata metadata; | 376 media::VideoFrameMetadata metadata; |
| 375 FakeMediaStreamVideoSink fake_sink( | 377 FakeMediaStreamVideoSink fake_sink( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 387 run_loop.Run(); | 389 run_loop.Run(); |
| 388 FakeMediaStreamVideoSink::RemoveFromVideoTrack(&fake_sink, track); | 390 FakeMediaStreamVideoSink::RemoveFromVideoTrack(&fake_sink, track); |
| 389 EXPECT_EQ(reference_capture_time, capture_time); | 391 EXPECT_EQ(reference_capture_time, capture_time); |
| 390 double metadata_value; | 392 double metadata_value; |
| 391 EXPECT_TRUE(metadata.GetDouble(media::VideoFrameMetadata::FRAME_RATE, | 393 EXPECT_TRUE(metadata.GetDouble(media::VideoFrameMetadata::FRAME_RATE, |
| 392 &metadata_value)); | 394 &metadata_value)); |
| 393 EXPECT_EQ(30.0, metadata_value); | 395 EXPECT_EQ(30.0, metadata_value); |
| 394 } | 396 } |
| 395 | 397 |
| 396 } // namespace content | 398 } // namespace content |
| OLD | NEW |