• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_METHOD(void, OnFrame, (const VideoFrame& frame), (override));
26   MOCK_METHOD(void, OnDiscardedFrame, (), (override));
27 };
28 }  // namespace
TEST(FrameGeneratorCapturerTest,CreateFromConfig)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))))
41       .Times(21);
42   time.AdvanceTime(TimeDelta::Seconds(1));
43 }
44 }  // namespace test
45 }  // namespace webrtc
46