blob: bd2db305da7daf15cc727583a51f22f2d576bb4f [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
15#include "webrtc/base/gunit.h"
16
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];
56 RTCPeerConnection *peerConnection = [factory peerConnectionWithConfiguration:config
57 constraints:contraints delegate:nil];
58
59 RTCConfiguration *newConfig = peerConnection.configuration;
60
61 EXPECT_EQ([config.iceServers count], [newConfig.iceServers count]);
62 RTCIceServer *newServer = newConfig.iceServers[0];
63 RTCIceServer *origServer = config.iceServers[0];
64 std::string origUrl = origServer.urlStrings.firstObject.UTF8String;
65 std::string url = newServer.urlStrings.firstObject.UTF8String;
66 EXPECT_EQ(origUrl, url);
67
68 EXPECT_EQ(config.iceTransportPolicy, newConfig.iceTransportPolicy);
69 EXPECT_EQ(config.bundlePolicy, newConfig.bundlePolicy);
70 EXPECT_EQ(config.rtcpMuxPolicy, newConfig.rtcpMuxPolicy);
71 EXPECT_EQ(config.tcpCandidatePolicy, newConfig.tcpCandidatePolicy);
72 EXPECT_EQ(config.candidateNetworkPolicy, newConfig.candidateNetworkPolicy);
73 EXPECT_EQ(config.audioJitterBufferMaxPackets, newConfig.audioJitterBufferMaxPackets);
74 EXPECT_EQ(config.audioJitterBufferFastAccelerate, newConfig.audioJitterBufferFastAccelerate);
75 EXPECT_EQ(config.iceConnectionReceivingTimeout, newConfig.iceConnectionReceivingTimeout);
76 EXPECT_EQ(config.iceBackupCandidatePairPingInterval,
77 newConfig.iceBackupCandidatePairPingInterval);
78 EXPECT_EQ(config.continualGatheringPolicy, newConfig.continualGatheringPolicy);
79 EXPECT_EQ(config.shouldPruneTurnPorts, newConfig.shouldPruneTurnPorts);
80}
81
82@end
83
84TEST(RTCPeerConnectionTest, ConfigurationGetterTest) {
85 @autoreleasepool {
86 RTCPeerConnectionTest *test = [[RTCPeerConnectionTest alloc] init];
87 [test testConfigurationGetter];
88 }
89}
90
91