peah | 8d2ade6 | 2016-03-22 11:05:12 -0700 | [diff] [blame] | 1 | /* |
Sam Zackrisson | 8c147b6 | 2018-09-28 12:40:47 +0200 | [diff] [blame] | 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. |
peah | 8d2ade6 | 2016-03-22 11:05:12 -0700 | [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 | */ |
Sam Zackrisson | 8c147b6 | 2018-09-28 12:40:47 +0200 | [diff] [blame] | 10 | |
| 11 | #include <array> |
peah | 8d2ade6 | 2016-03-22 11:05:12 -0700 | [diff] [blame] | 12 | #include <vector> |
| 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "modules/audio_processing/echo_control_mobile_impl.h" |
Sam Zackrisson | 8c147b6 | 2018-09-28 12:40:47 +0200 | [diff] [blame] | 15 | #include "modules/audio_processing/include/audio_processing.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 16 | #include "rtc_base/critical_section.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "test/gtest.h" |
peah | 8d2ade6 | 2016-03-22 11:05:12 -0700 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
Sam Zackrisson | 8c147b6 | 2018-09-28 12:40:47 +0200 | [diff] [blame] | 20 | TEST(EchoControlMobileTest, InterfaceConfiguration) { |
Sam Zackrisson | c22f551 | 2018-11-05 16:10:00 +0100 | [diff] [blame] | 21 | EchoControlMobileImpl aecm; |
Sam Zackrisson | 8c147b6 | 2018-09-28 12:40:47 +0200 | [diff] [blame] | 22 | aecm.Initialize(AudioProcessing::kSampleRate16kHz, 2, 2); |
peah | 8d2ade6 | 2016-03-22 11:05:12 -0700 | [diff] [blame] | 23 | |
Sam Zackrisson | 8c147b6 | 2018-09-28 12:40:47 +0200 | [diff] [blame] | 24 | // Turn AECM on |
| 25 | EXPECT_EQ(0, aecm.Enable(true)); |
| 26 | EXPECT_TRUE(aecm.is_enabled()); |
peah | 8d2ade6 | 2016-03-22 11:05:12 -0700 | [diff] [blame] | 27 | |
Sam Zackrisson | 8c147b6 | 2018-09-28 12:40:47 +0200 | [diff] [blame] | 28 | // Toggle routing modes |
| 29 | std::array<EchoControlMobileImpl::RoutingMode, 5> routing_modes = { |
| 30 | EchoControlMobileImpl::kQuietEarpieceOrHeadset, |
| 31 | EchoControlMobileImpl::kEarpiece, |
| 32 | EchoControlMobileImpl::kLoudEarpiece, |
| 33 | EchoControlMobileImpl::kSpeakerphone, |
| 34 | EchoControlMobileImpl::kLoudSpeakerphone, |
| 35 | }; |
| 36 | for (auto mode : routing_modes) { |
| 37 | EXPECT_EQ(0, aecm.set_routing_mode(mode)); |
| 38 | EXPECT_EQ(mode, aecm.routing_mode()); |
peah | 8d2ade6 | 2016-03-22 11:05:12 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Sam Zackrisson | 8c147b6 | 2018-09-28 12:40:47 +0200 | [diff] [blame] | 41 | // Turn comfort noise off/on |
| 42 | EXPECT_EQ(0, aecm.enable_comfort_noise(false)); |
| 43 | EXPECT_FALSE(aecm.is_comfort_noise_enabled()); |
| 44 | EXPECT_EQ(0, aecm.enable_comfort_noise(true)); |
| 45 | EXPECT_TRUE(aecm.is_comfort_noise_enabled()); |
peah | 8d2ade6 | 2016-03-22 11:05:12 -0700 | [diff] [blame] | 46 | |
Sam Zackrisson | 8c147b6 | 2018-09-28 12:40:47 +0200 | [diff] [blame] | 47 | // Turn AECM off |
| 48 | EXPECT_EQ(0, aecm.Enable(false)); |
| 49 | EXPECT_FALSE(aecm.is_enabled()); |
peah | 8d2ade6 | 2016-03-22 11:05:12 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | } // namespace webrtc |