| Index: webrtc/p2p/base/portallocator_unittest.cc
|
| diff --git a/webrtc/p2p/base/portallocator_unittest.cc b/webrtc/p2p/base/portallocator_unittest.cc
|
| index 74e2a3dc1fa35a3c4d2dbdb19691348f433649b0..bb96433c4daae5fe670505a7d13e7f4622a2c72e 100644
|
| --- a/webrtc/p2p/base/portallocator_unittest.cc
|
| +++ b/webrtc/p2p/base/portallocator_unittest.cc
|
| @@ -169,15 +169,6 @@ TEST_F(PortAllocatorTest, SetConfigurationDestroysPooledSessions) {
|
| EXPECT_EQ(1, GetAllPooledSessionsReturnCount());
|
| }
|
|
|
| -// Test that after the pool starts to be drained, changing the pool size is not
|
| -// allowed.
|
| -TEST_F(PortAllocatorTest, CantChangePoolSizeAfterTakePooledSession) {
|
| - SetConfigurationWithPoolSize(1);
|
| - TakePooledSession();
|
| - SetConfigurationWithPoolSizeExpectFailure(2);
|
| - SetConfigurationWithPoolSizeExpectFailure(0);
|
| -}
|
| -
|
| // According to JSEP, existing pooled sessions should be destroyed and new
|
| // ones created when the ICE servers change.
|
| TEST_F(PortAllocatorTest,
|
| @@ -205,6 +196,31 @@ TEST_F(PortAllocatorTest,
|
| EXPECT_EQ(0, GetAllPooledSessionsReturnCount());
|
| }
|
|
|
| +// According to JSEP, after SetLocalDescription, setting different ICE servers
|
| +// will not cause the pool to be refilled. This is implemented by the
|
| +// PeerConnection calling FreezeCandidatePool when a local description is set.
|
| +TEST_F(PortAllocatorTest,
|
| + SetConfigurationDoesNotRecreatePooledSessionsAfterFreezeCandidatePool) {
|
| + cricket::ServerAddresses stun_servers_1 = {stun_server_1};
|
| + std::vector<cricket::RelayServerConfig> turn_servers_1 = {turn_server_1};
|
| + allocator_->SetConfiguration(stun_servers_1, turn_servers_1, 1, false);
|
| + EXPECT_EQ(stun_servers_1, allocator_->stun_servers());
|
| + EXPECT_EQ(turn_servers_1, allocator_->turn_servers());
|
| +
|
| + // Update with a different set of servers, but first freeze the pool.
|
| + allocator_->FreezeCandidatePool();
|
| + cricket::ServerAddresses stun_servers_2 = {stun_server_2};
|
| + std::vector<cricket::RelayServerConfig> turn_servers_2 = {turn_server_2};
|
| + allocator_->SetConfiguration(stun_servers_2, turn_servers_2, 2, false);
|
| + EXPECT_EQ(stun_servers_2, allocator_->stun_servers());
|
| + EXPECT_EQ(turn_servers_2, allocator_->turn_servers());
|
| + auto session = TakePooledSession();
|
| + ASSERT_NE(nullptr, session.get());
|
| + EXPECT_EQ(stun_servers_1, session->stun_servers());
|
| + EXPECT_EQ(turn_servers_1, session->turn_servers());
|
| + EXPECT_EQ(0, GetAllPooledSessionsReturnCount());
|
| +}
|
| +
|
| TEST_F(PortAllocatorTest, GetPooledSessionReturnsNextSession) {
|
| SetConfigurationWithPoolSize(2);
|
| auto peeked_session_1 = GetPooledSession();
|
| @@ -247,3 +263,11 @@ TEST_F(PortAllocatorTest, TakePooledSessionUpdatesCandidateFilter) {
|
| auto session = TakePooledSession();
|
| EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter());
|
| }
|
| +
|
| +// Verify that after DiscardPooledSessions, TakePooledSession doesn't return
|
| +// anything.
|
| +TEST_F(PortAllocatorTest, DiscardPooledSessions) {
|
| + SetConfigurationWithPoolSize(1);
|
| + allocator_->DiscardPooledSessions();
|
| + EXPECT_EQ(0, GetAllPooledSessionsReturnCount());
|
| +}
|
|
|