| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2012 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 "webrtc/test/testsupport/fileutils.h" | |
| 12 #include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h" | |
| 13 #include "webrtc/voice_engine/test/auto_test/voe_standard_test.h" | |
| 14 | |
| 15 class AudioProcessingTest : public AfterStreamingFixture { | |
| 16 protected: | |
| 17 // Note: Be careful with this one, it is used in the | |
| 18 // Android / iPhone part too. | |
| 19 void TryEnablingAgcWithMode(webrtc::AgcModes agc_mode_to_set) { | |
| 20 EXPECT_EQ(0, voe_apm_->SetAgcStatus(true, agc_mode_to_set)); | |
| 21 | |
| 22 bool agc_enabled = false; | |
| 23 webrtc::AgcModes agc_mode = webrtc::kAgcDefault; | |
| 24 | |
| 25 EXPECT_EQ(0, voe_apm_->GetAgcStatus(agc_enabled, agc_mode)); | |
| 26 EXPECT_TRUE(agc_enabled); | |
| 27 EXPECT_EQ(agc_mode_to_set, agc_mode); | |
| 28 } | |
| 29 | |
| 30 // EC modes can map to other EC modes, so we have a separate parameter | |
| 31 // for what we expect the EC mode to be set to. | |
| 32 void TryEnablingEcWithMode(webrtc::EcModes ec_mode_to_set, | |
| 33 webrtc::EcModes expected_mode) { | |
| 34 EXPECT_EQ(0, voe_apm_->SetEcStatus(true, ec_mode_to_set)); | |
| 35 | |
| 36 bool ec_enabled = true; | |
| 37 webrtc::EcModes ec_mode = webrtc::kEcDefault; | |
| 38 | |
| 39 EXPECT_EQ(0, voe_apm_->GetEcStatus(ec_enabled, ec_mode)); | |
| 40 | |
| 41 EXPECT_EQ(expected_mode, ec_mode); | |
| 42 } | |
| 43 | |
| 44 // Here, the CNG mode will be expected to be on or off depending on the mode. | |
| 45 void TryEnablingAecmWithMode(webrtc::AecmModes aecm_mode_to_set, | |
| 46 bool cng_enabled_to_set) { | |
| 47 EXPECT_EQ(0, voe_apm_->SetAecmMode(aecm_mode_to_set, cng_enabled_to_set)); | |
| 48 | |
| 49 bool cng_enabled = false; | |
| 50 webrtc::AecmModes aecm_mode = webrtc::kAecmEarpiece; | |
| 51 | |
| 52 voe_apm_->GetAecmMode(aecm_mode, cng_enabled); | |
| 53 | |
| 54 EXPECT_EQ(cng_enabled_to_set, cng_enabled); | |
| 55 EXPECT_EQ(aecm_mode_to_set, aecm_mode); | |
| 56 } | |
| 57 | |
| 58 void TryEnablingNsWithMode(webrtc::NsModes ns_mode_to_set, | |
| 59 webrtc::NsModes expected_ns_mode) { | |
| 60 EXPECT_EQ(0, voe_apm_->SetNsStatus(true, ns_mode_to_set)); | |
| 61 | |
| 62 bool ns_status = true; | |
| 63 webrtc::NsModes ns_mode = webrtc::kNsDefault; | |
| 64 EXPECT_EQ(0, voe_apm_->GetNsStatus(ns_status, ns_mode)); | |
| 65 | |
| 66 EXPECT_TRUE(ns_status); | |
| 67 EXPECT_EQ(expected_ns_mode, ns_mode); | |
| 68 } | |
| 69 }; | |
| 70 | |
| 71 #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) | |
| 72 | |
| 73 // Duplicated in apm_helpers_unittest.cc. | |
| 74 TEST_F(AudioProcessingTest, AgcIsOnByDefault) { | |
| 75 bool agc_enabled = false; | |
| 76 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; | |
| 77 | |
| 78 EXPECT_EQ(0, voe_apm_->GetAgcStatus(agc_enabled, agc_mode)); | |
| 79 EXPECT_TRUE(agc_enabled); | |
| 80 EXPECT_EQ(webrtc::kAgcAdaptiveAnalog, agc_mode); | |
| 81 } | |
| 82 | |
| 83 // Duplicated in apm_helpers_unittest.cc. | |
| 84 TEST_F(AudioProcessingTest, CanEnableAgcWithAllModes) { | |
| 85 TryEnablingAgcWithMode(webrtc::kAgcAdaptiveDigital); | |
| 86 TryEnablingAgcWithMode(webrtc::kAgcAdaptiveAnalog); | |
| 87 TryEnablingAgcWithMode(webrtc::kAgcFixedDigital); | |
| 88 } | |
| 89 | |
| 90 // Duplicated in apm_helpers_unittest.cc. | |
| 91 TEST_F(AudioProcessingTest, EcIsDisabledAndAecIsDefaultEcMode) { | |
| 92 bool ec_enabled = true; | |
| 93 webrtc::EcModes ec_mode = webrtc::kEcDefault; | |
| 94 | |
| 95 EXPECT_EQ(0, voe_apm_->GetEcStatus(ec_enabled, ec_mode)); | |
| 96 EXPECT_FALSE(ec_enabled); | |
| 97 EXPECT_EQ(webrtc::kEcAec, ec_mode); | |
| 98 } | |
| 99 | |
| 100 // Not needed anymore - apm_helpers::SetEcStatus() doesn't take kEcAec. | |
| 101 TEST_F(AudioProcessingTest, EnablingEcAecShouldEnableEcAec) { | |
| 102 TryEnablingEcWithMode(webrtc::kEcAec, webrtc::kEcAec); | |
| 103 } | |
| 104 | |
| 105 // Duplicated in apm_helpers_unittest.cc. | |
| 106 TEST_F(AudioProcessingTest, EnablingEcConferenceShouldEnableEcAec) { | |
| 107 TryEnablingEcWithMode(webrtc::kEcConference, webrtc::kEcAec); | |
| 108 } | |
| 109 | |
| 110 // Not needed anymore - apm_helpers::SetEcStatus() doesn't take kEcDefault. | |
| 111 TEST_F(AudioProcessingTest, EcModeIsPreservedWhenEcIsTurnedOff) { | |
| 112 TryEnablingEcWithMode(webrtc::kEcConference, webrtc::kEcAec); | |
| 113 | |
| 114 EXPECT_EQ(0, voe_apm_->SetEcStatus(false)); | |
| 115 | |
| 116 bool ec_enabled = true; | |
| 117 webrtc::EcModes ec_mode = webrtc::kEcDefault; | |
| 118 EXPECT_EQ(0, voe_apm_->GetEcStatus(ec_enabled, ec_mode)); | |
| 119 | |
| 120 EXPECT_FALSE(ec_enabled); | |
| 121 EXPECT_EQ(webrtc::kEcAec, ec_mode); | |
| 122 } | |
| 123 | |
| 124 // Not needed anymore - apm_helpers::SetEcStatus() doesn't take kEcDefault. | |
| 125 TEST_F(AudioProcessingTest, CanEnableAndDisableEcModeSeveralTimesInARow) { | |
| 126 for (int i = 0; i < 10; i++) { | |
| 127 EXPECT_EQ(0, voe_apm_->SetEcStatus(true)); | |
| 128 EXPECT_EQ(0, voe_apm_->SetEcStatus(false)); | |
| 129 } | |
| 130 | |
| 131 bool ec_enabled = true; | |
| 132 webrtc::EcModes ec_mode = webrtc::kEcDefault; | |
| 133 EXPECT_EQ(0, voe_apm_->GetEcStatus(ec_enabled, ec_mode)); | |
| 134 | |
| 135 EXPECT_FALSE(ec_enabled); | |
| 136 EXPECT_EQ(webrtc::kEcAec, ec_mode); | |
| 137 } | |
| 138 | |
| 139 #endif // !WEBRTC_IOS && !WEBRTC_ANDROID | |
| 140 | |
| 141 // Duplicated in apm_helpers_unittest.cc. | |
| 142 TEST_F(AudioProcessingTest, EnablingEcAecmShouldEnableEcAecm) { | |
| 143 // This one apparently applies to Android and iPhone as well. | |
| 144 TryEnablingEcWithMode(webrtc::kEcAecm, webrtc::kEcAecm); | |
| 145 } | |
| 146 | |
| 147 // Duplicated in apm_helpers_unittest.cc. | |
| 148 TEST_F(AudioProcessingTest, EcAecmModeIsEnabledAndSpeakerphoneByDefault) { | |
| 149 bool cng_enabled = false; | |
| 150 webrtc::AecmModes aecm_mode = webrtc::kAecmEarpiece; | |
| 151 | |
| 152 voe_apm_->GetAecmMode(aecm_mode, cng_enabled); | |
| 153 | |
| 154 EXPECT_TRUE(cng_enabled); | |
| 155 EXPECT_EQ(webrtc::kAecmSpeakerphone, aecm_mode); | |
| 156 } | |
| 157 | |
| 158 // Duplicated in apm_helpers_unittest.cc. | |
| 159 TEST_F(AudioProcessingTest, CanSetAecmMode) { | |
| 160 EXPECT_EQ(0, voe_apm_->SetEcStatus(true, webrtc::kEcAecm)); | |
| 161 | |
| 162 // Try some AECM mode - CNG enabled combinations. | |
| 163 TryEnablingAecmWithMode(webrtc::kAecmEarpiece, true); | |
| 164 TryEnablingAecmWithMode(webrtc::kAecmEarpiece, false); | |
| 165 TryEnablingAecmWithMode(webrtc::kAecmLoudEarpiece, true); | |
| 166 TryEnablingAecmWithMode(webrtc::kAecmLoudSpeakerphone, false); | |
| 167 TryEnablingAecmWithMode(webrtc::kAecmQuietEarpieceOrHeadset, true); | |
| 168 TryEnablingAecmWithMode(webrtc::kAecmSpeakerphone, false); | |
| 169 } | |
| 170 | |
| 171 // Duplicated in apm_helpers_unittest.cc. | |
| 172 TEST_F(AudioProcessingTest, NsIsOffWithModerateSuppressionByDefault) { | |
| 173 bool ns_status = true; | |
| 174 webrtc::NsModes ns_mode = webrtc::kNsDefault; | |
| 175 EXPECT_EQ(0, voe_apm_->GetNsStatus(ns_status, ns_mode)); | |
| 176 | |
| 177 EXPECT_FALSE(ns_status); | |
| 178 EXPECT_EQ(webrtc::kNsModerateSuppression, ns_mode); | |
| 179 } | |
| 180 | |
| 181 // Duplicated in apm_helpers_unittest.cc. | |
| 182 TEST_F(AudioProcessingTest, CanSetNsMode) { | |
| 183 // Concrete suppression values map to themselves. | |
| 184 TryEnablingNsWithMode(webrtc::kNsHighSuppression, | |
| 185 webrtc::kNsHighSuppression); | |
| 186 TryEnablingNsWithMode(webrtc::kNsLowSuppression, | |
| 187 webrtc::kNsLowSuppression); | |
| 188 TryEnablingNsWithMode(webrtc::kNsModerateSuppression, | |
| 189 webrtc::kNsModerateSuppression); | |
| 190 TryEnablingNsWithMode(webrtc::kNsVeryHighSuppression, | |
| 191 webrtc::kNsVeryHighSuppression); | |
| 192 | |
| 193 // Conference and Default map to concrete values. | |
| 194 TryEnablingNsWithMode(webrtc::kNsConference, | |
| 195 webrtc::kNsHighSuppression); | |
| 196 TryEnablingNsWithMode(webrtc::kNsDefault, | |
| 197 webrtc::kNsModerateSuppression); | |
| 198 } | |
| 199 | |
| 200 // TODO(solenberg): Duplicate this test at the voe::Channel layer. | |
| 201 // Not needed anymore - API is unused. | |
| 202 TEST_F(AudioProcessingTest, VadIsDisabledByDefault) { | |
| 203 bool vad_enabled; | |
| 204 bool disabled_dtx; | |
| 205 webrtc::VadModes vad_mode; | |
| 206 | |
| 207 EXPECT_EQ(0, voe_codec_->GetVADStatus( | |
| 208 channel_, vad_enabled, vad_mode, disabled_dtx)); | |
| 209 | |
| 210 EXPECT_FALSE(vad_enabled); | |
| 211 } | |
| 212 | |
| 213 // Not needed anymore - API is unused. | |
| 214 TEST_F(AudioProcessingTest, VoiceActivityIndicatorReturns1WithSpeechOn) { | |
| 215 // This sleep is necessary since the voice detection algorithm needs some | |
| 216 // time to detect the speech from the fake microphone. | |
| 217 Sleep(500); | |
| 218 EXPECT_EQ(1, voe_apm_->VoiceActivityIndicator(channel_)); | |
| 219 } | |
| 220 | |
| 221 // Not needed anymore - API is unused. | |
| 222 TEST_F(AudioProcessingTest, CanSetDelayOffset) { | |
| 223 voe_apm_->SetDelayOffsetMs(50); | |
| 224 EXPECT_EQ(50, voe_apm_->DelayOffsetMs()); | |
| 225 voe_apm_->SetDelayOffsetMs(-50); | |
| 226 EXPECT_EQ(-50, voe_apm_->DelayOffsetMs()); | |
| 227 } | |
| 228 | |
| 229 // Duplicated in apm_helpers_unittest.cc. | |
| 230 TEST_F(AudioProcessingTest, HighPassFilterIsOnByDefault) { | |
| 231 EXPECT_TRUE(voe_apm_->IsHighPassFilterEnabled()); | |
| 232 } | |
| 233 | |
| 234 // TODO(solenberg): Check that sufficient testing is done in APM. | |
| 235 // Not needed anymore - API is unused. | |
| 236 TEST_F(AudioProcessingTest, CanSetHighPassFilter) { | |
| 237 EXPECT_EQ(0, voe_apm_->EnableHighPassFilter(true)); | |
| 238 EXPECT_TRUE(voe_apm_->IsHighPassFilterEnabled()); | |
| 239 EXPECT_EQ(0, voe_apm_->EnableHighPassFilter(false)); | |
| 240 EXPECT_FALSE(voe_apm_->IsHighPassFilterEnabled()); | |
| 241 } | |
| 242 | |
| 243 // Duplicated in apm_helpers_unittest.cc. | |
| 244 TEST_F(AudioProcessingTest, StereoChannelSwappingIsOffByDefault) { | |
| 245 EXPECT_FALSE(voe_apm_->IsStereoChannelSwappingEnabled()); | |
| 246 } | |
| 247 | |
| 248 // Duplicated in apm_helpers_unittest.cc. | |
| 249 TEST_F(AudioProcessingTest, CanSetStereoChannelSwapping) { | |
| 250 voe_apm_->EnableStereoChannelSwapping(true); | |
| 251 EXPECT_TRUE(voe_apm_->IsStereoChannelSwappingEnabled()); | |
| 252 voe_apm_->EnableStereoChannelSwapping(false); | |
| 253 EXPECT_FALSE(voe_apm_->IsStereoChannelSwappingEnabled()); | |
| 254 } | |
| 255 | |
| 256 // TODO(solenberg): Check that sufficient testing is done in APM. | |
| 257 TEST_F(AudioProcessingTest, CanStartAndStopDebugRecording) { | |
| 258 std::string output_path = webrtc::test::OutputPath(); | |
| 259 std::string output_file = output_path + "apm_debug.txt"; | |
| 260 | |
| 261 EXPECT_EQ(0, voe_apm_->StartDebugRecording(output_file.c_str())); | |
| 262 Sleep(1000); | |
| 263 EXPECT_EQ(0, voe_apm_->StopDebugRecording()); | |
| 264 } | |
| 265 | |
| 266 #if defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID) | |
| 267 | |
| 268 // Duplicated in apm_helpers_unittest.cc. | |
| 269 TEST_F(AudioProcessingTest, AgcIsOffByDefaultAndDigital) { | |
| 270 bool agc_enabled = true; | |
| 271 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; | |
| 272 | |
| 273 EXPECT_EQ(0, voe_apm_->GetAgcStatus(agc_enabled, agc_mode)); | |
| 274 EXPECT_FALSE(agc_enabled); | |
| 275 EXPECT_EQ(webrtc::kAgcAdaptiveDigital, agc_mode); | |
| 276 } | |
| 277 | |
| 278 // Duplicated in apm_helpers_unittest.cc. | |
| 279 TEST_F(AudioProcessingTest, CanEnableAgcInAdaptiveDigitalMode) { | |
| 280 TryEnablingAgcWithMode(webrtc::kAgcAdaptiveDigital); | |
| 281 } | |
| 282 | |
| 283 // Duplicated in apm_helpers_unittest.cc. | |
| 284 TEST_F(AudioProcessingTest, AgcIsPossibleExceptInAdaptiveAnalogMode) { | |
| 285 EXPECT_EQ(-1, voe_apm_->SetAgcStatus(true, webrtc::kAgcAdaptiveAnalog)); | |
| 286 EXPECT_EQ(0, voe_apm_->SetAgcStatus(true, webrtc::kAgcFixedDigital)); | |
| 287 EXPECT_EQ(0, voe_apm_->SetAgcStatus(true, webrtc::kAgcAdaptiveDigital)); | |
| 288 } | |
| 289 | |
| 290 // Duplicated in apm_helpers_unittest.cc. | |
| 291 TEST_F(AudioProcessingTest, EcIsDisabledAndAecmIsDefaultEcMode) { | |
| 292 bool ec_enabled = true; | |
| 293 webrtc::EcModes ec_mode = webrtc::kEcDefault; | |
| 294 | |
| 295 EXPECT_EQ(0, voe_apm_->GetEcStatus(ec_enabled, ec_mode)); | |
| 296 EXPECT_FALSE(ec_enabled); | |
| 297 EXPECT_EQ(webrtc::kEcAecm, ec_mode); | |
| 298 } | |
| 299 | |
| 300 #endif // WEBRTC_IOS || WEBRTC_ANDROID | |
| OLD | NEW |