1 /*
2 * Copyright (c) 2012 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 "video/encoder_rtcp_feedback.h"
12
13 #include <memory>
14
15 #include "test/gmock.h"
16 #include "test/gtest.h"
17 #include "video/test/mock_video_stream_encoder.h"
18
19 namespace webrtc {
20
21 class VieKeyRequestTest : public ::testing::Test {
22 public:
VieKeyRequestTest()23 VieKeyRequestTest()
24 : simulated_clock_(123456789),
25 encoder_(),
26 encoder_rtcp_feedback_(
27 &simulated_clock_,
28 std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
29 &encoder_) {}
30
31 protected:
32 const uint32_t kSsrc = 1234;
33
34 SimulatedClock simulated_clock_;
35 ::testing::StrictMock<MockVideoStreamEncoder> encoder_;
36 EncoderRtcpFeedback encoder_rtcp_feedback_;
37 };
38
TEST_F(VieKeyRequestTest,CreateAndTriggerRequests)39 TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) {
40 EXPECT_CALL(encoder_, SendKeyFrame()).Times(1);
41 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
42 }
43
TEST_F(VieKeyRequestTest,TooManyOnReceivedIntraFrameRequest)44 TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) {
45 EXPECT_CALL(encoder_, SendKeyFrame()).Times(1);
46 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
47 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
48 simulated_clock_.AdvanceTimeMilliseconds(10);
49 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
50
51 EXPECT_CALL(encoder_, SendKeyFrame()).Times(1);
52 simulated_clock_.AdvanceTimeMilliseconds(300);
53 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
54 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
55 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
56 }
57
58 } // namespace webrtc
59