blob: 3ff3dd8cd4d5fb5a63ac469496328551125659ed [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 <stdio.h>
kjellander@webrtc.org5490c712011-12-21 13:34:18 +000012#include <string>
niklase@google.com470e71d2011-07-07 08:21:25 +000013#include <vector>
14
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000015#include "testing/gtest/include/gtest/gtest.h"
kjellander3e6db232015-11-26 04:44:54 -080016#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
17#include "webrtc/modules/audio_coding/test/APITest.h"
18#include "webrtc/modules/audio_coding/test/EncodeDecodeTest.h"
19#include "webrtc/modules/audio_coding/test/iSACTest.h"
20#include "webrtc/modules/audio_coding/test/opus_test.h"
21#include "webrtc/modules/audio_coding/test/PacketLossTest.h"
22#include "webrtc/modules/audio_coding/test/TestAllCodecs.h"
23#include "webrtc/modules/audio_coding/test/TestRedFec.h"
24#include "webrtc/modules/audio_coding/test/TestStereo.h"
25#include "webrtc/modules/audio_coding/test/TestVADDTX.h"
26#include "webrtc/modules/audio_coding/test/TwoWayCommunication.h"
Henrik Kjellander98f53512015-10-28 18:17:40 +010027#include "webrtc/system_wrappers/include/trace.h"
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000028#include "webrtc/test/testsupport/fileutils.h"
henrike@webrtc.org89c67402013-08-02 16:53:47 +000029#include "webrtc/test/testsupport/gtest_disable.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000030
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000031using webrtc::Trace;
32
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000033// This parameter is used to describe how to run the tests. It is normally
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000034// set to 0, and all tests are run in quite mode.
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000035#define ACM_TEST_MODE 0
niklase@google.com470e71d2011-07-07 08:21:25 +000036
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000037TEST(AudioCodingModuleTest, TestAllCodecs) {
38 Trace::CreateTrace();
39 Trace::SetTraceFile((webrtc::test::OutputPath() +
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000040 "acm_allcodecs_trace.txt").c_str());
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000041 webrtc::TestAllCodecs(ACM_TEST_MODE).Perform();
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +000042 Trace::ReturnTrace();
43}
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000044
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +000045TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(TestEncodeDecode)) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000046 Trace::CreateTrace();
47 Trace::SetTraceFile((webrtc::test::OutputPath() +
48 "acm_encodedecode_trace.txt").c_str());
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000049 webrtc::EncodeDecodeTest(ACM_TEST_MODE).Perform();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000050 Trace::ReturnTrace();
51}
52
kwiberg98ab3a42015-09-30 21:54:21 -070053#ifdef WEBRTC_CODEC_RED
54#define IF_RED(x) x
55#else
56#define IF_RED(x) DISABLED_##x
57#endif
58
59TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(IF_RED(TestRedFec))) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000060 Trace::CreateTrace();
61 Trace::SetTraceFile((webrtc::test::OutputPath() +
62 "acm_fec_trace.txt").c_str());
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000063 webrtc::TestRedFec().Perform();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000064 Trace::ReturnTrace();
65}
66
kwiberg98ab3a42015-09-30 21:54:21 -070067#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
68#define IF_ISAC(x) x
69#else
70#define IF_ISAC(x) DISABLED_##x
71#endif
72
73TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(IF_ISAC(TestIsac))) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000074 Trace::CreateTrace();
75 Trace::SetTraceFile((webrtc::test::OutputPath() +
76 "acm_isac_trace.txt").c_str());
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000077 webrtc::ISACTest(ACM_TEST_MODE).Perform();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000078 Trace::ReturnTrace();
79}
80
kwiberg98ab3a42015-09-30 21:54:21 -070081#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \
82 defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722)
83#define IF_ALL_CODECS(x) x
84#else
85#define IF_ALL_CODECS(x) DISABLED_##x
86#endif
87
88TEST(AudioCodingModuleTest,
89 DISABLED_ON_ANDROID(IF_ALL_CODECS(TwoWayCommunication))) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000090 Trace::CreateTrace();
91 Trace::SetTraceFile((webrtc::test::OutputPath() +
92 "acm_twowaycom_trace.txt").c_str());
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000093 webrtc::TwoWayCommunication(ACM_TEST_MODE).Perform();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000094 Trace::ReturnTrace();
95}
96
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +000097TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(TestStereo)) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000098 Trace::CreateTrace();
99 Trace::SetTraceFile((webrtc::test::OutputPath() +
100 "acm_stereo_trace.txt").c_str());
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000101 webrtc::TestStereo(ACM_TEST_MODE).Perform();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000102 Trace::ReturnTrace();
103}
104
minyue@webrtc.org05617162015-03-03 12:02:30 +0000105TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(TestWebRtcVadDtx)) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000106 Trace::CreateTrace();
107 Trace::SetTraceFile((webrtc::test::OutputPath() +
108 "acm_vaddtx_trace.txt").c_str());
minyue@webrtc.org05617162015-03-03 12:02:30 +0000109 webrtc::TestWebRtcVadDtx().Perform();
110 Trace::ReturnTrace();
111}
112
113TEST(AudioCodingModuleTest, TestOpusDtx) {
114 Trace::CreateTrace();
115 Trace::SetTraceFile((webrtc::test::OutputPath() +
116 "acm_opusdtx_trace.txt").c_str());
117 webrtc::TestOpusDtx().Perform();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000118 Trace::ReturnTrace();
119}
tina.legrand@webrtc.org50d5ca52012-06-18 13:35:52 +0000120
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +0000121TEST(AudioCodingModuleTest, TestOpus) {
122 Trace::CreateTrace();
123 Trace::SetTraceFile((webrtc::test::OutputPath() +
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000124 "acm_opus_trace.txt").c_str());
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000125 webrtc::OpusTest().Perform();
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +0000126 Trace::ReturnTrace();
127}
128
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000129TEST(AudioCodingModuleTest, TestPacketLoss) {
130 Trace::CreateTrace();
131 Trace::SetTraceFile((webrtc::test::OutputPath() +
132 "acm_packetloss_trace.txt").c_str());
133 webrtc::PacketLossTest(1, 10, 10, 1).Perform();
134 Trace::ReturnTrace();
135}
136
137TEST(AudioCodingModuleTest, TestPacketLossBurst) {
138 Trace::CreateTrace();
139 Trace::SetTraceFile((webrtc::test::OutputPath() +
140 "acm_packetloss_burst_trace.txt").c_str());
141 webrtc::PacketLossTest(1, 10, 10, 2).Perform();
142 Trace::ReturnTrace();
143}
144
145TEST(AudioCodingModuleTest, TestPacketLossStereo) {
146 Trace::CreateTrace();
147 Trace::SetTraceFile((webrtc::test::OutputPath() +
148 "acm_packetloss_trace.txt").c_str());
149 webrtc::PacketLossTest(2, 10, 10, 1).Perform();
150 Trace::ReturnTrace();
151}
152
153TEST(AudioCodingModuleTest, TestPacketLossStereoBurst) {
154 Trace::CreateTrace();
155 Trace::SetTraceFile((webrtc::test::OutputPath() +
156 "acm_packetloss_burst_trace.txt").c_str());
157 webrtc::PacketLossTest(2, 10, 10, 2).Perform();
158 Trace::ReturnTrace();
159}
160
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000161// The full API test is too long to run automatically on bots, but can be used
162// for offline testing. User interaction is needed.
163#ifdef ACM_TEST_FULL_API
164 TEST(AudioCodingModuleTest, TestAPI) {
165 Trace::CreateTrace();
166 Trace::SetTraceFile((webrtc::test::OutputPath() +
167 "acm_apitest_trace.txt").c_str());
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000168 webrtc::APITest().Perform();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000169 Trace::ReturnTrace();
tina.legrand@webrtc.org5e7ca602012-06-12 07:16:24 +0000170 }
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000171#endif