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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
958 TEST_F(BasicPortAllocatorTest, TestGetAllPortsRestarts) { | 958 TEST_F(BasicPortAllocatorTest, TestGetAllPortsRestarts) { |
959 AddInterface(kClientAddr); | 959 AddInterface(kClientAddr); |
960 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 960 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
961 session_->StartGettingPorts(); | 961 session_->StartGettingPorts(); |
962 EXPECT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 962 EXPECT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); |
963 EXPECT_EQ(4U, ports_.size()); | 963 EXPECT_EQ(4U, ports_.size()); |
964 EXPECT_TRUE(candidate_allocation_done_); | 964 EXPECT_TRUE(candidate_allocation_done_); |
965 // TODO(deadbeef): Extend this to verify ICE restart. | 965 // TODO(deadbeef): Extend this to verify ICE restart. |
966 } | 966 } |
967 | 967 |
968 // Test that the allocator session uses the candidate filter it's created with, | |
969 // rather than the filter of its parent allocator. | |
970 // The filter of the allocator should only affect the next gathering phase, | |
971 // according to JSEP, which means the *next* allocator session returned. | |
972 TEST_F(BasicPortAllocatorTest, TestSessionUsesOwnCandidateFilter) { | |
973 AddInterface(kClientAddr); | |
974 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | |
975 // Set candidate filter *after* creating the session. Should have no effect. | |
976 allocator().set_candidate_filter(cricket::CF_RELAY); | |
977 session_->StartGettingPorts(); | |
978 EXPECT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | |
979 EXPECT_EQ(4U, ports_.size()); | |
pthatcher1
2016/05/20 01:23:54
Can you make it clear that 7 candidates on 4 ports
Taylor Brandstetter
2016/05/20 21:03:37
Done.
| |
980 EXPECT_TRUE(candidate_allocation_done_); | |
981 } | |
982 | |
968 // Test ICE candidate filter mechanism with options Relay/Host/Reflexive. | 983 // Test ICE candidate filter mechanism with options Relay/Host/Reflexive. |
969 // This test also verifies that when the allocator is only allowed to use | 984 // This test also verifies that when the allocator is only allowed to use |
970 // relay (i.e. IceTransportsType is relay), the raddr is an empty | 985 // relay (i.e. IceTransportsType is relay), the raddr is an empty |
971 // address with the correct family. This is to prevent any local | 986 // address with the correct family. This is to prevent any local |
972 // reflective address leakage in the sdp line. | 987 // reflective address leakage in the sdp line. |
973 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithRelayOnly) { | 988 TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithRelayOnly) { |
974 AddInterface(kClientAddr); | 989 AddInterface(kClientAddr); |
975 // GTURN is not configured here. | 990 // GTURN is not configured here. |
976 ResetWithTurnServersNoNat(kTurnUdpIntAddr, rtc::SocketAddress()); | 991 ResetWithTurnServersNoNat(kTurnUdpIntAddr, rtc::SocketAddress()); |
977 allocator().set_candidate_filter(cricket::CF_RELAY); | 992 allocator().set_candidate_filter(cricket::CF_RELAY); |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1491 EXPECT_EQ(1, port->component()); | 1506 EXPECT_EQ(1, port->component()); |
1492 EXPECT_EQ(kIceUfrag0, port->username_fragment()); | 1507 EXPECT_EQ(kIceUfrag0, port->username_fragment()); |
1493 EXPECT_EQ(kIcePwd0, port->password()); | 1508 EXPECT_EQ(kIcePwd0, port->password()); |
1494 } | 1509 } |
1495 for (const cricket::Candidate& candidate : candidates) { | 1510 for (const cricket::Candidate& candidate : candidates) { |
1496 EXPECT_EQ(1, candidate.component()); | 1511 EXPECT_EQ(1, candidate.component()); |
1497 EXPECT_EQ(kIceUfrag0, candidate.username()); | 1512 EXPECT_EQ(kIceUfrag0, candidate.username()); |
1498 EXPECT_EQ(kIcePwd0, candidate.password()); | 1513 EXPECT_EQ(kIcePwd0, candidate.password()); |
1499 } | 1514 } |
1500 } | 1515 } |
1516 | |
1517 // Test that a new candidate filter takes effect even on already-gathered | |
1518 // candidates. | |
1519 TEST_F(BasicPortAllocatorTest, TestSetCandidateFilterAfterCandidatesGathered) { | |
1520 AddInterface(kClientAddr); | |
1521 int pool_size = 1; | |
1522 allocator_->SetConfiguration(allocator_->stun_servers(), | |
1523 allocator_->turn_servers(), pool_size); | |
1524 const cricket::PortAllocatorSession* peeked_session = | |
1525 allocator_->GetPooledSession(); | |
1526 ASSERT_NE(nullptr, peeked_session); | |
1527 EXPECT_EQ_WAIT(true, peeked_session->CandidatesAllocationDone(), | |
1528 kDefaultAllocationTimeout); | |
1529 size_t initial_candidates_size = peeked_session->ReadyCandidates().size(); | |
1530 size_t initial_ports_size = peeked_session->ReadyPorts().size(); | |
1531 allocator_->set_candidate_filter(cricket::CF_RELAY); | |
1532 // Assume that when TakePooledSession is called, the candidate filter will be | |
1533 // applied to the pooled session. This is tested by PortAllocatorTest. | |
1534 session_ = | |
1535 allocator_->TakePooledSession(kContentName, 1, kIceUfrag0, kIcePwd0); | |
1536 ASSERT_NE(nullptr, session_.get()); | |
1537 auto candidates = session_->ReadyCandidates(); | |
1538 // Check that the number of candidates and ports decreased. | |
1539 EXPECT_GT(initial_candidates_size, candidates.size()); | |
1540 EXPECT_GT(initial_ports_size, session_->ReadyPorts().size()); | |
1541 for (size_t i = 0; i < candidates.size(); ++i) { | |
pthatcher1
2016/05/20 01:23:54
c++11 for-loop?
Taylor Brandstetter
2016/05/20 21:03:37
Done.
| |
1542 // Expect only relay candidates now that the filter is applied. | |
1543 EXPECT_EQ(std::string(cricket::RELAY_PORT_TYPE), candidates[i].type()); | |
1544 // Expect that the raddr is emptied due to the CF_RELAY filter. | |
1545 EXPECT_EQ( | |
1546 candidates[0].related_address(), | |
1547 rtc::EmptySocketAddressWithFamily(candidates[0].address().family())); | |
1548 } | |
1549 } | |
OLD | NEW |