hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [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 | |
| 15 | #include "webrtc/base/gunit.h" |
| 16 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 17 | #import "NSString+StdString.h" |
| 18 | #import "RTCConfiguration+Private.h" |
| 19 | #import "WebRTC/RTCConfiguration.h" |
| 20 | #import "WebRTC/RTCIceServer.h" |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 21 | |
| 22 | @interface RTCConfigurationTest : NSObject |
| 23 | - (void)testConversionToNativeConfiguration; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 24 | @end |
| 25 | |
| 26 | @implementation RTCConfigurationTest |
| 27 | |
| 28 | - (void)testConversionToNativeConfiguration { |
| 29 | NSArray *urlStrings = @[ @"stun:stun1.example.net" ]; |
| 30 | RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings]; |
| 31 | |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 32 | 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; |
| 38 | const int maxPackets = 60; |
| 39 | const int timeout = 1; |
| 40 | const int interval = 2; |
| 41 | config.audioJitterBufferMaxPackets = maxPackets; |
| 42 | config.iceConnectionReceivingTimeout = timeout; |
| 43 | config.iceBackupCandidatePairPingInterval = interval; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 44 | |
| 45 | webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig = |
| 46 | config.nativeConfiguration; |
| 47 | EXPECT_EQ(1u, nativeConfig.servers.size()); |
| 48 | webrtc::PeerConnectionInterface::IceServer nativeServer = |
| 49 | nativeConfig.servers.front(); |
| 50 | EXPECT_EQ(1u, nativeServer.urls.size()); |
| 51 | EXPECT_EQ("stun:stun1.example.net", nativeServer.urls.front()); |
| 52 | |
| 53 | EXPECT_EQ(webrtc::PeerConnectionInterface::kRelay, nativeConfig.type); |
| 54 | EXPECT_EQ(webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle, |
| 55 | nativeConfig.bundle_policy); |
| 56 | EXPECT_EQ(webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate, |
| 57 | nativeConfig.rtcp_mux_policy); |
| 58 | EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled, |
| 59 | nativeConfig.tcp_candidate_policy); |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 60 | EXPECT_EQ(maxPackets, nativeConfig.audio_jitter_buffer_max_packets); |
| 61 | EXPECT_EQ(timeout, nativeConfig.ice_connection_receiving_timeout); |
| 62 | EXPECT_EQ(interval, nativeConfig.ice_backup_candidate_pair_ping_interval); |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | @end |
| 66 | |
| 67 | TEST(RTCConfigurationTest, NativeConfigurationConversionTest) { |
| 68 | @autoreleasepool { |
| 69 | RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init]; |
| 70 | [test testConversionToNativeConfiguration]; |
| 71 | } |
| 72 | } |
| 73 | |