Sebastian Jansson | 53571c7 | 2019-07-31 17:30:03 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "test/frame_generator_capturer.h" |
| 12 | #include "test/gmock.h" |
| 13 | #include "test/gtest.h" |
| 14 | #include "test/time_controller/simulated_time_controller.h" |
| 15 | |
| 16 | namespace webrtc { |
| 17 | namespace test { |
| 18 | namespace { |
| 19 | using ::testing::Eq; |
| 20 | using ::testing::Property; |
| 21 | |
| 22 | class MockVideoSinkInterfaceVideoFrame |
| 23 | : public rtc::VideoSinkInterface<VideoFrame> { |
| 24 | public: |
| 25 | MOCK_METHOD1(OnFrame, void(const VideoFrame& frame)); |
| 26 | MOCK_METHOD0(OnDiscardedFrame, void()); |
| 27 | }; |
| 28 | } // namespace |
| 29 | TEST(FrameGeneratorCapturerTest, CreateFromConfig) { |
| 30 | GlobalSimulatedTimeController time(Timestamp::seconds(1000)); |
| 31 | FrameGeneratorCapturerConfig config; |
| 32 | config.squares_video->width = 300; |
| 33 | config.squares_video->height = 200; |
| 34 | config.squares_video->framerate = 20; |
| 35 | auto capturer = FrameGeneratorCapturer::Create( |
| 36 | time.GetClock(), *time.GetTaskQueueFactory(), config); |
| 37 | testing::StrictMock<MockVideoSinkInterfaceVideoFrame> mock_sink; |
| 38 | capturer->AddOrUpdateSink(&mock_sink, rtc::VideoSinkWants()); |
| 39 | capturer->Start(); |
| 40 | EXPECT_CALL(mock_sink, OnFrame(Property(&VideoFrame::width, Eq(300)))) |
philipel | d572748 | 2020-01-03 14:43:10 +0100 | [diff] [blame] | 41 | .Times(21); |
Markus Handell | 486cc55 | 2019-12-03 14:37:28 +0100 | [diff] [blame] | 42 | time.AdvanceTime(TimeDelta::seconds(1)); |
Sebastian Jansson | 53571c7 | 2019-07-31 17:30:03 +0200 | [diff] [blame] | 43 | } |
| 44 | } // namespace test |
| 45 | } // namespace webrtc |