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

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

Powered by Google App Engine
This is Rietveld 408576698