Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: webrtc/modules/audio_processing/aec_dump/aec_dump_integration_test.cc

Issue 2888533005: MockAecDump and integration tests between AecDump and AudioProcessing (Closed)
Patch Set: Remove test which is special case of next test. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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, ConfigurationAndInitShouldBeLogged) {
51 auto apm = CreateAudioProcessing();
52
53 apm->AttachAecDump(CreateMockAecDump());
54 }
55
56 TEST(AecDumpIntegration,
57 RenderStreamShouldBeLoggedOnceEveryProcessReverseStream) {
58 auto apm = CreateAudioProcessing();
59 auto mock_aec_dump = CreateMockAecDump();
60 auto fake_frame = CreateFakeFrame();
61
62 EXPECT_CALL(*mock_aec_dump.get(),
63 WriteRenderStreamMessage(Matcher<const webrtc::AudioFrame&>(_)))
64 .Times(Exactly(1));
65
66 apm->AttachAecDump(std::move(mock_aec_dump));
67 apm->ProcessReverseStream(fake_frame.get());
68 }
69
70 TEST(AecDumpIntegration, CaptureStreamShouldBeLoggedOnceEveryProcessStream) {
71 auto apm = CreateAudioProcessing();
72 auto mock_aec_dump = CreateMockAecDump();
73 auto fake_frame = CreateFakeFrame();
74
75 EXPECT_CALL(*mock_aec_dump.get(),
76 AddCaptureStreamInput(Matcher<const webrtc::AudioFrame&>(_)))
77 .Times(AtLeast(1));
78
79 EXPECT_CALL(*mock_aec_dump.get(),
80 AddCaptureStreamOutput(Matcher<const webrtc::AudioFrame&>(_)))
81 .Times(Exactly(1));
82
83 EXPECT_CALL(*mock_aec_dump.get(), AddAudioProcessingState(_))
84 .Times(Exactly(1));
85
86 EXPECT_CALL(*mock_aec_dump.get(), WriteCaptureStreamMessage())
87 .Times(Exactly(1));
88
89 apm->AttachAecDump(std::move(mock_aec_dump));
90 apm->ProcessStream(fake_frame.get());
91 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec_dump/BUILD.gn ('k') | webrtc/modules/audio_processing/aec_dump/mock_aec_dump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698