blob: 79c39fffb828f8eb11aaa149fb94b6ee6bf2291e [file] [log] [blame]
Ruslan Burakov428dcb22019-04-18 17:49:49 +02001/*
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
Jonas Olssona4d87372019-07-05 19:08:33 +020011#include "pc/jitter_buffer_delay.h"
12
Ruslan Burakov428dcb22019-04-18 17:49:49 +020013#include "test/gtest.h"
14
Ruslan Burakov428dcb22019-04-18 17:49:49 +020015namespace webrtc {
16
17class JitterBufferDelayTest : public ::testing::Test {
18 public:
Tommi4ccdf932021-05-17 14:50:10 +020019 JitterBufferDelayTest() {}
Ruslan Burakov428dcb22019-04-18 17:49:49 +020020
21 protected:
Tommi4ccdf932021-05-17 14:50:10 +020022 JitterBufferDelay delay_;
Ruslan Burakov428dcb22019-04-18 17:49:49 +020023};
24
25TEST_F(JitterBufferDelayTest, Set) {
Ruslan Burakov428dcb22019-04-18 17:49:49 +020026 // Delay in seconds.
Tommi4ccdf932021-05-17 14:50:10 +020027 delay_.Set(3.0);
28 EXPECT_EQ(delay_.GetMs(), 3000);
Ruslan Burakov428dcb22019-04-18 17:49:49 +020029}
30
Tommi4ccdf932021-05-17 14:50:10 +020031TEST_F(JitterBufferDelayTest, DefaultValue) {
32 EXPECT_EQ(delay_.GetMs(), 0); // Default value is 0ms.
Ruslan Burakov428dcb22019-04-18 17:49:49 +020033}
34
35TEST_F(JitterBufferDelayTest, Clamping) {
Ruslan Burakov428dcb22019-04-18 17:49:49 +020036 // In current Jitter Buffer implementation (Audio or Video) maximum supported
37 // value is 10000 milliseconds.
Tommi4ccdf932021-05-17 14:50:10 +020038 delay_.Set(10.5);
39 EXPECT_EQ(delay_.GetMs(), 10000);
Ruslan Burakov428dcb22019-04-18 17:49:49 +020040
41 // Test int overflow.
Tommi4ccdf932021-05-17 14:50:10 +020042 delay_.Set(21474836470.0);
43 EXPECT_EQ(delay_.GetMs(), 10000);
Ruslan Burakov428dcb22019-04-18 17:49:49 +020044
Tommi4ccdf932021-05-17 14:50:10 +020045 delay_.Set(-21474836470.0);
46 EXPECT_EQ(delay_.GetMs(), 0);
Ruslan Burakov428dcb22019-04-18 17:49:49 +020047
48 // Boundary value in seconds to milliseconds conversion.
Tommi4ccdf932021-05-17 14:50:10 +020049 delay_.Set(0.0009);
50 EXPECT_EQ(delay_.GetMs(), 0);
Ruslan Burakov428dcb22019-04-18 17:49:49 +020051
Tommi4ccdf932021-05-17 14:50:10 +020052 delay_.Set(-2.0);
53 EXPECT_EQ(delay_.GetMs(), 0);
Ruslan Burakov428dcb22019-04-18 17:49:49 +020054}
55
56} // namespace webrtc