xref: /aosp_15_r20/external/webrtc/pc/jitter_buffer_delay_unittest.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 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 "pc/jitter_buffer_delay.h"
12 
13 #include "test/gtest.h"
14 
15 namespace webrtc {
16 
17 class JitterBufferDelayTest : public ::testing::Test {
18  public:
JitterBufferDelayTest()19   JitterBufferDelayTest() {}
20 
21  protected:
22   JitterBufferDelay delay_;
23 };
24 
TEST_F(JitterBufferDelayTest,Set)25 TEST_F(JitterBufferDelayTest, Set) {
26   // Delay in seconds.
27   delay_.Set(3.0);
28   EXPECT_EQ(delay_.GetMs(), 3000);
29 }
30 
TEST_F(JitterBufferDelayTest,DefaultValue)31 TEST_F(JitterBufferDelayTest, DefaultValue) {
32   EXPECT_EQ(delay_.GetMs(), 0);  // Default value is 0ms.
33 }
34 
TEST_F(JitterBufferDelayTest,Clamping)35 TEST_F(JitterBufferDelayTest, Clamping) {
36   // In current Jitter Buffer implementation (Audio or Video) maximum supported
37   // value is 10000 milliseconds.
38   delay_.Set(10.5);
39   EXPECT_EQ(delay_.GetMs(), 10000);
40 
41   // Test int overflow.
42   delay_.Set(21474836470.0);
43   EXPECT_EQ(delay_.GetMs(), 10000);
44 
45   delay_.Set(-21474836470.0);
46   EXPECT_EQ(delay_.GetMs(), 0);
47 
48   // Boundary value in seconds to milliseconds conversion.
49   delay_.Set(0.0009);
50   EXPECT_EQ(delay_.GetMs(), 0);
51 
52   delay_.Set(-2.0);
53   EXPECT_EQ(delay_.GetMs(), 0);
54 }
55 
56 }  // namespace webrtc
57