Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: webrtc/modules/congestion_controller/probing_calculator_unittest.cc

Issue 2121183002: New ProbingCalculator class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added kMaxNumSavedClusters. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 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 "webrtc/modules/congestion_controller/probing_calculator.h"
12
13 #include <vector>
14 #include <utility>
15
16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
19
20 namespace webrtc {
21
22 class TestProbingCalculator : public ::testing::Test,
23 public ProbingResultCallback {
24 public:
25 TestProbingCalculator() : probing_calculator_(this) {}
26
27 void AddPacketFeedback(int probe_cluster_id,
28 size_t size,
29 int64_t send_time_ms,
30 int64_t arrival_time_ms) {
31 PacketInfo info(arrival_time_ms, send_time_ms, 0, size, probe_cluster_id);
32 probing_calculator_.PacketFeedback(info);
33 }
34
35 void ProbingResult(int bps, int64_t timestamp) {
36 results_.emplace_back(bps, timestamp);
37 }
38
39 void CheckResult(size_t index, int bps, int max_diff, int64_t timestamp) {
40 ASSERT_GT(results_.size(), index);
41 EXPECT_NEAR(results_[index].first, bps, max_diff);
42 EXPECT_EQ(results_[index].second, timestamp);
43 }
44
45 protected:
46 std::vector<std::pair<int, int64_t>> results_;
47 ProbingCalculator probing_calculator_;
48 };
49
50 TEST_F(TestProbingCalculator, OneCluster) {
51 AddPacketFeedback(0, 1000, 0, 10);
52 AddPacketFeedback(0, 1000, 10, 20);
53 AddPacketFeedback(0, 1000, 20, 30);
54 AddPacketFeedback(0, 1000, 40, 50);
55
56 CheckResult(0, 100000, 10, 50);
57 }
58
59 TEST_F(TestProbingCalculator, FastReceive) {
60 AddPacketFeedback(0, 1000, 0, 15);
61 AddPacketFeedback(0, 1000, 10, 30);
62 AddPacketFeedback(0, 1000, 20, 40);
63 AddPacketFeedback(0, 1000, 40, 50);
64
65 CheckResult(0, 100000, 10, 50);
66 }
67
68 TEST_F(TestProbingCalculator, TooFastReceive) {
69 AddPacketFeedback(0, 1000, 0, 19);
70 AddPacketFeedback(0, 1000, 10, 30);
71 AddPacketFeedback(0, 1000, 20, 40);
72 AddPacketFeedback(0, 1000, 40, 50);
73
74 EXPECT_TRUE(results_.empty());
75 }
76
77 TEST_F(TestProbingCalculator, SlowReceive) {
78 AddPacketFeedback(0, 1000, 0, 10);
79 AddPacketFeedback(0, 1000, 10, 40);
80 AddPacketFeedback(0, 1000, 20, 70);
81 AddPacketFeedback(0, 1000, 40, 110);
82
83 CheckResult(0, 40000, 10, 110);
84 }
85
86 TEST_F(TestProbingCalculator, BurstReceive) {
87 AddPacketFeedback(0, 1000, 0, 50);
88 AddPacketFeedback(0, 1000, 10, 50);
89 AddPacketFeedback(0, 1000, 20, 50);
90 AddPacketFeedback(0, 1000, 40, 50);
91
92 EXPECT_TRUE(results_.empty());
93 }
94
95 TEST_F(TestProbingCalculator, MultipleClusters) {
96 AddPacketFeedback(0, 1000, 0, 10);
97 AddPacketFeedback(0, 1000, 10, 20);
98 AddPacketFeedback(0, 1000, 20, 30);
99 AddPacketFeedback(0, 1000, 40, 60);
100 AddPacketFeedback(0, 1000, 50, 60);
101
102 CheckResult(0, 80000, 10, 60);
103 CheckResult(1, 100000, 10, 60);
104
105 AddPacketFeedback(1, 1000, 60, 70);
106 AddPacketFeedback(1, 1000, 65, 77);
107 AddPacketFeedback(1, 1000, 70, 84);
108 AddPacketFeedback(1, 1000, 75, 90);
109
110 CheckResult(2, 200000, 10, 90);
111 }
112
113 TEST_F(TestProbingCalculator, OldProbe) {
114 AddPacketFeedback(0, 1000, 0, 10);
115 AddPacketFeedback(0, 1000, 10, 20);
116 AddPacketFeedback(0, 1000, 20, 30);
117
118 AddPacketFeedback(1, 1000, 60, 70);
119 AddPacketFeedback(1, 1000, 65, 77);
120 AddPacketFeedback(1, 1000, 70, 84);
121 AddPacketFeedback(1, 1000, 75, 90);
122
123 CheckResult(0, 200000, 10, 90);
124
125 AddPacketFeedback(0, 1000, 40, 60);
126
127 EXPECT_EQ(1ul, results_.size());
128 }
129
130 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698