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

Unified Diff: webrtc/p2p/base/portallocator_unittest.cc

Issue 2717893003: Making candidate pool size behave as decided in JSEP. (Closed)
Patch Set: Merge with master Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/portallocator.cc ('k') | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ac1c862f5f37552e3290853ccca4c60a52cbab08 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 DiscardCandidatePool, TakePooledSession doesn't return
+// anything.
+TEST_F(PortAllocatorTest, DiscardCandidatePool) {
+ SetConfigurationWithPoolSize(1);
+ allocator_->DiscardCandidatePool();
+ EXPECT_EQ(0, GetAllPooledSessionsReturnCount());
+}
« no previous file with comments | « webrtc/p2p/base/portallocator.cc ('k') | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698