jtteh | 4eeb537 | 2017-04-03 15:06:37 -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 | |
| 13 | #include <vector> |
| 14 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #include "rtc_base/gunit.h" |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 16 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 17 | #import "api/peerconnection/RTCConfiguration+Private.h" |
| 18 | #import "api/peerconnection/RTCConfiguration.h" |
| 19 | #import "api/peerconnection/RTCIceServer.h" |
| 20 | #import "api/peerconnection/RTCMediaConstraints.h" |
| 21 | #import "api/peerconnection/RTCPeerConnection.h" |
| 22 | #import "api/peerconnection/RTCPeerConnectionFactory.h" |
| 23 | #import "helpers/NSString+StdString.h" |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 24 | |
| 25 | @interface RTCPeerConnectionTest : NSObject |
| 26 | - (void)testConfigurationGetter; |
| 27 | @end |
| 28 | |
| 29 | @implementation RTCPeerConnectionTest |
| 30 | |
| 31 | - (void)testConfigurationGetter { |
| 32 | NSArray *urlStrings = @[ @"stun:stun1.example.net" ]; |
| 33 | RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings]; |
| 34 | |
| 35 | RTCConfiguration *config = [[RTCConfiguration alloc] init]; |
| 36 | config.iceServers = @[ server ]; |
| 37 | config.iceTransportPolicy = RTCIceTransportPolicyRelay; |
| 38 | config.bundlePolicy = RTCBundlePolicyMaxBundle; |
| 39 | config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate; |
| 40 | config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled; |
| 41 | config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost; |
| 42 | const int maxPackets = 60; |
Qingsi Wang | dea6889 | 2018-03-27 10:55:21 -0700 | [diff] [blame] | 43 | const int timeout = 1500; |
| 44 | const int interval = 2000; |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 45 | config.audioJitterBufferMaxPackets = maxPackets; |
| 46 | config.audioJitterBufferFastAccelerate = YES; |
| 47 | config.iceConnectionReceivingTimeout = timeout; |
| 48 | config.iceBackupCandidatePairPingInterval = interval; |
| 49 | config.continualGatheringPolicy = |
| 50 | RTCContinualGatheringPolicyGatherContinually; |
| 51 | config.shouldPruneTurnPorts = YES; |
Zhi Huang | b57e169 | 2018-06-12 11:41:11 -0700 | [diff] [blame] | 52 | config.activeResetSrtpParams = YES; |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 53 | |
| 54 | RTCMediaConstraints *contraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{} |
| 55 | optionalConstraints:nil]; |
| 56 | RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init]; |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 57 | |
kthelgason | c097710 | 2017-04-24 00:57:16 -0700 | [diff] [blame] | 58 | RTCConfiguration *newConfig; |
| 59 | @autoreleasepool { |
| 60 | RTCPeerConnection *peerConnection = |
| 61 | [factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil]; |
| 62 | newConfig = peerConnection.configuration; |
zstein | 03adb7c | 2017-08-09 14:29:42 -0700 | [diff] [blame] | 63 | |
zstein | 8b47617 | 2017-09-05 14:43:03 -0700 | [diff] [blame] | 64 | EXPECT_TRUE([peerConnection setBweMinBitrateBps:[NSNumber numberWithInt:100000] |
| 65 | currentBitrateBps:[NSNumber numberWithInt:5000000] |
| 66 | maxBitrateBps:[NSNumber numberWithInt:500000000]]); |
| 67 | EXPECT_FALSE([peerConnection setBweMinBitrateBps:[NSNumber numberWithInt:2] |
| 68 | currentBitrateBps:[NSNumber numberWithInt:1] |
| 69 | maxBitrateBps:nil]); |
kthelgason | c097710 | 2017-04-24 00:57:16 -0700 | [diff] [blame] | 70 | } |
zstein | 03adb7c | 2017-08-09 14:29:42 -0700 | [diff] [blame] | 71 | |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 72 | EXPECT_EQ([config.iceServers count], [newConfig.iceServers count]); |
| 73 | RTCIceServer *newServer = newConfig.iceServers[0]; |
| 74 | RTCIceServer *origServer = config.iceServers[0]; |
| 75 | std::string origUrl = origServer.urlStrings.firstObject.UTF8String; |
| 76 | std::string url = newServer.urlStrings.firstObject.UTF8String; |
| 77 | EXPECT_EQ(origUrl, url); |
| 78 | |
| 79 | EXPECT_EQ(config.iceTransportPolicy, newConfig.iceTransportPolicy); |
| 80 | EXPECT_EQ(config.bundlePolicy, newConfig.bundlePolicy); |
| 81 | EXPECT_EQ(config.rtcpMuxPolicy, newConfig.rtcpMuxPolicy); |
| 82 | EXPECT_EQ(config.tcpCandidatePolicy, newConfig.tcpCandidatePolicy); |
| 83 | EXPECT_EQ(config.candidateNetworkPolicy, newConfig.candidateNetworkPolicy); |
| 84 | EXPECT_EQ(config.audioJitterBufferMaxPackets, newConfig.audioJitterBufferMaxPackets); |
| 85 | EXPECT_EQ(config.audioJitterBufferFastAccelerate, newConfig.audioJitterBufferFastAccelerate); |
| 86 | EXPECT_EQ(config.iceConnectionReceivingTimeout, newConfig.iceConnectionReceivingTimeout); |
| 87 | EXPECT_EQ(config.iceBackupCandidatePairPingInterval, |
| 88 | newConfig.iceBackupCandidatePairPingInterval); |
| 89 | EXPECT_EQ(config.continualGatheringPolicy, newConfig.continualGatheringPolicy); |
| 90 | EXPECT_EQ(config.shouldPruneTurnPorts, newConfig.shouldPruneTurnPorts); |
Zhi Huang | b57e169 | 2018-06-12 11:41:11 -0700 | [diff] [blame] | 91 | EXPECT_EQ(config.activeResetSrtpParams, newConfig.activeResetSrtpParams); |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | @end |
| 95 | |
| 96 | TEST(RTCPeerConnectionTest, ConfigurationGetterTest) { |
| 97 | @autoreleasepool { |
| 98 | RTCPeerConnectionTest *test = [[RTCPeerConnectionTest alloc] init]; |
| 99 | [test testConfigurationGetter]; |
| 100 | } |
| 101 | } |