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 | |
| 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]; |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 56 | |
kthelgason | c097710 | 2017-04-24 00:57:16 -0700 | [diff] [blame] | 57 | RTCConfiguration *newConfig; |
| 58 | @autoreleasepool { |
| 59 | RTCPeerConnection *peerConnection = |
| 60 | [factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil]; |
| 61 | newConfig = peerConnection.configuration; |
zstein | 03adb7c | 2017-08-09 14:29:42 -0700 | [diff] [blame] | 62 | |
zstein | 8b47617 | 2017-09-05 14:43:03 -0700 | [diff] [blame] | 63 | 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]); |
kthelgason | c097710 | 2017-04-24 00:57:16 -0700 | [diff] [blame] | 69 | } |
zstein | 03adb7c | 2017-08-09 14:29:42 -0700 | [diff] [blame] | 70 | |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 71 | 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 | |
| 94 | TEST(RTCPeerConnectionTest, ConfigurationGetterTest) { |
| 95 | @autoreleasepool { |
| 96 | RTCPeerConnectionTest *test = [[RTCPeerConnectionTest alloc] init]; |
| 97 | [test testConfigurationGetter]; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | |