blob: 65bedde704a92fad8977285d2231d3d18039b6fd [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
17#import "NSString+StdString.h"
18#import "RTCConfiguration+Private.h"
19#import "WebRTC/RTCConfiguration.h"
20#import "WebRTC/RTCPeerConnection.h"
21#import "WebRTC/RTCPeerConnectionFactory.h"
22#import "WebRTC/RTCIceServer.h"
23#import "WebRTC/RTCMediaConstraints.h"
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;
43 const int timeout = 1;
44 const int interval = 2;
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;
52
53 RTCMediaConstraints *contraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{}
54 optionalConstraints:nil];
55 RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init];
jtteh4eeb5372017-04-03 15:06:37 -070056
kthelgasonc0977102017-04-24 00:57:16 -070057 RTCConfiguration *newConfig;
58 @autoreleasepool {
59 RTCPeerConnection *peerConnection =
60 [factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil];
61 newConfig = peerConnection.configuration;
zstein03adb7c2017-08-09 14:29:42 -070062
zstein8b476172017-09-05 14:43:03 -070063 EXPECT_TRUE([peerConnection setBweMinBitrateBps:[NSNumber numberWithInt:100000]
64 currentBitrateBps:[NSNumber numberWithInt:5000000]
65 maxBitrateBps:[NSNumber numberWithInt:500000000]]);
66 EXPECT_FALSE([peerConnection setBweMinBitrateBps:[NSNumber numberWithInt:2]
67 currentBitrateBps:[NSNumber numberWithInt:1]
68 maxBitrateBps:nil]);
kthelgasonc0977102017-04-24 00:57:16 -070069 }
zstein03adb7c2017-08-09 14:29:42 -070070
jtteh4eeb5372017-04-03 15:06:37 -070071 EXPECT_EQ([config.iceServers count], [newConfig.iceServers count]);
72 RTCIceServer *newServer = newConfig.iceServers[0];
73 RTCIceServer *origServer = config.iceServers[0];
74 std::string origUrl = origServer.urlStrings.firstObject.UTF8String;
75 std::string url = newServer.urlStrings.firstObject.UTF8String;
76 EXPECT_EQ(origUrl, url);
77
78 EXPECT_EQ(config.iceTransportPolicy, newConfig.iceTransportPolicy);
79 EXPECT_EQ(config.bundlePolicy, newConfig.bundlePolicy);
80 EXPECT_EQ(config.rtcpMuxPolicy, newConfig.rtcpMuxPolicy);
81 EXPECT_EQ(config.tcpCandidatePolicy, newConfig.tcpCandidatePolicy);
82 EXPECT_EQ(config.candidateNetworkPolicy, newConfig.candidateNetworkPolicy);
83 EXPECT_EQ(config.audioJitterBufferMaxPackets, newConfig.audioJitterBufferMaxPackets);
84 EXPECT_EQ(config.audioJitterBufferFastAccelerate, newConfig.audioJitterBufferFastAccelerate);
85 EXPECT_EQ(config.iceConnectionReceivingTimeout, newConfig.iceConnectionReceivingTimeout);
86 EXPECT_EQ(config.iceBackupCandidatePairPingInterval,
87 newConfig.iceBackupCandidatePairPingInterval);
88 EXPECT_EQ(config.continualGatheringPolicy, newConfig.continualGatheringPolicy);
89 EXPECT_EQ(config.shouldPruneTurnPorts, newConfig.shouldPruneTurnPorts);
90}
91
92@end
93
94TEST(RTCPeerConnectionTest, ConfigurationGetterTest) {
95 @autoreleasepool {
96 RTCPeerConnectionTest *test = [[RTCPeerConnectionTest alloc] init];
97 [test testConfigurationGetter];
98 }
99}
100
101