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

Unified Diff: webrtc/rtc_base/moving_max_counter_unittest.cc

Issue 2995143002: Report max interframe delay over window insdead of interframe delay sum (Closed)
Patch Set: Implemented Sprang@ comments Created 3 years, 4 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/rtc_base/moving_max_counter_unittest.cc
diff --git a/webrtc/rtc_base/moving_max_counter_unittest.cc b/webrtc/rtc_base/moving_max_counter_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..792c19701d5206582618aef67ea0173912ba71c8
--- /dev/null
+++ b/webrtc/rtc_base/moving_max_counter_unittest.cc
@@ -0,0 +1,45 @@
+/*
+ * 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/rtc_base/moving_max_counter.h"
+#include "webrtc/test/gtest.h"
+
+TEST(MovingMaxCounter, ReportsMaximumInTheWindow) {
+ rtc::MovingMaxCounter<int> counter(100);
+ counter.Add(1, 1);
+ EXPECT_EQ(*counter.MovingMax(1), 1);
+ counter.Add(2, 30);
+ EXPECT_EQ(*counter.MovingMax(30), 2);
+ counter.Add(100, 60);
+ EXPECT_EQ(*counter.MovingMax(60), 100);
+ counter.Add(4, 70);
+ EXPECT_EQ(*counter.MovingMax(70), 100);
+ counter.Add(5, 90);
+ EXPECT_EQ(*counter.MovingMax(90), 100);
+}
+
+TEST(MovingMaxCounter, IgnoresOldElements) {
+ rtc::MovingMaxCounter<int> counter(100);
+ counter.Add(1, 1);
+ counter.Add(2, 30);
+ counter.Add(100, 60);
+ counter.Add(5, 70);
+ counter.Add(4, 90);
+ EXPECT_EQ(*counter.MovingMax(160), 100);
+ // 100 is now out of the window.
+ EXPECT_EQ(*counter.MovingMax(161), 5);
+}
+
+TEST(MovingMaxCounter, HandlesEmptyWindow) {
+ rtc::MovingMaxCounter<int> counter(100);
+ counter.Add(123, 1);
+ EXPECT_TRUE(counter.MovingMax(101).has_value());
+ EXPECT_FALSE(counter.MovingMax(102).has_value());
+}
sprang_webrtc 2017/08/21 14:41:09 Add a test coverage for duplicate data points for
ilnik 2017/08/21 14:59:27 Done.

Powered by Google App Engine
This is Rietveld 408576698