blob: 28fdee6a2bd6ed81e0700b4ec110a24b2ca0a3cd [file] [log] [blame]
jtteh4eeb5372017-04-03 15:06:37 -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
13#include <vector>
14
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "rtc_base/gunit.h"
jtteh4eeb5372017-04-03 15:06:37 -070016
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020017#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"
jtteh4eeb5372017-04-03 15:06:37 -070024
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 Wangdea68892018-03-27 10:55:21 -070043 const int timeout = 1500;
44 const int interval = 2000;
jtteh4eeb5372017-04-03 15:06:37 -070045 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 Huangb57e1692018-06-12 11:41:11 -070052 config.activeResetSrtpParams = YES;
jtteh4eeb5372017-04-03 15:06:37 -070053
54 RTCMediaConstraints *contraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{}
55 optionalConstraints:nil];
56 RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init];
jtteh4eeb5372017-04-03 15:06:37 -070057
kthelgasonc0977102017-04-24 00:57:16 -070058 RTCConfiguration *newConfig;
59 @autoreleasepool {
60 RTCPeerConnection *peerConnection =
61 [factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil];
62 newConfig = peerConnection.configuration;
zstein03adb7c2017-08-09 14:29:42 -070063
zstein8b476172017-09-05 14:43:03 -070064 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]);
kthelgasonc0977102017-04-24 00:57:16 -070070 }
zstein03adb7c2017-08-09 14:29:42 -070071
jtteh4eeb5372017-04-03 15:06:37 -070072 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 Huangb57e1692018-06-12 11:41:11 -070091 EXPECT_EQ(config.activeResetSrtpParams, newConfig.activeResetSrtpParams);
jtteh4eeb5372017-04-03 15:06:37 -070092}
93
94@end
95
96TEST(RTCPeerConnectionTest, ConfigurationGetterTest) {
97 @autoreleasepool {
98 RTCPeerConnectionTest *test = [[RTCPeerConnectionTest alloc] init];
99 [test testConfigurationGetter];
100 }
101}