blob: 1434474c3fdf810a2837b15ded9ffe3a3473a889 [file] [log] [blame]
Sebastian Jansson53571c72019-07-31 17:30:03 +02001/*
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
16namespace webrtc {
17namespace test {
18namespace {
19using ::testing::Eq;
20using ::testing::Property;
21
22class MockVideoSinkInterfaceVideoFrame
23 : public rtc::VideoSinkInterface<VideoFrame> {
24 public:
25 MOCK_METHOD1(OnFrame, void(const VideoFrame& frame));
26 MOCK_METHOD0(OnDiscardedFrame, void());
27};
28} // namespace
29TEST(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))))
philipeld5727482020-01-03 14:43:10 +010041 .Times(21);
Markus Handell486cc552019-12-03 14:37:28 +010042 time.AdvanceTime(TimeDelta::seconds(1));
Sebastian Jansson53571c72019-07-31 17:30:03 +020043}
44} // namespace test
45} // namespace webrtc