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

Side by Side Diff: webrtc/pc/mediasession_unittest.cc

Issue 2224563004: Add signaling to support ICE renomination. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « webrtc/pc/mediasession.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (c1.size() != c2.size()) 260 if (c1.size() != c2.size())
261 return false; 261 return false;
262 for (size_t i = 0; i < c1.size(); ++i) 262 for (size_t i = 0; i < c1.size(); ++i)
263 if (c1[i].tag != c2[i].tag || c1[i].cipher_suite != c2[i].cipher_suite || 263 if (c1[i].tag != c2[i].tag || c1[i].cipher_suite != c2[i].cipher_suite ||
264 c1[i].key_params != c2[i].key_params || 264 c1[i].key_params != c2[i].key_params ||
265 c1[i].session_params != c2[i].session_params) 265 c1[i].session_params != c2[i].session_params)
266 return false; 266 return false;
267 return true; 267 return true;
268 } 268 }
269 269
270 // Returns true if the transport info contains "renomination" as an
271 // ICE option.
272 bool GetIceRenomination(const TransportInfo* transport_info) {
273 const std::vector<std::string>& ice_options =
274 transport_info->description.transport_options;
275 auto iter = std::find(ice_options.begin(), ice_options.end(),
276 cricket::ICE_RENOMINATION_STR);
277 return iter != ice_options.end();
278 }
279
270 void TestTransportInfo(bool offer, const MediaSessionOptions& options, 280 void TestTransportInfo(bool offer, const MediaSessionOptions& options,
271 bool has_current_desc) { 281 bool has_current_desc) {
272 const std::string current_audio_ufrag = "current_audio_ufrag"; 282 const std::string current_audio_ufrag = "current_audio_ufrag";
273 const std::string current_audio_pwd = "current_audio_pwd"; 283 const std::string current_audio_pwd = "current_audio_pwd";
274 const std::string current_video_ufrag = "current_video_ufrag"; 284 const std::string current_video_ufrag = "current_video_ufrag";
275 const std::string current_video_pwd = "current_video_pwd"; 285 const std::string current_video_pwd = "current_video_pwd";
276 const std::string current_data_ufrag = "current_data_ufrag"; 286 const std::string current_data_ufrag = "current_data_ufrag";
277 const std::string current_data_pwd = "current_data_pwd"; 287 const std::string current_data_pwd = "current_data_pwd";
278 std::unique_ptr<SessionDescription> current_desc; 288 std::unique_ptr<SessionDescription> current_desc;
279 std::unique_ptr<SessionDescription> desc; 289 std::unique_ptr<SessionDescription> desc;
(...skipping 25 matching lines...) Expand all
305 EXPECT_TRUE(ti_audio != NULL); 315 EXPECT_TRUE(ti_audio != NULL);
306 if (has_current_desc) { 316 if (has_current_desc) {
307 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag); 317 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag);
308 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd); 318 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd);
309 } else { 319 } else {
310 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), 320 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH),
311 ti_audio->description.ice_ufrag.size()); 321 ti_audio->description.ice_ufrag.size());
312 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), 322 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH),
313 ti_audio->description.ice_pwd.size()); 323 ti_audio->description.ice_pwd.size());
314 } 324 }
325 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_audio));
315 326
316 } else { 327 } else {
317 EXPECT_TRUE(ti_audio == NULL); 328 EXPECT_TRUE(ti_audio == NULL);
318 } 329 }
319 const TransportInfo* ti_video = desc->GetTransportInfoByName("video"); 330 const TransportInfo* ti_video = desc->GetTransportInfoByName("video");
320 if (options.has_video()) { 331 if (options.has_video()) {
321 EXPECT_TRUE(ti_video != NULL); 332 EXPECT_TRUE(ti_video != NULL);
322 if (options.bundle_enabled) { 333 if (options.bundle_enabled) {
323 EXPECT_EQ(ti_audio->description.ice_ufrag, 334 EXPECT_EQ(ti_audio->description.ice_ufrag,
324 ti_video->description.ice_ufrag); 335 ti_video->description.ice_ufrag);
325 EXPECT_EQ(ti_audio->description.ice_pwd, 336 EXPECT_EQ(ti_audio->description.ice_pwd,
326 ti_video->description.ice_pwd); 337 ti_video->description.ice_pwd);
327 } else { 338 } else {
328 if (has_current_desc) { 339 if (has_current_desc) {
329 EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag); 340 EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag);
330 EXPECT_EQ(current_video_pwd, ti_video->description.ice_pwd); 341 EXPECT_EQ(current_video_pwd, ti_video->description.ice_pwd);
331 } else { 342 } else {
332 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), 343 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH),
333 ti_video->description.ice_ufrag.size()); 344 ti_video->description.ice_ufrag.size());
334 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), 345 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH),
335 ti_video->description.ice_pwd.size()); 346 ti_video->description.ice_pwd.size());
336 } 347 }
337 } 348 }
349 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_video));
338 } else { 350 } else {
339 EXPECT_TRUE(ti_video == NULL); 351 EXPECT_TRUE(ti_video == NULL);
340 } 352 }
341 const TransportInfo* ti_data = desc->GetTransportInfoByName("data"); 353 const TransportInfo* ti_data = desc->GetTransportInfoByName("data");
342 if (options.has_data()) { 354 if (options.has_data()) {
343 EXPECT_TRUE(ti_data != NULL); 355 EXPECT_TRUE(ti_data != NULL);
344 if (options.bundle_enabled) { 356 if (options.bundle_enabled) {
345 EXPECT_EQ(ti_audio->description.ice_ufrag, 357 EXPECT_EQ(ti_audio->description.ice_ufrag,
346 ti_data->description.ice_ufrag); 358 ti_data->description.ice_ufrag);
347 EXPECT_EQ(ti_audio->description.ice_pwd, 359 EXPECT_EQ(ti_audio->description.ice_pwd,
348 ti_data->description.ice_pwd); 360 ti_data->description.ice_pwd);
349 } else { 361 } else {
350 if (has_current_desc) { 362 if (has_current_desc) {
351 EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag); 363 EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag);
352 EXPECT_EQ(current_data_pwd, ti_data->description.ice_pwd); 364 EXPECT_EQ(current_data_pwd, ti_data->description.ice_pwd);
353 } else { 365 } else {
354 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), 366 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH),
355 ti_data->description.ice_ufrag.size()); 367 ti_data->description.ice_ufrag.size());
356 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), 368 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH),
357 ti_data->description.ice_pwd.size()); 369 ti_data->description.ice_pwd.size());
358 } 370 }
359 } 371 }
372 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_data));
373
360 } else { 374 } else {
361 EXPECT_TRUE(ti_video == NULL); 375 EXPECT_TRUE(ti_video == NULL);
362 } 376 }
363 } 377 }
364 378
365 void TestCryptoWithBundle(bool offer) { 379 void TestCryptoWithBundle(bool offer) {
366 f1_.set_secure(SEC_ENABLED); 380 f1_.set_secure(SEC_ENABLED);
367 MediaSessionOptions options; 381 MediaSessionOptions options;
368 options.recv_audio = true; 382 options.recv_audio = true;
369 options.recv_video = true; 383 options.recv_video = true;
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 } 2147 }
2134 2148
2135 // The below TestTransportInfoXXX tests create different offers/answers, and 2149 // The below TestTransportInfoXXX tests create different offers/answers, and
2136 // ensure the TransportInfo in the SessionDescription matches what we expect. 2150 // ensure the TransportInfo in the SessionDescription matches what we expect.
2137 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudio) { 2151 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudio) {
2138 MediaSessionOptions options; 2152 MediaSessionOptions options;
2139 options.recv_audio = true; 2153 options.recv_audio = true;
2140 TestTransportInfo(true, options, false); 2154 TestTransportInfo(true, options, false);
2141 } 2155 }
2142 2156
2157 TEST_F(MediaSessionDescriptionFactoryTest,
2158 TestTransportInfoOfferIceRenomination) {
2159 MediaSessionOptions options;
2160 options.enable_ice_renomination = true;
2161 TestTransportInfo(true, options, false);
2162 }
2163
2143 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudioCurrent) { 2164 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudioCurrent) {
2144 MediaSessionOptions options; 2165 MediaSessionOptions options;
2145 options.recv_audio = true; 2166 options.recv_audio = true;
2146 TestTransportInfo(true, options, true); 2167 TestTransportInfo(true, options, true);
2147 } 2168 }
2148 2169
2149 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferMultimedia) { 2170 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferMultimedia) {
2150 MediaSessionOptions options; 2171 MediaSessionOptions options;
2151 options.recv_audio = true; 2172 options.recv_audio = true;
2152 options.recv_video = true; 2173 options.recv_video = true;
(...skipping 29 matching lines...) Expand all
2182 TestTransportInfo(true, options, true); 2203 TestTransportInfo(true, options, true);
2183 } 2204 }
2184 2205
2185 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerAudio) { 2206 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerAudio) {
2186 MediaSessionOptions options; 2207 MediaSessionOptions options;
2187 options.recv_audio = true; 2208 options.recv_audio = true;
2188 TestTransportInfo(false, options, false); 2209 TestTransportInfo(false, options, false);
2189 } 2210 }
2190 2211
2191 TEST_F(MediaSessionDescriptionFactoryTest, 2212 TEST_F(MediaSessionDescriptionFactoryTest,
2192 TestTransportInfoAnswerAudioCurrent) { 2213 TestTransportInfoAnswerIceRenomination) {
2214 MediaSessionOptions options;
2215 options.enable_ice_renomination = true;
2216 TestTransportInfo(false, options, false);
2217 }
2218
2219 TEST_F(MediaSessionDescriptionFactoryTest,
2220 TestTransportInfoAnswerAudioCurrent) {
2193 MediaSessionOptions options; 2221 MediaSessionOptions options;
2194 options.recv_audio = true; 2222 options.recv_audio = true;
2195 TestTransportInfo(false, options, true); 2223 TestTransportInfo(false, options, true);
2196 } 2224 }
2197 2225
2198 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerMultimedia) { 2226 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerMultimedia) {
2199 MediaSessionOptions options; 2227 MediaSessionOptions options;
2200 options.recv_audio = true; 2228 options.recv_audio = true;
2201 options.recv_video = true; 2229 options.recv_video = true;
2202 options.data_channel_type = cricket::DCT_RTP; 2230 options.data_channel_type = cricket::DCT_RTP;
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 ::testing::Combine( 2904 ::testing::Combine(
2877 ::testing::Values(cricket::MD_SENDONLY, 2905 ::testing::Values(cricket::MD_SENDONLY,
2878 cricket::MD_RECVONLY, 2906 cricket::MD_RECVONLY,
2879 cricket::MD_SENDRECV, 2907 cricket::MD_SENDRECV,
2880 cricket::MD_INACTIVE), 2908 cricket::MD_INACTIVE),
2881 ::testing::Values(cricket::MD_SENDONLY, 2909 ::testing::Values(cricket::MD_SENDONLY,
2882 cricket::MD_RECVONLY, 2910 cricket::MD_RECVONLY,
2883 cricket::MD_SENDRECV, 2911 cricket::MD_SENDRECV,
2884 cricket::MD_INACTIVE), 2912 cricket::MD_INACTIVE),
2885 ::testing::Bool())); 2913 ::testing::Bool()));
OLDNEW
« no previous file with comments | « webrtc/pc/mediasession.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698