Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 1 | /* |
| 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 |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | #import <OCMock/OCMock.h> |
| 16 | #ifdef __cplusplus |
| 17 | } |
| 18 | #endif |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 19 | #import "api/peerconnection/RTCPeerConnectionFactory+Native.h" |
| 20 | #import "api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.h" |
| 21 | #import "api/peerconnection/RTCPeerConnectionFactoryBuilder.h" |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 22 | |
| 23 | #include "api/audio_codecs/builtin_audio_decoder_factory.h" |
| 24 | #include "api/audio_codecs/builtin_audio_encoder_factory.h" |
Niels Möller | 65f17ca | 2019-09-12 13:59:36 +0200 | [diff] [blame] | 25 | #include "api/transport/media/media_transport_interface.h" |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 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öller | a12c42a | 2018-07-25 16:05:48 +0200 | [diff] [blame] | 32 | #include "rtc_base/system/unused.h" |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 33 | |
| 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) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 53 | audioProcessingModule:nullptr |
| 54 | mediaTransportFactory:nullptr]); |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 55 | #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) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 74 | audioProcessingModule:nullptr |
| 75 | mediaTransportFactory:nullptr]); |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 76 | #endif |
| 77 | RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder]; |
| 78 | RTCPeerConnectionFactory* peerConnectionFactory = [builder createPeerConnectionFactory]; |
| 79 | EXPECT_TRUE(peerConnectionFactory != nil); |
| 80 | OCMVerifyAll(factoryMock); |
| 81 | } |
| 82 | @end |
| 83 | |
| 84 | TEST(RTCPeerConnectionFactoryBuilderTest, BuilderTest) { |
| 85 | @autoreleasepool { |
| 86 | RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init]; |
| 87 | [test testBuilder]; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | TEST(RTCPeerConnectionFactoryBuilderTest, DefaultComponentsBuilderTest) { |
| 92 | @autoreleasepool { |
| 93 | RTCPeerConnectionFactoryBuilderTest* test = [[RTCPeerConnectionFactoryBuilderTest alloc] init]; |
| 94 | [test testDefaultComponentsBuilder]; |
| 95 | } |
| 96 | } |