Index: webrtc/pc/peerconnectioninterface_unittest.cc |
diff --git a/webrtc/pc/peerconnectioninterface_unittest.cc b/webrtc/pc/peerconnectioninterface_unittest.cc |
index 8a80e5e90793a61605af899c1dfa73c11286475e..53e0a9ec7ed125c8b9470b0a87de8b4dad8232f0 100644 |
--- a/webrtc/pc/peerconnectioninterface_unittest.cc |
+++ b/webrtc/pc/peerconnectioninterface_unittest.cc |
@@ -2284,6 +2284,43 @@ TEST_F(PeerConnectionInterfaceTest, |
EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type()); |
} |
+// Test that after setting an answer, extra pooled sessions are discarded. The |
+// ICE candidate pool is only intended to be used for the first offer/answer. |
+TEST_F(PeerConnectionInterfaceTest, |
+ ExtraPooledSessionsDiscardedAfterApplyingAnswer) { |
+ CreatePeerConnection(); |
+ |
+ // Set a larger-than-necessary size. |
+ PeerConnectionInterface::RTCConfiguration config; |
+ config.ice_candidate_pool_size = 4; |
+ EXPECT_TRUE(pc_->SetConfiguration(config)); |
+ |
+ // Do offer/answer. |
+ CreateOfferAsRemoteDescription(); |
+ CreateAnswerAsLocalDescription(); |
+ |
+ // Expect no pooled sessions to be left. |
+ const cricket::PortAllocatorSession* session = |
+ port_allocator_->GetPooledSession(); |
+ EXPECT_EQ(nullptr, session); |
+} |
+ |
+// After Close is called, pooled candidates should be discarded so as to not |
+// waste network resources. |
+TEST_F(PeerConnectionInterfaceTest, PooledSessionsDiscardedAfterClose) { |
+ CreatePeerConnection(); |
+ |
+ PeerConnectionInterface::RTCConfiguration config; |
+ config.ice_candidate_pool_size = 3; |
+ EXPECT_TRUE(pc_->SetConfiguration(config)); |
+ pc_->Close(); |
+ |
+ // Expect no pooled sessions to be left. |
+ const cricket::PortAllocatorSession* session = |
+ port_allocator_->GetPooledSession(); |
+ EXPECT_EQ(nullptr, session); |
+} |
+ |
// Test that SetConfiguration returns an invalid modification error if |
// modifying a field in the configuration that isn't allowed to be modified. |
TEST_F(PeerConnectionInterfaceTest, |