OLD | NEW |
---|---|
(Empty) | |
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 | |
17 #import "webrtc/api/objc/RTCConfiguration.h" | |
18 #import "webrtc/api/objc/RTCConfiguration+Private.h" | |
19 #import "webrtc/api/objc/RTCIceServer.h" | |
20 #import "webrtc/base/objc/NSString+StdString.h" | |
21 | |
22 @interface RTCConfigurationTest : NSObject | |
23 - (void)testConversionToNativeConfiguration; | |
24 - (void)testInitFromNativeConfiguration; | |
25 @end | |
26 | |
27 @implementation RTCConfigurationTest | |
28 | |
29 - (void)testConversionToNativeConfiguration { | |
30 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:@[ | |
tkchin_webrtc
2016/01/22 21:17:04
separate out the array in its own var
hjon_webrtc
2016/01/22 21:35:22
Done.
| |
31 @"stun:stun1.example.net" ]]; | |
32 | |
33 RTCConfiguration *config = | |
34 [[RTCConfiguration alloc] initWithIceServers:@[server] | |
tkchin_webrtc
2016/01/22 21:17:04
@[ server ]
hjon_webrtc
2016/01/22 21:35:22
Done.
| |
35 iceTransportPolicy:RTCIceTransportPolicyRelay | |
36 bundlePolicy:RTCBundlePolicyMaxBundle | |
37 rtcpMuxPolicy:RTCRtcpMuxPolicyNegotiate | |
38 tcpCandidatePolicy:RTCTcpCandidatePolicyDisabled | |
39 audioJitterBufferMaxPackets:60 | |
40 iceConnectionReceivingTimeout:1 | |
41 iceBackupCandidatePairPingInterval:2]; | |
42 | |
43 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig = | |
44 config.nativeConfiguration; | |
45 EXPECT_EQ((size_t)1, nativeConfig.servers.size()); | |
tkchin_webrtc
2016/01/22 21:17:04
1u?
hjon_webrtc
2016/01/22 21:35:22
Done.
| |
46 webrtc::PeerConnectionInterface::IceServer nativeServer = | |
47 nativeConfig.servers.front(); | |
48 EXPECT_EQ((size_t)1, nativeServer.urls.size()); | |
49 EXPECT_EQ("stun:stun1.example.net", nativeServer.urls.front()); | |
50 | |
51 EXPECT_EQ(webrtc::PeerConnectionInterface::kRelay, nativeConfig.type); | |
52 EXPECT_EQ(webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle, | |
53 nativeConfig.bundle_policy); | |
54 EXPECT_EQ(webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate, | |
55 nativeConfig.rtcp_mux_policy); | |
56 EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled, | |
57 nativeConfig.tcp_candidate_policy); | |
58 EXPECT_EQ(60, nativeConfig.audio_jitter_buffer_max_packets); | |
59 EXPECT_EQ(1, nativeConfig.ice_connection_receiving_timeout); | |
60 EXPECT_EQ(2, nativeConfig.ice_backup_candidate_pair_ping_interval); | |
61 } | |
62 | |
63 - (void)testInitFromNativeConfiguration { | |
64 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig; | |
65 | |
66 webrtc::PeerConnectionInterface::IceServer nativeServer; | |
67 nativeServer.username = "username"; | |
68 nativeServer.password = "password"; | |
69 nativeServer.urls.push_back("stun:stun.example.net"); | |
70 webrtc::PeerConnectionInterface::IceServers servers { nativeServer }; | |
71 | |
72 nativeConfig.servers = servers; | |
73 nativeConfig.type = webrtc::PeerConnectionInterface::kNoHost; | |
74 nativeConfig.bundle_policy = | |
75 webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat; | |
76 nativeConfig.rtcp_mux_policy = | |
77 webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire; | |
78 nativeConfig.tcp_candidate_policy = | |
79 webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; | |
80 nativeConfig.audio_jitter_buffer_max_packets = 40; | |
81 nativeConfig.ice_connection_receiving_timeout = | |
82 webrtc::PeerConnectionInterface::RTCConfiguration::kUndefined; | |
83 nativeConfig.ice_backup_candidate_pair_ping_interval = | |
84 webrtc::PeerConnectionInterface::RTCConfiguration::kUndefined; | |
85 | |
86 RTCConfiguration *config = | |
87 [[RTCConfiguration alloc] initWithNativeConfiguration:nativeConfig]; | |
88 | |
89 EXPECT_EQ((size_t)1, config.iceServers.count); | |
90 RTCIceServer *server = config.iceServers.firstObject; | |
91 EXPECT_EQ((size_t)1, server.urlStrings.count); | |
92 EXPECT_TRUE([@"stun:stun.example.net" isEqualToString: | |
93 server.urlStrings.firstObject]); | |
94 | |
95 EXPECT_EQ(RTCIceTransportPolicyNoHost, config.iceTransportPolicy); | |
96 EXPECT_EQ(RTCBundlePolicyMaxCompat, config.bundlePolicy); | |
97 EXPECT_EQ(RTCRtcpMuxPolicyRequire, config.rtcpMuxPolicy); | |
98 EXPECT_EQ(RTCTcpCandidatePolicyEnabled, config.tcpCandidatePolicy); | |
99 EXPECT_EQ(40, config.audioJitterBufferMaxPackets); | |
100 EXPECT_EQ(-1, config.iceConnectionReceivingTimeout); | |
101 EXPECT_EQ(-1, config.iceBackupCandidatePairPingInterval); | |
102 } | |
103 | |
104 @end | |
105 | |
106 TEST(RTCConfigurationTest, NativeConfigurationConversionTest) { | |
107 @autoreleasepool { | |
108 RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init]; | |
109 [test testConversionToNativeConfiguration]; | |
110 } | |
111 } | |
112 | |
113 TEST(RTCConfigurationTest, InitFromConfigurationTest) { | |
114 @autoreleasepool { | |
115 RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init]; | |
116 [test testInitFromNativeConfiguration]; | |
117 } | |
118 } | |
OLD | NEW |