blob: 40b3aa039998427d067f1da4ec9f1e572fcffd4a [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 {
42 id factoryMock = OCMStrictClassMock([RTCPeerConnectionFactory class]);
43 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];
57 RTCPeerConnectionFactory* peerConnectionFactory = [builder createPeerConnectionFactory];
58 EXPECT_TRUE(peerConnectionFactory != nil);
59 OCMVerifyAll(factoryMock);
60}
61
62- (void)testDefaultComponentsBuilder {
63 id factoryMock = OCMStrictClassMock([RTCPeerConnectionFactory class]);
64 OCMExpect([factoryMock alloc]).andReturn(factoryMock);
65#ifdef HAVE_NO_MEDIA
66 RTC_UNUSED([[[factoryMock expect] andReturn:factoryMock] initWithNoMedia]);
67#else
68 RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] ignoringNonObjectArgs]
69 initWithNativeAudioEncoderFactory:nullptr
70 nativeAudioDecoderFactory:nullptr
71 nativeVideoEncoderFactory:nullptr
72 nativeVideoDecoderFactory:nullptr
73 audioDeviceModule:nullptr
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -070074 audioProcessingModule:nullptr
75 mediaTransportFactory:nullptr]);
Jiawei Ouae810c12018-06-20 16:18:59 -070076#endif
77 RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder];
78 RTCPeerConnectionFactory* peerConnectionFactory = [builder createPeerConnectionFactory];
79 EXPECT_TRUE(peerConnectionFactory != nil);
80 OCMVerifyAll(factoryMock);
81}
82@end
83
84TEST(RTCPeerConnectionFactoryBuilderTest, BuilderTest) {
85 @autoreleasepool {
86 RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init];
87 [test testBuilder];
88 }
89}
90
91TEST(RTCPeerConnectionFactoryBuilderTest, DefaultComponentsBuilderTest) {
92 @autoreleasepool {
93 RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init];
94 [test testDefaultComponentsBuilder];
95 }
96}