| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 // STUN timeout (with all retries) is 9500ms. | 77 // STUN timeout (with all retries) is 9500ms. |
| 78 // Add some margin of error for slow bots. | 78 // Add some margin of error for slow bots. |
| 79 // TODO(deadbeef): Use simulated clock instead of just increasing timeouts to | 79 // TODO(deadbeef): Use simulated clock instead of just increasing timeouts to |
| 80 // fix flaky tests. | 80 // fix flaky tests. |
| 81 static const int kStunTimeoutMs = 15000; | 81 static const int kStunTimeoutMs = 15000; |
| 82 | 82 |
| 83 namespace cricket { | 83 namespace cricket { |
| 84 | 84 |
| 85 // Helper for dumping candidates | 85 // Helper for dumping candidates |
| 86 std::ostream& operator<<(std::ostream& os, const Candidate& c) { | 86 std::ostream& operator<<(std::ostream& os, |
| 87 os << c.ToString(); | 87 const std::vector<Candidate>& candidates) { |
| 88 os << '['; |
| 89 bool first = true; |
| 90 for (const Candidate& c : candidates) { |
| 91 if (!first) { |
| 92 os << ", "; |
| 93 } |
| 94 os << c.ToString(); |
| 95 first = false; |
| 96 }; |
| 97 os << ']'; |
| 88 return os; | 98 return os; |
| 89 } | 99 } |
| 90 | 100 |
| 91 class BasicPortAllocatorTest : public testing::Test, | 101 class BasicPortAllocatorTest : public testing::Test, |
| 92 public sigslot::has_slots<> { | 102 public sigslot::has_slots<> { |
| 93 public: | 103 public: |
| 94 BasicPortAllocatorTest() | 104 BasicPortAllocatorTest() |
| 95 : pss_(new rtc::PhysicalSocketServer), | 105 : pss_(new rtc::PhysicalSocketServer), |
| 96 vss_(new rtc::VirtualSocketServer(pss_.get())), | 106 vss_(new rtc::VirtualSocketServer(pss_.get())), |
| 97 fss_(new rtc::FirewallSocketServer(vss_.get())), | 107 fss_(new rtc::FirewallSocketServer(vss_.get())), |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 sid, content_name, component, ice_ufrag, ice_pwd); | 232 sid, content_name, component, ice_ufrag, ice_pwd); |
| 223 session->SignalPortReady.connect(this, | 233 session->SignalPortReady.connect(this, |
| 224 &BasicPortAllocatorTest::OnPortReady); | 234 &BasicPortAllocatorTest::OnPortReady); |
| 225 session->SignalCandidatesReady.connect( | 235 session->SignalCandidatesReady.connect( |
| 226 this, &BasicPortAllocatorTest::OnCandidatesReady); | 236 this, &BasicPortAllocatorTest::OnCandidatesReady); |
| 227 session->SignalCandidatesAllocationDone.connect( | 237 session->SignalCandidatesAllocationDone.connect( |
| 228 this, &BasicPortAllocatorTest::OnCandidatesAllocationDone); | 238 this, &BasicPortAllocatorTest::OnCandidatesAllocationDone); |
| 229 return session; | 239 return session; |
| 230 } | 240 } |
| 231 | 241 |
| 232 static bool CheckCandidate(const Candidate& c, | 242 // Return true if the addresses are the same, or the port is 0 in |pattern| |
| 233 int component, | 243 // (acting as a wildcard) and the IPs are the same. |
| 234 const std::string& type, | 244 // Even with a wildcard port, the port of the address should be nonzero if |
| 235 const std::string& proto, | 245 // the IP is nonzero. |
| 236 const SocketAddress& addr) { | 246 static bool AddressMatch(const SocketAddress& address, |
| 237 return (c.component() == component && c.type() == type && | 247 const SocketAddress& pattern) { |
| 238 c.protocol() == proto && c.address().ipaddr() == addr.ipaddr() && | 248 return address.ipaddr() == pattern.ipaddr() && |
| 239 ((addr.port() == 0 && (c.address().port() != 0)) || | 249 ((pattern.port() == 0 && |
| 240 (c.address().port() == addr.port()))); | 250 (address.port() != 0 || IPIsAny(address.ipaddr()))) || |
| 251 (pattern.port() != 0 && address.port() == pattern.port())); |
| 241 } | 252 } |
| 253 |
| 254 // Find a candidate and return it. |
| 255 static bool FindCandidate(const std::vector<Candidate>& candidates, |
| 256 const std::string& type, |
| 257 const std::string& proto, |
| 258 const SocketAddress& addr, |
| 259 Candidate* found) { |
| 260 auto it = std::find_if(candidates.begin(), candidates.end(), |
| 261 [type, proto, addr](const Candidate& c) { |
| 262 return c.type() == type && c.protocol() == proto && |
| 263 AddressMatch(c.address(), addr); |
| 264 }); |
| 265 if (it != candidates.end() && found) { |
| 266 *found = *it; |
| 267 } |
| 268 return it != candidates.end(); |
| 269 } |
| 270 |
| 271 // Convenience method to call FindCandidate with no return. |
| 272 static bool HasCandidate(const std::vector<Candidate>& candidates, |
| 273 const std::string& type, |
| 274 const std::string& proto, |
| 275 const SocketAddress& addr) { |
| 276 return FindCandidate(candidates, type, proto, addr, nullptr); |
| 277 } |
| 278 |
| 279 // Version of HasCandidate that also takes a related address. |
| 280 static bool HasCandidateWithRelatedAddr( |
| 281 const std::vector<Candidate>& candidates, |
| 282 const std::string& type, |
| 283 const std::string& proto, |
| 284 const SocketAddress& addr, |
| 285 const SocketAddress& related_addr) { |
| 286 auto it = |
| 287 std::find_if(candidates.begin(), candidates.end(), |
| 288 [type, proto, addr, related_addr](const Candidate& c) { |
| 289 return c.type() == type && c.protocol() == proto && |
| 290 AddressMatch(c.address(), addr) && |
| 291 AddressMatch(c.related_address(), related_addr); |
| 292 }); |
| 293 return it != candidates.end(); |
| 294 } |
| 295 |
| 242 static bool CheckPort(const rtc::SocketAddress& addr, | 296 static bool CheckPort(const rtc::SocketAddress& addr, |
| 243 int min_port, | 297 int min_port, |
| 244 int max_port) { | 298 int max_port) { |
| 245 return (addr.port() >= min_port && addr.port() <= max_port); | 299 return (addr.port() >= min_port && addr.port() <= max_port); |
| 246 } | 300 } |
| 247 | 301 |
| 248 void OnCandidatesAllocationDone(PortAllocatorSession* session) { | 302 void OnCandidatesAllocationDone(PortAllocatorSession* session) { |
| 249 // We should only get this callback once, except in the mux test where | 303 // We should only get this callback once, except in the mux test where |
| 250 // we have multiple port allocation sessions. | 304 // we have multiple port allocation sessions. |
| 251 if (session == session_.get()) { | 305 if (session == session_.get()) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 344 } |
| 291 session_->set_flags(session_->flags() | | 345 session_->set_flags(session_->flags() | |
| 292 PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | | 346 PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | |
| 293 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 347 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 294 allocator().set_allow_tcp_listen(false); | 348 allocator().set_allow_tcp_listen(false); |
| 295 session_->StartGettingPorts(); | 349 session_->StartGettingPorts(); |
| 296 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 350 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 297 | 351 |
| 298 uint32_t total_candidates = 0; | 352 uint32_t total_candidates = 0; |
| 299 if (!host_candidate_addr.IsNil()) { | 353 if (!host_candidate_addr.IsNil()) { |
| 300 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], | 354 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", |
| 301 ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", | |
| 302 rtc::SocketAddress(kPrivateAddr.ipaddr(), 0)); | 355 rtc::SocketAddress(kPrivateAddr.ipaddr(), 0)); |
| 303 ++total_candidates; | 356 ++total_candidates; |
| 304 } | 357 } |
| 305 if (!stun_candidate_addr.IsNil()) { | 358 if (!stun_candidate_addr.IsNil()) { |
| 306 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], | 359 rtc::SocketAddress related_address(host_candidate_addr, 0); |
| 307 ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", | |
| 308 rtc::SocketAddress(stun_candidate_addr, 0)); | |
| 309 rtc::IPAddress related_address = host_candidate_addr; | |
| 310 if (host_candidate_addr.IsNil()) { | 360 if (host_candidate_addr.IsNil()) { |
| 311 related_address = | 361 related_address.SetIP(rtc::GetAnyIP(stun_candidate_addr.family())); |
| 312 rtc::GetAnyIP(candidates_[total_candidates].address().family()); | |
| 313 } | 362 } |
| 314 EXPECT_EQ(related_address, | 363 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "stun", "udp", |
| 315 candidates_[total_candidates].related_address().ipaddr()); | 364 rtc::SocketAddress(stun_candidate_addr, 0), related_address); |
| 316 ++total_candidates; | 365 ++total_candidates; |
| 317 } | 366 } |
| 318 if (!relay_candidate_udp_transport_addr.IsNil()) { | 367 if (!relay_candidate_udp_transport_addr.IsNil()) { |
| 319 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], | 368 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp", |
| 320 ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp", | 369 rtc::SocketAddress(relay_candidate_udp_transport_addr, 0), |
| 321 rtc::SocketAddress(relay_candidate_udp_transport_addr, 0)); | 370 rtc::SocketAddress(stun_candidate_addr, 0)); |
| 322 EXPECT_EQ(stun_candidate_addr, | |
| 323 candidates_[total_candidates].related_address().ipaddr()); | |
| 324 ++total_candidates; | 371 ++total_candidates; |
| 325 } | 372 } |
| 326 if (!relay_candidate_tcp_transport_addr.IsNil()) { | 373 if (!relay_candidate_tcp_transport_addr.IsNil()) { |
| 327 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], | 374 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp", |
| 328 ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp", | 375 rtc::SocketAddress(relay_candidate_tcp_transport_addr, 0), |
| 329 rtc::SocketAddress(relay_candidate_tcp_transport_addr, 0)); | 376 rtc::SocketAddress(stun_candidate_addr, 0)); |
| 330 EXPECT_EQ(stun_candidate_addr, | |
| 331 candidates_[total_candidates].related_address().ipaddr()); | |
| 332 ++total_candidates; | 377 ++total_candidates; |
| 333 } | 378 } |
| 334 | 379 |
| 335 EXPECT_EQ(total_candidates, candidates_.size()); | 380 EXPECT_EQ(total_candidates, candidates_.size()); |
| 336 EXPECT_EQ(total_ports, ports_.size()); | 381 EXPECT_EQ(total_ports, ports_.size()); |
| 337 } | 382 } |
| 338 | 383 |
| 339 protected: | 384 protected: |
| 340 BasicPortAllocator& allocator() { return *allocator_; } | 385 BasicPortAllocator& allocator() { return *allocator_; } |
| 341 | 386 |
| 342 void OnPortReady(PortAllocatorSession* ses, PortInterface* port) { | 387 void OnPortReady(PortAllocatorSession* ses, PortInterface* port) { |
| 343 LOG(LS_INFO) << "OnPortReady: " << port->ToString(); | 388 LOG(LS_INFO) << "OnPortReady: " << port->ToString(); |
| 344 ports_.push_back(port); | 389 ports_.push_back(port); |
| 345 // Make sure the new port is added to ReadyPorts. | 390 // Make sure the new port is added to ReadyPorts. |
| 346 auto ready_ports = ses->ReadyPorts(); | 391 auto ready_ports = ses->ReadyPorts(); |
| 347 EXPECT_NE(ready_ports.end(), | 392 EXPECT_NE(ready_ports.end(), |
| 348 std::find(ready_ports.begin(), ready_ports.end(), port)); | 393 std::find(ready_ports.begin(), ready_ports.end(), port)); |
| 349 } | 394 } |
| 350 void OnCandidatesReady(PortAllocatorSession* ses, | 395 void OnCandidatesReady(PortAllocatorSession* ses, |
| 351 const std::vector<Candidate>& candidates) { | 396 const std::vector<Candidate>& candidates) { |
| 352 for (size_t i = 0; i < candidates.size(); ++i) { | 397 for (const Candidate& candidate : candidates) { |
| 353 LOG(LS_INFO) << "OnCandidatesReady: " << candidates[i].ToString(); | 398 LOG(LS_INFO) << "OnCandidatesReady: " << candidate.ToString(); |
| 354 candidates_.push_back(candidates[i]); | 399 // Sanity check that the ICE component is set. |
| 400 EXPECT_EQ(ICE_CANDIDATE_COMPONENT_RTP, candidate.component()); |
| 401 candidates_.push_back(candidate); |
| 355 } | 402 } |
| 356 // Make sure the new candidates are added to Candidates. | 403 // Make sure the new candidates are added to Candidates. |
| 357 auto ses_candidates = ses->ReadyCandidates(); | 404 auto ses_candidates = ses->ReadyCandidates(); |
| 358 for (const Candidate& candidate : candidates) { | 405 for (const Candidate& candidate : candidates) { |
| 359 EXPECT_NE( | 406 EXPECT_NE( |
| 360 ses_candidates.end(), | 407 ses_candidates.end(), |
| 361 std::find(ses_candidates.begin(), ses_candidates.end(), candidate)); | 408 std::find(ses_candidates.begin(), ses_candidates.end(), candidate)); |
| 362 } | 409 } |
| 363 } | 410 } |
| 364 | 411 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 EXPECT_EQ(1U, candidates_.size()); | 544 EXPECT_EQ(1U, candidates_.size()); |
| 498 } | 545 } |
| 499 | 546 |
| 500 // Tests that we can get all the desired addresses successfully. | 547 // Tests that we can get all the desired addresses successfully. |
| 501 TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithMinimumStepDelay) { | 548 TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithMinimumStepDelay) { |
| 502 AddInterface(kClientAddr); | 549 AddInterface(kClientAddr); |
| 503 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 550 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 504 session_->StartGettingPorts(); | 551 session_->StartGettingPorts(); |
| 505 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 552 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); |
| 506 EXPECT_EQ(4U, ports_.size()); | 553 EXPECT_EQ(4U, ports_.size()); |
| 507 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 554 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 508 "local", "udp", kClientAddr); | 555 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr); |
| 509 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 556 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 510 "stun", "udp", kClientAddr); | 557 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 511 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | 558 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 512 "relay", "udp", kRelayUdpIntAddr); | 559 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 513 EXPECT_PRED5(CheckCandidate, candidates_[3], ICE_CANDIDATE_COMPONENT_RTP, | 560 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 514 "relay", "udp", kRelayUdpExtAddr); | 561 kRelaySslTcpIntAddr); |
| 515 EXPECT_PRED5(CheckCandidate, candidates_[4], ICE_CANDIDATE_COMPONENT_RTP, | |
| 516 "relay", "tcp", kRelayTcpIntAddr); | |
| 517 EXPECT_PRED5(CheckCandidate, candidates_[5], ICE_CANDIDATE_COMPONENT_RTP, | |
| 518 "local", "tcp", kClientAddr); | |
| 519 EXPECT_PRED5(CheckCandidate, candidates_[6], ICE_CANDIDATE_COMPONENT_RTP, | |
| 520 "relay", "ssltcp", kRelaySslTcpIntAddr); | |
| 521 EXPECT_TRUE(candidate_allocation_done_); | 562 EXPECT_TRUE(candidate_allocation_done_); |
| 522 } | 563 } |
| 523 | 564 |
| 524 // Test that when the same network interface is brought down and up, the | 565 // Test that when the same network interface is brought down and up, the |
| 525 // port allocator session will restart a new allocation sequence if | 566 // port allocator session will restart a new allocation sequence if |
| 526 // it is not stopped. | 567 // it is not stopped. |
| 527 TEST_F(BasicPortAllocatorTest, TestSameNetworkDownAndUpWhenSessionNotStopped) { | 568 TEST_F(BasicPortAllocatorTest, TestSameNetworkDownAndUpWhenSessionNotStopped) { |
| 528 std::string if_name("test_net0"); | 569 std::string if_name("test_net0"); |
| 529 AddInterface(kClientAddr, if_name); | 570 AddInterface(kClientAddr, if_name); |
| 530 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 571 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 // Verify candidates with default step delay of 1sec. | 620 // Verify candidates with default step delay of 1sec. |
| 580 TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithOneSecondStepDelay) { | 621 TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithOneSecondStepDelay) { |
| 581 AddInterface(kClientAddr); | 622 AddInterface(kClientAddr); |
| 582 allocator_->set_step_delay(kDefaultStepDelay); | 623 allocator_->set_step_delay(kDefaultStepDelay); |
| 583 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 624 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 584 session_->StartGettingPorts(); | 625 session_->StartGettingPorts(); |
| 585 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 626 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); |
| 586 EXPECT_EQ(2U, ports_.size()); | 627 EXPECT_EQ(2U, ports_.size()); |
| 587 ASSERT_EQ_WAIT(4U, candidates_.size(), 2000); | 628 ASSERT_EQ_WAIT(4U, candidates_.size(), 2000); |
| 588 EXPECT_EQ(3U, ports_.size()); | 629 EXPECT_EQ(3U, ports_.size()); |
| 589 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | 630 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 590 "relay", "udp", kRelayUdpIntAddr); | 631 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 591 EXPECT_PRED5(CheckCandidate, candidates_[3], ICE_CANDIDATE_COMPONENT_RTP, | |
| 592 "relay", "udp", kRelayUdpExtAddr); | |
| 593 ASSERT_EQ_WAIT(6U, candidates_.size(), 1500); | 632 ASSERT_EQ_WAIT(6U, candidates_.size(), 1500); |
| 594 EXPECT_PRED5(CheckCandidate, candidates_[4], ICE_CANDIDATE_COMPONENT_RTP, | 633 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 595 "relay", "tcp", kRelayTcpIntAddr); | 634 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 596 EXPECT_PRED5(CheckCandidate, candidates_[5], ICE_CANDIDATE_COMPONENT_RTP, | |
| 597 "local", "tcp", kClientAddr); | |
| 598 EXPECT_EQ(4U, ports_.size()); | 635 EXPECT_EQ(4U, ports_.size()); |
| 599 ASSERT_EQ_WAIT(7U, candidates_.size(), 2000); | 636 ASSERT_EQ_WAIT(7U, candidates_.size(), 2000); |
| 600 EXPECT_PRED5(CheckCandidate, candidates_[6], ICE_CANDIDATE_COMPONENT_RTP, | 637 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 601 "relay", "ssltcp", kRelaySslTcpIntAddr); | 638 kRelaySslTcpIntAddr); |
| 602 EXPECT_EQ(4U, ports_.size()); | 639 EXPECT_EQ(4U, ports_.size()); |
| 603 EXPECT_TRUE(candidate_allocation_done_); | 640 EXPECT_TRUE(candidate_allocation_done_); |
| 604 // If we Stop gathering now, we shouldn't get a second "done" callback. | 641 // If we Stop gathering now, we shouldn't get a second "done" callback. |
| 605 session_->StopGettingPorts(); | 642 session_->StopGettingPorts(); |
| 606 } | 643 } |
| 607 | 644 |
| 608 TEST_F(BasicPortAllocatorTest, TestSetupVideoRtpPortsWithNormalSendBuffers) { | 645 TEST_F(BasicPortAllocatorTest, TestSetupVideoRtpPortsWithNormalSendBuffers) { |
| 609 AddInterface(kClientAddr); | 646 AddInterface(kClientAddr); |
| 610 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP, CN_VIDEO)); | 647 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP, CN_VIDEO)); |
| 611 session_->StartGettingPorts(); | 648 session_->StartGettingPorts(); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 ResetWithStunServerAndNat(kStunAddr); | 802 ResetWithStunServerAndNat(kStunAddr); |
| 766 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 803 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 767 session_->set_flags(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); | 804 session_->set_flags(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); |
| 768 // Expect to see 2 ports: STUN and TCP ports, and single STUN candidate. | 805 // Expect to see 2 ports: STUN and TCP ports, and single STUN candidate. |
| 769 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), kNatUdpAddr.ipaddr(), | 806 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), kNatUdpAddr.ipaddr(), |
| 770 rtc::IPAddress(), rtc::IPAddress()); | 807 rtc::IPAddress(), rtc::IPAddress()); |
| 771 } | 808 } |
| 772 | 809 |
| 773 // Test that we disable relay over UDP, and only TCP is used when connecting to | 810 // Test that we disable relay over UDP, and only TCP is used when connecting to |
| 774 // the relay server. | 811 // the relay server. |
| 775 TEST_F(BasicPortAllocatorTest, DISABLED_TestDisableUdpTurn) { | 812 TEST_F(BasicPortAllocatorTest, TestDisableUdpTurn) { |
| 776 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); | 813 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); |
| 777 AddInterface(kClientAddr); | 814 AddInterface(kClientAddr); |
| 778 ResetWithStunServerAndNat(kStunAddr); | 815 ResetWithStunServerAndNat(kStunAddr); |
| 779 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 816 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |
| 780 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 817 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 781 session_->set_flags(PORTALLOCATOR_DISABLE_UDP_RELAY | | 818 session_->set_flags(PORTALLOCATOR_DISABLE_UDP_RELAY | |
| 782 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | | 819 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | |
| 783 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 820 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 784 | 821 |
| 785 session_->StartGettingPorts(); | 822 session_->StartGettingPorts(); |
| 786 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 823 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 787 | 824 |
| 788 // Expect to see 2 ports and 2 candidates - TURN/TCP and TCP ports, TCP and | 825 // Expect to see 2 ports and 2 candidates - TURN/TCP and TCP ports, TCP and |
| 789 // TURN/TCP candidates. | 826 // TURN/TCP candidates. |
| 790 EXPECT_EQ(2U, ports_.size()); | 827 EXPECT_EQ(2U, ports_.size()); |
| 791 EXPECT_EQ(2U, candidates_.size()); | 828 EXPECT_EQ(2U, candidates_.size()); |
| 792 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 829 Candidate turn_candidate; |
| 793 "relay", "udp", kTurnUdpExtAddr); | 830 EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp", kTurnUdpExtAddr, |
| 831 &turn_candidate); |
| 794 // The TURN candidate should use TCP to contact the TURN server. | 832 // The TURN candidate should use TCP to contact the TURN server. |
| 795 EXPECT_EQ(TCP_PROTOCOL_NAME, candidates_[0].relay_protocol()); | 833 EXPECT_EQ(TCP_PROTOCOL_NAME, turn_candidate.relay_protocol()); |
| 796 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 834 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 797 "local", "tcp", kClientAddr); | |
| 798 } | 835 } |
| 799 | 836 |
| 800 // Disable for asan, see | 837 // Disable for asan, see |
| 801 // https://code.google.com/p/webrtc/issues/detail?id=4743 for details. | 838 // https://code.google.com/p/webrtc/issues/detail?id=4743 for details. |
| 802 #if !defined(ADDRESS_SANITIZER) | 839 #if !defined(ADDRESS_SANITIZER) |
| 803 | 840 |
| 804 // Test that we can get OnCandidatesAllocationDone callback when all the ports | 841 // Test that we can get OnCandidatesAllocationDone callback when all the ports |
| 805 // are disabled. | 842 // are disabled. |
| 806 TEST_F(BasicPortAllocatorTest, TestDisableAllPorts) { | 843 TEST_F(BasicPortAllocatorTest, TestDisableAllPorts) { |
| 807 AddInterface(kClientAddr); | 844 AddInterface(kClientAddr); |
| 808 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 845 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 809 session_->set_flags(PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | | 846 session_->set_flags(PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | |
| 810 PORTALLOCATOR_DISABLE_RELAY | PORTALLOCATOR_DISABLE_TCP); | 847 PORTALLOCATOR_DISABLE_RELAY | PORTALLOCATOR_DISABLE_TCP); |
| 811 session_->StartGettingPorts(); | 848 session_->StartGettingPorts(); |
| 812 rtc::Thread::Current()->ProcessMessages(100); | 849 rtc::Thread::Current()->ProcessMessages(100); |
| 813 EXPECT_EQ(0U, candidates_.size()); | 850 EXPECT_EQ(0U, candidates_.size()); |
| 814 EXPECT_TRUE(candidate_allocation_done_); | 851 EXPECT_TRUE(candidate_allocation_done_); |
| 815 } | 852 } |
| 816 | 853 |
| 817 // Test that we don't crash or malfunction if we can't create UDP sockets. | 854 // Test that we don't crash or malfunction if we can't create UDP sockets. |
| 818 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSockets) { | 855 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSockets) { |
| 819 AddInterface(kClientAddr); | 856 AddInterface(kClientAddr); |
| 820 fss_->set_udp_sockets_enabled(false); | 857 fss_->set_udp_sockets_enabled(false); |
| 821 EXPECT_TRUE(CreateSession(1)); | 858 EXPECT_TRUE(CreateSession(1)); |
| 822 session_->StartGettingPorts(); | 859 session_->StartGettingPorts(); |
| 823 ASSERT_EQ_WAIT(5U, candidates_.size(), kDefaultAllocationTimeout); | 860 ASSERT_EQ_WAIT(5U, candidates_.size(), kDefaultAllocationTimeout); |
| 824 EXPECT_EQ(2U, ports_.size()); | 861 EXPECT_EQ(2U, ports_.size()); |
| 825 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 862 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 826 "relay", "udp", kRelayUdpIntAddr); | 863 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 827 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 864 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 828 "relay", "udp", kRelayUdpExtAddr); | 865 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 829 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | 866 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 830 "relay", "tcp", kRelayTcpIntAddr); | 867 kRelaySslTcpIntAddr); |
| 831 EXPECT_PRED5(CheckCandidate, candidates_[3], ICE_CANDIDATE_COMPONENT_RTP, | |
| 832 "local", "tcp", kClientAddr); | |
| 833 EXPECT_PRED5(CheckCandidate, candidates_[4], ICE_CANDIDATE_COMPONENT_RTP, | |
| 834 "relay", "ssltcp", kRelaySslTcpIntAddr); | |
| 835 EXPECT_TRUE(candidate_allocation_done_); | 868 EXPECT_TRUE(candidate_allocation_done_); |
| 836 } | 869 } |
| 837 | 870 |
| 838 #endif // if !defined(ADDRESS_SANITIZER) | 871 #endif // if !defined(ADDRESS_SANITIZER) |
| 839 | 872 |
| 840 // Test that we don't crash or malfunction if we can't create UDP sockets or | 873 // Test that we don't crash or malfunction if we can't create UDP sockets or |
| 841 // listen on TCP sockets. We still give out a local TCP address, since | 874 // listen on TCP sockets. We still give out a local TCP address, since |
| 842 // apparently this is needed for the remote side to accept our connection. | 875 // apparently this is needed for the remote side to accept our connection. |
| 843 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSocketsNoTcpListen) { | 876 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSocketsNoTcpListen) { |
| 844 AddInterface(kClientAddr); | 877 AddInterface(kClientAddr); |
| 845 fss_->set_udp_sockets_enabled(false); | 878 fss_->set_udp_sockets_enabled(false); |
| 846 fss_->set_tcp_listen_enabled(false); | 879 fss_->set_tcp_listen_enabled(false); |
| 847 EXPECT_TRUE(CreateSession(1)); | 880 EXPECT_TRUE(CreateSession(1)); |
| 848 session_->StartGettingPorts(); | 881 session_->StartGettingPorts(); |
| 849 ASSERT_EQ_WAIT(5U, candidates_.size(), kDefaultAllocationTimeout); | 882 ASSERT_EQ_WAIT(5U, candidates_.size(), kDefaultAllocationTimeout); |
| 850 EXPECT_EQ(2U, ports_.size()); | 883 EXPECT_EQ(2U, ports_.size()); |
| 851 EXPECT_PRED5(CheckCandidate, candidates_[0], 1, "relay", "udp", | 884 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 852 kRelayUdpIntAddr); | 885 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 853 EXPECT_PRED5(CheckCandidate, candidates_[1], 1, "relay", "udp", | 886 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 854 kRelayUdpExtAddr); | 887 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 855 EXPECT_PRED5(CheckCandidate, candidates_[2], 1, "relay", "tcp", | 888 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 856 kRelayTcpIntAddr); | |
| 857 EXPECT_PRED5(CheckCandidate, candidates_[3], 1, "local", "tcp", kClientAddr); | |
| 858 EXPECT_PRED5(CheckCandidate, candidates_[4], 1, "relay", "ssltcp", | |
| 859 kRelaySslTcpIntAddr); | 889 kRelaySslTcpIntAddr); |
| 860 EXPECT_TRUE(candidate_allocation_done_); | 890 EXPECT_TRUE(candidate_allocation_done_); |
| 861 } | 891 } |
| 862 | 892 |
| 863 // Test that we don't crash or malfunction if we can't create any sockets. | 893 // Test that we don't crash or malfunction if we can't create any sockets. |
| 864 // TODO(deadbeef): Find a way to exit early here. | 894 // TODO(deadbeef): Find a way to exit early here. |
| 865 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoSockets) { | 895 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoSockets) { |
| 866 AddInterface(kClientAddr); | 896 AddInterface(kClientAddr); |
| 867 fss_->set_tcp_sockets_enabled(false); | 897 fss_->set_tcp_sockets_enabled(false); |
| 868 fss_->set_udp_sockets_enabled(false); | 898 fss_->set_udp_sockets_enabled(false); |
| 869 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 899 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 870 session_->StartGettingPorts(); | 900 session_->StartGettingPorts(); |
| 871 WAIT(candidates_.size() > 0, 2000); | 901 WAIT(candidates_.size() > 0, 2000); |
| 872 // TODO(deadbeef): Check candidate_allocation_done signal. | 902 // TODO(deadbeef): Check candidate_allocation_done signal. |
| 873 // In case of Relay, ports creation will succeed but sockets will fail. | 903 // In case of Relay, ports creation will succeed but sockets will fail. |
| 874 // There is no error reporting from RelayEntry to handle this failure. | 904 // There is no error reporting from RelayEntry to handle this failure. |
| 875 } | 905 } |
| 876 | 906 |
| 877 // Testing STUN timeout. | 907 // Testing STUN timeout. |
| 878 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpAllowed) { | 908 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpAllowed) { |
| 879 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); | 909 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); |
| 880 AddInterface(kClientAddr); | 910 AddInterface(kClientAddr); |
| 881 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 911 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 882 session_->StartGettingPorts(); | 912 session_->StartGettingPorts(); |
| 883 EXPECT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); | 913 EXPECT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); |
| 884 EXPECT_EQ(2U, ports_.size()); | 914 EXPECT_EQ(2U, ports_.size()); |
| 885 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 915 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 886 "local", "udp", kClientAddr); | 916 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 887 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | |
| 888 "local", "tcp", kClientAddr); | |
| 889 // RelayPort connection timeout is 3sec. TCP connection with RelayServer | 917 // RelayPort connection timeout is 3sec. TCP connection with RelayServer |
| 890 // will be tried after 3 seconds. | 918 // will be tried after 3 seconds. |
| 891 EXPECT_EQ_WAIT(6U, candidates_.size(), 4000); | 919 EXPECT_EQ_WAIT(6U, candidates_.size(), 4000); |
| 892 EXPECT_EQ(3U, ports_.size()); | 920 EXPECT_EQ(3U, ports_.size()); |
| 893 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | 921 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
| 894 "relay", "udp", kRelayUdpIntAddr); | 922 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
| 895 EXPECT_PRED5(CheckCandidate, candidates_[3], ICE_CANDIDATE_COMPONENT_RTP, | 923 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
| 896 "relay", "tcp", kRelayTcpIntAddr); | 924 kRelaySslTcpIntAddr); |
| 897 EXPECT_PRED5(CheckCandidate, candidates_[4], ICE_CANDIDATE_COMPONENT_RTP, | 925 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
| 898 "relay", "ssltcp", kRelaySslTcpIntAddr); | |
| 899 EXPECT_PRED5(CheckCandidate, candidates_[5], ICE_CANDIDATE_COMPONENT_RTP, | |
| 900 "relay", "udp", kRelayUdpExtAddr); | |
| 901 // Stun Timeout is 9sec. | 926 // Stun Timeout is 9sec. |
| 902 EXPECT_TRUE_WAIT(candidate_allocation_done_, 9000); | 927 EXPECT_TRUE_WAIT(candidate_allocation_done_, 9000); |
| 903 } | 928 } |
| 904 | 929 |
| 905 TEST_F(BasicPortAllocatorTest, TestCandidatePriorityOfMultipleInterfaces) { | 930 TEST_F(BasicPortAllocatorTest, TestCandidatePriorityOfMultipleInterfaces) { |
| 906 AddInterface(kClientAddr); | 931 AddInterface(kClientAddr); |
| 907 AddInterface(kClientAddr2); | 932 AddInterface(kClientAddr2); |
| 908 // Allocating only host UDP ports. This is done purely for testing | 933 // Allocating only host UDP ports. This is done purely for testing |
| 909 // convenience. | 934 // convenience. |
| 910 allocator().set_flags(PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_STUN | | 935 allocator().set_flags(PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_STUN | |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 // address with the correct family. This is to prevent any local | 977 // address with the correct family. This is to prevent any local |
| 953 // reflective address leakage in the sdp line. | 978 // reflective address leakage in the sdp line. |
| 954 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithRelayOnly) { | 979 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithRelayOnly) { |
| 955 AddInterface(kClientAddr); | 980 AddInterface(kClientAddr); |
| 956 // GTURN is not configured here. | 981 // GTURN is not configured here. |
| 957 ResetWithTurnServersNoNat(kTurnUdpIntAddr, rtc::SocketAddress()); | 982 ResetWithTurnServersNoNat(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 958 allocator().set_candidate_filter(CF_RELAY); | 983 allocator().set_candidate_filter(CF_RELAY); |
| 959 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 984 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 960 session_->StartGettingPorts(); | 985 session_->StartGettingPorts(); |
| 961 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 986 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 962 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 987 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 963 "relay", "udp", rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 988 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 964 | 989 |
| 965 EXPECT_EQ(1U, candidates_.size()); | 990 EXPECT_EQ(1U, candidates_.size()); |
| 966 EXPECT_EQ(1U, ports_.size()); // Only Relay port will be in ready state. | 991 EXPECT_EQ(1U, ports_.size()); // Only Relay port will be in ready state. |
| 967 for (size_t i = 0; i < candidates_.size(); ++i) { | 992 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidates_[0].type()); |
| 968 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidates_[i].type()); | 993 EXPECT_EQ( |
| 969 EXPECT_EQ( | 994 candidates_[0].related_address(), |
| 970 candidates_[0].related_address(), | 995 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); |
| 971 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); | |
| 972 } | |
| 973 } | 996 } |
| 974 | 997 |
| 975 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithHostOnly) { | 998 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithHostOnly) { |
| 976 AddInterface(kClientAddr); | 999 AddInterface(kClientAddr); |
| 977 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1000 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 978 allocator().set_candidate_filter(CF_HOST); | 1001 allocator().set_candidate_filter(CF_HOST); |
| 979 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1002 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 980 session_->StartGettingPorts(); | 1003 session_->StartGettingPorts(); |
| 981 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1004 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 982 EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only. | 1005 EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only. |
| 983 EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only. | 1006 EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only. |
| 984 for (size_t i = 0; i < candidates_.size(); ++i) { | 1007 for (const Candidate& candidate : candidates_) { |
| 985 EXPECT_EQ(std::string(LOCAL_PORT_TYPE), candidates_[i].type()); | 1008 EXPECT_EQ(std::string(LOCAL_PORT_TYPE), candidate.type()); |
| 986 } | 1009 } |
| 987 } | 1010 } |
| 988 | 1011 |
| 989 // Host is behind the NAT. | 1012 // Host is behind the NAT. |
| 990 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { | 1013 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { |
| 991 AddInterface(kPrivateAddr); | 1014 AddInterface(kPrivateAddr); |
| 992 ResetWithStunServerAndNat(kStunAddr); | 1015 ResetWithStunServerAndNat(kStunAddr); |
| 993 | 1016 |
| 994 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1017 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 995 allocator().set_candidate_filter(CF_REFLEXIVE); | 1018 allocator().set_candidate_filter(CF_REFLEXIVE); |
| 996 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1019 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 997 session_->StartGettingPorts(); | 1020 session_->StartGettingPorts(); |
| 998 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1021 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 999 // Host is behind NAT, no private address will be exposed. Hence only UDP | 1022 // Host is behind NAT, no private address will be exposed. Hence only UDP |
| 1000 // port with STUN candidate will be sent outside. | 1023 // port with STUN candidate will be sent outside. |
| 1001 EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate. | 1024 EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate. |
| 1002 EXPECT_EQ(1U, ports_.size()); // Only UDP port will be in ready state. | 1025 EXPECT_EQ(1U, ports_.size()); // Only UDP port will be in ready state. |
| 1003 for (size_t i = 0; i < candidates_.size(); ++i) { | 1026 EXPECT_EQ(std::string(STUN_PORT_TYPE), candidates_[0].type()); |
| 1004 EXPECT_EQ(std::string(STUN_PORT_TYPE), candidates_[i].type()); | 1027 EXPECT_EQ( |
| 1005 EXPECT_EQ( | 1028 candidates_[0].related_address(), |
| 1006 candidates_[0].related_address(), | 1029 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); |
| 1007 rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); | |
| 1008 } | |
| 1009 } | 1030 } |
| 1010 | 1031 |
| 1011 // Host is not behind the NAT. | 1032 // Host is not behind the NAT. |
| 1012 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { | 1033 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { |
| 1013 AddInterface(kClientAddr); | 1034 AddInterface(kClientAddr); |
| 1014 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1035 allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1015 allocator().set_candidate_filter(CF_REFLEXIVE); | 1036 allocator().set_candidate_filter(CF_REFLEXIVE); |
| 1016 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1037 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1017 session_->StartGettingPorts(); | 1038 session_->StartGettingPorts(); |
| 1018 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1039 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1019 // Host has a public address, both UDP and TCP candidates will be exposed. | 1040 // Host has a public address, both UDP and TCP candidates will be exposed. |
| 1020 EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate. | 1041 EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate. |
| 1021 EXPECT_EQ(2U, ports_.size()); // UDP and TCP ports will be in ready state. | 1042 EXPECT_EQ(2U, ports_.size()); // UDP and TCP ports will be in ready state. |
| 1022 for (size_t i = 0; i < candidates_.size(); ++i) { | 1043 for (const Candidate& candidate : candidates_) { |
| 1023 EXPECT_EQ(std::string(LOCAL_PORT_TYPE), candidates_[i].type()); | 1044 EXPECT_EQ(std::string(LOCAL_PORT_TYPE), candidate.type()); |
| 1024 } | 1045 } |
| 1025 } | 1046 } |
| 1026 | 1047 |
| 1027 // Test that we get the same ufrag and pwd for all candidates. | 1048 // Test that we get the same ufrag and pwd for all candidates. |
| 1028 TEST_F(BasicPortAllocatorTest, TestEnableSharedUfrag) { | 1049 TEST_F(BasicPortAllocatorTest, TestEnableSharedUfrag) { |
| 1029 AddInterface(kClientAddr); | 1050 AddInterface(kClientAddr); |
| 1030 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1051 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1031 session_->StartGettingPorts(); | 1052 session_->StartGettingPorts(); |
| 1032 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 1053 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); |
| 1033 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1054 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1034 "local", "udp", kClientAddr); | 1055 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr); |
| 1035 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 1056 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 1036 "stun", "udp", kClientAddr); | |
| 1037 EXPECT_PRED5(CheckCandidate, candidates_[5], ICE_CANDIDATE_COMPONENT_RTP, | |
| 1038 "local", "tcp", kClientAddr); | |
| 1039 EXPECT_EQ(4U, ports_.size()); | 1057 EXPECT_EQ(4U, ports_.size()); |
| 1040 EXPECT_EQ(kIceUfrag0, candidates_[0].username()); | 1058 for (const Candidate& candidate : candidates_) { |
| 1041 EXPECT_EQ(kIceUfrag0, candidates_[1].username()); | 1059 EXPECT_EQ(kIceUfrag0, candidate.username()); |
| 1042 EXPECT_EQ(kIceUfrag0, candidates_[2].username()); | 1060 EXPECT_EQ(kIcePwd0, candidate.password()); |
| 1043 EXPECT_EQ(kIcePwd0, candidates_[0].password()); | 1061 } |
| 1044 EXPECT_EQ(kIcePwd0, candidates_[1].password()); | |
| 1045 EXPECT_TRUE(candidate_allocation_done_); | 1062 EXPECT_TRUE(candidate_allocation_done_); |
| 1046 } | 1063 } |
| 1047 | 1064 |
| 1048 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port | 1065 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |
| 1049 // is allocated for udp and stun. Also verify there is only one candidate | 1066 // is allocated for udp and stun. Also verify there is only one candidate |
| 1050 // (local) if stun candidate is same as local candidate, which will be the case | 1067 // (local) if stun candidate is same as local candidate, which will be the case |
| 1051 // in a public network like the below test. | 1068 // in a public network like the below test. |
| 1052 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNat) { | 1069 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNat) { |
| 1053 AddInterface(kClientAddr); | 1070 AddInterface(kClientAddr); |
| 1054 allocator_->set_flags(allocator().flags() | | 1071 allocator_->set_flags(allocator().flags() | |
| 1055 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1072 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1056 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1073 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1057 session_->StartGettingPorts(); | 1074 session_->StartGettingPorts(); |
| 1058 ASSERT_EQ_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout); | 1075 ASSERT_EQ_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout); |
| 1059 EXPECT_EQ(3U, ports_.size()); | 1076 EXPECT_EQ(3U, ports_.size()); |
| 1060 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1077 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1061 "local", "udp", kClientAddr); | |
| 1062 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1078 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1063 } | 1079 } |
| 1064 | 1080 |
| 1065 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port | 1081 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |
| 1066 // is allocated for udp and stun. In this test we should expect both stun and | 1082 // is allocated for udp and stun. In this test we should expect both stun and |
| 1067 // local candidates as client behind a nat. | 1083 // local candidates as client behind a nat. |
| 1068 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNat) { | 1084 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNat) { |
| 1069 AddInterface(kClientAddr); | 1085 AddInterface(kClientAddr); |
| 1070 ResetWithStunServerAndNat(kStunAddr); | 1086 ResetWithStunServerAndNat(kStunAddr); |
| 1071 | 1087 |
| 1072 allocator_->set_flags(allocator().flags() | | 1088 allocator_->set_flags(allocator().flags() | |
| 1073 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1089 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1074 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1090 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1075 session_->StartGettingPorts(); | 1091 session_->StartGettingPorts(); |
| 1076 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1092 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |
| 1077 ASSERT_EQ(2U, ports_.size()); | 1093 ASSERT_EQ(2U, ports_.size()); |
| 1078 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1094 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1079 "local", "udp", kClientAddr); | 1095 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", |
| 1080 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 1096 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); |
| 1081 "stun", "udp", rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); | |
| 1082 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1097 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1083 EXPECT_EQ(3U, candidates_.size()); | 1098 EXPECT_EQ(3U, candidates_.size()); |
| 1084 } | 1099 } |
| 1085 | 1100 |
| 1086 // Test TURN port in shared socket mode with UDP and TCP TURN server addresses. | 1101 // Test TURN port in shared socket mode with UDP and TCP TURN server addresses. |
| 1087 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { | 1102 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { |
| 1088 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); | 1103 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); |
| 1089 AddInterface(kClientAddr); | 1104 AddInterface(kClientAddr); |
| 1090 allocator_.reset(new BasicPortAllocator(&network_manager_)); | 1105 allocator_.reset(new BasicPortAllocator(&network_manager_)); |
| 1091 | 1106 |
| 1092 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 1107 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |
| 1093 | 1108 |
| 1094 allocator_->set_step_delay(kMinimumStepDelay); | 1109 allocator_->set_step_delay(kMinimumStepDelay); |
| 1095 allocator_->set_flags(allocator().flags() | | 1110 allocator_->set_flags(allocator().flags() | |
| 1096 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1111 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1097 PORTALLOCATOR_DISABLE_TCP); | 1112 PORTALLOCATOR_DISABLE_TCP); |
| 1098 | 1113 |
| 1099 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1114 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1100 session_->StartGettingPorts(); | 1115 session_->StartGettingPorts(); |
| 1101 | 1116 |
| 1102 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1117 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |
| 1103 ASSERT_EQ(3U, ports_.size()); | 1118 ASSERT_EQ(3U, ports_.size()); |
| 1104 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1119 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1105 "local", "udp", kClientAddr); | 1120 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 1106 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 1121 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 1107 "relay", "udp", rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 1122 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 1108 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | 1123 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 1109 "relay", "udp", rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | |
| 1110 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1124 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1111 EXPECT_EQ(3U, candidates_.size()); | 1125 EXPECT_EQ(3U, candidates_.size()); |
| 1112 } | 1126 } |
| 1113 | 1127 |
| 1114 // Testing DNS resolve for the TURN server, this will test AllocationSequence | 1128 // Testing DNS resolve for the TURN server, this will test AllocationSequence |
| 1115 // handling the unresolved address signal from TurnPort. | 1129 // handling the unresolved address signal from TurnPort. |
| 1116 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithServerAddressResolve) { | 1130 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithServerAddressResolve) { |
| 1117 turn_server_.AddInternalSocket(rtc::SocketAddress("127.0.0.1", 3478), | 1131 turn_server_.AddInternalSocket(rtc::SocketAddress("127.0.0.1", 3478), |
| 1118 PROTO_UDP); | 1132 PROTO_UDP); |
| 1119 AddInterface(kClientAddr); | 1133 AddInterface(kClientAddr); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1147 | 1161 |
| 1148 allocator_->set_flags(allocator().flags() | | 1162 allocator_->set_flags(allocator().flags() | |
| 1149 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1163 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1150 PORTALLOCATOR_DISABLE_TCP); | 1164 PORTALLOCATOR_DISABLE_TCP); |
| 1151 | 1165 |
| 1152 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1166 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1153 session_->StartGettingPorts(); | 1167 session_->StartGettingPorts(); |
| 1154 | 1168 |
| 1155 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1169 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |
| 1156 ASSERT_EQ(2U, ports_.size()); | 1170 ASSERT_EQ(2U, ports_.size()); |
| 1157 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1171 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1158 "local", "udp", kClientAddr); | 1172 EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", |
| 1159 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 1173 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); |
| 1160 "stun", "udp", rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); | 1174 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 1161 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | 1175 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 1162 "relay", "udp", rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | |
| 1163 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1176 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1164 EXPECT_EQ(3U, candidates_.size()); | 1177 EXPECT_EQ(3U, candidates_.size()); |
| 1165 // Local port will be created first and then TURN port. | 1178 // Local port will be created first and then TURN port. |
| 1166 EXPECT_EQ(2U, ports_[0]->Candidates().size()); | 1179 EXPECT_EQ(2U, ports_[0]->Candidates().size()); |
| 1167 EXPECT_EQ(1U, ports_[1]->Candidates().size()); | 1180 EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
| 1168 } | 1181 } |
| 1169 | 1182 |
| 1170 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled and the TURN | 1183 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled and the TURN |
| 1171 // server is also used as the STUN server, we should get 'local', 'stun', and | 1184 // server is also used as the STUN server, we should get 'local', 'stun', and |
| 1172 // 'relay' candidates. | 1185 // 'relay' candidates. |
| 1173 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) { | 1186 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) { |
| 1174 AddInterface(kClientAddr); | 1187 AddInterface(kClientAddr); |
| 1175 // Use an empty SocketAddress to add a NAT without STUN server. | 1188 // Use an empty SocketAddress to add a NAT without STUN server. |
| 1176 ResetWithStunServerAndNat(SocketAddress()); | 1189 ResetWithStunServerAndNat(SocketAddress()); |
| 1177 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 1190 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 1178 | 1191 |
| 1179 // Must set the step delay to 0 to make sure the relay allocation phase is | 1192 // Must set the step delay to 0 to make sure the relay allocation phase is |
| 1180 // started before the STUN candidates are obtained, so that the STUN binding | 1193 // started before the STUN candidates are obtained, so that the STUN binding |
| 1181 // response is processed when both StunPort and TurnPort exist to reproduce | 1194 // response is processed when both StunPort and TurnPort exist to reproduce |
| 1182 // webrtc issue 3537. | 1195 // webrtc issue 3537. |
| 1183 allocator_->set_step_delay(0); | 1196 allocator_->set_step_delay(0); |
| 1184 allocator_->set_flags(allocator().flags() | | 1197 allocator_->set_flags(allocator().flags() | |
| 1185 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1198 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1186 PORTALLOCATOR_DISABLE_TCP); | 1199 PORTALLOCATOR_DISABLE_TCP); |
| 1187 | 1200 |
| 1188 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1201 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1189 session_->StartGettingPorts(); | 1202 session_->StartGettingPorts(); |
| 1190 | 1203 |
| 1191 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1204 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |
| 1192 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1205 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1193 "local", "udp", kClientAddr); | 1206 Candidate stun_candidate; |
| 1194 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 1207 EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp", |
| 1195 "stun", "udp", rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); | 1208 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate); |
| 1196 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | 1209 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp", |
| 1197 "relay", "udp", rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 1210 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), |
| 1198 EXPECT_EQ(candidates_[2].related_address(), candidates_[1].address()); | 1211 stun_candidate.address()); |
| 1199 | 1212 |
| 1200 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1213 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1201 EXPECT_EQ(3U, candidates_.size()); | 1214 EXPECT_EQ(3U, candidates_.size()); |
| 1202 // Local port will be created first and then TURN port. | 1215 // Local port will be created first and then TURN port. |
| 1203 EXPECT_EQ(2U, ports_[0]->Candidates().size()); | 1216 EXPECT_EQ(2U, ports_[0]->Candidates().size()); |
| 1204 EXPECT_EQ(1U, ports_[1]->Candidates().size()); | 1217 EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
| 1205 } | 1218 } |
| 1206 | 1219 |
| 1207 // Test that when only a TCP TURN server is available, we do NOT use it as | 1220 // Test that when only a TCP TURN server is available, we do NOT use it as |
| 1208 // a UDP STUN server, as this could leak our IP address. Thus we should only | 1221 // a UDP STUN server, as this could leak our IP address. Thus we should only |
| 1209 // expect two ports, a UDPPort and TurnPort. | 1222 // expect two ports, a UDPPort and TurnPort. |
| 1210 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { | 1223 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { |
| 1211 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); | 1224 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); |
| 1212 AddInterface(kClientAddr); | 1225 AddInterface(kClientAddr); |
| 1213 ResetWithStunServerAndNat(rtc::SocketAddress()); | 1226 ResetWithStunServerAndNat(rtc::SocketAddress()); |
| 1214 AddTurnServers(rtc::SocketAddress(), kTurnTcpIntAddr); | 1227 AddTurnServers(rtc::SocketAddress(), kTurnTcpIntAddr); |
| 1215 | 1228 |
| 1216 allocator_->set_flags(allocator().flags() | | 1229 allocator_->set_flags(allocator().flags() | |
| 1217 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1230 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1218 PORTALLOCATOR_DISABLE_TCP); | 1231 PORTALLOCATOR_DISABLE_TCP); |
| 1219 | 1232 |
| 1220 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1233 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1221 session_->StartGettingPorts(); | 1234 session_->StartGettingPorts(); |
| 1222 | 1235 |
| 1223 ASSERT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); | 1236 ASSERT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); |
| 1224 ASSERT_EQ(2U, ports_.size()); | 1237 ASSERT_EQ(2U, ports_.size()); |
| 1225 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1238 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1226 "local", "udp", kClientAddr); | 1239 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", |
| 1227 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 1240 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
| 1228 "relay", "udp", rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | |
| 1229 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1241 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1230 EXPECT_EQ(2U, candidates_.size()); | 1242 EXPECT_EQ(2U, candidates_.size()); |
| 1231 EXPECT_EQ(1U, ports_[0]->Candidates().size()); | 1243 EXPECT_EQ(1U, ports_[0]->Candidates().size()); |
| 1232 EXPECT_EQ(1U, ports_[1]->Candidates().size()); | 1244 EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
| 1233 } | 1245 } |
| 1234 | 1246 |
| 1235 // Test that even when PORTALLOCATOR_ENABLE_SHARED_SOCKET is NOT enabled, the | 1247 // Test that even when PORTALLOCATOR_ENABLE_SHARED_SOCKET is NOT enabled, the |
| 1236 // TURN server is used as the STUN server and we get 'local', 'stun', and | 1248 // TURN server is used as the STUN server and we get 'local', 'stun', and |
| 1237 // 'relay' candidates. | 1249 // 'relay' candidates. |
| 1238 // TODO(deadbeef): Remove this test when support for non-shared socket mode | 1250 // TODO(deadbeef): Remove this test when support for non-shared socket mode |
| 1239 // is removed. | 1251 // is removed. |
| 1240 TEST_F(BasicPortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) { | 1252 TEST_F(BasicPortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) { |
| 1241 AddInterface(kClientAddr); | 1253 AddInterface(kClientAddr); |
| 1242 // Use an empty SocketAddress to add a NAT without STUN server. | 1254 // Use an empty SocketAddress to add a NAT without STUN server. |
| 1243 ResetWithStunServerAndNat(SocketAddress()); | 1255 ResetWithStunServerAndNat(SocketAddress()); |
| 1244 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 1256 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 1245 | 1257 |
| 1246 allocator_->set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_TCP); | 1258 allocator_->set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_TCP); |
| 1247 | 1259 |
| 1248 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1260 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1249 session_->StartGettingPorts(); | 1261 session_->StartGettingPorts(); |
| 1250 | 1262 |
| 1251 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1263 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |
| 1252 ASSERT_EQ(3U, ports_.size()); | 1264 ASSERT_EQ(3U, ports_.size()); |
| 1253 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1265 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1254 "local", "udp", kClientAddr); | 1266 Candidate stun_candidate; |
| 1255 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 1267 EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp", |
| 1256 "stun", "udp", rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); | 1268 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate); |
| 1257 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | 1269 Candidate turn_candidate; |
| 1258 "relay", "udp", rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 1270 EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp", |
| 1271 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), |
| 1272 &turn_candidate); |
| 1259 // Not using shared socket, so the STUN request's server reflexive address | 1273 // Not using shared socket, so the STUN request's server reflexive address |
| 1260 // should be different than the TURN request's server reflexive address. | 1274 // should be different than the TURN request's server reflexive address. |
| 1261 EXPECT_NE(candidates_[2].related_address(), candidates_[1].address()); | 1275 EXPECT_NE(turn_candidate.related_address(), stun_candidate.address()); |
| 1262 | 1276 |
| 1263 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1277 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1264 EXPECT_EQ(3U, candidates_.size()); | 1278 EXPECT_EQ(3U, candidates_.size()); |
| 1265 EXPECT_EQ(1U, ports_[0]->Candidates().size()); | 1279 EXPECT_EQ(1U, ports_[0]->Candidates().size()); |
| 1266 EXPECT_EQ(1U, ports_[1]->Candidates().size()); | 1280 EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
| 1267 EXPECT_EQ(1U, ports_[2]->Candidates().size()); | 1281 EXPECT_EQ(1U, ports_[2]->Candidates().size()); |
| 1268 } | 1282 } |
| 1269 | 1283 |
| 1270 // Test that even when both a STUN and TURN server are configured, the TURN | 1284 // Test that even when both a STUN and TURN server are configured, the TURN |
| 1271 // server is used as a STUN server and we get a 'stun' candidate. | 1285 // server is used as a STUN server and we get a 'stun' candidate. |
| 1272 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { | 1286 TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { |
| 1273 AddInterface(kClientAddr); | 1287 AddInterface(kClientAddr); |
| 1274 // Configure with STUN server but destroy it, so we can ensure that it's | 1288 // Configure with STUN server but destroy it, so we can ensure that it's |
| 1275 // the TURN server actually being used as a STUN server. | 1289 // the TURN server actually being used as a STUN server. |
| 1276 ResetWithStunServerAndNat(kStunAddr); | 1290 ResetWithStunServerAndNat(kStunAddr); |
| 1277 stun_server_.reset(); | 1291 stun_server_.reset(); |
| 1278 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 1292 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
| 1279 | 1293 |
| 1280 allocator_->set_flags(allocator().flags() | | 1294 allocator_->set_flags(allocator().flags() | |
| 1281 PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1295 PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1282 PORTALLOCATOR_DISABLE_TCP); | 1296 PORTALLOCATOR_DISABLE_TCP); |
| 1283 | 1297 |
| 1284 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1298 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1285 session_->StartGettingPorts(); | 1299 session_->StartGettingPorts(); |
| 1286 | 1300 |
| 1287 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 1301 ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |
| 1288 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1302 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1289 "local", "udp", kClientAddr); | 1303 Candidate stun_candidate; |
| 1290 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 1304 EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp", |
| 1291 "stun", "udp", rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); | 1305 rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate); |
| 1292 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | 1306 EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp", |
| 1293 "relay", "udp", rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 1307 rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), |
| 1294 EXPECT_EQ(candidates_[2].related_address(), candidates_[1].address()); | 1308 stun_candidate.address()); |
| 1295 | 1309 |
| 1296 // Don't bother waiting for STUN timeout, since we already verified | 1310 // Don't bother waiting for STUN timeout, since we already verified |
| 1297 // that we got a STUN candidate from the TURN server. | 1311 // that we got a STUN candidate from the TURN server. |
| 1298 } | 1312 } |
| 1299 | 1313 |
| 1300 // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled | 1314 // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled |
| 1301 // and fail to generate STUN candidate, local UDP candidate is generated | 1315 // and fail to generate STUN candidate, local UDP candidate is generated |
| 1302 // properly. | 1316 // properly. |
| 1303 TEST_F(BasicPortAllocatorTest, TestSharedSocketNoUdpAllowed) { | 1317 TEST_F(BasicPortAllocatorTest, TestSharedSocketNoUdpAllowed) { |
| 1304 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | | 1318 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | |
| 1305 PORTALLOCATOR_DISABLE_TCP | | 1319 PORTALLOCATOR_DISABLE_TCP | |
| 1306 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1320 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1307 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); | 1321 fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); |
| 1308 AddInterface(kClientAddr); | 1322 AddInterface(kClientAddr); |
| 1309 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1323 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1310 session_->StartGettingPorts(); | 1324 session_->StartGettingPorts(); |
| 1311 ASSERT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); | 1325 ASSERT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); |
| 1312 EXPECT_EQ(1U, candidates_.size()); | 1326 EXPECT_EQ(1U, candidates_.size()); |
| 1313 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1327 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1314 "local", "udp", kClientAddr); | |
| 1315 // STUN timeout is 9.5sec. We need to wait to get candidate done signal. | 1328 // STUN timeout is 9.5sec. We need to wait to get candidate done signal. |
| 1316 EXPECT_TRUE_WAIT(candidate_allocation_done_, kStunTimeoutMs); | 1329 EXPECT_TRUE_WAIT(candidate_allocation_done_, kStunTimeoutMs); |
| 1317 EXPECT_EQ(1U, candidates_.size()); | 1330 EXPECT_EQ(1U, candidates_.size()); |
| 1318 } | 1331 } |
| 1319 | 1332 |
| 1320 // Test that when the NetworkManager doesn't have permission to enumerate | 1333 // Test that when the NetworkManager doesn't have permission to enumerate |
| 1321 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified | 1334 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified |
| 1322 // automatically. | 1335 // automatically. |
| 1323 TEST_F(BasicPortAllocatorTest, TestNetworkPermissionBlocked) { | 1336 TEST_F(BasicPortAllocatorTest, TestNetworkPermissionBlocked) { |
| 1324 network_manager_.set_default_local_addresses(kPrivateAddr.ipaddr(), | 1337 network_manager_.set_default_local_addresses(kPrivateAddr.ipaddr(), |
| 1325 rtc::IPAddress()); | 1338 rtc::IPAddress()); |
| 1326 network_manager_.set_enumeration_permission( | 1339 network_manager_.set_enumeration_permission( |
| 1327 rtc::NetworkManager::ENUMERATION_BLOCKED); | 1340 rtc::NetworkManager::ENUMERATION_BLOCKED); |
| 1328 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | | 1341 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | |
| 1329 PORTALLOCATOR_DISABLE_TCP | | 1342 PORTALLOCATOR_DISABLE_TCP | |
| 1330 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1343 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1331 EXPECT_EQ(0U, | 1344 EXPECT_EQ(0U, |
| 1332 allocator_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); | 1345 allocator_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); |
| 1333 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1346 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1334 EXPECT_EQ(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); | 1347 EXPECT_EQ(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); |
| 1335 session_->StartGettingPorts(); | 1348 session_->StartGettingPorts(); |
| 1336 EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); | 1349 EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); |
| 1337 EXPECT_EQ(1U, candidates_.size()); | 1350 EXPECT_EQ(1U, candidates_.size()); |
| 1338 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1351 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kPrivateAddr); |
| 1339 "local", "udp", kPrivateAddr); | |
| 1340 EXPECT_NE(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); | 1352 EXPECT_NE(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); |
| 1341 } | 1353 } |
| 1342 | 1354 |
| 1343 // This test verifies allocator can use IPv6 addresses along with IPv4. | 1355 // This test verifies allocator can use IPv6 addresses along with IPv4. |
| 1344 TEST_F(BasicPortAllocatorTest, TestEnableIPv6Addresses) { | 1356 TEST_F(BasicPortAllocatorTest, TestEnableIPv6Addresses) { |
| 1345 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | | 1357 allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | |
| 1346 PORTALLOCATOR_ENABLE_IPV6 | | 1358 PORTALLOCATOR_ENABLE_IPV6 | |
| 1347 PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1359 PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1348 AddInterface(kClientIPv6Addr); | 1360 AddInterface(kClientIPv6Addr); |
| 1349 AddInterface(kClientAddr); | 1361 AddInterface(kClientAddr); |
| 1350 allocator_->set_step_delay(kMinimumStepDelay); | 1362 allocator_->set_step_delay(kMinimumStepDelay); |
| 1351 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1363 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1352 session_->StartGettingPorts(); | 1364 session_->StartGettingPorts(); |
| 1353 ASSERT_EQ_WAIT(4U, ports_.size(), kDefaultAllocationTimeout); | 1365 ASSERT_EQ_WAIT(4U, ports_.size(), kDefaultAllocationTimeout); |
| 1354 EXPECT_EQ(4U, candidates_.size()); | 1366 EXPECT_EQ(4U, candidates_.size()); |
| 1355 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 1367 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1356 EXPECT_PRED5(CheckCandidate, candidates_[0], ICE_CANDIDATE_COMPONENT_RTP, | 1368 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr); |
| 1357 "local", "udp", kClientIPv6Addr); | 1369 EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr); |
| 1358 EXPECT_PRED5(CheckCandidate, candidates_[1], ICE_CANDIDATE_COMPONENT_RTP, | 1370 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientIPv6Addr); |
| 1359 "local", "udp", kClientAddr); | 1371 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
| 1360 EXPECT_PRED5(CheckCandidate, candidates_[2], ICE_CANDIDATE_COMPONENT_RTP, | |
| 1361 "local", "tcp", kClientIPv6Addr); | |
| 1362 EXPECT_PRED5(CheckCandidate, candidates_[3], ICE_CANDIDATE_COMPONENT_RTP, | |
| 1363 "local", "tcp", kClientAddr); | |
| 1364 EXPECT_EQ(4U, candidates_.size()); | 1372 EXPECT_EQ(4U, candidates_.size()); |
| 1365 } | 1373 } |
| 1366 | 1374 |
| 1367 TEST_F(BasicPortAllocatorTest, TestStopGettingPorts) { | 1375 TEST_F(BasicPortAllocatorTest, TestStopGettingPorts) { |
| 1368 AddInterface(kClientAddr); | 1376 AddInterface(kClientAddr); |
| 1369 allocator_->set_step_delay(kDefaultStepDelay); | 1377 allocator_->set_step_delay(kDefaultStepDelay); |
| 1370 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1378 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1371 session_->StartGettingPorts(); | 1379 session_->StartGettingPorts(); |
| 1372 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 1380 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); |
| 1373 EXPECT_EQ(2U, ports_.size()); | 1381 EXPECT_EQ(2U, ports_.size()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 for (const Candidate& candidate : candidates) { | 1481 for (const Candidate& candidate : candidates) { |
| 1474 // Expect only relay candidates now that the filter is applied. | 1482 // Expect only relay candidates now that the filter is applied. |
| 1475 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); | 1483 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); |
| 1476 // Expect that the raddr is emptied due to the CF_RELAY filter. | 1484 // Expect that the raddr is emptied due to the CF_RELAY filter. |
| 1477 EXPECT_EQ(candidate.related_address(), | 1485 EXPECT_EQ(candidate.related_address(), |
| 1478 rtc::EmptySocketAddressWithFamily(candidate.address().family())); | 1486 rtc::EmptySocketAddressWithFamily(candidate.address().family())); |
| 1479 } | 1487 } |
| 1480 } | 1488 } |
| 1481 | 1489 |
| 1482 } // namespace cricket | 1490 } // namespace cricket |
| OLD | NEW |