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

Side by Side Diff: webrtc/api/webrtcsession_unittest.cc

Issue 2043193003: Make the default value of rtcp-mux policy to required. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Merge with new changes. Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 376 }
377 void RemoveInterface(const SocketAddress& addr) { 377 void RemoveInterface(const SocketAddress& addr) {
378 network_manager_.RemoveInterface(addr); 378 network_manager_.RemoveInterface(addr);
379 } 379 }
380 380
381 // If |cert_generator| != null or |rtc_configuration| contains |certificates| 381 // If |cert_generator| != null or |rtc_configuration| contains |certificates|
382 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| 382 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration|
383 // options. When DTLS is enabled a certificate will be used if provided, 383 // options. When DTLS is enabled a certificate will be used if provided,
384 // otherwise one will be generated using the |cert_generator|. 384 // otherwise one will be generated using the |cert_generator|.
385 void Init( 385 void Init(
386 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator) { 386 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
387 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) {
387 ASSERT_TRUE(session_.get() == NULL); 388 ASSERT_TRUE(session_.get() == NULL);
388 session_.reset(new WebRtcSessionForTest( 389 session_.reset(new WebRtcSessionForTest(
389 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), 390 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(),
390 rtc::Thread::Current(), allocator_.get(), &observer_, 391 rtc::Thread::Current(), allocator_.get(), &observer_,
391 std::unique_ptr<cricket::TransportController>( 392 std::unique_ptr<cricket::TransportController>(
392 new cricket::TransportController(rtc::Thread::Current(), 393 new cricket::TransportController(rtc::Thread::Current(),
393 rtc::Thread::Current(), 394 rtc::Thread::Current(),
394 allocator_.get())))); 395 allocator_.get()))));
395 session_->SignalDataChannelOpenMessage.connect( 396 session_->SignalDataChannelOpenMessage.connect(
396 this, &WebRtcSessionTest::OnDataChannelOpenMessage); 397 this, &WebRtcSessionTest::OnDataChannelOpenMessage);
397 session_->GetOnDestroyedSignal()->connect( 398 session_->GetOnDestroyedSignal()->connect(
398 this, &WebRtcSessionTest::OnSessionDestroyed); 399 this, &WebRtcSessionTest::OnSessionDestroyed);
399 400
401 configuration_.rtcp_mux_policy = rtcp_mux_policy;
400 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, 402 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew,
401 observer_.ice_connection_state_); 403 observer_.ice_connection_state_);
402 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, 404 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew,
403 observer_.ice_gathering_state_); 405 observer_.ice_gathering_state_);
404 406
405 EXPECT_TRUE(session_->Initialize(options_, std::move(cert_generator), 407 EXPECT_TRUE(session_->Initialize(options_, std::move(cert_generator),
406 configuration_)); 408 configuration_));
407 session_->set_metrics_observer(metrics_observer_); 409 session_->set_metrics_observer(metrics_observer_);
408 } 410 }
409 411
410 void OnDataChannelOpenMessage(const std::string& label, 412 void OnDataChannelOpenMessage(const std::string& label,
411 const InternalDataChannelInit& config) { 413 const InternalDataChannelInit& config) {
412 last_data_channel_label_ = label; 414 last_data_channel_label_ = label;
413 last_data_channel_config_ = config; 415 last_data_channel_config_ = config;
414 } 416 }
415 417
416 void OnSessionDestroyed() { session_destroyed_ = true; } 418 void OnSessionDestroyed() { session_destroyed_ = true; }
417 419
418 void Init() { Init(nullptr); } 420 void Init() {
421 Init(nullptr, PeerConnectionInterface::kRtcpMuxPolicyNegotiate);
422 }
423
424 void Init(PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) {
425 Init(nullptr, rtcp_mux_policy);
426 }
419 427
420 void InitWithBundlePolicy( 428 void InitWithBundlePolicy(
421 PeerConnectionInterface::BundlePolicy bundle_policy) { 429 PeerConnectionInterface::BundlePolicy bundle_policy) {
422 configuration_.bundle_policy = bundle_policy; 430 configuration_.bundle_policy = bundle_policy;
423 Init(); 431 Init();
424 } 432 }
425 433
426 void InitWithRtcpMuxPolicy( 434 void InitWithRtcpMuxPolicy(
427 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { 435 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) {
428 PeerConnectionInterface::RTCConfiguration configuration; 436 PeerConnectionInterface::RTCConfiguration configuration;
429 configuration_.rtcp_mux_policy = rtcp_mux_policy; 437 Init(rtcp_mux_policy);
430 Init();
431 } 438 }
432 439
433 // Successfully init with DTLS; with a certificate generated and supplied or 440 // Successfully init with DTLS; with a certificate generated and supplied or
434 // with a store that generates it for us. 441 // with a store that generates it for us.
435 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) { 442 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) {
436 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator; 443 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator;
437 if (cert_gen_method == ALREADY_GENERATED) { 444 if (cert_gen_method == ALREADY_GENERATED) {
438 configuration_.certificates.push_back( 445 configuration_.certificates.push_back(
439 FakeRTCCertificateGenerator::GenerateCertificate()); 446 FakeRTCCertificateGenerator::GenerateCertificate());
440 } else if (cert_gen_method == DTLS_IDENTITY_STORE) { 447 } else if (cert_gen_method == DTLS_IDENTITY_STORE) {
441 cert_generator.reset(new FakeRTCCertificateGenerator()); 448 cert_generator.reset(new FakeRTCCertificateGenerator());
442 cert_generator->set_should_fail(false); 449 cert_generator->set_should_fail(false);
443 } else { 450 } else {
444 RTC_CHECK(false); 451 RTC_CHECK(false);
445 } 452 }
446 Init(std::move(cert_generator)); 453 Init(std::move(cert_generator),
454 PeerConnectionInterface::kRtcpMuxPolicyNegotiate);
447 } 455 }
448 456
449 // Init with DTLS with a store that will fail to generate a certificate. 457 // Init with DTLS with a store that will fail to generate a certificate.
450 void InitWithDtlsIdentityGenFail() { 458 void InitWithDtlsIdentityGenFail() {
451 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( 459 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
452 new FakeRTCCertificateGenerator()); 460 new FakeRTCCertificateGenerator());
453 cert_generator->set_should_fail(true); 461 cert_generator->set_should_fail(true);
454 Init(std::move(cert_generator)); 462 Init(std::move(cert_generator),
463 PeerConnectionInterface::kRtcpMuxPolicyNegotiate);
455 } 464 }
456 465
457 void InitWithDtmfCodec() { 466 void InitWithDtmfCodec() {
458 // Add kTelephoneEventCodec for dtmf test. 467 // Add kTelephoneEventCodec for dtmf test.
459 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, 468 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000,
460 0, 1); 469 0, 1);
461 std::vector<cricket::AudioCodec> codecs; 470 std::vector<cricket::AudioCodec> codecs;
462 codecs.push_back(kTelephoneEventCodec); 471 codecs.push_back(kTelephoneEventCodec);
463 media_engine_->SetAudioCodecs(codecs); 472 media_engine_->SetAudioCodecs(codecs);
464 desc_factory_->set_audio_codecs(codecs, codecs); 473 desc_factory_->set_audio_codecs(codecs, codecs);
(...skipping 2875 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 // disconnected non-bundle transport and then replacing it. The application 3349 // disconnected non-bundle transport and then replacing it. The application
3341 // should not receive any changes in the ICE state. 3350 // should not receive any changes in the ICE state.
3342 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) { 3351 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) {
3343 LoopbackNetworkConfiguration config; 3352 LoopbackNetworkConfiguration config;
3344 LoopbackNetworkManager loopback_network_manager(this, config); 3353 LoopbackNetworkManager loopback_network_manager(this, config);
3345 // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain 3354 // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain
3346 // connected. Disabling either of these two means that we need to wait for the 3355 // connected. Disabling either of these two means that we need to wait for the
3347 // answer to find out if more transports are needed. 3356 // answer to find out if more transports are needed.
3348 configuration_.bundle_policy = 3357 configuration_.bundle_policy =
3349 PeerConnectionInterface::kBundlePolicyMaxBundle; 3358 PeerConnectionInterface::kBundlePolicyMaxBundle;
3350 configuration_.rtcp_mux_policy =
3351 PeerConnectionInterface::kRtcpMuxPolicyRequire;
3352 options_.disable_encryption = true; 3359 options_.disable_encryption = true;
3353 Init(); 3360 Init(PeerConnectionInterface::kRtcpMuxPolicyRequire);
3354 3361
3355 // Negotiate an audio channel with MAX_BUNDLE enabled. 3362 // Negotiate an audio channel with MAX_BUNDLE enabled.
3356 SendAudioOnlyStream2(); 3363 SendAudioOnlyStream2();
3357 SessionDescriptionInterface* offer = CreateOffer(); 3364 SessionDescriptionInterface* offer = CreateOffer();
3358 SetLocalDescriptionWithoutError(offer); 3365 SetLocalDescriptionWithoutError(offer);
3359 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, 3366 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
3360 observer_.ice_gathering_state_, kIceCandidatesTimeout); 3367 observer_.ice_gathering_state_, kIceCandidatesTimeout);
3361 std::string sdp; 3368 std::string sdp;
3362 offer->ToString(&sdp); 3369 offer->ToString(&sdp);
3363 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription( 3370 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription(
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
4355 } 4362 }
4356 4363
4357 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4364 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4358 // currently fails because upon disconnection and reconnection OnIceComplete is 4365 // currently fails because upon disconnection and reconnection OnIceComplete is
4359 // called more than once without returning to IceGatheringGathering. 4366 // called more than once without returning to IceGatheringGathering.
4360 4367
4361 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4368 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4362 WebRtcSessionTest, 4369 WebRtcSessionTest,
4363 testing::Values(ALREADY_GENERATED, 4370 testing::Values(ALREADY_GENERATED,
4364 DTLS_IDENTITY_STORE)); 4371 DTLS_IDENTITY_STORE));
OLDNEW
« webrtc/api/peerconnectioninterface.h ('K') | « webrtc/api/test/testsdpstrings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698