blob: 79ffd17289fe3d610a8c65cf107061418e1526e9 [file] [log] [blame]
hjon6d49a8e2016-01-26 13:06:42 -08001/*
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
tkchin9eeb6242016-04-27 01:54:20 -070017#import "NSString+StdString.h"
18#import "RTCConfiguration+Private.h"
19#import "WebRTC/RTCConfiguration.h"
20#import "WebRTC/RTCIceServer.h"
hjon6d49a8e2016-01-26 13:06:42 -080021
22@interface RTCConfigurationTest : NSObject
23- (void)testConversionToNativeConfiguration;
hjon6d49a8e2016-01-26 13:06:42 -080024@end
25
26@implementation RTCConfigurationTest
27
28- (void)testConversionToNativeConfiguration {
29 NSArray *urlStrings = @[ @"stun:stun1.example.net" ];
30 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings];
31
tkchinab8f82f2016-01-27 17:50:11 -080032 RTCConfiguration *config = [[RTCConfiguration alloc] init];
33 config.iceServers = @[ server ];
34 config.iceTransportPolicy = RTCIceTransportPolicyRelay;
35 config.bundlePolicy = RTCBundlePolicyMaxBundle;
36 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
37 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
Honghai Zhang46007ae2016-06-03 16:31:32 -070038 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost;
tkchinab8f82f2016-01-27 17:50:11 -080039 const int maxPackets = 60;
40 const int timeout = 1;
41 const int interval = 2;
42 config.audioJitterBufferMaxPackets = maxPackets;
hayscc9f95002016-12-05 14:24:32 -080043 config.audioJitterBufferFastAccelerate = YES;
tkchinab8f82f2016-01-27 17:50:11 -080044 config.iceConnectionReceivingTimeout = timeout;
45 config.iceBackupCandidatePairPingInterval = interval;
Honghai Zhang3108fc92016-05-11 10:10:39 -070046 config.continualGatheringPolicy =
47 RTCContinualGatheringPolicyGatherContinually;
honghaizaf6b6e02016-07-11 15:09:26 -070048 config.shouldPruneTurnPorts = YES;
hjon6d49a8e2016-01-26 13:06:42 -080049
Henrik Boströme06c2dd2016-05-13 13:50:38 +020050 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
hbosa73ca562016-05-17 03:28:58 -070051 nativeConfig([config createNativeConfiguration]);
52 EXPECT_TRUE(nativeConfig.get());
Henrik Boströme06c2dd2016-05-13 13:50:38 +020053 EXPECT_EQ(1u, nativeConfig->servers.size());
hjon6d49a8e2016-01-26 13:06:42 -080054 webrtc::PeerConnectionInterface::IceServer nativeServer =
Henrik Boströme06c2dd2016-05-13 13:50:38 +020055 nativeConfig->servers.front();
hjon6d49a8e2016-01-26 13:06:42 -080056 EXPECT_EQ(1u, nativeServer.urls.size());
57 EXPECT_EQ("stun:stun1.example.net", nativeServer.urls.front());
58
Henrik Boströme06c2dd2016-05-13 13:50:38 +020059 EXPECT_EQ(webrtc::PeerConnectionInterface::kRelay, nativeConfig->type);
hjon6d49a8e2016-01-26 13:06:42 -080060 EXPECT_EQ(webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle,
Henrik Boströme06c2dd2016-05-13 13:50:38 +020061 nativeConfig->bundle_policy);
hjon6d49a8e2016-01-26 13:06:42 -080062 EXPECT_EQ(webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate,
Henrik Boströme06c2dd2016-05-13 13:50:38 +020063 nativeConfig->rtcp_mux_policy);
hjon6d49a8e2016-01-26 13:06:42 -080064 EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled,
Henrik Boströme06c2dd2016-05-13 13:50:38 +020065 nativeConfig->tcp_candidate_policy);
Honghai Zhang46007ae2016-06-03 16:31:32 -070066 EXPECT_EQ(webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost,
67 nativeConfig->candidate_network_policy);
Henrik Boströme06c2dd2016-05-13 13:50:38 +020068 EXPECT_EQ(maxPackets, nativeConfig->audio_jitter_buffer_max_packets);
hayscc9f95002016-12-05 14:24:32 -080069 EXPECT_EQ(true, nativeConfig->audio_jitter_buffer_fast_accelerate);
Henrik Boströme06c2dd2016-05-13 13:50:38 +020070 EXPECT_EQ(timeout, nativeConfig->ice_connection_receiving_timeout);
71 EXPECT_EQ(interval, nativeConfig->ice_backup_candidate_pair_ping_interval);
Honghai Zhang3108fc92016-05-11 10:10:39 -070072 EXPECT_EQ(webrtc::PeerConnectionInterface::GATHER_CONTINUALLY,
Henrik Boströme06c2dd2016-05-13 13:50:38 +020073 nativeConfig->continual_gathering_policy);
Honghai Zhange2e35ca2016-07-01 14:22:17 -070074 EXPECT_EQ(true, nativeConfig->prune_turn_ports);
hjon6d49a8e2016-01-26 13:06:42 -080075}
76
77@end
78
79TEST(RTCConfigurationTest, NativeConfigurationConversionTest) {
80 @autoreleasepool {
81 RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init];
82 [test testConversionToNativeConfiguration];
83 }
84}
85