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

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

Issue 1998813002: Fixing the behavior of the candidate filter with pooled candidates. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Undoing unintentional "git cl format" of unrelated files. Created 4 years, 7 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/base/stunport.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 2e16725de483d55f2e9ef2f59fff4165159ca815..dd845236c401de30048729598d87969e1ae52dde 100644
--- a/webrtc/p2p/base/portallocator_unittest.cc
+++ b/webrtc/p2p/base/portallocator_unittest.cc
@@ -15,6 +15,7 @@
#include "webrtc/p2p/base/fakeportallocator.h"
#include "webrtc/p2p/base/portallocator.h"
+static const char kSessionId[] = "session id";
static const char kContentName[] = "test content";
// Based on ICE_UFRAG_LENGTH
static const char kIceUfrag[] = "TESTICEUFRAG0000";
@@ -37,6 +38,20 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
candidate_pool_size);
}
+ std::unique_ptr<cricket::FakePortAllocatorSession> CreateSession(
+ const std::string& sid,
+ const std::string& content_name,
+ int component,
+ const std::string& ice_ufrag,
+ const std::string& ice_pwd) {
+ return std::unique_ptr<cricket::FakePortAllocatorSession>(
+ static_cast<cricket::FakePortAllocatorSession*>(
+ allocator_
+ ->CreateSession(sid, content_name, component, ice_ufrag,
+ ice_pwd)
+ .release()));
+ }
+
const cricket::FakePortAllocatorSession* GetPooledSession() const {
return static_cast<const cricket::FakePortAllocatorSession*>(
allocator_->GetPooledSession());
@@ -76,6 +91,19 @@ TEST_F(PortAllocatorTest, TestDefaults) {
EXPECT_EQ(0, GetAllPooledSessionsReturnCount());
}
+// Call CreateSession and verify that the parameters passed in and the
+// candidate filter are applied as expected.
+TEST_F(PortAllocatorTest, CreateSession) {
+ allocator_->set_candidate_filter(cricket::CF_RELAY);
+ auto session = CreateSession(kSessionId, kContentName, 1, kIceUfrag, kIcePwd);
+ ASSERT_NE(nullptr, session);
+ EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter());
+ EXPECT_EQ(kContentName, session->content_name());
+ EXPECT_EQ(1, session->component());
+ EXPECT_EQ(kIceUfrag, session->ice_ufrag());
+ EXPECT_EQ(kIcePwd, session->ice_pwd());
+}
+
TEST_F(PortAllocatorTest, SetConfigurationUpdatesIceServers) {
cricket::ServerAddresses stun_servers_1 = {stun_server_1};
std::vector<cricket::RelayServerConfig> turn_servers_1 = {turn_server_1};
@@ -203,3 +231,17 @@ TEST_F(PortAllocatorTest, TakePooledSessionUpdatesIceParameters) {
EXPECT_EQ(kIceUfrag, session->ice_ufrag());
EXPECT_EQ(kIcePwd, session->ice_pwd());
}
+
+// According to JSEP, candidate filtering should be done when the pooled
+// candidates are surfaced to the application. This means when a pooled
+// session is taken. So a pooled session should gather candidates
+// unfiltered until it's returned by TakePooledSession.
+TEST_F(PortAllocatorTest, TakePooledSessionUpdatesCandidateFilter) {
+ allocator_->set_candidate_filter(cricket::CF_RELAY);
+ SetConfigurationWithPoolSize(1);
+ auto peeked_session = GetPooledSession();
+ ASSERT_NE(nullptr, peeked_session);
+ EXPECT_EQ(cricket::CF_ALL, peeked_session->candidate_filter());
+ auto session = TakePooledSession();
+ EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter());
+}
« no previous file with comments | « webrtc/p2p/base/portallocator.cc ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698