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

Unified Diff: webrtc/modules/audio_processing/utility/mean_calculator_unittest.cc

Issue 1739993003: Adding fraction of filter divergence in AEC metrics. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: addressing Per's comments Created 4 years, 9 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/audio_processing/utility/mean_calculator_unittest.cc
diff --git a/webrtc/modules/audio_processing/utility/mean_calculator_unittest.cc b/webrtc/modules/audio_processing/utility/mean_calculator_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..49745e1fdd631ef93defa81cc5a1340bbd9b314f
--- /dev/null
+++ b/webrtc/modules/audio_processing/utility/mean_calculator_unittest.cc
@@ -0,0 +1,52 @@
+/*
+ * 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 "testing/gtest/include/gtest/gtest.h"
+
+#include "webrtc/modules/audio_processing/utility/mean_calculator.h"
+
+namespace webrtc {
+
+TEST(MeanCalculatorTest, Correctness) {
+ const size_t kWindowLength = 10;
+ MeanCalculator mean_calculator(kWindowLength);
+ size_t i = 0;
+ for (; i < kWindowLength; ++i) {
+ EXPECT_FALSE(mean_calculator.IsWindowFull()) << i;
+ EXPECT_FALSE(mean_calculator.GetMean());
+ mean_calculator.AddSample(static_cast<float>(i));
+ }
+ for (; i < 3 * kWindowLength; ++i) {
+ EXPECT_TRUE(mean_calculator.IsWindowFull());
+ // (i - kWindowLength) ... (i - 1)
+ EXPECT_EQ(i - 0.5 * (1 + kWindowLength), *mean_calculator.GetMean());
peah-webrtc 2016/03/15 09:18:41 The test tests the accuracy of the mean calculator
+ mean_calculator.AddSample(static_cast<float>(i));
+ }
+}
+
+TEST(MeanCalculatorTest, Clear) {
+ const size_t kWindowLength = 10;
+ MeanCalculator mean_calculator(kWindowLength);
+ for (size_t i = 0; i < kWindowLength; ++i) {
+ mean_calculator.AddSample(static_cast<float>(i));
+ }
+ EXPECT_TRUE(mean_calculator.IsWindowFull());
+ mean_calculator.Clear();
+
+ for (size_t i = 0; i < kWindowLength; ++i) {
+ EXPECT_FALSE(mean_calculator.IsWindowFull());
+ EXPECT_FALSE(mean_calculator.GetMean());
+ mean_calculator.AddSample(static_cast<float>(i));
+ }
+ EXPECT_TRUE(mean_calculator.IsWindowFull());
+ EXPECT_EQ(0.5 * (kWindowLength - 1), *mean_calculator.GetMean());
+}
+
+} // namespace webrt

Powered by Google App Engine
This is Rietveld 408576698