Chromium Code Reviews| Index: webrtc/modules/audio_processing/aec3/delay_handler_unittest.cc |
| diff --git a/webrtc/modules/audio_processing/aec3/delay_handler_unittest.cc b/webrtc/modules/audio_processing/aec3/delay_handler_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..967328916e070b36e0b0095c9e32c6d714c99f91 |
| --- /dev/null |
| +++ b/webrtc/modules/audio_processing/aec3/delay_handler_unittest.cc |
| @@ -0,0 +1,61 @@ |
| +/* |
| + * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#include "webrtc/modules/audio_processing/aec3/delay_handler.h" |
| +#include "webrtc/test/gtest.h" |
| + |
| +namespace webrtc { |
| + |
| +TEST(DelayHandler, CorrectOperation) { |
|
ivoc
2017/02/10 13:52:34
I think it makes sense to split this test up into
peah-webrtc
2017/02/20 07:37:16
Done.
|
| + constexpr int kFilterLength = 10; |
| + DelayHandler handler; |
| + |
| + std::vector<std::array<float, kFftLengthBy2Plus1>> frequency_response( |
| + kFilterLength); |
| + for (auto& v : frequency_response) { |
| + v.fill(0.01f); |
| + } |
| + |
| + // Verify that a non-significant filter delay is identified correctly. |
| + handler.UpdateDelays(frequency_response, rtc::Optional<size_t>()); |
| + EXPECT_FALSE(handler.FilterDelay()); |
| + |
| + // Verify that the filter delay for a converged filter is properly identified. |
| + for (int k = 0; k < kFilterLength; ++k) { |
| + for (auto& v : frequency_response) { |
| + v.fill(0.01f); |
| + } |
| + frequency_response[k].fill(100.f); |
| + |
| + handler.UpdateDelays(frequency_response, rtc::Optional<size_t>()); |
| + EXPECT_TRUE(k == (kFilterLength - 1) || handler.FilterDelay()); |
| + if (k != (kFilterLength - 1)) { |
| + EXPECT_EQ(k, handler.FilterDelay()); |
| + } |
| + } |
| + |
| + // Verify that the externally reported delay is properly reported and |
| + // converted. |
| + handler.UpdateDelays(frequency_response, rtc::Optional<size_t>()); |
| + EXPECT_FALSE(handler.ExternalDelay()); |
| + for (int k = 0; k < kFilterLength - 1; ++k) { |
| + handler.UpdateDelays(frequency_response, |
| + rtc::Optional<size_t>(k * kBlockSize + 5)); |
| + EXPECT_TRUE(handler.ExternalDelay()); |
| + EXPECT_EQ(k, handler.ExternalDelay()); |
| + } |
| + |
| + // Verify that the externally reported delay is properly unset when it is no |
| + // longer present. |
| + handler.UpdateDelays(frequency_response, rtc::Optional<size_t>()); |
| + EXPECT_FALSE(handler.ExternalDelay()); |
| +} |
| + |
| +} // namespace webrtc |