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> |
Byoungchan Lee | c8a6fb2 | 2022-05-13 19:59:49 +0900 | [diff] [blame^] | 12 | #import <XCTest/XCTest.h> |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | #import <OCMock/OCMock.h> |
| 17 | #ifdef __cplusplus |
| 18 | } |
| 19 | #endif |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 20 | #import "api/peerconnection/RTCPeerConnectionFactory+Native.h" |
| 21 | #import "api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.h" |
| 22 | #import "api/peerconnection/RTCPeerConnectionFactoryBuilder.h" |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 23 | |
| 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ö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 | |
Byoungchan Lee | c8a6fb2 | 2022-05-13 19:59:49 +0900 | [diff] [blame^] | 34 | @interface RTCPeerConnectionFactoryBuilderTests : XCTestCase |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 35 | @end |
| 36 | |
Byoungchan Lee | c8a6fb2 | 2022-05-13 19:59:49 +0900 | [diff] [blame^] | 37 | @implementation RTCPeerConnectionFactoryBuilderTests |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 38 | |
| 39 | - (void)testBuilder { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 40 | id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]); |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 41 | 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öller | 938bc33 | 2020-06-10 17:36:17 +0200 | [diff] [blame] | 51 | audioProcessingModule:nullptr]); |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 52 | #endif |
| 53 | RTCPeerConnectionFactoryBuilder* builder = [[RTCPeerConnectionFactoryBuilder alloc] init]; |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 54 | RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory = |
| 55 | [builder createPeerConnectionFactory]; |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 56 | EXPECT_TRUE(peerConnectionFactory != nil); |
| 57 | OCMVerifyAll(factoryMock); |
| 58 | } |
| 59 | |
| 60 | - (void)testDefaultComponentsBuilder { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 61 | id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]); |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 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 |
Niels Möller | 938bc33 | 2020-06-10 17:36:17 +0200 | [diff] [blame] | 72 | audioProcessingModule:nullptr]); |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 73 | #endif |
| 74 | RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder]; |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 75 | RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory = |
| 76 | [builder createPeerConnectionFactory]; |
Jiawei Ou | ae810c1 | 2018-06-20 16:18:59 -0700 | [diff] [blame] | 77 | EXPECT_TRUE(peerConnectionFactory != nil); |
| 78 | OCMVerifyAll(factoryMock); |
| 79 | } |
| 80 | @end |