| 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 15 matching lines...) Expand all Loading... |
| 26 using ::testing::InSequence; | 26 using ::testing::InSequence; |
| 27 using ::testing::Invoke; | 27 using ::testing::Invoke; |
| 28 using ::testing::WithArgs; | 28 using ::testing::WithArgs; |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 class MockVideoCapturerSource : public media::VideoCapturerSource { | 34 class MockVideoCapturerSource : public media::VideoCapturerSource { |
| 35 public: | 35 public: |
| 36 MockVideoCapturerSource() { | 36 MockVideoCapturerSource() {} |
| 37 ON_CALL(*this, GetCurrentSupportedFormats(_, _, _, _)) | |
| 38 .WillByDefault(WithArgs<3>( | |
| 39 Invoke(this, &MockVideoCapturerSource::EnumerateDeviceFormats))); | |
| 40 } | |
| 41 | 37 |
| 42 MOCK_METHOD0(RequestRefreshFrame, void()); | 38 MOCK_METHOD0(RequestRefreshFrame, void()); |
| 43 MOCK_METHOD4(GetCurrentSupportedFormats, | |
| 44 void(int max_requested_width, | |
| 45 int max_requested_height, | |
| 46 double max_requested_frame_rate, | |
| 47 const VideoCaptureDeviceFormatsCB& callback)); | |
| 48 MOCK_METHOD0(GetPreferredFormats, media::VideoCaptureFormats()); | 39 MOCK_METHOD0(GetPreferredFormats, media::VideoCaptureFormats()); |
| 49 MOCK_METHOD3(StartCapture, | 40 MOCK_METHOD3(StartCapture, |
| 50 void(const media::VideoCaptureParams& params, | 41 void(const media::VideoCaptureParams& params, |
| 51 const VideoCaptureDeliverFrameCB& new_frame_callback, | 42 const VideoCaptureDeliverFrameCB& new_frame_callback, |
| 52 const RunningCallback& running_callback)); | 43 const RunningCallback& running_callback)); |
| 53 MOCK_METHOD0(StopCapture, void()); | 44 MOCK_METHOD0(StopCapture, void()); |
| 54 | |
| 55 void EnumerateDeviceFormats(const VideoCaptureDeviceFormatsCB& callback) { | |
| 56 media::VideoCaptureFormat kFormatSmall(gfx::Size(640, 480), 30.0, | |
| 57 media::PIXEL_FORMAT_I420); | |
| 58 media::VideoCaptureFormat kFormatLarge(gfx::Size(1920, 1080), 30.0, | |
| 59 media::PIXEL_FORMAT_I420); | |
| 60 media::VideoCaptureFormats formats; | |
| 61 formats.push_back(kFormatSmall); | |
| 62 formats.push_back(kFormatLarge); | |
| 63 callback.Run(formats); | |
| 64 } | |
| 65 }; | 45 }; |
| 66 | 46 |
| 67 class FakeMediaStreamVideoSink : public MediaStreamVideoSink { | 47 class FakeMediaStreamVideoSink : public MediaStreamVideoSink { |
| 68 public: | 48 public: |
| 69 FakeMediaStreamVideoSink(base::TimeTicks* capture_time, | 49 FakeMediaStreamVideoSink(base::TimeTicks* capture_time, |
| 70 media::VideoFrameMetadata* metadata, | 50 media::VideoFrameMetadata* metadata, |
| 71 base::Closure got_frame_cb) | 51 base::Closure got_frame_cb) |
| 72 : capture_time_(capture_time), | 52 : capture_time_(capture_time), |
| 73 metadata_(metadata), | 53 metadata_(metadata), |
| 74 got_frame_cb_(got_frame_cb) {} | 54 got_frame_cb_(got_frame_cb) {} |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 run_loop.Run(); | 237 run_loop.Run(); |
| 258 fake_sink.DisconnectFromTrack(); | 238 fake_sink.DisconnectFromTrack(); |
| 259 EXPECT_EQ(reference_capture_time, capture_time); | 239 EXPECT_EQ(reference_capture_time, capture_time); |
| 260 double metadata_value; | 240 double metadata_value; |
| 261 EXPECT_TRUE(metadata.GetDouble(media::VideoFrameMetadata::FRAME_RATE, | 241 EXPECT_TRUE(metadata.GetDouble(media::VideoFrameMetadata::FRAME_RATE, |
| 262 &metadata_value)); | 242 &metadata_value)); |
| 263 EXPECT_EQ(30.0, metadata_value); | 243 EXPECT_EQ(30.0, metadata_value); |
| 264 } | 244 } |
| 265 | 245 |
| 266 } // namespace content | 246 } // namespace content |
| OLD | NEW |