blob: 79c39fffb828f8eb11aaa149fb94b6ee6bf2291e [file] [log] [blame]
Ruslan Burakov428dcb22019-04-18 15:49:491/*
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 17:08:3311#include "pc/jitter_buffer_delay.h"
12
Ruslan Burakov428dcb22019-04-18 15:49:4913#include "test/gtest.h"
14
Ruslan Burakov428dcb22019-04-18 15:49:4915namespace webrtc {
16
17class JitterBufferDelayTest : public ::testing::Test {
18 public:
Tommi4ccdf9322021-05-17 12:50:1019 JitterBufferDelayTest() {}
Ruslan Burakov428dcb22019-04-18 15:49:4920
21 protected:
Tommi4ccdf9322021-05-17 12:50:1022 JitterBufferDelay delay_;
Ruslan Burakov428dcb22019-04-18 15:49:4923};
24
25TEST_F(JitterBufferDelayTest, Set) {
Ruslan Burakov428dcb22019-04-18 15:49:4926 // Delay in seconds.
Tommi4ccdf9322021-05-17 12:50:1027 delay_.Set(3.0);
28 EXPECT_EQ(delay_.GetMs(), 3000);
Ruslan Burakov428dcb22019-04-18 15:49:4929}
30
Tommi4ccdf9322021-05-17 12:50:1031TEST_F(JitterBufferDelayTest, DefaultValue) {
32 EXPECT_EQ(delay_.GetMs(), 0); // Default value is 0ms.
Ruslan Burakov428dcb22019-04-18 15:49:4933}
34
35TEST_F(JitterBufferDelayTest, Clamping) {
Ruslan Burakov428dcb22019-04-18 15:49:4936 // In current Jitter Buffer implementation (Audio or Video) maximum supported
37 // value is 10000 milliseconds.
Tommi4ccdf9322021-05-17 12:50:1038 delay_.Set(10.5);
39 EXPECT_EQ(delay_.GetMs(), 10000);
Ruslan Burakov428dcb22019-04-18 15:49:4940
41 // Test int overflow.
Tommi4ccdf9322021-05-17 12:50:1042 delay_.Set(21474836470.0);
43 EXPECT_EQ(delay_.GetMs(), 10000);
Ruslan Burakov428dcb22019-04-18 15:49:4944
Tommi4ccdf9322021-05-17 12:50:1045 delay_.Set(-21474836470.0);
46 EXPECT_EQ(delay_.GetMs(), 0);
Ruslan Burakov428dcb22019-04-18 15:49:4947
48 // Boundary value in seconds to milliseconds conversion.
Tommi4ccdf9322021-05-17 12:50:1049 delay_.Set(0.0009);
50 EXPECT_EQ(delay_.GetMs(), 0);
Ruslan Burakov428dcb22019-04-18 15:49:4951
Tommi4ccdf9322021-05-17 12:50:1052 delay_.Set(-2.0);
53 EXPECT_EQ(delay_.GetMs(), 0);
Ruslan Burakov428dcb22019-04-18 15:49:4954}
55
56} // namespace webrtc