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

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: Clean up 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 "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
16
17 namespace webrtc {
18
19 class MockAimdRateControl : public AimdRateControl {
20 public:
21 MOCK_METHOD2(SetEstimate, void(int bitrate_bps, int64_t now_ms));
22 };
23
24 class TestProbingCalculator : public ::testing::Test {
25 public:
26 TestProbingCalculator() : probing_calculator_(&rate_controller_) {}
27
28 void AddPacketFeedback(int probe_cluster_id,
29 size_t size,
30 int64_t send_time_ms,
31 int64_t arrival_time_ms) {
32 PacketInfo info(arrival_time_ms, send_time_ms, 0, size, probe_cluster_id);
33 probing_calculator_.PacketFeedback(info);
34 }
35
36 protected:
37 testing::StrictMock<MockAimdRateControl> rate_controller_;
38 ProbingCalculator probing_calculator_;
39 };
40
41 TEST_F(TestProbingCalculator, OneCluster) {
42 EXPECT_CALL(rate_controller_, SetEstimate(100000, 50));
43 AddPacketFeedback(0, 1000, 0, 10);
44 AddPacketFeedback(0, 1000, 10, 20);
45 AddPacketFeedback(0, 1000, 20, 30);
46 AddPacketFeedback(0, 1000, 40, 50);
47 }
48
49 TEST_F(TestProbingCalculator, FastReceive) {
50 EXPECT_CALL(rate_controller_, SetEstimate(100000, 50));
51 AddPacketFeedback(0, 1000, 0, 15);
52 AddPacketFeedback(0, 1000, 10, 30);
53 AddPacketFeedback(0, 1000, 20, 40);
54 AddPacketFeedback(0, 1000, 40, 50);
55 }
56
57 TEST_F(TestProbingCalculator, TooFastReceive) {
58 AddPacketFeedback(0, 1000, 0, 19);
59 AddPacketFeedback(0, 1000, 10, 30);
60 AddPacketFeedback(0, 1000, 20, 40);
61 AddPacketFeedback(0, 1000, 40, 50);
62 }
63
64 TEST_F(TestProbingCalculator, SlowReceive) {
65 EXPECT_CALL(rate_controller_, SetEstimate(40000, 110));
66 AddPacketFeedback(0, 1000, 0, 10);
67 AddPacketFeedback(0, 1000, 10, 40);
68 AddPacketFeedback(0, 1000, 20, 70);
69 AddPacketFeedback(0, 1000, 40, 110);
70 }
71
72 TEST_F(TestProbingCalculator, BurstReceive) {
73 AddPacketFeedback(0, 1000, 0, 50);
74 AddPacketFeedback(0, 1000, 10, 50);
75 AddPacketFeedback(0, 1000, 20, 50);
76 AddPacketFeedback(0, 1000, 40, 50);
77 }
78
79 TEST_F(TestProbingCalculator, MultipleClusters) {
80 EXPECT_CALL(rate_controller_, SetEstimate(80000, 60));
81 EXPECT_CALL(rate_controller_, SetEstimate(100000, 60));
82 AddPacketFeedback(0, 1000, 0, 10);
83 AddPacketFeedback(0, 1000, 10, 20);
84 AddPacketFeedback(0, 1000, 20, 30);
85 AddPacketFeedback(0, 1000, 40, 60);
86 AddPacketFeedback(0, 1000, 50, 60);
87
88 EXPECT_CALL(rate_controller_, SetEstimate(200000, 90));
89 AddPacketFeedback(1, 1000, 60, 70);
90 AddPacketFeedback(1, 1000, 65, 77);
91 AddPacketFeedback(1, 1000, 70, 84);
92 AddPacketFeedback(1, 1000, 75, 90);
93 }
94
95 TEST_F(TestProbingCalculator, OldProbe) {
96 AddPacketFeedback(0, 1000, 0, 10);
97 AddPacketFeedback(0, 1000, 10, 20);
98 AddPacketFeedback(0, 1000, 20, 30);
99
100 EXPECT_CALL(rate_controller_, SetEstimate(200000, 90));
101 AddPacketFeedback(1, 1000, 60, 70);
102 AddPacketFeedback(1, 1000, 65, 77);
103 AddPacketFeedback(1, 1000, 70, 84);
104 AddPacketFeedback(1, 1000, 75, 90);
105
106 AddPacketFeedback(0, 1000, 40, 60);
107 }
108
109 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698