blob: 5ba5a52a5315cbcf52a278ed4782883c1ee3a7f4 [file] [log] [blame]
Jiawei Ouae810c12018-06-20 16:18:59 -07001/*
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>
Byoungchan Leec8a6fb22022-05-13 19:59:49 +090012#import <XCTest/XCTest.h>
Jiawei Ouae810c12018-06-20 16:18:59 -070013#ifdef __cplusplus
14extern "C" {
15#endif
16#import <OCMock/OCMock.h>
17#ifdef __cplusplus
18}
19#endif
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020020#import "api/peerconnection/RTCPeerConnectionFactory+Native.h"
21#import "api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.h"
22#import "api/peerconnection/RTCPeerConnectionFactoryBuilder.h"
Jiawei Ouae810c12018-06-20 16:18:59 -070023
24#include "api/audio_codecs/builtin_audio_decoder_factory.h"
25#include "api/audio_codecs/builtin_audio_encoder_factory.h"
26#include "api/video_codecs/video_decoder_factory.h"
27#include "api/video_codecs/video_encoder_factory.h"
28#include "modules/audio_device/include/audio_device.h"
29#include "modules/audio_processing/include/audio_processing.h"
30
31#include "rtc_base/gunit.h"
Niels Möllera12c42a2018-07-25 16:05:48 +020032#include "rtc_base/system/unused.h"
Jiawei Ouae810c12018-06-20 16:18:59 -070033
Byoungchan Leec8a6fb22022-05-13 19:59:49 +090034@interface RTCPeerConnectionFactoryBuilderTests : XCTestCase
Jiawei Ouae810c12018-06-20 16:18:59 -070035@end
36
Byoungchan Leec8a6fb22022-05-13 19:59:49 +090037@implementation RTCPeerConnectionFactoryBuilderTests
Jiawei Ouae810c12018-06-20 16:18:59 -070038
39- (void)testBuilder {
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020040 id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]);
Jiawei Ouae810c12018-06-20 16:18:59 -070041 OCMExpect([factoryMock alloc]).andReturn(factoryMock);
Jiawei Ouae810c12018-06-20 16:18:59 -070042 RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs]
43 initWithNativeAudioEncoderFactory:nullptr
44 nativeAudioDecoderFactory:nullptr
45 nativeVideoEncoderFactory:nullptr
46 nativeVideoDecoderFactory:nullptr
47 audioDeviceModule:nullptr
Niels Möller938bc332020-06-10 17:36:17 +020048 audioProcessingModule:nullptr]);
Jiawei Ouae810c12018-06-20 16:18:59 -070049 RTCPeerConnectionFactoryBuilder* builder = [[RTCPeerConnectionFactoryBuilder alloc] init];
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020050 RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory =
51 [builder createPeerConnectionFactory];
Jiawei Ouae810c12018-06-20 16:18:59 -070052 EXPECT_TRUE(peerConnectionFactory != nil);
53 OCMVerifyAll(factoryMock);
54}
55
56- (void)testDefaultComponentsBuilder {
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020057 id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]);
Jiawei Ouae810c12018-06-20 16:18:59 -070058 OCMExpect([factoryMock alloc]).andReturn(factoryMock);
Jiawei Ouae810c12018-06-20 16:18:59 -070059 RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs]
60 initWithNativeAudioEncoderFactory:nullptr
61 nativeAudioDecoderFactory:nullptr
62 nativeVideoEncoderFactory:nullptr
63 nativeVideoDecoderFactory:nullptr
64 audioDeviceModule:nullptr
Niels Möller938bc332020-06-10 17:36:17 +020065 audioProcessingModule:nullptr]);
Jiawei Ouae810c12018-06-20 16:18:59 -070066 RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder];
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020067 RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory =
68 [builder createPeerConnectionFactory];
Jiawei Ouae810c12018-06-20 16:18:59 -070069 EXPECT_TRUE(peerConnectionFactory != nil);
70 OCMVerifyAll(factoryMock);
71}
72@end