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 <utility> |
| 12 |
| 13 #include "webrtc/base/ptr_util.h" |
| 14 #include "webrtc/modules/audio_processing/aec_dump/mock_aec_dump.h" |
| 15 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 16 |
| 17 using testing::_; |
| 18 using testing::AtLeast; |
| 19 using testing::Exactly; |
| 20 using testing::Matcher; |
| 21 using testing::StrictMock; |
| 22 |
| 23 namespace { |
| 24 std::unique_ptr<webrtc::AudioProcessing> CreateAudioProcessing() { |
| 25 webrtc::Config config; |
| 26 std::unique_ptr<webrtc::AudioProcessing> apm( |
| 27 webrtc::AudioProcessing::Create(config)); |
| 28 RTC_DCHECK(apm); |
| 29 return apm; |
| 30 } |
| 31 |
| 32 std::unique_ptr<webrtc::test::MockAecDump> CreateMockAecDump() { |
| 33 auto mock_aec_dump = |
| 34 rtc::MakeUnique<testing::StrictMock<webrtc::test::MockAecDump>>(); |
| 35 EXPECT_CALL(*mock_aec_dump.get(), WriteConfig(_, _)).Times(AtLeast(1)); |
| 36 EXPECT_CALL(*mock_aec_dump.get(), WriteInitMessage(_)).Times(AtLeast(1)); |
| 37 return std::unique_ptr<webrtc::test::MockAecDump>(std::move(mock_aec_dump)); |
| 38 } |
| 39 |
| 40 std::unique_ptr<webrtc::AudioFrame> CreateFakeFrame() { |
| 41 auto fake_frame = rtc::MakeUnique<webrtc::AudioFrame>(); |
| 42 fake_frame->num_channels_ = 1; |
| 43 fake_frame->sample_rate_hz_ = 48000; |
| 44 fake_frame->samples_per_channel_ = 480; |
| 45 return fake_frame; |
| 46 } |
| 47 |
| 48 } // namespace |
| 49 |
| 50 TEST(AecDumpIntegration, Construct) { |
| 51 auto apm = CreateAudioProcessing(); |
| 52 auto mock_aec_dump = rtc::MakeUnique<webrtc::test::MockAecDump>(); |
| 53 |
| 54 apm->AttachAecDump(std::move(mock_aec_dump)); |
| 55 } |
| 56 |
| 57 TEST(AecDumpIntegration, ConfigurationAndInitShouldBeLogged) { |
| 58 auto apm = CreateAudioProcessing(); |
| 59 |
| 60 apm->AttachAecDump(CreateMockAecDump()); |
| 61 } |
| 62 |
| 63 TEST(AecDumpIntegration, |
| 64 RenderStreamShouldBeLoggedOnceEveryProcessReverseStream) { |
| 65 auto apm = CreateAudioProcessing(); |
| 66 auto mock_aec_dump = CreateMockAecDump(); |
| 67 auto fake_frame = CreateFakeFrame(); |
| 68 |
| 69 EXPECT_CALL(*mock_aec_dump.get(), |
| 70 WriteRenderStreamMessage(Matcher<const webrtc::AudioFrame&>(_))) |
| 71 .Times(Exactly(1)); |
| 72 |
| 73 apm->AttachAecDump(std::move(mock_aec_dump)); |
| 74 apm->ProcessReverseStream(fake_frame.get()); |
| 75 } |
| 76 |
| 77 TEST(AecDumpIntegration, CaptureStreamShouldBeLoggedOnceEveryProcessStream) { |
| 78 auto apm = CreateAudioProcessing(); |
| 79 auto mock_aec_dump = CreateMockAecDump(); |
| 80 auto fake_frame = CreateFakeFrame(); |
| 81 |
| 82 EXPECT_CALL(*mock_aec_dump.get(), |
| 83 AddCaptureStreamInput(Matcher<const webrtc::AudioFrame&>(_))) |
| 84 .Times(AtLeast(1)); |
| 85 |
| 86 EXPECT_CALL(*mock_aec_dump.get(), |
| 87 AddCaptureStreamOutput(Matcher<const webrtc::AudioFrame&>(_))) |
| 88 .Times(Exactly(1)); |
| 89 |
| 90 EXPECT_CALL(*mock_aec_dump.get(), AddAudioProcessingState(_)) |
| 91 .Times(Exactly(1)); |
| 92 |
| 93 EXPECT_CALL(*mock_aec_dump.get(), WriteCaptureStreamMessage()) |
| 94 .Times(Exactly(1)); |
| 95 |
| 96 apm->AttachAecDump(std::move(mock_aec_dump)); |
| 97 apm->ProcessStream(fake_frame.get()); |
| 98 } |
OLD | NEW |