1 /*
2 * Copyright (c) 2017 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 "modules/audio_processing/aec3/render_delay_controller_metrics.h"
12
13 #include "absl/types/optional.h"
14 #include "modules/audio_processing/aec3/aec3_common.h"
15 #include "system_wrappers/include/metrics.h"
16 #include "test/gtest.h"
17
18 namespace webrtc {
19
20 // Verify the general functionality of RenderDelayControllerMetrics.
TEST(RenderDelayControllerMetrics,NormalUsage)21 TEST(RenderDelayControllerMetrics, NormalUsage) {
22 metrics::Reset();
23
24 RenderDelayControllerMetrics metrics;
25
26 int expected_num_metric_reports = 0;
27
28 for (int j = 0; j < 3; ++j) {
29 for (int k = 0; k < kMetricsReportingIntervalBlocks - 1; ++k) {
30 metrics.Update(absl::nullopt, absl::nullopt,
31 ClockdriftDetector::Level::kNone);
32 }
33 EXPECT_METRIC_EQ(
34 metrics::NumSamples("WebRTC.Audio.EchoCanceller.EchoPathDelay"),
35 expected_num_metric_reports);
36 EXPECT_METRIC_EQ(
37 metrics::NumSamples("WebRTC.Audio.EchoCanceller.BufferDelay"),
38 expected_num_metric_reports);
39 EXPECT_METRIC_EQ(metrics::NumSamples(
40 "WebRTC.Audio.EchoCanceller.ReliableDelayEstimates"),
41 expected_num_metric_reports);
42 EXPECT_METRIC_EQ(
43 metrics::NumSamples("WebRTC.Audio.EchoCanceller.DelayChanges"),
44 expected_num_metric_reports);
45 EXPECT_METRIC_EQ(
46 metrics::NumSamples("WebRTC.Audio.EchoCanceller.Clockdrift"),
47 expected_num_metric_reports);
48
49 // We expect metric reports every kMetricsReportingIntervalBlocks blocks.
50 ++expected_num_metric_reports;
51
52 metrics.Update(absl::nullopt, absl::nullopt,
53 ClockdriftDetector::Level::kNone);
54 EXPECT_METRIC_EQ(
55 metrics::NumSamples("WebRTC.Audio.EchoCanceller.EchoPathDelay"),
56 expected_num_metric_reports);
57 EXPECT_METRIC_EQ(
58 metrics::NumSamples("WebRTC.Audio.EchoCanceller.BufferDelay"),
59 expected_num_metric_reports);
60 EXPECT_METRIC_EQ(metrics::NumSamples(
61 "WebRTC.Audio.EchoCanceller.ReliableDelayEstimates"),
62 expected_num_metric_reports);
63 EXPECT_METRIC_EQ(
64 metrics::NumSamples("WebRTC.Audio.EchoCanceller.DelayChanges"),
65 expected_num_metric_reports);
66 EXPECT_METRIC_EQ(
67 metrics::NumSamples("WebRTC.Audio.EchoCanceller.Clockdrift"),
68 expected_num_metric_reports);
69 }
70 }
71
72 } // namespace webrtc
73