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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 rtc::ADAPTER_TYPE_WIFI); | 512 rtc::ADAPTER_TYPE_WIFI); |
513 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 513 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
514 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | | 514 session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | |
515 PORTALLOCATOR_DISABLE_TCP); | 515 PORTALLOCATOR_DISABLE_TCP); |
516 session_->StartGettingPorts(); | 516 session_->StartGettingPorts(); |
517 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 517 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
518 EXPECT_EQ(1U, candidates_.size()); | 518 EXPECT_EQ(1U, candidates_.size()); |
519 EXPECT_EQ(0x12345602U, candidates_[0].address().ip()); | 519 EXPECT_EQ(0x12345602U, candidates_[0].address().ip()); |
520 } | 520 } |
521 | 521 |
| 522 // Test that high cost networks are filtered if the flag |
| 523 // PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is set. |
| 524 TEST_F(BasicPortAllocatorTest, TestGatherLowCostNetworkOnly) { |
| 525 SocketAddress addr_wifi(IPAddress(0x12345600U), 0); |
| 526 SocketAddress addr_cellular(IPAddress(0x12345601U), 0); |
| 527 SocketAddress addr_unknown1(IPAddress(0x12345602U), 0); |
| 528 SocketAddress addr_unknown2(IPAddress(0x12345603U), 0); |
| 529 // If both Wi-Fi and cellular interfaces are present, only gather on the Wi-Fi |
| 530 // interface. |
| 531 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI); |
| 532 AddInterface(addr_cellular, "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); |
| 533 allocator().set_flags(cricket::PORTALLOCATOR_DISABLE_STUN | |
| 534 cricket::PORTALLOCATOR_DISABLE_RELAY | |
| 535 cricket::PORTALLOCATOR_DISABLE_TCP | |
| 536 cricket::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); |
| 537 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 538 session_->StartGettingPorts(); |
| 539 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 540 EXPECT_EQ(1U, candidates_.size()); |
| 541 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address())); |
| 542 |
| 543 // If both cellular and unknown interfaces are present, only gather on the |
| 544 // unknown interfaces. |
| 545 candidates_.clear(); |
| 546 candidate_allocation_done_ = false; |
| 547 RemoveInterface(addr_wifi); |
| 548 AddInterface(addr_unknown1, "test_unknown0", rtc::ADAPTER_TYPE_UNKNOWN); |
| 549 AddInterface(addr_unknown2, "test_unknown1", rtc::ADAPTER_TYPE_UNKNOWN); |
| 550 session_->StartGettingPorts(); |
| 551 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 552 EXPECT_EQ(2U, candidates_.size()); |
| 553 EXPECT_TRUE((addr_unknown1.EqualIPs(candidates_[0].address()) && |
| 554 addr_unknown2.EqualIPs(candidates_[1].address())) || |
| 555 (addr_unknown1.EqualIPs(candidates_[1].address()) && |
| 556 addr_unknown2.EqualIPs(candidates_[0].address()))); |
| 557 |
| 558 // If Wi-Fi, cellular, unknown interfaces are all present, only gather on the |
| 559 // Wi-Fi interface. |
| 560 candidates_.clear(); |
| 561 candidate_allocation_done_ = false; |
| 562 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI); |
| 563 session_->StartGettingPorts(); |
| 564 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 565 EXPECT_EQ(1U, candidates_.size()); |
| 566 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address())); |
| 567 } |
| 568 |
522 // Tests that we allocator session not trying to allocate ports for every 250ms. | 569 // Tests that we allocator session not trying to allocate ports for every 250ms. |
523 TEST_F(BasicPortAllocatorTest, TestNoNetworkInterface) { | 570 TEST_F(BasicPortAllocatorTest, TestNoNetworkInterface) { |
524 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 571 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
525 session_->StartGettingPorts(); | 572 session_->StartGettingPorts(); |
526 // Waiting for one second to make sure BasicPortAllocatorSession has not | 573 // Waiting for one second to make sure BasicPortAllocatorSession has not |
527 // called OnAllocate multiple times. In old behavior it's called every 250ms. | 574 // called OnAllocate multiple times. In old behavior it's called every 250ms. |
528 // When there are no network interfaces, each execution of OnAllocate will | 575 // When there are no network interfaces, each execution of OnAllocate will |
529 // result in SignalCandidatesAllocationDone signal. | 576 // result in SignalCandidatesAllocationDone signal. |
530 rtc::Thread::Current()->ProcessMessages(1000); | 577 rtc::Thread::Current()->ProcessMessages(1000); |
531 EXPECT_TRUE(candidate_allocation_done_); | 578 EXPECT_TRUE(candidate_allocation_done_); |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 for (const Candidate& candidate : candidates) { | 1530 for (const Candidate& candidate : candidates) { |
1484 // Expect only relay candidates now that the filter is applied. | 1531 // Expect only relay candidates now that the filter is applied. |
1485 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); | 1532 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); |
1486 // Expect that the raddr is emptied due to the CF_RELAY filter. | 1533 // Expect that the raddr is emptied due to the CF_RELAY filter. |
1487 EXPECT_EQ(candidate.related_address(), | 1534 EXPECT_EQ(candidate.related_address(), |
1488 rtc::EmptySocketAddressWithFamily(candidate.address().family())); | 1535 rtc::EmptySocketAddressWithFamily(candidate.address().family())); |
1489 } | 1536 } |
1490 } | 1537 } |
1491 | 1538 |
1492 } // namespace cricket | 1539 } // namespace cricket |
OLD | NEW |