niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 <stdio.h> |
kjellander@webrtc.org | 5490c71 | 2011-12-21 13:34:18 +0000 | [diff] [blame] | 12 | #include <string> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | #include <vector> |
| 14 | |
| 15 | #include "audio_coding_module.h" |
| 16 | #include "trace.h" |
| 17 | |
| 18 | #include "APITest.h" |
| 19 | #include "EncodeDecodeTest.h" |
kjellander@webrtc.org | 5490c71 | 2011-12-21 13:34:18 +0000 | [diff] [blame] | 20 | #include "gtest/gtest.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | #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.org | 5490c71 | 2011-12-21 13:34:18 +0000 | [diff] [blame] | 28 | #include "testsupport/fileutils.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 30 | using webrtc::AudioCodingModule; |
| 31 | using webrtc::Trace; |
| 32 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | // 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 | |
| 50 | void PopulateTests(std::vector<ACMTest*>* tests) |
| 51 | { |
| 52 | |
| 53 | Trace::CreateTrace(); |
kjellander@webrtc.org | 5490c71 | 2011-12-21 13:34:18 +0000 | [diff] [blame] | 54 | std::string trace_file = webrtc::test::OutputPath() + "acm_trace.txt"; |
| 55 | Trace::SetTraceFile(trace_file.c_str()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | |
| 57 | printf("The following tests will be executed:\n"); |
| 58 | #ifdef ACM_AUTO_TEST |
| 59 | printf(" ACM auto test\n"); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 60 | 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.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame^] | 64 | // tests->push_back(new webrtc::SpatialAudio(0)); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 65 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | #endif |
| 69 | #ifdef ACM_TEST_ENC_DEC |
| 70 | printf(" ACM encode-decode test\n"); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 71 | tests->push_back(new webrtc::EncodeDecodeTest(2)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 72 | #endif |
| 73 | #ifdef ACM_TEST_TWO_WAY |
| 74 | printf(" ACM two-way communication test\n"); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 75 | tests->push_back(new webrtc::TwoWayCommunication(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | #endif |
| 77 | #ifdef ACM_TEST_ALL_ENC_DEC |
| 78 | printf(" ACM all codecs test\n"); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 79 | tests->push_back(new webrtc::TestAllCodecs(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | #endif |
| 81 | #ifdef ACM_TEST_STEREO |
| 82 | printf(" ACM stereo test\n"); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 83 | tests->push_back(new webrtc::TestStereo(1)); |
tina.legrand@webrtc.org | 16b6b90 | 2012-04-12 11:02:38 +0000 | [diff] [blame^] | 84 | //tests->push_back(new webrtc::SpatialAudio(2)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | #endif |
| 86 | #ifdef ACM_TEST_VAD_DTX |
| 87 | printf(" ACM VAD-DTX test\n"); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 88 | tests->push_back(new webrtc::TestVADDTX(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | #endif |
| 90 | #ifdef ACM_TEST_FEC |
| 91 | printf(" ACM FEC test\n"); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 92 | tests->push_back(new webrtc::TestFEC(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | #endif |
| 94 | #ifdef ACM_TEST_CODEC_SPEC_API |
| 95 | printf(" ACM codec API test\n"); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 96 | tests->push_back(new webrtc::ISACTest(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | #endif |
| 98 | #ifdef ACM_TEST_FULL_API |
| 99 | printf(" ACM full API test\n"); |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 100 | tests->push_back(new webrtc::APITest()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | #endif |
| 102 | printf("\n"); |
| 103 | } |
| 104 | |
kjellander@webrtc.org | 5490c71 | 2011-12-21 13:34:18 +0000 | [diff] [blame] | 105 | // TODO(kjellander): Make this a proper gtest instead of using this single test |
| 106 | // to run all the tests. |
| 107 | TEST(AudioCodingModuleTest, RunAllTests) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 108 | { |
| 109 | std::vector<ACMTest*> tests; |
| 110 | PopulateTests(&tests); |
| 111 | std::vector<ACMTest*>::iterator it; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | for (it=tests.begin() ; it < tests.end(); it++) |
| 113 | { |
kjellander@webrtc.org | 5490c71 | 2011-12-21 13:34:18 +0000 | [diff] [blame] | 114 | (*it)->Perform(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | delete (*it); |
| 116 | } |
| 117 | |
| 118 | Trace::ReturnTrace(); |
| 119 | printf("ACM test completed\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 120 | } |