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 | |
tina.legrand@webrtc.org | 73222cf | 2013-03-15 13:29:17 +0000 | [diff] [blame] | 15 | #include "testing/gtest/include/gtest/gtest.h" |
| 16 | #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" |
| 17 | #include "webrtc/modules/audio_coding/main/test/APITest.h" |
| 18 | #include "webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h" |
| 19 | #include "webrtc/modules/audio_coding/main/test/iSACTest.h" |
| 20 | #include "webrtc/modules/audio_coding/main/test/opus_test.h" |
| 21 | #include "webrtc/modules/audio_coding/main/test/TestAllCodecs.h" |
| 22 | #include "webrtc/modules/audio_coding/main/test/TestFEC.h" |
| 23 | #include "webrtc/modules/audio_coding/main/test/TestStereo.h" |
| 24 | #include "webrtc/modules/audio_coding/main/test/TestVADDTX.h" |
| 25 | #include "webrtc/modules/audio_coding/main/test/TwoWayCommunication.h" |
| 26 | #include "webrtc/system_wrappers/interface/trace.h" |
| 27 | #include "webrtc/test/testsupport/fileutils.h" |
henrike@webrtc.org | 89c6740 | 2013-08-02 16:53:47 +0000 | [diff] [blame^] | 28 | #include "webrtc/test/testsupport/gtest_disable.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 | |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 33 | // This parameter is used to describe how to run the tests. It is normally |
| 34 | // set to 1, but in auto test all printing is turned off, and the parameter is |
| 35 | // set to 0. |
| 36 | #define ACM_TEST_MODE 1 |
| 37 | |
| 38 | // TODO(tlegrand): Add all tests as individual gtests, like already done for |
| 39 | // TestAllCodecs (ACM_TEST_ALL_ENC_DEC). |
| 40 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | // Choose what tests to run by defining one or more of the following: |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 42 | // |
| 43 | // ACM_AUTO_TEST - Most common codecs and settings will be tested. All the |
| 44 | // other tests will be activated. |
| 45 | // ACM_TEST_ENC_DEC - You decide what to test in run time. Used for debugging |
| 46 | // and for testing while implementing. |
| 47 | // ACM_TEST_TWO_WAY - Mainly for debugging. |
| 48 | // ACM_TEST_ALL_CODECS - Loop through all defined codecs and settings. |
| 49 | // ACM_TEST_STEREO - Run stereo and spatial audio tests. |
| 50 | // ACM_TEST_VAD_DTX - Run all VAD/DTX tests. |
| 51 | // ACM_TEST_FEC - Test FEC (also called RED). |
| 52 | // ACM_TEST_CODEC_SPEC_API - Test the iSAC has codec specfic APIs. |
| 53 | // ACM_TEST_FULL_API - Test all APIs with threads (long test). |
| 54 | |
| 55 | #define ACM_AUTO_TEST |
| 56 | //#define ACM_TEST_ENC_DEC |
| 57 | //#define ACM_TEST_TWO_WAY |
| 58 | //#define ACM_TEST_ALL_CODECS |
| 59 | //#define ACM_TEST_STEREO |
| 60 | //#define ACM_TEST_VAD_DTX |
| 61 | //#define ACM_TEST_FEC |
| 62 | //#define ACM_TEST_CODEC_SPEC_API |
| 63 | //#define ACM_TEST_FULL_API |
| 64 | |
| 65 | // If Auto test is active, we activate all tests. |
| 66 | #ifdef ACM_AUTO_TEST |
| 67 | #undef ACM_TEST_MODE |
| 68 | #define ACM_TEST_MODE 0 |
| 69 | #ifndef ACM_TEST_ALL_CODECS |
| 70 | #define ACM_TEST_ALL_CODECS |
| 71 | #endif |
| 72 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 74 | void PopulateTests(std::vector<ACMTest*>* tests) { |
| 75 | Trace::CreateTrace(); |
| 76 | Trace::SetTraceFile((webrtc::test::OutputPath() + "acm_trace.txt").c_str()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 78 | printf("The following tests will be executed:\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | #ifdef ACM_AUTO_TEST |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 80 | printf(" ACM auto test\n"); |
| 81 | tests->push_back(new webrtc::EncodeDecodeTest(0)); |
| 82 | tests->push_back(new webrtc::TwoWayCommunication(0)); |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 83 | tests->push_back(new webrtc::TestStereo(0)); |
| 84 | tests->push_back(new webrtc::TestVADDTX(0)); |
| 85 | tests->push_back(new webrtc::TestFEC(0)); |
| 86 | tests->push_back(new webrtc::ISACTest(0)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | #endif |
| 88 | #ifdef ACM_TEST_ENC_DEC |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 89 | printf(" ACM encode-decode test\n"); |
| 90 | tests->push_back(new webrtc::EncodeDecodeTest(2)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | #endif |
| 92 | #ifdef ACM_TEST_TWO_WAY |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 93 | printf(" ACM two-way communication test\n"); |
| 94 | tests->push_back(new webrtc::TwoWayCommunication(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | #ifdef ACM_TEST_STEREO |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 97 | printf(" ACM stereo test\n"); |
| 98 | tests->push_back(new webrtc::TestStereo(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | #endif |
| 100 | #ifdef ACM_TEST_VAD_DTX |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 101 | printf(" ACM VAD-DTX test\n"); |
| 102 | tests->push_back(new webrtc::TestVADDTX(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 103 | #endif |
| 104 | #ifdef ACM_TEST_FEC |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 105 | printf(" ACM FEC test\n"); |
| 106 | tests->push_back(new webrtc::TestFEC(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 107 | #endif |
| 108 | #ifdef ACM_TEST_CODEC_SPEC_API |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 109 | printf(" ACM codec API test\n"); |
| 110 | tests->push_back(new webrtc::ISACTest(1)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | #endif |
| 112 | #ifdef ACM_TEST_FULL_API |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 113 | printf(" ACM full API test\n"); |
| 114 | tests->push_back(new webrtc::APITest()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | #endif |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 116 | printf("\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | } |
| 118 | |
kjellander@webrtc.org | 5490c71 | 2011-12-21 13:34:18 +0000 | [diff] [blame] | 119 | // TODO(kjellander): Make this a proper gtest instead of using this single test |
| 120 | // to run all the tests. |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 121 | |
| 122 | #ifdef ACM_TEST_ALL_CODECS |
| 123 | TEST(AudioCodingModuleTest, TestAllCodecs) { |
| 124 | Trace::CreateTrace(); |
| 125 | Trace::SetTraceFile((webrtc::test::OutputPath() + |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 126 | "acm_allcodecs_trace.txt").c_str()); |
tina.legrand@webrtc.org | 50d5ca5 | 2012-06-18 13:35:52 +0000 | [diff] [blame] | 127 | webrtc::TestAllCodecs(ACM_TEST_MODE).Perform(); |
| 128 | Trace::ReturnTrace(); |
| 129 | } |
| 130 | #endif |
| 131 | |
tina.legrand@webrtc.org | 73222cf | 2013-03-15 13:29:17 +0000 | [diff] [blame] | 132 | TEST(AudioCodingModuleTest, TestOpus) { |
| 133 | Trace::CreateTrace(); |
| 134 | Trace::SetTraceFile((webrtc::test::OutputPath() + |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 135 | "acm_opus_trace.txt").c_str()); |
tina.legrand@webrtc.org | 73222cf | 2013-03-15 13:29:17 +0000 | [diff] [blame] | 136 | webrtc::OpusTest().Perform(); |
| 137 | Trace::ReturnTrace(); |
| 138 | } |
| 139 | |
henrike@webrtc.org | 89c6740 | 2013-08-02 16:53:47 +0000 | [diff] [blame^] | 140 | TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(RunAllTests)) { |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 141 | std::vector<ACMTest*> tests; |
| 142 | PopulateTests(&tests); |
| 143 | std::vector<ACMTest*>::iterator it; |
| 144 | for (it = tests.begin(); it < tests.end(); it++) { |
| 145 | (*it)->Perform(); |
| 146 | delete (*it); |
| 147 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 148 | |
tina.legrand@webrtc.org | 5e7ca60 | 2012-06-12 07:16:24 +0000 | [diff] [blame] | 149 | Trace::ReturnTrace(); |
| 150 | printf("ACM test completed\n"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 151 | } |