blob: b96977b8e473ae318805aa79b542b64836bc58cd [file] [log] [blame]
wu@webrtc.org24301a62013-12-13 19:17:43 +00001/*
2 * Copyright (c) 2013 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "modules/audio_coding/acm2/call_statistics.h"
Jonas Olssona4d87372019-07-05 19:08:33 +020012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "test/gtest.h"
wu@webrtc.org24301a62013-12-13 19:17:43 +000014
15namespace webrtc {
16
17namespace acm2 {
18
19TEST(CallStatisticsTest, InitializedZero) {
20 CallStatistics call_stats;
21 AudioDecodingCallStats stats;
22
23 stats = call_stats.GetDecodingStatistics();
24 EXPECT_EQ(0, stats.calls_to_neteq);
25 EXPECT_EQ(0, stats.calls_to_silence_generator);
26 EXPECT_EQ(0, stats.decoded_normal);
27 EXPECT_EQ(0, stats.decoded_cng);
Alex Narest5b5d97c2019-08-07 18:15:08 +020028 EXPECT_EQ(0, stats.decoded_neteq_plc);
wu@webrtc.org24301a62013-12-13 19:17:43 +000029 EXPECT_EQ(0, stats.decoded_plc_cng);
henrik.lundin63489782016-09-20 01:47:12 -070030 EXPECT_EQ(0, stats.decoded_muted_output);
wu@webrtc.org24301a62013-12-13 19:17:43 +000031}
32
33TEST(CallStatisticsTest, AllCalls) {
34 CallStatistics call_stats;
35 AudioDecodingCallStats stats;
36
37 call_stats.DecodedBySilenceGenerator();
henrik.lundin63489782016-09-20 01:47:12 -070038 call_stats.DecodedByNetEq(AudioFrame::kNormalSpeech, false);
39 call_stats.DecodedByNetEq(AudioFrame::kPLC, false);
Alex Narest5b5d97c2019-08-07 18:15:08 +020040 call_stats.DecodedByNetEq(AudioFrame::kCodecPLC, false);
henrik.lundin63489782016-09-20 01:47:12 -070041 call_stats.DecodedByNetEq(AudioFrame::kPLCCNG, true); // Let this be muted.
42 call_stats.DecodedByNetEq(AudioFrame::kCNG, false);
wu@webrtc.org24301a62013-12-13 19:17:43 +000043
44 stats = call_stats.GetDecodingStatistics();
Alex Narest5b5d97c2019-08-07 18:15:08 +020045 EXPECT_EQ(5, stats.calls_to_neteq);
wu@webrtc.org24301a62013-12-13 19:17:43 +000046 EXPECT_EQ(1, stats.calls_to_silence_generator);
47 EXPECT_EQ(1, stats.decoded_normal);
48 EXPECT_EQ(1, stats.decoded_cng);
Alex Narest5b5d97c2019-08-07 18:15:08 +020049 EXPECT_EQ(1, stats.decoded_neteq_plc);
50 EXPECT_EQ(1, stats.decoded_codec_plc);
wu@webrtc.org24301a62013-12-13 19:17:43 +000051 EXPECT_EQ(1, stats.decoded_plc_cng);
henrik.lundin63489782016-09-20 01:47:12 -070052 EXPECT_EQ(1, stats.decoded_muted_output);
wu@webrtc.org24301a62013-12-13 19:17:43 +000053}
54
55} // namespace acm2
56
57} // namespace webrtc