OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_
filter.h" | 11 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_
filter.h" |
12 | 12 |
13 #include "webrtc/test/gtest.h" | 13 #include "webrtc/test/gtest.h" |
14 | 14 |
15 namespace webrtc { | 15 namespace webrtc { |
16 namespace testing { | 16 namespace testing { |
17 namespace bwe { | 17 namespace bwe { |
18 TEST(MaxBandwidthFilterTest, InitializationCheck) { | 18 TEST(MaxBandwidthFilterTest, InitializationCheck) { |
19 MaxBandwidthFilter max_bandwidth_filter; | 19 MaxBandwidthFilter max_bandwidth_filter; |
20 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 0); | 20 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 0); |
21 } | 21 } |
22 | 22 |
23 TEST(MaxBandwidthFilterTest, AddOneBandwidthSample) { | 23 TEST(MaxBandwidthFilterTest, AddOneBandwidthSample) { |
24 MaxBandwidthFilter max_bandwidth_filter; | 24 MaxBandwidthFilter max_bandwidth_filter; |
25 max_bandwidth_filter.AddBandwidthSample(13, 4, 10); | 25 max_bandwidth_filter.AddBandwidthSample(13, 4); |
26 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 13); | 26 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 13); |
27 } | 27 } |
28 | 28 |
29 TEST(MaxBandwidthFilterTest, AddSeveralBandwidthSamples) { | 29 TEST(MaxBandwidthFilterTest, AddSeveralBandwidthSamples) { |
30 MaxBandwidthFilter max_bandwidth_filter; | 30 MaxBandwidthFilter max_bandwidth_filter; |
31 max_bandwidth_filter.AddBandwidthSample(10, 5, 10); | 31 max_bandwidth_filter.AddBandwidthSample(10, 5); |
32 max_bandwidth_filter.AddBandwidthSample(13, 6, 10); | 32 max_bandwidth_filter.AddBandwidthSample(13, 6); |
33 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 13); | 33 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 13); |
34 } | 34 } |
35 | 35 |
36 TEST(MaxBandwidthFilterTest, FirstSampleTimeOut) { | 36 TEST(MaxBandwidthFilterTest, FirstSampleTimeOut) { |
37 MaxBandwidthFilter max_bandwidth_filter; | 37 MaxBandwidthFilter max_bandwidth_filter; |
38 max_bandwidth_filter.AddBandwidthSample(13, 5, 10); | 38 max_bandwidth_filter.AddBandwidthSample(13, 5); |
39 max_bandwidth_filter.AddBandwidthSample(10, 15, 10); | 39 max_bandwidth_filter.AddBandwidthSample(10, 15); |
40 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 10); | 40 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 10); |
41 } | 41 } |
42 | 42 |
43 TEST(MaxBandwidthFilterTest, SecondSampleBecomesTheFirst) { | 43 TEST(MaxBandwidthFilterTest, SecondSampleBecomesTheFirst) { |
44 MaxBandwidthFilter max_bandwidth_filter; | 44 MaxBandwidthFilter max_bandwidth_filter; |
45 max_bandwidth_filter.AddBandwidthSample(4, 5, 10); | 45 max_bandwidth_filter.AddBandwidthSample(4, 5); |
46 max_bandwidth_filter.AddBandwidthSample(3, 10, 10); | 46 max_bandwidth_filter.AddBandwidthSample(3, 10); |
47 max_bandwidth_filter.AddBandwidthSample(2, 15, 10); | 47 max_bandwidth_filter.AddBandwidthSample(2, 15); |
48 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 3); | 48 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 3); |
49 } | 49 } |
50 | 50 |
51 TEST(MaxBandwidthFilterTest, ThirdSampleBecomesTheFirst) { | 51 TEST(MaxBandwidthFilterTest, ThirdSampleBecomesTheFirst) { |
52 MaxBandwidthFilter max_bandwidth_filter; | 52 MaxBandwidthFilter max_bandwidth_filter; |
53 max_bandwidth_filter.AddBandwidthSample(4, 5, 10); | 53 max_bandwidth_filter.AddBandwidthSample(4, 5); |
54 max_bandwidth_filter.AddBandwidthSample(3, 10, 10); | 54 max_bandwidth_filter.AddBandwidthSample(3, 10); |
55 max_bandwidth_filter.AddBandwidthSample(2, 25, 10); | 55 max_bandwidth_filter.AddBandwidthSample(2, 25); |
56 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 2); | 56 EXPECT_EQ(max_bandwidth_filter.max_bandwidth_estimate_bps(), 2); |
57 } | 57 } |
58 | 58 |
59 TEST(MaxBandwidthFilterTest, FullBandwidthReached) { | 59 TEST(MaxBandwidthFilterTest, FullBandwidthReached) { |
60 MaxBandwidthFilter max_bandwidth_filter; | 60 MaxBandwidthFilter max_bandwidth_filter; |
61 max_bandwidth_filter.AddBandwidthSample(100, 1, 10); | 61 max_bandwidth_filter.AddBandwidthSample(100, 1); |
62 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); | 62 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); |
63 max_bandwidth_filter.AddBandwidthSample(110, 2, 10); | 63 max_bandwidth_filter.AddBandwidthSample(110, 2); |
64 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); | 64 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); |
65 max_bandwidth_filter.AddBandwidthSample(120, 3, 10); | 65 max_bandwidth_filter.AddBandwidthSample(120, 3); |
66 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); | 66 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); |
67 max_bandwidth_filter.AddBandwidthSample(124, 4, 10); | 67 max_bandwidth_filter.AddBandwidthSample(124, 4); |
68 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), true); | 68 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), true); |
69 } | 69 } |
70 | 70 |
71 TEST(MaxBandwidthFilterTest, FullBandwidthNotReached) { | 71 TEST(MaxBandwidthFilterTest, FullBandwidthNotReached) { |
72 MaxBandwidthFilter max_bandwidth_filter; | 72 MaxBandwidthFilter max_bandwidth_filter; |
73 max_bandwidth_filter.AddBandwidthSample(100, 1, 10); | 73 max_bandwidth_filter.AddBandwidthSample(100, 1); |
74 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); | 74 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); |
75 max_bandwidth_filter.AddBandwidthSample(110, 2, 10); | 75 max_bandwidth_filter.AddBandwidthSample(110, 2); |
76 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); | 76 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); |
77 max_bandwidth_filter.AddBandwidthSample(120, 3, 10); | 77 max_bandwidth_filter.AddBandwidthSample(120, 3); |
78 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); | 78 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); |
79 max_bandwidth_filter.AddBandwidthSample(125, 4, 10); | 79 max_bandwidth_filter.AddBandwidthSample(125, 4); |
80 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); | 80 EXPECT_EQ(max_bandwidth_filter.FullBandwidthReached(1.25f, 3), false); |
81 } | 81 } |
82 } // namespace bwe | 82 } // namespace bwe |
83 } // namespace testing | 83 } // namespace testing |
84 } // namespace webrtc | 84 } // namespace webrtc |
OLD | NEW |