blob: 8362164161753fc315bb276c34fb411e2166ce99 [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
15#include "audio_coding_module.h"
16#include "trace.h"
17
18#include "APITest.h"
19#include "EncodeDecodeTest.h"
kjellander@webrtc.org5490c712011-12-21 13:34:18 +000020#include "gtest/gtest.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021#include "iSACTest.h"
22#include "SpatialAudio.h"
23#include "TestAllCodecs.h"
24#include "TestFEC.h"
25#include "TestStereo.h"
26#include "TestVADDTX.h"
27#include "TwoWayCommunication.h"
kjellander@webrtc.org5490c712011-12-21 13:34:18 +000028#include "testsupport/fileutils.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000029
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000030using webrtc::AudioCodingModule;
31using webrtc::Trace;
32
niklase@google.com470e71d2011-07-07 08:21:25 +000033// Be sure to create the following directories before running the tests:
34// ./modules/audio_coding/main/test/res_tests
35// ./modules/audio_coding/main/test/res_autotests
36
37// Choose what tests to run by defining one or more of the following:
38#define ACM_AUTO_TEST // Most common codecs and settings will be tested
39//#define ACM_TEST_ENC_DEC // You decide what to test in run time.
40 // Used for debugging and for testing while implementing.
41//#define ACM_TEST_TWO_WAY // Debugging
42//#define ACM_TEST_ALL_ENC_DEC // Loop through all defined codecs and settings
43//#define ACM_TEST_STEREO // Run stereo and spatial audio tests
44//#define ACM_TEST_VAD_DTX // Run all VAD/DTX tests
45//#define ACM_TEST_FEC // Test FEC (also called RED)
46//#define ACM_TEST_CODEC_SPEC_API // Only iSAC has codec specfic APIs in this version
47//#define ACM_TEST_FULL_API // Test all APIs with threads (long test)
48
49
50void PopulateTests(std::vector<ACMTest*>* tests)
51{
52
53 Trace::CreateTrace();
kjellander@webrtc.org5490c712011-12-21 13:34:18 +000054 std::string trace_file = webrtc::test::OutputPath() + "acm_trace.txt";
55 Trace::SetTraceFile(trace_file.c_str());
niklase@google.com470e71d2011-07-07 08:21:25 +000056
57 printf("The following tests will be executed:\n");
58#ifdef ACM_AUTO_TEST
59 printf(" ACM auto test\n");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000060 tests->push_back(new webrtc::EncodeDecodeTest(0));
61 tests->push_back(new webrtc::TwoWayCommunication(0));
62 tests->push_back(new webrtc::TestAllCodecs(0));
63 tests->push_back(new webrtc::TestStereo(0));
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +000064// tests->push_back(new webrtc::SpatialAudio(0));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000065 tests->push_back(new webrtc::TestVADDTX(0));
66 tests->push_back(new webrtc::TestFEC(0));
67 tests->push_back(new webrtc::ISACTest(0));
niklase@google.com470e71d2011-07-07 08:21:25 +000068#endif
69#ifdef ACM_TEST_ENC_DEC
70 printf(" ACM encode-decode test\n");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000071 tests->push_back(new webrtc::EncodeDecodeTest(2));
niklase@google.com470e71d2011-07-07 08:21:25 +000072#endif
73#ifdef ACM_TEST_TWO_WAY
74 printf(" ACM two-way communication test\n");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000075 tests->push_back(new webrtc::TwoWayCommunication(1));
niklase@google.com470e71d2011-07-07 08:21:25 +000076#endif
77#ifdef ACM_TEST_ALL_ENC_DEC
78 printf(" ACM all codecs test\n");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000079 tests->push_back(new webrtc::TestAllCodecs(1));
niklase@google.com470e71d2011-07-07 08:21:25 +000080#endif
81#ifdef ACM_TEST_STEREO
82 printf(" ACM stereo test\n");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000083 tests->push_back(new webrtc::TestStereo(1));
tina.legrand@webrtc.org16b6b902012-04-12 11:02:38 +000084 //tests->push_back(new webrtc::SpatialAudio(2));
niklase@google.com470e71d2011-07-07 08:21:25 +000085#endif
86#ifdef ACM_TEST_VAD_DTX
87 printf(" ACM VAD-DTX test\n");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000088 tests->push_back(new webrtc::TestVADDTX(1));
niklase@google.com470e71d2011-07-07 08:21:25 +000089#endif
90#ifdef ACM_TEST_FEC
91 printf(" ACM FEC test\n");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000092 tests->push_back(new webrtc::TestFEC(1));
niklase@google.com470e71d2011-07-07 08:21:25 +000093#endif
94#ifdef ACM_TEST_CODEC_SPEC_API
95 printf(" ACM codec API test\n");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000096 tests->push_back(new webrtc::ISACTest(1));
niklase@google.com470e71d2011-07-07 08:21:25 +000097#endif
98#ifdef ACM_TEST_FULL_API
99 printf(" ACM full API test\n");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000100 tests->push_back(new webrtc::APITest());
niklase@google.com470e71d2011-07-07 08:21:25 +0000101#endif
102 printf("\n");
103}
104
kjellander@webrtc.org5490c712011-12-21 13:34:18 +0000105// TODO(kjellander): Make this a proper gtest instead of using this single test
106// to run all the tests.
107TEST(AudioCodingModuleTest, RunAllTests)
niklase@google.com470e71d2011-07-07 08:21:25 +0000108{
109 std::vector<ACMTest*> tests;
110 PopulateTests(&tests);
111 std::vector<ACMTest*>::iterator it;
niklase@google.com470e71d2011-07-07 08:21:25 +0000112 for (it=tests.begin() ; it < tests.end(); it++)
113 {
kjellander@webrtc.org5490c712011-12-21 13:34:18 +0000114 (*it)->Perform();
niklase@google.com470e71d2011-07-07 08:21:25 +0000115 delete (*it);
116 }
117
118 Trace::ReturnTrace();
119 printf("ACM test completed\n");
niklase@google.com470e71d2011-07-07 08:21:25 +0000120}