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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 #include "webrtc/modules/audio_processing/utility/mean_calculator.h"
14
15 namespace webrtc {
16
17 TEST(MeanCalculatorTest, Correctness) {
18 const size_t kWindowLength = 10;
19 MeanCalculator mean_calculator(kWindowLength);
20 size_t i = 0;
21 for (; i < kWindowLength; ++i) {
22 EXPECT_FALSE(mean_calculator.IsWindowFull()) << i;
23 EXPECT_FALSE(mean_calculator.GetMean());
24 mean_calculator.AddSample(static_cast<float>(i));
25 }
26 for (; i < 3 * kWindowLength; ++i) {
27 EXPECT_TRUE(mean_calculator.IsWindowFull());
28 // (i - kWindowLength) ... (i - 1)
29 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
30 mean_calculator.AddSample(static_cast<float>(i));
31 }
32 }
33
34 TEST(MeanCalculatorTest, Clear) {
35 const size_t kWindowLength = 10;
36 MeanCalculator mean_calculator(kWindowLength);
37 for (size_t i = 0; i < kWindowLength; ++i) {
38 mean_calculator.AddSample(static_cast<float>(i));
39 }
40 EXPECT_TRUE(mean_calculator.IsWindowFull());
41 mean_calculator.Clear();
42
43 for (size_t i = 0; i < kWindowLength; ++i) {
44 EXPECT_FALSE(mean_calculator.IsWindowFull());
45 EXPECT_FALSE(mean_calculator.GetMean());
46 mean_calculator.AddSample(static_cast<float>(i));
47 }
48 EXPECT_TRUE(mean_calculator.IsWindowFull());
49 EXPECT_EQ(0.5 * (kWindowLength - 1), *mean_calculator.GetMean());
50 }
51
52 } // namespace webrt
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698