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

Unified Diff: webrtc/modules/pacing/bitrate_prober_unittest.cc

Issue 2681733004: Fix bug in BitrateProber where an old probe added at a high bitrate will stay active indefinit… (Closed)
Patch Set: Add unittest. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/pacing/bitrate_prober.cc ('k') | webrtc/modules/pacing/paced_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/pacing/bitrate_prober_unittest.cc
diff --git a/webrtc/modules/pacing/bitrate_prober_unittest.cc b/webrtc/modules/pacing/bitrate_prober_unittest.cc
index b5bc889014382e4581ca088a4ba9e86689ed5b02..d36d8108b946427f8c155dfe6eeda0b9f3650367 100644
--- a/webrtc/modules/pacing/bitrate_prober_unittest.cc
+++ b/webrtc/modules/pacing/bitrate_prober_unittest.cc
@@ -27,8 +27,8 @@ TEST(BitrateProberTest, VerifyStatesAndTimeBetweenProbes) {
const int kProbeSize = 1000;
const int kMinProbeDurationMs = 15;
- prober.CreateProbeCluster(kTestBitrate1);
- prober.CreateProbeCluster(kTestBitrate2);
+ prober.CreateProbeCluster(kTestBitrate1, now_ms);
+ prober.CreateProbeCluster(kTestBitrate2, now_ms);
EXPECT_FALSE(prober.IsProbing());
prober.OnIncomingPacket(kProbeSize);
@@ -78,7 +78,7 @@ TEST(BitrateProberTest, DoesntProbeWithoutRecentPackets) {
int64_t now_ms = 0;
EXPECT_EQ(-1, prober.TimeUntilNextProbe(now_ms));
- prober.CreateProbeCluster(900000);
+ prober.CreateProbeCluster(900000, now_ms);
EXPECT_FALSE(prober.IsProbing());
prober.OnIncomingPacket(1000);
@@ -111,7 +111,7 @@ TEST(BitrateProberTest, VerifyProbeSizeOnHighBitrate) {
BitrateProber prober;
constexpr unsigned kHighBitrateBps = 10000000; // 10 Mbps
- prober.CreateProbeCluster(kHighBitrateBps);
+ prober.CreateProbeCluster(kHighBitrateBps, 0);
// Probe size should ensure a minimum of 1 ms interval.
EXPECT_GT(prober.RecommendedMinProbeSize(), kHighBitrateBps / 8000);
}
@@ -123,7 +123,7 @@ TEST(BitrateProberTest, MinumumNumberOfProbingPackets) {
constexpr int kBitrateBps = 100000; // 100 kbps
constexpr int kPacketSizeBytes = 1000;
- prober.CreateProbeCluster(kBitrateBps);
+ prober.CreateProbeCluster(kBitrateBps, 0);
prober.OnIncomingPacket(kPacketSizeBytes);
for (int i = 0; i < 5; ++i) {
EXPECT_TRUE(prober.IsProbing());
@@ -139,7 +139,7 @@ TEST(BitrateProberTest, ScaleBytesUsedForProbing) {
constexpr int kPacketSizeBytes = 1000;
constexpr int kExpectedBytesSent = kBitrateBps * 15 / 8000;
- prober.CreateProbeCluster(kBitrateBps);
+ prober.CreateProbeCluster(kBitrateBps, 0);
prober.OnIncomingPacket(kPacketSizeBytes);
int bytes_sent = 0;
while (bytes_sent < kExpectedBytesSent) {
@@ -151,4 +151,33 @@ TEST(BitrateProberTest, ScaleBytesUsedForProbing) {
EXPECT_FALSE(prober.IsProbing());
}
+TEST(BitrateProberTest, ProbeClusterTimeout) {
+ BitrateProber prober;
+ constexpr int kBitrateBps = 300000; // 300 kbps
+ constexpr int kSmallPacketSize = 20;
+ // Expecting two probe clusters of 5 packets each.
+ constexpr int kExpectedBytesSent = 20 * 2 * 5;
+ constexpr int64_t kTimeoutMs = 5000;
+
+ int64_t now_ms = 0;
+ prober.CreateProbeCluster(kBitrateBps, now_ms);
+ prober.OnIncomingPacket(kSmallPacketSize);
+ EXPECT_FALSE(prober.IsProbing());
+ now_ms += kTimeoutMs;
+ prober.CreateProbeCluster(kBitrateBps / 10, now_ms);
+ prober.OnIncomingPacket(kSmallPacketSize);
+ EXPECT_FALSE(prober.IsProbing());
+ now_ms += 1;
+ prober.CreateProbeCluster(kBitrateBps / 10, now_ms);
+ prober.OnIncomingPacket(kSmallPacketSize);
+ EXPECT_TRUE(prober.IsProbing());
+ int bytes_sent = 0;
+ while (bytes_sent < kExpectedBytesSent) {
+ ASSERT_TRUE(prober.IsProbing());
+ prober.ProbeSent(0, kSmallPacketSize);
+ bytes_sent += kSmallPacketSize;
+ }
+
+ EXPECT_FALSE(prober.IsProbing());
+}
} // namespace webrtc
« no previous file with comments | « webrtc/modules/pacing/bitrate_prober.cc ('k') | webrtc/modules/pacing/paced_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698