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

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

Issue 2979993003: Revert of 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"
22 21
23 @interface RTCConfigurationTest : NSObject 22 @interface RTCConfigurationTest : NSObject
24 - (void)testConversionToNativeConfiguration; 23 - (void)testConversionToNativeConfiguration;
25 - (void)testNativeConversionToConfiguration; 24 - (void)testNativeConversionToConfiguration;
26 @end 25 @end
27 26
28 @implementation RTCConfigurationTest 27 @implementation RTCConfigurationTest
29 28
30 - (void)testConversionToNativeConfiguration { 29 - (void)testConversionToNativeConfiguration {
31 NSArray *urlStrings = @[ @"stun:stun1.example.net" ]; 30 NSArray *urlStrings = @[ @"stun:stun1.example.net" ];
32 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings]; 31 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings];
33 RTCIntervalRange *range = [[RTCIntervalRange alloc] initWithMin:0 max:100];
34 32
35 RTCConfiguration *config = [[RTCConfiguration alloc] init]; 33 RTCConfiguration *config = [[RTCConfiguration alloc] init];
36 config.iceServers = @[ server ]; 34 config.iceServers = @[ server ];
37 config.iceTransportPolicy = RTCIceTransportPolicyRelay; 35 config.iceTransportPolicy = RTCIceTransportPolicyRelay;
38 config.bundlePolicy = RTCBundlePolicyMaxBundle; 36 config.bundlePolicy = RTCBundlePolicyMaxBundle;
39 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate; 37 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
40 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled; 38 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
41 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost; 39 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost;
42 const int maxPackets = 60; 40 const int maxPackets = 60;
43 const int timeout = 1; 41 const int timeout = 1;
44 const int interval = 2; 42 const int interval = 2;
45 config.audioJitterBufferMaxPackets = maxPackets; 43 config.audioJitterBufferMaxPackets = maxPackets;
46 config.audioJitterBufferFastAccelerate = YES; 44 config.audioJitterBufferFastAccelerate = YES;
47 config.iceConnectionReceivingTimeout = timeout; 45 config.iceConnectionReceivingTimeout = timeout;
48 config.iceBackupCandidatePairPingInterval = interval; 46 config.iceBackupCandidatePairPingInterval = interval;
49 config.continualGatheringPolicy = 47 config.continualGatheringPolicy =
50 RTCContinualGatheringPolicyGatherContinually; 48 RTCContinualGatheringPolicyGatherContinually;
51 config.shouldPruneTurnPorts = YES; 49 config.shouldPruneTurnPorts = YES;
52 config.iceRegatherIntervalRange = range;
53 50
54 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> 51 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
55 nativeConfig([config createNativeConfiguration]); 52 nativeConfig([config createNativeConfiguration]);
56 EXPECT_TRUE(nativeConfig.get()); 53 EXPECT_TRUE(nativeConfig.get());
57 EXPECT_EQ(1u, nativeConfig->servers.size()); 54 EXPECT_EQ(1u, nativeConfig->servers.size());
58 webrtc::PeerConnectionInterface::IceServer nativeServer = 55 webrtc::PeerConnectionInterface::IceServer nativeServer =
59 nativeConfig->servers.front(); 56 nativeConfig->servers.front();
60 EXPECT_EQ(1u, nativeServer.urls.size()); 57 EXPECT_EQ(1u, nativeServer.urls.size());
61 EXPECT_EQ("stun:stun1.example.net", nativeServer.urls.front()); 58 EXPECT_EQ("stun:stun1.example.net", nativeServer.urls.front());
62 59
63 EXPECT_EQ(webrtc::PeerConnectionInterface::kRelay, nativeConfig->type); 60 EXPECT_EQ(webrtc::PeerConnectionInterface::kRelay, nativeConfig->type);
64 EXPECT_EQ(webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle, 61 EXPECT_EQ(webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle,
65 nativeConfig->bundle_policy); 62 nativeConfig->bundle_policy);
66 EXPECT_EQ(webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate, 63 EXPECT_EQ(webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate,
67 nativeConfig->rtcp_mux_policy); 64 nativeConfig->rtcp_mux_policy);
68 EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled, 65 EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled,
69 nativeConfig->tcp_candidate_policy); 66 nativeConfig->tcp_candidate_policy);
70 EXPECT_EQ(webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost, 67 EXPECT_EQ(webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost,
71 nativeConfig->candidate_network_policy); 68 nativeConfig->candidate_network_policy);
72 EXPECT_EQ(maxPackets, nativeConfig->audio_jitter_buffer_max_packets); 69 EXPECT_EQ(maxPackets, nativeConfig->audio_jitter_buffer_max_packets);
73 EXPECT_EQ(true, nativeConfig->audio_jitter_buffer_fast_accelerate); 70 EXPECT_EQ(true, nativeConfig->audio_jitter_buffer_fast_accelerate);
74 EXPECT_EQ(timeout, nativeConfig->ice_connection_receiving_timeout); 71 EXPECT_EQ(timeout, nativeConfig->ice_connection_receiving_timeout);
75 EXPECT_EQ(interval, nativeConfig->ice_backup_candidate_pair_ping_interval); 72 EXPECT_EQ(interval, nativeConfig->ice_backup_candidate_pair_ping_interval);
76 EXPECT_EQ(webrtc::PeerConnectionInterface::GATHER_CONTINUALLY, 73 EXPECT_EQ(webrtc::PeerConnectionInterface::GATHER_CONTINUALLY,
77 nativeConfig->continual_gathering_policy); 74 nativeConfig->continual_gathering_policy);
78 EXPECT_EQ(true, nativeConfig->prune_turn_ports); 75 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());
81 } 76 }
82 77
83 - (void)testNativeConversionToConfiguration { 78 - (void)testNativeConversionToConfiguration {
84 NSArray *urlStrings = @[ @"stun:stun1.example.net" ]; 79 NSArray *urlStrings = @[ @"stun:stun1.example.net" ];
85 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings]; 80 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings];
86 RTCIntervalRange *range = [[RTCIntervalRange alloc] initWithMin:0 max:100];
87 81
88 RTCConfiguration *config = [[RTCConfiguration alloc] init]; 82 RTCConfiguration *config = [[RTCConfiguration alloc] init];
89 config.iceServers = @[ server ]; 83 config.iceServers = @[ server ];
90 config.iceTransportPolicy = RTCIceTransportPolicyRelay; 84 config.iceTransportPolicy = RTCIceTransportPolicyRelay;
91 config.bundlePolicy = RTCBundlePolicyMaxBundle; 85 config.bundlePolicy = RTCBundlePolicyMaxBundle;
92 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate; 86 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
93 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled; 87 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
94 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost; 88 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost;
95 const int maxPackets = 60; 89 const int maxPackets = 60;
96 const int timeout = 1; 90 const int timeout = 1;
97 const int interval = 2; 91 const int interval = 2;
98 config.audioJitterBufferMaxPackets = maxPackets; 92 config.audioJitterBufferMaxPackets = maxPackets;
99 config.audioJitterBufferFastAccelerate = YES; 93 config.audioJitterBufferFastAccelerate = YES;
100 config.iceConnectionReceivingTimeout = timeout; 94 config.iceConnectionReceivingTimeout = timeout;
101 config.iceBackupCandidatePairPingInterval = interval; 95 config.iceBackupCandidatePairPingInterval = interval;
102 config.continualGatheringPolicy = 96 config.continualGatheringPolicy =
103 RTCContinualGatheringPolicyGatherContinually; 97 RTCContinualGatheringPolicyGatherContinually;
104 config.shouldPruneTurnPorts = YES; 98 config.shouldPruneTurnPorts = YES;
105 config.iceRegatherIntervalRange = range;
106 99
107 webrtc::PeerConnectionInterface::RTCConfiguration *nativeConfig = 100 webrtc::PeerConnectionInterface::RTCConfiguration *nativeConfig =
108 [config createNativeConfiguration]; 101 [config createNativeConfiguration];
109 RTCConfiguration *newConfig = [[RTCConfiguration alloc] 102 RTCConfiguration *newConfig = [[RTCConfiguration alloc]
110 initWithNativeConfiguration:*nativeConfig]; 103 initWithNativeConfiguration:*nativeConfig];
111 EXPECT_EQ([config.iceServers count], newConfig.iceServers.count); 104 EXPECT_EQ([config.iceServers count], newConfig.iceServers.count);
112 RTCIceServer *newServer = newConfig.iceServers[0]; 105 RTCIceServer *newServer = newConfig.iceServers[0];
113 RTCIceServer *origServer = config.iceServers[0]; 106 RTCIceServer *origServer = config.iceServers[0];
114 EXPECT_EQ(origServer.urlStrings.count, server.urlStrings.count); 107 EXPECT_EQ(origServer.urlStrings.count, server.urlStrings.count);
115 std::string origUrl = origServer.urlStrings.firstObject.UTF8String; 108 std::string origUrl = origServer.urlStrings.firstObject.UTF8String;
116 std::string url = newServer.urlStrings.firstObject.UTF8String; 109 std::string url = newServer.urlStrings.firstObject.UTF8String;
117 EXPECT_EQ(origUrl, url); 110 EXPECT_EQ(origUrl, url);
118 111
119 EXPECT_EQ(config.iceTransportPolicy, newConfig.iceTransportPolicy); 112 EXPECT_EQ(config.iceTransportPolicy, newConfig.iceTransportPolicy);
120 EXPECT_EQ(config.bundlePolicy, newConfig.bundlePolicy); 113 EXPECT_EQ(config.bundlePolicy, newConfig.bundlePolicy);
121 EXPECT_EQ(config.rtcpMuxPolicy, newConfig.rtcpMuxPolicy); 114 EXPECT_EQ(config.rtcpMuxPolicy, newConfig.rtcpMuxPolicy);
122 EXPECT_EQ(config.tcpCandidatePolicy, newConfig.tcpCandidatePolicy); 115 EXPECT_EQ(config.tcpCandidatePolicy, newConfig.tcpCandidatePolicy);
123 EXPECT_EQ(config.candidateNetworkPolicy, newConfig.candidateNetworkPolicy); 116 EXPECT_EQ(config.candidateNetworkPolicy, newConfig.candidateNetworkPolicy);
124 EXPECT_EQ(config.audioJitterBufferMaxPackets, newConfig.audioJitterBufferMaxPa ckets); 117 EXPECT_EQ(config.audioJitterBufferMaxPackets, newConfig.audioJitterBufferMaxPa ckets);
125 EXPECT_EQ(config.audioJitterBufferFastAccelerate, newConfig.audioJitterBufferF astAccelerate); 118 EXPECT_EQ(config.audioJitterBufferFastAccelerate, newConfig.audioJitterBufferF astAccelerate);
126 EXPECT_EQ(config.iceConnectionReceivingTimeout, newConfig.iceConnectionReceivi ngTimeout); 119 EXPECT_EQ(config.iceConnectionReceivingTimeout, newConfig.iceConnectionReceivi ngTimeout);
127 EXPECT_EQ(config.iceBackupCandidatePairPingInterval, 120 EXPECT_EQ(config.iceBackupCandidatePairPingInterval,
128 newConfig.iceBackupCandidatePairPingInterval); 121 newConfig.iceBackupCandidatePairPingInterval);
129 EXPECT_EQ(config.continualGatheringPolicy, newConfig.continualGatheringPolicy) ; 122 EXPECT_EQ(config.continualGatheringPolicy, newConfig.continualGatheringPolicy) ;
130 EXPECT_EQ(config.shouldPruneTurnPorts, newConfig.shouldPruneTurnPorts); 123 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);
133 } 124 }
134 125
135 @end 126 @end
136 127
137 TEST(RTCConfigurationTest, NativeConfigurationConversionTest) { 128 TEST(RTCConfigurationTest, NativeConfigurationConversionTest) {
138 @autoreleasepool { 129 @autoreleasepool {
139 RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init]; 130 RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init];
140 [test testConversionToNativeConfiguration]; 131 [test testConversionToNativeConfiguration];
141 [test testNativeConversionToConfiguration]; 132 [test testNativeConversionToConfiguration];
142 } 133 }
143 } 134 }
144 135
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