xref: /aosp_15_r20/external/webrtc/video/encoder_rtcp_feedback_unittest.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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 using ::testing::_;
20 
21 namespace webrtc {
22 
23 class VieKeyRequestTest : public ::testing::Test {
24  public:
VieKeyRequestTest()25   VieKeyRequestTest()
26       : simulated_clock_(123456789),
27         encoder_(),
28         encoder_rtcp_feedback_(
29             &simulated_clock_,
30             std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
31             &encoder_,
32             nullptr) {}
33 
34  protected:
35   const uint32_t kSsrc = 1234;
36 
37   SimulatedClock simulated_clock_;
38   ::testing::StrictMock<MockVideoStreamEncoder> encoder_;
39   EncoderRtcpFeedback encoder_rtcp_feedback_;
40 };
41 
TEST_F(VieKeyRequestTest,CreateAndTriggerRequests)42 TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) {
43   EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
44   encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
45 }
46 
TEST_F(VieKeyRequestTest,TooManyOnReceivedIntraFrameRequest)47 TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) {
48   EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
49   encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
50   encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
51   simulated_clock_.AdvanceTimeMilliseconds(10);
52   encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
53 
54   EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
55   simulated_clock_.AdvanceTimeMilliseconds(300);
56   encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
57   encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
58   encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
59 }
60 
61 }  // namespace webrtc
62