xref: /aosp_15_r20/external/webrtc/modules/audio_coding/acm2/call_statistics_unittest.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
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 
11 #include "modules/audio_coding/acm2/call_statistics.h"
12 
13 #include "test/gtest.h"
14 
15 namespace webrtc {
16 
17 namespace acm2 {
18 
TEST(CallStatisticsTest,InitializedZero)19 TEST(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);
28   EXPECT_EQ(0, stats.decoded_neteq_plc);
29   EXPECT_EQ(0, stats.decoded_plc_cng);
30   EXPECT_EQ(0, stats.decoded_muted_output);
31 }
32 
TEST(CallStatisticsTest,AllCalls)33 TEST(CallStatisticsTest, AllCalls) {
34   CallStatistics call_stats;
35   AudioDecodingCallStats stats;
36 
37   call_stats.DecodedBySilenceGenerator();
38   call_stats.DecodedByNetEq(AudioFrame::kNormalSpeech, false);
39   call_stats.DecodedByNetEq(AudioFrame::kPLC, false);
40   call_stats.DecodedByNetEq(AudioFrame::kCodecPLC, false);
41   call_stats.DecodedByNetEq(AudioFrame::kPLCCNG, true);  // Let this be muted.
42   call_stats.DecodedByNetEq(AudioFrame::kCNG, false);
43 
44   stats = call_stats.GetDecodingStatistics();
45   EXPECT_EQ(5, stats.calls_to_neteq);
46   EXPECT_EQ(1, stats.calls_to_silence_generator);
47   EXPECT_EQ(1, stats.decoded_normal);
48   EXPECT_EQ(1, stats.decoded_cng);
49   EXPECT_EQ(1, stats.decoded_neteq_plc);
50   EXPECT_EQ(1, stats.decoded_codec_plc);
51   EXPECT_EQ(1, stats.decoded_plc_cng);
52   EXPECT_EQ(1, stats.decoded_muted_output);
53 }
54 
55 }  // namespace acm2
56 
57 }  // namespace webrtc
58