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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine_unittest.cc

Issue 2737633002: Remove VoEHardware interface usage. (Closed)
Patch Set: test Created 3 years, 9 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
1 /* 1 /*
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 const uint32_t kSsrcZ = 0x42; 55 const uint32_t kSsrcZ = 0x42;
56 const uint32_t kSsrcW = 0x02; 56 const uint32_t kSsrcW = 0x02;
57 const uint32_t kSsrcs4[] = { 11, 200, 30, 44 }; 57 const uint32_t kSsrcs4[] = { 11, 200, 30, 44 };
58 58
59 constexpr int kRtpHistoryMs = 5000; 59 constexpr int kRtpHistoryMs = 5000;
60 60
61 class FakeVoEWrapper : public cricket::VoEWrapper { 61 class FakeVoEWrapper : public cricket::VoEWrapper {
62 public: 62 public:
63 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) 63 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine)
64 : cricket::VoEWrapper(engine, // base 64 : cricket::VoEWrapper(engine, // base
65 engine, // codec 65 engine) { // codec
66 engine) { // hw
67 } 66 }
68 }; 67 };
69 68
70 class MockTransmitMixer : public webrtc::voe::TransmitMixer { 69 class MockTransmitMixer : public webrtc::voe::TransmitMixer {
71 public: 70 public:
72 MockTransmitMixer() = default; 71 MockTransmitMixer() = default;
73 virtual ~MockTransmitMixer() = default; 72 virtual ~MockTransmitMixer() = default;
74 73
75 MOCK_METHOD1(EnableStereoChannelSwapping, void(bool enable)); 74 MOCK_METHOD1(EnableStereoChannelSwapping, void(bool enable));
76 }; 75 };
76
77 void AdmSetupExpectations(webrtc::test::MockAudioDeviceModule* adm) {
henrika_webrtc 2017/03/13 11:15:55 These changes does not correlate 100% with the rem
the sun 2017/03/15 12:47:57 Certainly! The previous calls to SetRecordingDevi
henrika_webrtc 2017/03/15 12:50:19 Acknowledged.
78 RTC_DCHECK(adm);
79 EXPECT_CALL(*adm, AddRef()).WillOnce(Return(0));
80 EXPECT_CALL(*adm, Release()).WillOnce(Return(0));
81 #if !defined(WEBRTC_IOS)
82 EXPECT_CALL(*adm, Recording()).WillOnce(Return(false));
83 EXPECT_CALL(*adm, SetRecordingChannel(webrtc::AudioDeviceModule::
84 ChannelType::kChannelBoth)).WillOnce(Return(0));
85 #if defined(WEBRTC_WIN)
86 EXPECT_CALL(*adm, SetRecordingDevice(
87 static_cast<webrtc::AudioDeviceModule::WindowsDeviceType>(
88 webrtc::AudioDeviceModule::WindowsDeviceType::kDefaultCommunicationDev ice)))
89 .WillOnce(Return(0));
90 #else
91 EXPECT_CALL(*adm, SetRecordingDevice(0)).WillOnce(Return(0));
92 #endif // #if defined(WEBRTC_WIN)
93 EXPECT_CALL(*adm, InitMicrophone()).WillOnce(Return(0));
94 EXPECT_CALL(*adm, StereoRecordingIsAvailable(testing::_)).WillOnce(Return(0));
95 EXPECT_CALL(*adm, SetStereoRecording(false)).WillOnce(Return(0));
96 EXPECT_CALL(*adm, Playing()).WillOnce(Return(false));
97 #if defined(WEBRTC_WIN)
98 EXPECT_CALL(*adm, SetPlayoutDevice(
99 static_cast<webrtc::AudioDeviceModule::WindowsDeviceType>(
100 webrtc::AudioDeviceModule::WindowsDeviceType::kDefaultCommunicationDev ice)))
101 .WillOnce(Return(0));
102 #else
103 EXPECT_CALL(*adm, SetPlayoutDevice(0)).WillOnce(Return(0));
104 #endif // #if defined(WEBRTC_WIN)
105 EXPECT_CALL(*adm, InitSpeaker()).WillOnce(Return(0));
106 EXPECT_CALL(*adm, StereoPlayoutIsAvailable(testing::_)).WillOnce(Return(0));
107 EXPECT_CALL(*adm, SetStereoPlayout(false)).WillOnce(Return(0));
108 #endif // #if !defined(WEBRTC_IOS)
109 EXPECT_CALL(*adm, BuiltInAECIsAvailable()).WillOnce(Return(false));
110 EXPECT_CALL(*adm, BuiltInAGCIsAvailable()).WillOnce(Return(false));
111 EXPECT_CALL(*adm, BuiltInNSIsAvailable()).WillOnce(Return(false));
112 EXPECT_CALL(*adm, SetAGC(true)).WillOnce(Return(0));
113 }
77 } // namespace 114 } // namespace
78 115
79 // Tests that our stub library "works". 116 // Tests that our stub library "works".
80 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) { 117 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) {
81 StrictMock<webrtc::test::MockAudioDeviceModule> adm; 118 StrictMock<webrtc::test::MockAudioDeviceModule> adm;
82 EXPECT_CALL(adm, AddRef()).WillOnce(Return(0)); 119 AdmSetupExpectations(&adm);
83 EXPECT_CALL(adm, Release()).WillOnce(Return(0));
84 EXPECT_CALL(adm, BuiltInAECIsAvailable()).WillOnce(Return(false));
85 EXPECT_CALL(adm, BuiltInAGCIsAvailable()).WillOnce(Return(false));
86 EXPECT_CALL(adm, BuiltInNSIsAvailable()).WillOnce(Return(false));
87 EXPECT_CALL(adm, SetAGC(true)).WillOnce(Return(0));
88 StrictMock<webrtc::test::MockAudioProcessing> apm; 120 StrictMock<webrtc::test::MockAudioProcessing> apm;
89 EXPECT_CALL(apm, ApplyConfig(testing::_)); 121 EXPECT_CALL(apm, ApplyConfig(testing::_));
90 EXPECT_CALL(apm, SetExtraOptions(testing::_)); 122 EXPECT_CALL(apm, SetExtraOptions(testing::_));
91 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); 123 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0));
92 StrictMock<MockTransmitMixer> transmit_mixer; 124 StrictMock<MockTransmitMixer> transmit_mixer;
93 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false)); 125 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false));
94 cricket::FakeWebRtcVoiceEngine voe(&apm, &transmit_mixer); 126 cricket::FakeWebRtcVoiceEngine voe(&apm, &transmit_mixer);
95 EXPECT_FALSE(voe.IsInited()); 127 EXPECT_FALSE(voe.IsInited());
96 { 128 {
97 cricket::WebRtcVoiceEngine engine( 129 cricket::WebRtcVoiceEngine engine(
(...skipping 16 matching lines...) Expand all
114 class WebRtcVoiceEngineTestFake : public testing::Test { 146 class WebRtcVoiceEngineTestFake : public testing::Test {
115 public: 147 public:
116 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} 148 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {}
117 149
118 explicit WebRtcVoiceEngineTestFake(const char* field_trials) 150 explicit WebRtcVoiceEngineTestFake(const char* field_trials)
119 : apm_gc_(*apm_.gain_control()), apm_ec_(*apm_.echo_cancellation()), 151 : apm_gc_(*apm_.gain_control()), apm_ec_(*apm_.echo_cancellation()),
120 apm_ns_(*apm_.noise_suppression()), apm_vd_(*apm_.voice_detection()), 152 apm_ns_(*apm_.noise_suppression()), apm_vd_(*apm_.voice_detection()),
121 call_(webrtc::Call::Config(&event_log_)), voe_(&apm_, &transmit_mixer_), 153 call_(webrtc::Call::Config(&event_log_)), voe_(&apm_, &transmit_mixer_),
122 override_field_trials_(field_trials) { 154 override_field_trials_(field_trials) {
123 // AudioDeviceModule. 155 // AudioDeviceModule.
124 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0)); 156 AdmSetupExpectations(&adm_);
125 EXPECT_CALL(adm_, Release()).WillOnce(Return(0));
126 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false));
127 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false));
128 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false));
129 EXPECT_CALL(adm_, SetAGC(true)).WillOnce(Return(0));
130 // AudioProcessing. 157 // AudioProcessing.
131 EXPECT_CALL(apm_, ApplyConfig(testing::_)); 158 EXPECT_CALL(apm_, ApplyConfig(testing::_));
132 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); 159 EXPECT_CALL(apm_, SetExtraOptions(testing::_));
133 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0)); 160 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0));
134 // Default Options. 161 // Default Options.
135 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); 162 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0));
136 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); 163 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0));
137 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); 164 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0));
138 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); 165 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0));
139 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0)); 166 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0));
(...skipping 3655 matching lines...) Expand 10 before | Expand all | Expand 10 after
3795 // Without this cast, the comparison turned unsigned and, thus, failed for -1. 3822 // Without this cast, the comparison turned unsigned and, thus, failed for -1.
3796 const int num_specs = static_cast<int>(specs.size()); 3823 const int num_specs = static_cast<int>(specs.size());
3797 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); 3824 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs);
3798 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); 3825 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs);
3799 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); 3826 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1);
3800 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); 3827 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs);
3801 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); 3828 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs);
3802 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); 3829 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs);
3803 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); 3830 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs);
3804 } 3831 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698