blob: 7d19d4095d7b66350a46306327e9dd0174d5b592 [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>
12#ifdef __cplusplus
13extern "C" {
14#endif
15#import <OCMock/OCMock.h>
16#ifdef __cplusplus
17}
18#endif
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020019#import "api/peerconnection/RTCPeerConnectionFactory+Native.h"
20#import "api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.h"
21#import "api/peerconnection/RTCPeerConnectionFactoryBuilder.h"
Jiawei Ouae810c12018-06-20 16:18:59 -070022
23#include "api/audio_codecs/builtin_audio_decoder_factory.h"
24#include "api/audio_codecs/builtin_audio_encoder_factory.h"
Niels Möller65f17ca2019-09-12 13:59:36 +020025#include "api/transport/media/media_transport_interface.h"
Jiawei Ouae810c12018-06-20 16:18:59 -070026#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
34@interface RTCPeerConnectionFactoryBuilderTest : NSObject
35- (void)testBuilder;
36- (void)testDefaultComponentsBuilder;
37@end
38
39@implementation RTCPeerConnectionFactoryBuilderTest
40
41- (void)testBuilder {
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020042 id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]);
Jiawei Ouae810c12018-06-20 16:18:59 -070043 OCMExpect([factoryMock alloc]).andReturn(factoryMock);
44#ifdef HAVE_NO_MEDIA
45 RTC_UNUSED([[[factoryMock expect] andReturn:factoryMock] initWithNoMedia]);
46#else
47 RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs]
48 initWithNativeAudioEncoderFactory:nullptr
49 nativeAudioDecoderFactory:nullptr
50 nativeVideoEncoderFactory:nullptr
51 nativeVideoDecoderFactory:nullptr
52 audioDeviceModule:nullptr
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -070053 audioProcessingModule:nullptr
54 mediaTransportFactory:nullptr]);
Jiawei Ouae810c12018-06-20 16:18:59 -070055#endif
56 RTCPeerConnectionFactoryBuilder* builder = [[RTCPeerConnectionFactoryBuilder alloc] init];
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020057 RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory =
58 [builder createPeerConnectionFactory];
Jiawei Ouae810c12018-06-20 16:18:59 -070059 EXPECT_TRUE(peerConnectionFactory != nil);
60 OCMVerifyAll(factoryMock);
61}
62
63- (void)testDefaultComponentsBuilder {
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020064 id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]);
Jiawei Ouae810c12018-06-20 16:18:59 -070065 OCMExpect([factoryMock alloc]).andReturn(factoryMock);
66#ifdef HAVE_NO_MEDIA
67 RTC_UNUSED([[[factoryMock expect] andReturn:factoryMock] initWithNoMedia]);
68#else
69 RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs]
70 initWithNativeAudioEncoderFactory:nullptr
71 nativeAudioDecoderFactory:nullptr
72 nativeVideoEncoderFactory:nullptr
73 nativeVideoDecoderFactory:nullptr
74 audioDeviceModule:nullptr
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -070075 audioProcessingModule:nullptr
76 mediaTransportFactory:nullptr]);
Jiawei Ouae810c12018-06-20 16:18:59 -070077#endif
78 RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder];
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020079 RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory =
80 [builder createPeerConnectionFactory];
Jiawei Ouae810c12018-06-20 16:18:59 -070081 EXPECT_TRUE(peerConnectionFactory != nil);
82 OCMVerifyAll(factoryMock);
83}
84@end
85
86TEST(RTCPeerConnectionFactoryBuilderTest, BuilderTest) {
87 @autoreleasepool {
88 RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init];
89 [test testBuilder];
90 }
91}
92
93TEST(RTCPeerConnectionFactoryBuilderTest, DefaultComponentsBuilderTest) {
94 @autoreleasepool {
95 RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init];
96 [test testDefaultComponentsBuilder];
97 }
98}