Index: webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window_unittest.cc |
diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window_unittest.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a2d50dfe9e2c7023c34c12cedc1142c63f0d4d20 |
--- /dev/null |
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window_unittest.cc |
@@ -0,0 +1,82 @@ |
+/* |
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#include "webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.h" |
+#include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h" |
+ |
+#include "webrtc/test/gtest.h" |
+ |
+namespace webrtc { |
+namespace testing { |
+namespace bwe { |
+namespace { |
+// These are the same values used in CongestionWindow class. |
+const int64_t kStartingCongestionWindow = 6000; |
+const int64_t kMinimumCongestionWindow = 5840; |
+} // namespace |
+ |
+TEST(CongestionWindowTest, InitializationCheck) { |
+ CongestionWindow congestion_window; |
+ congestion_window.PacketSent(0); |
+ EXPECT_EQ(congestion_window.data_inflight(), 0u); |
+ congestion_window.AckReceived(0); |
+ EXPECT_EQ(congestion_window.data_inflight(), 0u); |
+} |
+ |
+TEST(CongestionWindowTest, DataInflight) { |
+ CongestionWindow congestion_window; |
+ congestion_window.PacketSent(13); |
+ EXPECT_EQ(congestion_window.data_inflight(), 13u); |
+ congestion_window.AckReceived(12); |
+ EXPECT_EQ(congestion_window.data_inflight(), 1u); |
+ congestion_window.PacketSent(10); |
+ congestion_window.PacketSent(9); |
+ EXPECT_EQ(congestion_window.data_inflight(), 20u); |
+ congestion_window.AckReceived(20); |
+ EXPECT_EQ(congestion_window.data_inflight(), 0u); |
+} |
+ |
+TEST(CongestionWindowTest, ZeroBandwidthDelayProduct) { |
+ CongestionWindow congestion_window; |
+ int64_t target_congestion_window = |
+ congestion_window.GetTargetCongestionWindow(100, 0, 2.885); |
+ EXPECT_EQ(target_congestion_window, 2.885 * kStartingCongestionWindow); |
+} |
+ |
+TEST(CongestionWindowTest, BelowMinimumTargetCongestionWindow) { |
+ CongestionWindow congestion_window; |
+ int64_t target_congestion_window = |
+ congestion_window.GetTargetCongestionWindow(100, 2, 2.885); |
+ EXPECT_EQ(target_congestion_window, kMinimumCongestionWindow); |
+} |
+ |
+TEST(CongestionWindowTest, AboveMinimumTargetCongestionWindow) { |
+ CongestionWindow congestion_window; |
+ int64_t target_congestion_window = |
+ congestion_window.GetTargetCongestionWindow(100000, 2, 2.885); |
+ EXPECT_EQ(target_congestion_window, 577000); |
+} |
+ |
+TEST(CongestionWindowTest, MinimumCongestionWindow) { |
+ CongestionWindow congestion_window; |
+ int64_t cwnd = congestion_window.GetCongestionWindow(BbrBweSender::PROBE_RTT, |
+ 100, 100, 2.885f); |
+ EXPECT_EQ(cwnd, kMinimumCongestionWindow); |
+} |
+ |
+TEST(CongestionWindowTest, CalculateCongestionWindow) { |
+ CongestionWindow congestion_window; |
+ int64_t cwnd = congestion_window.GetCongestionWindow(BbrBweSender::STARTUP, |
+ 100, 100, 2.885f); |
+ EXPECT_EQ(cwnd, 28850); |
+} |
+} // namespace bwe |
+} // namespace testing |
+} // namespace webrtc |