| 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 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 allocator_->set_step_delay(kDefaultStepDelay); | 1604 allocator_->set_step_delay(kDefaultStepDelay); |
| 1605 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1605 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1606 session_->StartGettingPorts(); | 1606 session_->StartGettingPorts(); |
| 1607 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 1607 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); |
| 1608 EXPECT_EQ(2U, ports_.size()); | 1608 EXPECT_EQ(2U, ports_.size()); |
| 1609 session_->StopGettingPorts(); | 1609 session_->StopGettingPorts(); |
| 1610 EXPECT_TRUE_WAIT(candidate_allocation_done_, 1000); | 1610 EXPECT_TRUE_WAIT(candidate_allocation_done_, 1000); |
| 1611 | 1611 |
| 1612 // After stopping getting ports, adding a new interface will not start | 1612 // After stopping getting ports, adding a new interface will not start |
| 1613 // getting ports again. | 1613 // getting ports again. |
| 1614 allocator_->set_step_delay(kMinimumStepDelay); |
| 1614 candidates_.clear(); | 1615 candidates_.clear(); |
| 1615 ports_.clear(); | 1616 ports_.clear(); |
| 1616 candidate_allocation_done_ = false; | 1617 candidate_allocation_done_ = false; |
| 1617 network_manager_.AddInterface(kClientAddr2); | 1618 network_manager_.AddInterface(kClientAddr2); |
| 1618 rtc::Thread::Current()->ProcessMessages(1000); | 1619 rtc::Thread::Current()->ProcessMessages(1000); |
| 1619 EXPECT_EQ(0U, candidates_.size()); | 1620 EXPECT_EQ(0U, candidates_.size()); |
| 1620 EXPECT_EQ(0U, ports_.size()); | 1621 EXPECT_EQ(0U, ports_.size()); |
| 1621 } | 1622 } |
| 1622 | 1623 |
| 1623 TEST_F(BasicPortAllocatorTest, TestClearGettingPorts) { | 1624 TEST_F(BasicPortAllocatorTest, TestClearGettingPorts) { |
| 1624 AddInterface(kClientAddr); | 1625 AddInterface(kClientAddr); |
| 1625 allocator_->set_step_delay(kDefaultStepDelay); | 1626 allocator_->set_step_delay(kDefaultStepDelay); |
| 1626 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1627 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
| 1627 session_->StartGettingPorts(); | 1628 session_->StartGettingPorts(); |
| 1628 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 1629 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); |
| 1629 EXPECT_EQ(2U, ports_.size()); | 1630 EXPECT_EQ(2U, ports_.size()); |
| 1630 session_->ClearGettingPorts(); | 1631 session_->ClearGettingPorts(); |
| 1631 WAIT(candidate_allocation_done_, 1000); | 1632 EXPECT_TRUE_WAIT(candidate_allocation_done_, 1000); |
| 1632 EXPECT_FALSE(candidate_allocation_done_); | |
| 1633 | 1633 |
| 1634 // After clearing getting ports, adding a new interface will start getting | 1634 // After clearing getting ports, adding a new interface will start getting |
| 1635 // ports again. | 1635 // ports again. |
| 1636 allocator_->set_step_delay(kMinimumStepDelay); |
| 1636 candidates_.clear(); | 1637 candidates_.clear(); |
| 1637 ports_.clear(); | 1638 ports_.clear(); |
| 1638 candidate_allocation_done_ = false; | 1639 candidate_allocation_done_ = false; |
| 1639 network_manager_.AddInterface(kClientAddr2); | 1640 network_manager_.AddInterface(kClientAddr2); |
| 1640 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 1641 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); |
| 1641 EXPECT_EQ(2U, ports_.size()); | 1642 EXPECT_EQ(2U, ports_.size()); |
| 1643 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 1642 } | 1644 } |
| 1643 | 1645 |
| 1644 // Test that the ports and candidates are updated with new ufrag/pwd/etc. when | 1646 // Test that the ports and candidates are updated with new ufrag/pwd/etc. when |
| 1645 // a pooled session is taken out of the pool. | 1647 // a pooled session is taken out of the pool. |
| 1646 TEST_F(BasicPortAllocatorTest, TestTransportInformationUpdated) { | 1648 TEST_F(BasicPortAllocatorTest, TestTransportInformationUpdated) { |
| 1647 AddInterface(kClientAddr); | 1649 AddInterface(kClientAddr); |
| 1648 int pool_size = 1; | 1650 int pool_size = 1; |
| 1649 allocator_->SetConfiguration(allocator_->stun_servers(), | 1651 allocator_->SetConfiguration(allocator_->stun_servers(), |
| 1650 allocator_->turn_servers(), pool_size, false); | 1652 allocator_->turn_servers(), pool_size, false); |
| 1651 const PortAllocatorSession* peeked_session = allocator_->GetPooledSession(); | 1653 const PortAllocatorSession* peeked_session = allocator_->GetPooledSession(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 for (const Candidate& candidate : candidates) { | 1710 for (const Candidate& candidate : candidates) { |
| 1709 // Expect only relay candidates now that the filter is applied. | 1711 // Expect only relay candidates now that the filter is applied. |
| 1710 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); | 1712 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); |
| 1711 // Expect that the raddr is emptied due to the CF_RELAY filter. | 1713 // Expect that the raddr is emptied due to the CF_RELAY filter. |
| 1712 EXPECT_EQ(candidate.related_address(), | 1714 EXPECT_EQ(candidate.related_address(), |
| 1713 rtc::EmptySocketAddressWithFamily(candidate.address().family())); | 1715 rtc::EmptySocketAddressWithFamily(candidate.address().family())); |
| 1714 } | 1716 } |
| 1715 } | 1717 } |
| 1716 | 1718 |
| 1717 } // namespace cricket | 1719 } // namespace cricket |
| OLD | NEW |