voip_engine_factory_unittest.cc (2069B)
1 /* 2 * Copyright (c) 2020 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 "api/voip/voip_engine_factory.h" 12 13 #include <memory> 14 #include <utility> 15 16 #include "api/environment/environment_factory.h" 17 #include "api/make_ref_counted.h" 18 #include "modules/audio_device/include/mock_audio_device.h" 19 #include "modules/audio_processing/include/mock_audio_processing.h" 20 #include "test/create_test_field_trials.h" 21 #include "test/gmock.h" 22 #include "test/gtest.h" 23 #include "test/mock_audio_decoder_factory.h" 24 #include "test/mock_audio_encoder_factory.h" 25 26 namespace webrtc { 27 namespace { 28 29 using ::testing::NiceMock; 30 31 // Create voip engine with mock modules as normal use case. 32 TEST(VoipEngineFactoryTest, CreateEngineWithMockModules) { 33 VoipEngineConfig config; 34 config.encoder_factory = make_ref_counted<MockAudioEncoderFactory>(); 35 config.decoder_factory = make_ref_counted<MockAudioDecoderFactory>(); 36 config.env = CreateEnvironment(CreateTestFieldTrialsPtr()); 37 config.audio_processing_builder = 38 std::make_unique<NiceMock<test::MockAudioProcessingBuilder>>(); 39 config.audio_device_module = test::MockAudioDeviceModule::CreateNice(); 40 41 auto voip_engine = CreateVoipEngine(std::move(config)); 42 EXPECT_NE(voip_engine, nullptr); 43 } 44 45 // Create voip engine without setting optional components. 46 TEST(VoipEngineFactoryTest, UseNoAudioProcessing) { 47 VoipEngineConfig config; 48 config.encoder_factory = make_ref_counted<MockAudioEncoderFactory>(); 49 config.decoder_factory = make_ref_counted<MockAudioDecoderFactory>(); 50 config.audio_device_module = test::MockAudioDeviceModule::CreateNice(); 51 52 auto voip_engine = CreateVoipEngine(std::move(config)); 53 EXPECT_NE(voip_engine, nullptr); 54 } 55 56 } // namespace 57 } // namespace webrtc