Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: webrtc/sdk/objc/Framework/UnitTests/RTCConfigurationTest.mm

Issue 2976953002: iOS - Add iceRegatherIntervalRange. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #import <Foundation/Foundation.h> 11 #import <Foundation/Foundation.h>
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "webrtc/rtc_base/gunit.h" 15 #include "webrtc/rtc_base/gunit.h"
16 16
17 #import "NSString+StdString.h" 17 #import "NSString+StdString.h"
18 #import "RTCConfiguration+Private.h" 18 #import "RTCConfiguration+Private.h"
19 #import "WebRTC/RTCConfiguration.h" 19 #import "WebRTC/RTCConfiguration.h"
20 #import "WebRTC/RTCIceServer.h" 20 #import "WebRTC/RTCIceServer.h"
21 #import "WebRTC/RTCIntervalRange.h"
21 22
22 @interface RTCConfigurationTest : NSObject 23 @interface RTCConfigurationTest : NSObject
23 - (void)testConversionToNativeConfiguration; 24 - (void)testConversionToNativeConfiguration;
24 - (void)testNativeConversionToConfiguration; 25 - (void)testNativeConversionToConfiguration;
25 @end 26 @end
26 27
27 @implementation RTCConfigurationTest 28 @implementation RTCConfigurationTest
28 29
29 - (void)testConversionToNativeConfiguration { 30 - (void)testConversionToNativeConfiguration {
30 NSArray *urlStrings = @[ @"stun:stun1.example.net" ]; 31 NSArray *urlStrings = @[ @"stun:stun1.example.net" ];
31 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings]; 32 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings];
33 RTCIntervalRange *range = [[RTCIntervalRange alloc] initWithMin:0 max:100];
32 34
33 RTCConfiguration *config = [[RTCConfiguration alloc] init]; 35 RTCConfiguration *config = [[RTCConfiguration alloc] init];
34 config.iceServers = @[ server ]; 36 config.iceServers = @[ server ];
35 config.iceTransportPolicy = RTCIceTransportPolicyRelay; 37 config.iceTransportPolicy = RTCIceTransportPolicyRelay;
36 config.bundlePolicy = RTCBundlePolicyMaxBundle; 38 config.bundlePolicy = RTCBundlePolicyMaxBundle;
37 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate; 39 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
38 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled; 40 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
39 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost; 41 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost;
40 const int maxPackets = 60; 42 const int maxPackets = 60;
41 const int timeout = 1; 43 const int timeout = 1;
42 const int interval = 2; 44 const int interval = 2;
43 config.audioJitterBufferMaxPackets = maxPackets; 45 config.audioJitterBufferMaxPackets = maxPackets;
44 config.audioJitterBufferFastAccelerate = YES; 46 config.audioJitterBufferFastAccelerate = YES;
45 config.iceConnectionReceivingTimeout = timeout; 47 config.iceConnectionReceivingTimeout = timeout;
46 config.iceBackupCandidatePairPingInterval = interval; 48 config.iceBackupCandidatePairPingInterval = interval;
47 config.continualGatheringPolicy = 49 config.continualGatheringPolicy =
48 RTCContinualGatheringPolicyGatherContinually; 50 RTCContinualGatheringPolicyGatherContinually;
49 config.shouldPruneTurnPorts = YES; 51 config.shouldPruneTurnPorts = YES;
52 config.iceRegatherIntervalRange = range;
50 53
51 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> 54 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
52 nativeConfig([config createNativeConfiguration]); 55 nativeConfig([config createNativeConfiguration]);
53 EXPECT_TRUE(nativeConfig.get()); 56 EXPECT_TRUE(nativeConfig.get());
54 EXPECT_EQ(1u, nativeConfig->servers.size()); 57 EXPECT_EQ(1u, nativeConfig->servers.size());
55 webrtc::PeerConnectionInterface::IceServer nativeServer = 58 webrtc::PeerConnectionInterface::IceServer nativeServer =
56 nativeConfig->servers.front(); 59 nativeConfig->servers.front();
57 EXPECT_EQ(1u, nativeServer.urls.size()); 60 EXPECT_EQ(1u, nativeServer.urls.size());
58 EXPECT_EQ("stun:stun1.example.net", nativeServer.urls.front()); 61 EXPECT_EQ("stun:stun1.example.net", nativeServer.urls.front());
59 62
60 EXPECT_EQ(webrtc::PeerConnectionInterface::kRelay, nativeConfig->type); 63 EXPECT_EQ(webrtc::PeerConnectionInterface::kRelay, nativeConfig->type);
61 EXPECT_EQ(webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle, 64 EXPECT_EQ(webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle,
62 nativeConfig->bundle_policy); 65 nativeConfig->bundle_policy);
63 EXPECT_EQ(webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate, 66 EXPECT_EQ(webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate,
64 nativeConfig->rtcp_mux_policy); 67 nativeConfig->rtcp_mux_policy);
65 EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled, 68 EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled,
66 nativeConfig->tcp_candidate_policy); 69 nativeConfig->tcp_candidate_policy);
67 EXPECT_EQ(webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost, 70 EXPECT_EQ(webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost,
68 nativeConfig->candidate_network_policy); 71 nativeConfig->candidate_network_policy);
69 EXPECT_EQ(maxPackets, nativeConfig->audio_jitter_buffer_max_packets); 72 EXPECT_EQ(maxPackets, nativeConfig->audio_jitter_buffer_max_packets);
70 EXPECT_EQ(true, nativeConfig->audio_jitter_buffer_fast_accelerate); 73 EXPECT_EQ(true, nativeConfig->audio_jitter_buffer_fast_accelerate);
71 EXPECT_EQ(timeout, nativeConfig->ice_connection_receiving_timeout); 74 EXPECT_EQ(timeout, nativeConfig->ice_connection_receiving_timeout);
72 EXPECT_EQ(interval, nativeConfig->ice_backup_candidate_pair_ping_interval); 75 EXPECT_EQ(interval, nativeConfig->ice_backup_candidate_pair_ping_interval);
73 EXPECT_EQ(webrtc::PeerConnectionInterface::GATHER_CONTINUALLY, 76 EXPECT_EQ(webrtc::PeerConnectionInterface::GATHER_CONTINUALLY,
74 nativeConfig->continual_gathering_policy); 77 nativeConfig->continual_gathering_policy);
75 EXPECT_EQ(true, nativeConfig->prune_turn_ports); 78 EXPECT_EQ(true, nativeConfig->prune_turn_ports);
79 EXPECT_EQ(range.min, nativeConfig->ice_regather_interval_range->min());
80 EXPECT_EQ(range.max, nativeConfig->ice_regather_interval_range->max());
76 } 81 }
77 82
78 - (void)testNativeConversionToConfiguration { 83 - (void)testNativeConversionToConfiguration {
79 NSArray *urlStrings = @[ @"stun:stun1.example.net" ]; 84 NSArray *urlStrings = @[ @"stun:stun1.example.net" ];
80 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings]; 85 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings];
86 RTCIntervalRange *range = [[RTCIntervalRange alloc] initWithMin:0 max:100];
81 87
82 RTCConfiguration *config = [[RTCConfiguration alloc] init]; 88 RTCConfiguration *config = [[RTCConfiguration alloc] init];
83 config.iceServers = @[ server ]; 89 config.iceServers = @[ server ];
84 config.iceTransportPolicy = RTCIceTransportPolicyRelay; 90 config.iceTransportPolicy = RTCIceTransportPolicyRelay;
85 config.bundlePolicy = RTCBundlePolicyMaxBundle; 91 config.bundlePolicy = RTCBundlePolicyMaxBundle;
86 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate; 92 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
87 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled; 93 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
88 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost; 94 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost;
89 const int maxPackets = 60; 95 const int maxPackets = 60;
90 const int timeout = 1; 96 const int timeout = 1;
91 const int interval = 2; 97 const int interval = 2;
92 config.audioJitterBufferMaxPackets = maxPackets; 98 config.audioJitterBufferMaxPackets = maxPackets;
93 config.audioJitterBufferFastAccelerate = YES; 99 config.audioJitterBufferFastAccelerate = YES;
94 config.iceConnectionReceivingTimeout = timeout; 100 config.iceConnectionReceivingTimeout = timeout;
95 config.iceBackupCandidatePairPingInterval = interval; 101 config.iceBackupCandidatePairPingInterval = interval;
96 config.continualGatheringPolicy = 102 config.continualGatheringPolicy =
97 RTCContinualGatheringPolicyGatherContinually; 103 RTCContinualGatheringPolicyGatherContinually;
98 config.shouldPruneTurnPorts = YES; 104 config.shouldPruneTurnPorts = YES;
105 config.iceRegatherIntervalRange = range;
99 106
100 webrtc::PeerConnectionInterface::RTCConfiguration *nativeConfig = 107 webrtc::PeerConnectionInterface::RTCConfiguration *nativeConfig =
101 [config createNativeConfiguration]; 108 [config createNativeConfiguration];
102 RTCConfiguration *newConfig = [[RTCConfiguration alloc] 109 RTCConfiguration *newConfig = [[RTCConfiguration alloc]
103 initWithNativeConfiguration:*nativeConfig]; 110 initWithNativeConfiguration:*nativeConfig];
104 EXPECT_EQ([config.iceServers count], newConfig.iceServers.count); 111 EXPECT_EQ([config.iceServers count], newConfig.iceServers.count);
105 RTCIceServer *newServer = newConfig.iceServers[0]; 112 RTCIceServer *newServer = newConfig.iceServers[0];
106 RTCIceServer *origServer = config.iceServers[0]; 113 RTCIceServer *origServer = config.iceServers[0];
107 EXPECT_EQ(origServer.urlStrings.count, server.urlStrings.count); 114 EXPECT_EQ(origServer.urlStrings.count, server.urlStrings.count);
108 std::string origUrl = origServer.urlStrings.firstObject.UTF8String; 115 std::string origUrl = origServer.urlStrings.firstObject.UTF8String;
109 std::string url = newServer.urlStrings.firstObject.UTF8String; 116 std::string url = newServer.urlStrings.firstObject.UTF8String;
110 EXPECT_EQ(origUrl, url); 117 EXPECT_EQ(origUrl, url);
111 118
112 EXPECT_EQ(config.iceTransportPolicy, newConfig.iceTransportPolicy); 119 EXPECT_EQ(config.iceTransportPolicy, newConfig.iceTransportPolicy);
113 EXPECT_EQ(config.bundlePolicy, newConfig.bundlePolicy); 120 EXPECT_EQ(config.bundlePolicy, newConfig.bundlePolicy);
114 EXPECT_EQ(config.rtcpMuxPolicy, newConfig.rtcpMuxPolicy); 121 EXPECT_EQ(config.rtcpMuxPolicy, newConfig.rtcpMuxPolicy);
115 EXPECT_EQ(config.tcpCandidatePolicy, newConfig.tcpCandidatePolicy); 122 EXPECT_EQ(config.tcpCandidatePolicy, newConfig.tcpCandidatePolicy);
116 EXPECT_EQ(config.candidateNetworkPolicy, newConfig.candidateNetworkPolicy); 123 EXPECT_EQ(config.candidateNetworkPolicy, newConfig.candidateNetworkPolicy);
117 EXPECT_EQ(config.audioJitterBufferMaxPackets, newConfig.audioJitterBufferMaxPa ckets); 124 EXPECT_EQ(config.audioJitterBufferMaxPackets, newConfig.audioJitterBufferMaxPa ckets);
118 EXPECT_EQ(config.audioJitterBufferFastAccelerate, newConfig.audioJitterBufferF astAccelerate); 125 EXPECT_EQ(config.audioJitterBufferFastAccelerate, newConfig.audioJitterBufferF astAccelerate);
119 EXPECT_EQ(config.iceConnectionReceivingTimeout, newConfig.iceConnectionReceivi ngTimeout); 126 EXPECT_EQ(config.iceConnectionReceivingTimeout, newConfig.iceConnectionReceivi ngTimeout);
120 EXPECT_EQ(config.iceBackupCandidatePairPingInterval, 127 EXPECT_EQ(config.iceBackupCandidatePairPingInterval,
121 newConfig.iceBackupCandidatePairPingInterval); 128 newConfig.iceBackupCandidatePairPingInterval);
122 EXPECT_EQ(config.continualGatheringPolicy, newConfig.continualGatheringPolicy) ; 129 EXPECT_EQ(config.continualGatheringPolicy, newConfig.continualGatheringPolicy) ;
123 EXPECT_EQ(config.shouldPruneTurnPorts, newConfig.shouldPruneTurnPorts); 130 EXPECT_EQ(config.shouldPruneTurnPorts, newConfig.shouldPruneTurnPorts);
131 EXPECT_EQ(config.iceRegatherIntervalRange.min, newConfig.iceRegatherIntervalRa nge.min);
132 EXPECT_EQ(config.iceRegatherIntervalRange.max, newConfig.iceRegatherIntervalRa nge.max);
124 } 133 }
125 134
126 @end 135 @end
127 136
128 TEST(RTCConfigurationTest, NativeConfigurationConversionTest) { 137 TEST(RTCConfigurationTest, NativeConfigurationConversionTest) {
129 @autoreleasepool { 138 @autoreleasepool {
130 RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init]; 139 RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init];
131 [test testConversionToNativeConfiguration]; 140 [test testConversionToNativeConfiguration];
132 [test testNativeConversionToConfiguration]; 141 [test testNativeConversionToConfiguration];
133 } 142 }
134 } 143 }
135 144
OLDNEW
« no previous file with comments | « webrtc/sdk/objc/Framework/Headers/WebRTC/WebRTC.h ('k') | webrtc/sdk/objc/Framework/UnitTests/RTCIntervalRangeTests.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698