OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2017 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/modules/audio_processing/aec3/echo_path_delay_estimator.h" |
| 12 |
| 13 #include <sstream> |
| 14 #include <string> |
| 15 |
| 16 #include "webrtc/modules/audio_processing/aec3/aec3_constants.h" |
| 17 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" |
| 18 #include "webrtc/test/gtest.h" |
| 19 |
| 20 namespace webrtc { |
| 21 namespace { |
| 22 |
| 23 std::string ProduceDebugText(int sample_rate_hz) { |
| 24 std::ostringstream ss; |
| 25 ss << "Sample rate: " << sample_rate_hz; |
| 26 return ss.str(); |
| 27 } |
| 28 |
| 29 } // namespace |
| 30 |
| 31 // Verifies that the basic API calls work. |
| 32 TEST(EchoPathDelayEstimator, BasicApiCalls) { |
| 33 for (auto rate : {8000, 16000, 32000, 48000}) { |
| 34 ProduceDebugText(rate); |
| 35 ApmDataDumper data_dumper(0); |
| 36 EchoPathDelayEstimator estimator(&data_dumper, rate); |
| 37 std::vector<float> render(kBlockSize, 0.f); |
| 38 std::vector<float> capture(kBlockSize, 0.f); |
| 39 for (size_t k = 0; k < 100; ++k) { |
| 40 estimator.EstimateDelay(render, capture); |
| 41 } |
| 42 } |
| 43 } |
| 44 |
| 45 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
| 46 |
| 47 // Verifies the check for correct sample rate. |
| 48 TEST(EchoPathDelayEstimator, WrongSampleRate) { |
| 49 ApmDataDumper data_dumper(0); |
| 50 EXPECT_DEATH(EchoPathDelayEstimator remover(&data_dumper, 8001), ""); |
| 51 } |
| 52 |
| 53 // Verifies the check for the render blocksize. |
| 54 TEST(EchoPathDelayEstimator, WrongRenderBlockSize) { |
| 55 for (auto rate : {8000, 16000, 32000, 48000}) { |
| 56 ProduceDebugText(rate); |
| 57 ApmDataDumper data_dumper(0); |
| 58 EchoPathDelayEstimator estimator(&data_dumper, rate); |
| 59 std::vector<float> render(kBlockSize - 1, 0.f); |
| 60 std::vector<float> capture(kBlockSize, 0.f); |
| 61 EXPECT_DEATH(estimator.EstimateDelay(render, capture), ""); |
| 62 } |
| 63 } |
| 64 |
| 65 // Verifies the check for the capture blocksize. |
| 66 TEST(EchoPathDelayEstimator, WrongCaptureBlockSize) { |
| 67 for (auto rate : {8000, 16000, 32000, 48000}) { |
| 68 ProduceDebugText(rate); |
| 69 ApmDataDumper data_dumper(0); |
| 70 EchoPathDelayEstimator estimator(&data_dumper, rate); |
| 71 std::vector<float> render(kBlockSize, 0.f); |
| 72 std::vector<float> capture(kBlockSize - 1, 0.f); |
| 73 EXPECT_DEATH(estimator.EstimateDelay(render, capture), ""); |
| 74 } |
| 75 } |
| 76 |
| 77 // Verifies the check for non-null data dumper. |
| 78 TEST(EchoPathDelayEstimator, NullDataDumper) { |
| 79 EXPECT_DEATH(EchoPathDelayEstimator(nullptr, 8000), ""); |
| 80 } |
| 81 |
| 82 #endif |
| 83 |
| 84 } // namespace webrtc |
OLD | NEW |