OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 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 |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 cricket::PORTALLOCATOR_DISABLE_RELAY | | 1204 cricket::PORTALLOCATOR_DISABLE_RELAY | |
1205 cricket::PORTALLOCATOR_DISABLE_TCP | | 1205 cricket::PORTALLOCATOR_DISABLE_TCP | |
1206 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1206 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
1207 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 1207 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
1208 session_->StartGettingPorts(); | 1208 session_->StartGettingPorts(); |
1209 EXPECT_TRUE_WAIT(1U == ports_.size(), kDefaultAllocationTimeout); | 1209 EXPECT_TRUE_WAIT(1U == ports_.size(), kDefaultAllocationTimeout); |
1210 EXPECT_EQ(candidates_.size(), 0u); | 1210 EXPECT_EQ(candidates_.size(), 0u); |
1211 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1211 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
1212 } | 1212 } |
1213 | 1213 |
| 1214 // Test that when adapter enumeration is disabled, even with |
| 1215 // PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE specified, for endpoints not behind |
| 1216 // a NAT, there is only a single STUN candidate because a STUN server is |
| 1217 // specified. |
| 1218 TEST_F(PortAllocatorTest, |
| 1219 TestAdapterEnumerationDisabledWithoutNat_LocalhostFlagSpecified) { |
| 1220 AddInterfaceAsDefault(kClientAddr); |
| 1221 allocator_->set_flags(allocator().flags() | |
| 1222 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
| 1223 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | |
| 1224 cricket::PORTALLOCATOR_DISABLE_RELAY | |
| 1225 cricket::PORTALLOCATOR_DISABLE_TCP | |
| 1226 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE | |
| 1227 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1228 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 1229 session_->StartGettingPorts(); |
| 1230 EXPECT_TRUE_WAIT(1U == ports_.size(), kDefaultAllocationTimeout); |
| 1231 EXPECT_PRED5(CheckCandidate, candidates_[0], |
| 1232 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", |
| 1233 kClientAddr); |
| 1234 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1235 } |
| 1236 |
| 1237 // Test that when adapter enumeration is disabled, with |
| 1238 // PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE specified, a localhost candidate |
| 1239 // is generated because no STUN/TURN servers are specified. |
| 1240 TEST_F(PortAllocatorTest, |
| 1241 TestAdapterEnumerationDisabledWithoutNat_LocalhostCandidate) { |
| 1242 AddInterfaceAsDefault(kClientAddr); |
| 1243 ResetWithNoServers(); |
| 1244 allocator_->set_flags(allocator().flags() | |
| 1245 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
| 1246 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | |
| 1247 cricket::PORTALLOCATOR_DISABLE_RELAY | |
| 1248 cricket::PORTALLOCATOR_DISABLE_TCP | |
| 1249 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE | |
| 1250 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1251 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 1252 session_->StartGettingPorts(); |
| 1253 EXPECT_TRUE_WAIT(1U == ports_.size(), kDefaultAllocationTimeout); |
| 1254 EXPECT_EQ(candidates_.size(), 1u); |
| 1255 EXPECT_PRED5(CheckCandidate, candidates_[0], |
| 1256 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", |
| 1257 rtc::SocketAddress(rtc::GetLoopbackIP(AF_INET), 0)); |
| 1258 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1259 } |
| 1260 |
1214 class AllocationSequenceForTest : public cricket::AllocationSequence { | 1261 class AllocationSequenceForTest : public cricket::AllocationSequence { |
1215 public: | 1262 public: |
1216 AllocationSequenceForTest(cricket::BasicPortAllocatorSession* session, | 1263 AllocationSequenceForTest(cricket::BasicPortAllocatorSession* session, |
1217 rtc::Network* network, | 1264 rtc::Network* network, |
1218 cricket::PortConfiguration* config, | 1265 cricket::PortConfiguration* config, |
1219 uint32 flags) | 1266 uint32 flags) |
1220 : cricket::AllocationSequence(session, network, config, flags) {} | 1267 : cricket::AllocationSequence(session, network, config, flags) {} |
1221 using cricket::AllocationSequence::CreateTurnPort; | 1268 using cricket::AllocationSequence::CreateTurnPort; |
1222 }; | 1269 }; |
1223 | 1270 |
(...skipping 10 matching lines...) Expand all Loading... |
1234 AllocationSequenceForTest alloc_sequence( | 1281 AllocationSequenceForTest alloc_sequence( |
1235 static_cast<cricket::BasicPortAllocatorSession*>(session_.get()), | 1282 static_cast<cricket::BasicPortAllocatorSession*>(session_.get()), |
1236 &network1, &config, flag); | 1283 &network1, &config, flag); |
1237 // This simply tests it will not crash if udp_socket_ in the | 1284 // This simply tests it will not crash if udp_socket_ in the |
1238 // AllocationSequence is null, which is chosen in the constructor. | 1285 // AllocationSequence is null, which is chosen in the constructor. |
1239 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); | 1286 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); |
1240 relay_server.ports.push_back( | 1287 relay_server.ports.push_back( |
1241 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false)); | 1288 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false)); |
1242 alloc_sequence.CreateTurnPort(relay_server); | 1289 alloc_sequence.CreateTurnPort(relay_server); |
1243 } | 1290 } |
OLD | NEW |