blob: 1ec004bc4f67583071ee50585723a3455f225e3f [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);
42#ifdef HAVE_NO_MEDIA
43 RTC_UNUSED([[[factoryMock expect] andReturn:factoryMock] initWithNoMedia]);
44#else
45 RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs]
46 initWithNativeAudioEncoderFactory:nullptr
47 nativeAudioDecoderFactory:nullptr
48 nativeVideoEncoderFactory:nullptr
49 nativeVideoDecoderFactory:nullptr
50 audioDeviceModule:nullptr
Niels Möller938bc332020-06-10 17:36:17 +020051 audioProcessingModule:nullptr]);
Jiawei Ouae810c12018-06-20 16:18:59 -070052#endif
53 RTCPeerConnectionFactoryBuilder* builder = [[RTCPeerConnectionFactoryBuilder alloc] init];
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020054 RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory =
55 [builder createPeerConnectionFactory];
Jiawei Ouae810c12018-06-20 16:18:59 -070056 EXPECT_TRUE(peerConnectionFactory != nil);
57 OCMVerifyAll(factoryMock);
58}
59
60- (void)testDefaultComponentsBuilder {
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020061 id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]);
Jiawei Ouae810c12018-06-20 16:18:59 -070062 OCMExpect([factoryMock alloc]).andReturn(factoryMock);
63#ifdef HAVE_NO_MEDIA
64 RTC_UNUSED([[[factoryMock expect] andReturn:factoryMock] initWithNoMedia]);
65#else
66 RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs]
67 initWithNativeAudioEncoderFactory:nullptr
68 nativeAudioDecoderFactory:nullptr
69 nativeVideoEncoderFactory:nullptr
70 nativeVideoDecoderFactory:nullptr
71 audioDeviceModule:nullptr
Niels Möller938bc332020-06-10 17:36:17 +020072 audioProcessingModule:nullptr]);
Jiawei Ouae810c12018-06-20 16:18:59 -070073#endif
74 RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder];
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020075 RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory =
76 [builder createPeerConnectionFactory];
Jiawei Ouae810c12018-06-20 16:18:59 -070077 EXPECT_TRUE(peerConnectionFactory != nil);
78 OCMVerifyAll(factoryMock);
79}
80@end