OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 prober.CreateProbeCluster(900000); | 81 prober.CreateProbeCluster(900000); |
82 EXPECT_FALSE(prober.IsProbing()); | 82 EXPECT_FALSE(prober.IsProbing()); |
83 | 83 |
84 prober.OnIncomingPacket(1000); | 84 prober.OnIncomingPacket(1000); |
85 EXPECT_TRUE(prober.IsProbing()); | 85 EXPECT_TRUE(prober.IsProbing()); |
86 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); | 86 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); |
87 prober.ProbeSent(now_ms, 1000); | 87 prober.ProbeSent(now_ms, 1000); |
88 // Let time pass, no large enough packets put into prober. | 88 // Let time pass, no large enough packets put into prober. |
89 now_ms += 6000; | 89 now_ms += 6000; |
90 EXPECT_EQ(-1, prober.TimeUntilNextProbe(now_ms)); | 90 EXPECT_EQ(-1, prober.TimeUntilNextProbe(now_ms)); |
91 // Insert a small packet, not a candidate for probing. | |
92 prober.OnIncomingPacket(100); | |
93 EXPECT_FALSE(prober.IsProbing()); | |
94 EXPECT_EQ(-1, prober.TimeUntilNextProbe(now_ms)); | |
95 // Insert a large-enough packet after downtime while probing should reset to | 91 // Insert a large-enough packet after downtime while probing should reset to |
96 // perform a new probe since the requested one didn't finish. | 92 // perform a new probe since the requested one didn't finish. |
97 prober.OnIncomingPacket(1000); | 93 prober.OnIncomingPacket(1000); |
98 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); | 94 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); |
99 prober.ProbeSent(now_ms, 1000); | 95 prober.ProbeSent(now_ms, 1000); |
100 // Next packet should be part of new probe and be sent with non-zero delay. | 96 // Next packet should be part of new probe and be sent with non-zero delay. |
101 prober.OnIncomingPacket(1000); | 97 prober.OnIncomingPacket(1000); |
102 EXPECT_GT(prober.TimeUntilNextProbe(now_ms), 0); | 98 EXPECT_GT(prober.TimeUntilNextProbe(now_ms), 0); |
103 } | 99 } |
104 | 100 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 TEST(BitrateProberTest, ScaleBytesUsedForProbing) { | 136 TEST(BitrateProberTest, ScaleBytesUsedForProbing) { |
141 BitrateProber prober; | 137 BitrateProber prober; |
142 constexpr int kBitrateBps = 10000000; // 10 Mbps | 138 constexpr int kBitrateBps = 10000000; // 10 Mbps |
143 constexpr int kPacketSizeBytes = 1000; | 139 constexpr int kPacketSizeBytes = 1000; |
144 constexpr int kExpectedBytesSent = kBitrateBps * 15 / 8000; | 140 constexpr int kExpectedBytesSent = kBitrateBps * 15 / 8000; |
145 | 141 |
146 prober.CreateProbeCluster(kBitrateBps); | 142 prober.CreateProbeCluster(kBitrateBps); |
147 prober.OnIncomingPacket(kPacketSizeBytes); | 143 prober.OnIncomingPacket(kPacketSizeBytes); |
148 int bytes_sent = 0; | 144 int bytes_sent = 0; |
149 while (bytes_sent < kExpectedBytesSent) { | 145 while (bytes_sent < kExpectedBytesSent) { |
150 EXPECT_TRUE(prober.IsProbing()); | 146 ASSERT_TRUE(prober.IsProbing()); |
151 prober.ProbeSent(0, kPacketSizeBytes); | 147 prober.ProbeSent(0, kPacketSizeBytes); |
152 bytes_sent += kPacketSizeBytes; | 148 bytes_sent += kPacketSizeBytes; |
153 } | 149 } |
154 | 150 |
155 EXPECT_FALSE(prober.IsProbing()); | 151 EXPECT_FALSE(prober.IsProbing()); |
156 } | 152 } |
157 | 153 |
158 } // namespace webrtc | 154 } // namespace webrtc |
OLD | NEW |