Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel_unittest.cc

Issue 2093623004: Add config to prune TURN ports (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add all tests and fix a bug to set port type Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 // Test that a connection succeeds when the P2PTransportChannel uses a pooled 1583 // Test that a connection succeeds when the P2PTransportChannel uses a pooled
1584 // PortAllocatorSession that has not yet finished gathering candidates. 1584 // PortAllocatorSession that has not yet finished gathering candidates.
1585 TEST_F(P2PTransportChannelTest, TestUsingPooledSessionBeforeDoneGathering) { 1585 TEST_F(P2PTransportChannelTest, TestUsingPooledSessionBeforeDoneGathering) {
1586 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, 1586 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
1587 kDefaultPortAllocatorFlags); 1587 kDefaultPortAllocatorFlags);
1588 // First create a pooled session for each endpoint. 1588 // First create a pooled session for each endpoint.
1589 auto& allocator_1 = GetEndpoint(0)->allocator_; 1589 auto& allocator_1 = GetEndpoint(0)->allocator_;
1590 auto& allocator_2 = GetEndpoint(1)->allocator_; 1590 auto& allocator_2 = GetEndpoint(1)->allocator_;
1591 int pool_size = 1; 1591 int pool_size = 1;
1592 allocator_1->SetConfiguration(allocator_1->stun_servers(), 1592 allocator_1->SetConfiguration(allocator_1->stun_servers(),
1593 allocator_1->turn_servers(), pool_size); 1593 allocator_1->turn_servers(), pool_size, false);
1594 allocator_2->SetConfiguration(allocator_2->stun_servers(), 1594 allocator_2->SetConfiguration(allocator_2->stun_servers(),
1595 allocator_2->turn_servers(), pool_size); 1595 allocator_2->turn_servers(), pool_size, false);
1596 const PortAllocatorSession* pooled_session_1 = 1596 const PortAllocatorSession* pooled_session_1 =
1597 allocator_1->GetPooledSession(); 1597 allocator_1->GetPooledSession();
1598 const PortAllocatorSession* pooled_session_2 = 1598 const PortAllocatorSession* pooled_session_2 =
1599 allocator_2->GetPooledSession(); 1599 allocator_2->GetPooledSession();
1600 ASSERT_NE(nullptr, pooled_session_1); 1600 ASSERT_NE(nullptr, pooled_session_1);
1601 ASSERT_NE(nullptr, pooled_session_2); 1601 ASSERT_NE(nullptr, pooled_session_2);
1602 // Sanity check that pooled sessions haven't gathered anything yet. 1602 // Sanity check that pooled sessions haven't gathered anything yet.
1603 EXPECT_TRUE(pooled_session_1->ReadyPorts().empty()); 1603 EXPECT_TRUE(pooled_session_1->ReadyPorts().empty());
1604 EXPECT_TRUE(pooled_session_1->ReadyCandidates().empty()); 1604 EXPECT_TRUE(pooled_session_1->ReadyCandidates().empty());
1605 EXPECT_TRUE(pooled_session_2->ReadyPorts().empty()); 1605 EXPECT_TRUE(pooled_session_2->ReadyPorts().empty());
(...skipping 20 matching lines...) Expand all
1626 // Test that a connection succeeds when the P2PTransportChannel uses a pooled 1626 // Test that a connection succeeds when the P2PTransportChannel uses a pooled
1627 // PortAllocatorSession that already finished gathering candidates. 1627 // PortAllocatorSession that already finished gathering candidates.
1628 TEST_F(P2PTransportChannelTest, TestUsingPooledSessionAfterDoneGathering) { 1628 TEST_F(P2PTransportChannelTest, TestUsingPooledSessionAfterDoneGathering) {
1629 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, 1629 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
1630 kDefaultPortAllocatorFlags); 1630 kDefaultPortAllocatorFlags);
1631 // First create a pooled session for each endpoint. 1631 // First create a pooled session for each endpoint.
1632 auto& allocator_1 = GetEndpoint(0)->allocator_; 1632 auto& allocator_1 = GetEndpoint(0)->allocator_;
1633 auto& allocator_2 = GetEndpoint(1)->allocator_; 1633 auto& allocator_2 = GetEndpoint(1)->allocator_;
1634 int pool_size = 1; 1634 int pool_size = 1;
1635 allocator_1->SetConfiguration(allocator_1->stun_servers(), 1635 allocator_1->SetConfiguration(allocator_1->stun_servers(),
1636 allocator_1->turn_servers(), pool_size); 1636 allocator_1->turn_servers(), pool_size, false);
1637 allocator_2->SetConfiguration(allocator_2->stun_servers(), 1637 allocator_2->SetConfiguration(allocator_2->stun_servers(),
1638 allocator_2->turn_servers(), pool_size); 1638 allocator_2->turn_servers(), pool_size, false);
1639 const PortAllocatorSession* pooled_session_1 = 1639 const PortAllocatorSession* pooled_session_1 =
1640 allocator_1->GetPooledSession(); 1640 allocator_1->GetPooledSession();
1641 const PortAllocatorSession* pooled_session_2 = 1641 const PortAllocatorSession* pooled_session_2 =
1642 allocator_2->GetPooledSession(); 1642 allocator_2->GetPooledSession();
1643 ASSERT_NE(nullptr, pooled_session_1); 1643 ASSERT_NE(nullptr, pooled_session_1);
1644 ASSERT_NE(nullptr, pooled_session_2); 1644 ASSERT_NE(nullptr, pooled_session_2);
1645 // Wait for the pooled sessions to finish gathering before the 1645 // Wait for the pooled sessions to finish gathering before the
1646 // P2PTransportChannels try to use them. 1646 // P2PTransportChannels try to use them.
1647 EXPECT_TRUE_WAIT(pooled_session_1->CandidatesAllocationDone() && 1647 EXPECT_TRUE_WAIT(pooled_session_1->CandidatesAllocationDone() &&
1648 pooled_session_2->CandidatesAllocationDone(), 1648 pooled_session_2->CandidatesAllocationDone(),
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 3474
3475 // TCP Relay/Relay is the next. 3475 // TCP Relay/Relay is the next.
3476 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, 3476 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE,
3477 TCP_PROTOCOL_NAME); 3477 TCP_PROTOCOL_NAME);
3478 3478
3479 // Finally, Local/Relay will be pinged. 3479 // Finally, Local/Relay will be pinged.
3480 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); 3480 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE);
3481 } 3481 }
3482 3482
3483 } // namespace cricket { 3483 } // namespace cricket {
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698