1/* 2 * Copyright 2015 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#import <Foundation/Foundation.h> 12#ifdef __cplusplus 13extern "C" { 14#endif 15#import <OCMock/OCMock.h> 16#ifdef __cplusplus 17} 18#endif 19#import "api/peerconnection/RTCPeerConnectionFactory+Native.h" 20#import "api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.h" 21#import "api/peerconnection/RTCPeerConnectionFactoryBuilder.h" 22 23#include "api/audio_codecs/builtin_audio_decoder_factory.h" 24#include "api/audio_codecs/builtin_audio_encoder_factory.h" 25#include "api/video_codecs/video_decoder_factory.h" 26#include "api/video_codecs/video_encoder_factory.h" 27#include "modules/audio_device/include/audio_device.h" 28#include "modules/audio_processing/include/audio_processing.h" 29 30#include "rtc_base/gunit.h" 31#include "rtc_base/system/unused.h" 32 33@interface RTCPeerConnectionFactoryBuilderTest : NSObject 34- (void)testBuilder; 35- (void)testDefaultComponentsBuilder; 36@end 37 38@implementation RTCPeerConnectionFactoryBuilderTest 39 40- (void)testBuilder { 41 id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]); 42 OCMExpect([factoryMock alloc]).andReturn(factoryMock); 43#ifdef HAVE_NO_MEDIA 44 RTC_UNUSED([[[factoryMock expect] andReturn:factoryMock] initWithNoMedia]); 45#else 46 RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs] 47 initWithNativeAudioEncoderFactory:nullptr 48 nativeAudioDecoderFactory:nullptr 49 nativeVideoEncoderFactory:nullptr 50 nativeVideoDecoderFactory:nullptr 51 audioDeviceModule:nullptr 52 audioProcessingModule:nullptr]); 53#endif 54 RTCPeerConnectionFactoryBuilder* builder = [[RTCPeerConnectionFactoryBuilder alloc] init]; 55 RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory = 56 [builder createPeerConnectionFactory]; 57 EXPECT_TRUE(peerConnectionFactory != nil); 58 OCMVerifyAll(factoryMock); 59} 60 61- (void)testDefaultComponentsBuilder { 62 id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]); 63 OCMExpect([factoryMock alloc]).andReturn(factoryMock); 64#ifdef HAVE_NO_MEDIA 65 RTC_UNUSED([[[factoryMock expect] andReturn:factoryMock] initWithNoMedia]); 66#else 67 RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs] 68 initWithNativeAudioEncoderFactory:nullptr 69 nativeAudioDecoderFactory:nullptr 70 nativeVideoEncoderFactory:nullptr 71 nativeVideoDecoderFactory:nullptr 72 audioDeviceModule:nullptr 73 audioProcessingModule:nullptr]); 74#endif 75 RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder]; 76 RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory = 77 [builder createPeerConnectionFactory]; 78 EXPECT_TRUE(peerConnectionFactory != nil); 79 OCMVerifyAll(factoryMock); 80} 81@end 82 83TEST(RTCPeerConnectionFactoryBuilderTest, BuilderTest) { 84 @autoreleasepool { 85 RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init]; 86 [test testBuilder]; 87 } 88} 89 90TEST(RTCPeerConnectionFactoryBuilderTest, DefaultComponentsBuilderTest) { 91 @autoreleasepool { 92 RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init]; 93 [test testDefaultComponentsBuilder]; 94 } 95} 96