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

Unified Diff: webrtc/modules/congestion_controller/probing_calculator_unittest.cc

Issue 2121183002: New ProbingCalculator class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback fixes. Created 4 years, 5 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
Index: webrtc/modules/congestion_controller/probing_calculator_unittest.cc
diff --git a/webrtc/modules/congestion_controller/probing_calculator_unittest.cc b/webrtc/modules/congestion_controller/probing_calculator_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d78408a881555c004e91b948c0c4328e7df33920
--- /dev/null
+++ b/webrtc/modules/congestion_controller/probing_calculator_unittest.cc
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2016 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/congestion_controller/probing_calculator.h"
+
+#include <vector>
+#include <utility>
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
+
+namespace webrtc {
+
+class TestProbingCalculator : public ::testing::Test,
+ public ProbingResultCallback {
+ public:
+ TestProbingCalculator() : probing_calculator_(this) {}
+
+ void AddPacketFeedback(int probe_cluster_id,
+ size_t size,
+ int64_t send_time_ms,
+ int64_t arrival_time_ms) {
+ PacketInfo info(arrival_time_ms, send_time_ms, 0, size, probe_cluster_id);
+ probing_calculator_.PacketFeedback(info);
+ }
+
+ void ProbingResult(int bps, int64_t timestamp) {
+ results_.emplace_back(bps, timestamp);
+ }
+
+ void CheckResult(size_t index, int bps, int max_diff, int64_t timestamp) {
+ ASSERT_GT(results_.size(), index);
+ EXPECT_NEAR(results_[index].first, bps, max_diff);
+ EXPECT_EQ(results_[index].second, timestamp);
+ }
+
+ protected:
+ std::vector<std::pair<int, int64_t>> results_;
+ ProbingCalculator probing_calculator_;
+};
+
+TEST_F(TestProbingCalculator, OneCluster) {
+ AddPacketFeedback(0, 1000, 0, 10);
+ AddPacketFeedback(0, 1000, 10, 20);
+ AddPacketFeedback(0, 1000, 20, 30);
+ AddPacketFeedback(0, 1000, 40, 50);
+
+ CheckResult(0, 100000, 10, 50);
+}
+
+TEST_F(TestProbingCalculator, FastReceive) {
+ AddPacketFeedback(0, 1000, 0, 15);
+ AddPacketFeedback(0, 1000, 10, 30);
+ AddPacketFeedback(0, 1000, 20, 40);
+ AddPacketFeedback(0, 1000, 40, 50);
+
+ CheckResult(0, 100000, 10, 50);
+}
+
+TEST_F(TestProbingCalculator, TooFastReceive) {
+ AddPacketFeedback(0, 1000, 0, 19);
+ AddPacketFeedback(0, 1000, 10, 30);
+ AddPacketFeedback(0, 1000, 20, 40);
+ AddPacketFeedback(0, 1000, 40, 50);
+
+ EXPECT_TRUE(results_.empty());
+}
+
+TEST_F(TestProbingCalculator, SlowReceive) {
+ AddPacketFeedback(0, 1000, 0, 10);
+ AddPacketFeedback(0, 1000, 10, 40);
+ AddPacketFeedback(0, 1000, 20, 70);
+ AddPacketFeedback(0, 1000, 40, 110);
+
+ CheckResult(0, 40000, 10, 110);
+}
+
+TEST_F(TestProbingCalculator, BurstReceive) {
+ AddPacketFeedback(0, 1000, 0, 50);
+ AddPacketFeedback(0, 1000, 10, 50);
+ AddPacketFeedback(0, 1000, 20, 50);
+ AddPacketFeedback(0, 1000, 40, 50);
+
+ EXPECT_TRUE(results_.empty());
+}
+
+TEST_F(TestProbingCalculator, MultipleClusters) {
+ AddPacketFeedback(0, 1000, 0, 10);
+ AddPacketFeedback(0, 1000, 10, 20);
+ AddPacketFeedback(0, 1000, 20, 30);
+ AddPacketFeedback(0, 1000, 40, 60);
+ AddPacketFeedback(0, 1000, 50, 60);
+
+ CheckResult(0, 80000, 10, 60);
+ CheckResult(1, 100000, 10, 60);
+
+ AddPacketFeedback(1, 1000, 60, 70);
+ AddPacketFeedback(1, 1000, 65, 77);
+ AddPacketFeedback(1, 1000, 70, 84);
+ AddPacketFeedback(1, 1000, 75, 90);
+
+ CheckResult(2, 200000, 10, 90);
+}
+
+TEST_F(TestProbingCalculator, OldProbe) {
+ AddPacketFeedback(0, 1000, 0, 10);
+ AddPacketFeedback(0, 1000, 10, 20);
+ AddPacketFeedback(0, 1000, 20, 30);
+
+ AddPacketFeedback(1, 1000, 60, 70);
+ AddPacketFeedback(1, 1000, 65, 77);
+ AddPacketFeedback(1, 1000, 70, 84);
+ AddPacketFeedback(1, 1000, 75, 90);
+
+ CheckResult(0, 200000, 10, 90);
+
+ AddPacketFeedback(0, 1000, 40, 60);
+
+ EXPECT_EQ(1ul, results_.size());
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698