OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 17 matching lines...) Expand all Loading... |
28 public: | 28 public: |
29 PortAllocatorTest() { | 29 PortAllocatorTest() { |
30 allocator_.reset( | 30 allocator_.reset( |
31 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); | 31 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); |
32 } | 32 } |
33 | 33 |
34 protected: | 34 protected: |
35 void SetConfigurationWithPoolSize(int candidate_pool_size) { | 35 void SetConfigurationWithPoolSize(int candidate_pool_size) { |
36 allocator_->SetConfiguration(cricket::ServerAddresses(), | 36 allocator_->SetConfiguration(cricket::ServerAddresses(), |
37 std::vector<cricket::RelayServerConfig>(), | 37 std::vector<cricket::RelayServerConfig>(), |
38 candidate_pool_size); | 38 candidate_pool_size, false); |
39 } | 39 } |
40 | 40 |
41 std::unique_ptr<cricket::FakePortAllocatorSession> CreateSession( | 41 std::unique_ptr<cricket::FakePortAllocatorSession> CreateSession( |
42 const std::string& sid, | 42 const std::string& sid, |
43 const std::string& content_name, | 43 const std::string& content_name, |
44 int component, | 44 int component, |
45 const std::string& ice_ufrag, | 45 const std::string& ice_ufrag, |
46 const std::string& ice_pwd) { | 46 const std::string& ice_pwd) { |
47 return std::unique_ptr<cricket::FakePortAllocatorSession>( | 47 return std::unique_ptr<cricket::FakePortAllocatorSession>( |
48 static_cast<cricket::FakePortAllocatorSession*>( | 48 static_cast<cricket::FakePortAllocatorSession*>( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter()); | 100 EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter()); |
101 EXPECT_EQ(kContentName, session->content_name()); | 101 EXPECT_EQ(kContentName, session->content_name()); |
102 EXPECT_EQ(1, session->component()); | 102 EXPECT_EQ(1, session->component()); |
103 EXPECT_EQ(kIceUfrag, session->ice_ufrag()); | 103 EXPECT_EQ(kIceUfrag, session->ice_ufrag()); |
104 EXPECT_EQ(kIcePwd, session->ice_pwd()); | 104 EXPECT_EQ(kIcePwd, session->ice_pwd()); |
105 } | 105 } |
106 | 106 |
107 TEST_F(PortAllocatorTest, SetConfigurationUpdatesIceServers) { | 107 TEST_F(PortAllocatorTest, SetConfigurationUpdatesIceServers) { |
108 cricket::ServerAddresses stun_servers_1 = {stun_server_1}; | 108 cricket::ServerAddresses stun_servers_1 = {stun_server_1}; |
109 std::vector<cricket::RelayServerConfig> turn_servers_1 = {turn_server_1}; | 109 std::vector<cricket::RelayServerConfig> turn_servers_1 = {turn_server_1}; |
110 allocator_->SetConfiguration(stun_servers_1, turn_servers_1, 0); | 110 allocator_->SetConfiguration(stun_servers_1, turn_servers_1, 0, false); |
111 EXPECT_EQ(stun_servers_1, allocator_->stun_servers()); | 111 EXPECT_EQ(stun_servers_1, allocator_->stun_servers()); |
112 EXPECT_EQ(turn_servers_1, allocator_->turn_servers()); | 112 EXPECT_EQ(turn_servers_1, allocator_->turn_servers()); |
113 | 113 |
114 // Update with a different set of servers. | 114 // Update with a different set of servers. |
115 cricket::ServerAddresses stun_servers_2 = {stun_server_2}; | 115 cricket::ServerAddresses stun_servers_2 = {stun_server_2}; |
116 std::vector<cricket::RelayServerConfig> turn_servers_2 = {turn_server_2}; | 116 std::vector<cricket::RelayServerConfig> turn_servers_2 = {turn_server_2}; |
117 allocator_->SetConfiguration(stun_servers_2, turn_servers_2, 0); | 117 allocator_->SetConfiguration(stun_servers_2, turn_servers_2, 0, false); |
118 EXPECT_EQ(stun_servers_2, allocator_->stun_servers()); | 118 EXPECT_EQ(stun_servers_2, allocator_->stun_servers()); |
119 EXPECT_EQ(turn_servers_2, allocator_->turn_servers()); | 119 EXPECT_EQ(turn_servers_2, allocator_->turn_servers()); |
120 } | 120 } |
121 | 121 |
122 TEST_F(PortAllocatorTest, SetConfigurationUpdatesCandidatePoolSize) { | 122 TEST_F(PortAllocatorTest, SetConfigurationUpdatesCandidatePoolSize) { |
123 SetConfigurationWithPoolSize(2); | 123 SetConfigurationWithPoolSize(2); |
124 EXPECT_EQ(2, allocator_->candidate_pool_size()); | 124 EXPECT_EQ(2, allocator_->candidate_pool_size()); |
125 SetConfigurationWithPoolSize(3); | 125 SetConfigurationWithPoolSize(3); |
126 EXPECT_EQ(3, allocator_->candidate_pool_size()); | 126 EXPECT_EQ(3, allocator_->candidate_pool_size()); |
127 SetConfigurationWithPoolSize(1); | 127 SetConfigurationWithPoolSize(1); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 SetConfigurationWithPoolSize(1); | 175 SetConfigurationWithPoolSize(1); |
176 EXPECT_EQ(0, GetAllPooledSessionsReturnCount()); | 176 EXPECT_EQ(0, GetAllPooledSessionsReturnCount()); |
177 } | 177 } |
178 | 178 |
179 // According to JSEP, exising pooled sessions should be destroyed and new | 179 // According to JSEP, exising pooled sessions should be destroyed and new |
180 // ones created when the ICE servers change. | 180 // ones created when the ICE servers change. |
181 TEST_F(PortAllocatorTest, | 181 TEST_F(PortAllocatorTest, |
182 SetConfigurationRecreatesPooledSessionsWhenIceServersChange) { | 182 SetConfigurationRecreatesPooledSessionsWhenIceServersChange) { |
183 cricket::ServerAddresses stun_servers_1 = {stun_server_1}; | 183 cricket::ServerAddresses stun_servers_1 = {stun_server_1}; |
184 std::vector<cricket::RelayServerConfig> turn_servers_1 = {turn_server_1}; | 184 std::vector<cricket::RelayServerConfig> turn_servers_1 = {turn_server_1}; |
185 allocator_->SetConfiguration(stun_servers_1, turn_servers_1, 1); | 185 allocator_->SetConfiguration(stun_servers_1, turn_servers_1, 1, false); |
186 EXPECT_EQ(stun_servers_1, allocator_->stun_servers()); | 186 EXPECT_EQ(stun_servers_1, allocator_->stun_servers()); |
187 EXPECT_EQ(turn_servers_1, allocator_->turn_servers()); | 187 EXPECT_EQ(turn_servers_1, allocator_->turn_servers()); |
188 | 188 |
189 // Update with a different set of servers (and also change pool size). | 189 // Update with a different set of servers (and also change pool size). |
190 cricket::ServerAddresses stun_servers_2 = {stun_server_2}; | 190 cricket::ServerAddresses stun_servers_2 = {stun_server_2}; |
191 std::vector<cricket::RelayServerConfig> turn_servers_2 = {turn_server_2}; | 191 std::vector<cricket::RelayServerConfig> turn_servers_2 = {turn_server_2}; |
192 allocator_->SetConfiguration(stun_servers_2, turn_servers_2, 2); | 192 allocator_->SetConfiguration(stun_servers_2, turn_servers_2, 2, false); |
193 EXPECT_EQ(stun_servers_2, allocator_->stun_servers()); | 193 EXPECT_EQ(stun_servers_2, allocator_->stun_servers()); |
194 EXPECT_EQ(turn_servers_2, allocator_->turn_servers()); | 194 EXPECT_EQ(turn_servers_2, allocator_->turn_servers()); |
195 auto session_1 = TakePooledSession(); | 195 auto session_1 = TakePooledSession(); |
196 auto session_2 = TakePooledSession(); | 196 auto session_2 = TakePooledSession(); |
197 ASSERT_NE(nullptr, session_1.get()); | 197 ASSERT_NE(nullptr, session_1.get()); |
198 ASSERT_NE(nullptr, session_2.get()); | 198 ASSERT_NE(nullptr, session_2.get()); |
199 EXPECT_EQ(stun_servers_2, session_1->stun_servers()); | 199 EXPECT_EQ(stun_servers_2, session_1->stun_servers()); |
200 EXPECT_EQ(turn_servers_2, session_1->turn_servers()); | 200 EXPECT_EQ(turn_servers_2, session_1->turn_servers()); |
201 EXPECT_EQ(stun_servers_2, session_2->stun_servers()); | 201 EXPECT_EQ(stun_servers_2, session_2->stun_servers()); |
202 EXPECT_EQ(turn_servers_2, session_2->turn_servers()); | 202 EXPECT_EQ(turn_servers_2, session_2->turn_servers()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // unfiltered until it's returned by TakePooledSession. | 238 // unfiltered until it's returned by TakePooledSession. |
239 TEST_F(PortAllocatorTest, TakePooledSessionUpdatesCandidateFilter) { | 239 TEST_F(PortAllocatorTest, TakePooledSessionUpdatesCandidateFilter) { |
240 allocator_->set_candidate_filter(cricket::CF_RELAY); | 240 allocator_->set_candidate_filter(cricket::CF_RELAY); |
241 SetConfigurationWithPoolSize(1); | 241 SetConfigurationWithPoolSize(1); |
242 auto peeked_session = GetPooledSession(); | 242 auto peeked_session = GetPooledSession(); |
243 ASSERT_NE(nullptr, peeked_session); | 243 ASSERT_NE(nullptr, peeked_session); |
244 EXPECT_EQ(cricket::CF_ALL, peeked_session->candidate_filter()); | 244 EXPECT_EQ(cricket::CF_ALL, peeked_session->candidate_filter()); |
245 auto session = TakePooledSession(); | 245 auto session = TakePooledSession(); |
246 EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter()); | 246 EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter()); |
247 } | 247 } |
OLD | NEW |