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

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

Issue 2931873002: Test and fix for huge bwe drop after alr state. (Closed)
Patch Set: Created 3 years, 6 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) 2017 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/acknowledge_bitrate_estimator.h"
12
13 #include "webrtc/base/fakeclock.h"
14 #include "webrtc/base/ptr_util.h"
15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
16 #include "webrtc/test/gmock.h"
17 #include "webrtc/test/gtest.h"
18
19 using testing::_;
20 using testing::NiceMock;
21 using testing::InSequence;
22
23 namespace webrtc {
24
25 namespace {
26 class MockBitrateEstimator : public BitrateEstimator {
27 public:
28 ~MockBitrateEstimator() { Die(); }
29
30 MOCK_METHOD0(Die, void());
31 MOCK_METHOD2(Update, void(int64_t now_ms, int bytes));
32 MOCK_CONST_METHOD0(bitrate_bps, rtc::Optional<uint32_t>());
33 };
34
35 struct AcknowledgedBitrateEstimatorTestStates {
36 std::unique_ptr<AcknowledgedBitrateEstimator> acknowledged_bitrate_estimator;
37 MockBitrateEstimator* bitrate_estimator;
38 };
39
40 AcknowledgedBitrateEstimatorTestStates CreateTestStates() {
41 AcknowledgedBitrateEstimatorTestStates states;
42 states.acknowledged_bitrate_estimator =
43 rtc::MakeUnique<AcknowledgedBitrateEstimator>([&states]() {
44 auto bitrate_estimator =
45 rtc::MakeUnique<NiceMock<MockBitrateEstimator>>();
46 states.bitrate_estimator = bitrate_estimator.get();
47 return bitrate_estimator;
48 });
49 EXPECT_CALL(*states.bitrate_estimator, Die()).Times(1);
50 return states;
51 }
52
53 constexpr int64_t first_arrival_time_ms = 10;
54 constexpr int64_t first_send_time_ms = 10;
55 constexpr uint16_t sequence_number = 1;
56 constexpr size_t payload_size = 10;
57
58 std::vector<PacketFeedback> CreateFeedbackVector() {
59 std::vector<PacketFeedback> packet_feedback_vector;
60 const PacedPacketInfo pacing_info;
61 packet_feedback_vector.push_back(
62 PacketFeedback(first_arrival_time_ms, first_send_time_ms, sequence_number,
63 payload_size, pacing_info));
64 packet_feedback_vector.push_back(
65 PacketFeedback(first_arrival_time_ms + 10, first_send_time_ms + 10,
66 sequence_number, payload_size + 10, pacing_info));
67 return packet_feedback_vector;
68 }
69
70 } // anonymous namespace
71
72 TEST(TestAcknowledgedBitrateEstimator, DontAddPacketsWhichAreNotInSendHistory) {
73 auto states = CreateTestStates();
74 std::vector<PacketFeedback> packet_feedback_vector;
75 packet_feedback_vector.push_back(
76 PacketFeedback(first_arrival_time_ms, sequence_number));
77 EXPECT_CALL(*states.bitrate_estimator, Update(_, _)).Times(0);
78 states.acknowledged_bitrate_estimator->IncomingPacketFeedbackVector(
79 packet_feedback_vector, false);
80 }
81
82 TEST(TestAcknowledgedBitrateEstimator, UpdateBandwith) {
83 auto states = CreateTestStates();
84 auto packet_feedback_vector = CreateFeedbackVector();
85 {
86 InSequence dummy;
87 EXPECT_CALL(*states.bitrate_estimator,
88 Update(packet_feedback_vector[0].arrival_time_ms,
89 packet_feedback_vector[0].payload_size))
90 .Times(1);
91 EXPECT_CALL(*states.bitrate_estimator,
92 Update(packet_feedback_vector[1].arrival_time_ms,
93 packet_feedback_vector[1].payload_size))
94 .Times(1);
95 }
96 states.acknowledged_bitrate_estimator->IncomingPacketFeedbackVector(
97 packet_feedback_vector, false);
98 }
99
100 TEST(TestAcknowledgedBitrateEstimator,
101 ResetAfterLeafAlrStateAndDontAddOldPackets) {
102 auto states = CreateTestStates();
103 auto packet_feedback_vector = CreateFeedbackVector();
104 states.acknowledged_bitrate_estimator->IncomingPacketFeedbackVector(
105 packet_feedback_vector, true);
106
107 rtc::ScopedFakeClock fake_clock;
108
109 fake_clock.AdvanceTime(
110 rtc::TimeDelta::FromMilliseconds(first_arrival_time_ms + 1));
111 states.acknowledged_bitrate_estimator->IncomingPacketFeedbackVector(
112 std::vector<PacketFeedback>(), false);
113 EXPECT_CALL(*states.bitrate_estimator, Die()).Times(1);
114
115 {
116 InSequence dummy;
117 EXPECT_CALL(*states.bitrate_estimator,
118 Update(packet_feedback_vector[0].arrival_time_ms,
119 packet_feedback_vector[0].payload_size))
120 .Times(0);
121 EXPECT_CALL(*states.bitrate_estimator,
122 Update(packet_feedback_vector[1].arrival_time_ms,
123 packet_feedback_vector[1].payload_size))
124 .Times(1);
125 }
126 states.acknowledged_bitrate_estimator->IncomingPacketFeedbackVector(
127 packet_feedback_vector, false);
128 }
129
130 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698