blob: 9bb5179521f34a161cce3e15f7623ffd57ed5804 [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"
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"
Niels Möllera12c42a2018-07-25 16:05:48 +020031#include "rtc_base/system/unused.h"
Jiawei Ouae810c12018-06-20 16:18:59 -070032
33@interface RTCPeerConnectionFactoryBuilderTest : NSObject
34- (void)testBuilder;
35- (void)testDefaultComponentsBuilder;
36@end
37
38@implementation RTCPeerConnectionFactoryBuilderTest
39
40- (void)testBuilder {
41 id factoryMock = OCMStrictClassMock([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 RTCPeerConnectionFactory* peerConnectionFactory = [builder createPeerConnectionFactory];
56 EXPECT_TRUE(peerConnectionFactory != nil);
57 OCMVerifyAll(factoryMock);
58}
59
60- (void)testDefaultComponentsBuilder {
61 id factoryMock = OCMStrictClassMock([RTCPeerConnectionFactory class]);
62 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
72 audioProcessingModule:nullptr]);
73#endif
74 RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder];
75 RTCPeerConnectionFactory* peerConnectionFactory = [builder createPeerConnectionFactory];
76 EXPECT_TRUE(peerConnectionFactory != nil);
77 OCMVerifyAll(factoryMock);
78}
79@end
80
81TEST(RTCPeerConnectionFactoryBuilderTest, BuilderTest) {
82 @autoreleasepool {
83 RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init];
84 [test testBuilder];
85 }
86}
87
88TEST(RTCPeerConnectionFactoryBuilderTest, DefaultComponentsBuilderTest) {
89 @autoreleasepool {
90 RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init];
91 [test testDefaultComponentsBuilder];
92 }
93}