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..b5493c66e7d2bde133ec544b7c495ea2604a8e72 |
--- /dev/null |
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window_unittest.cc |
@@ -0,0 +1,79 @@ |
+/* |
+ * 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 { |
+const int64_t kStartingCongestionWindow = 6000; |
philipel
2017/07/06 12:15:15
anonymous namespace, comment where you got this fr
gnish1
2017/07/07 13:43:34
Done.
|
+const int64_t kMinimumCongestionWindow = 5840; |
+ |
+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, 10000, 2); |
+ EXPECT_EQ(cwnd, kMinimumCongestionWindow); |
+} |
+ |
+TEST(CongestionWindowTest, CalculateCongestionWindow) { |
+ CongestionWindow congestion_window; |
+ int64_t cwnd = congestion_window.GetCongestionWindow( |
+ BbrBweSender::STARTUP, 100, 100, 2.885f, 10000, 2); |
+ EXPECT_EQ(cwnd, 48850); |
+} |
+} // namespace bwe |
+} // namespace testing |
+} // namespace webrtc |