| OLD | NEW |
| 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // and constraints are propagated into the MediaConfig passed to | 638 // and constraints are propagated into the MediaConfig passed to |
| 639 // CreateMediaController. These settings are intended for MediaChannel | 639 // CreateMediaController. These settings are intended for MediaChannel |
| 640 // constructors, but that is not exercised by these unittest. | 640 // constructors, but that is not exercised by these unittest. |
| 641 class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory { | 641 class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory { |
| 642 public: | 642 public: |
| 643 PeerConnectionFactoryForTest() | 643 PeerConnectionFactoryForTest() |
| 644 : webrtc::PeerConnectionFactory( | 644 : webrtc::PeerConnectionFactory( |
| 645 webrtc::CreateBuiltinAudioEncoderFactory(), | 645 webrtc::CreateBuiltinAudioEncoderFactory(), |
| 646 webrtc::CreateBuiltinAudioDecoderFactory()) {} | 646 webrtc::CreateBuiltinAudioDecoderFactory()) {} |
| 647 | 647 |
| 648 webrtc::MediaControllerInterface* CreateMediaController( | |
| 649 const cricket::MediaConfig& config, | |
| 650 webrtc::RtcEventLog* event_log) const override { | |
| 651 create_media_controller_called_ = true; | |
| 652 create_media_controller_config_ = config; | |
| 653 | |
| 654 webrtc::MediaControllerInterface* mc = | |
| 655 PeerConnectionFactory::CreateMediaController(config, event_log); | |
| 656 EXPECT_TRUE(mc != nullptr); | |
| 657 return mc; | |
| 658 } | |
| 659 | |
| 660 cricket::TransportController* CreateTransportController( | 648 cricket::TransportController* CreateTransportController( |
| 661 cricket::PortAllocator* port_allocator, | 649 cricket::PortAllocator* port_allocator, |
| 662 bool redetermine_role_on_ice_restart) override { | 650 bool redetermine_role_on_ice_restart) override { |
| 663 transport_controller = new cricket::TransportController( | 651 transport_controller = new cricket::TransportController( |
| 664 rtc::Thread::Current(), rtc::Thread::Current(), port_allocator, | 652 rtc::Thread::Current(), rtc::Thread::Current(), port_allocator, |
| 665 redetermine_role_on_ice_restart, rtc::CryptoOptions()); | 653 redetermine_role_on_ice_restart, rtc::CryptoOptions()); |
| 666 return transport_controller; | 654 return transport_controller; |
| 667 } | 655 } |
| 668 | 656 |
| 669 cricket::TransportController* transport_controller; | 657 cricket::TransportController* transport_controller; |
| 670 // Mutable, so they can be modified in the above const-declared method. | |
| 671 mutable bool create_media_controller_called_ = false; | |
| 672 mutable cricket::MediaConfig create_media_controller_config_; | |
| 673 }; | 658 }; |
| 674 | 659 |
| 675 class PeerConnectionInterfaceTest : public testing::Test { | 660 class PeerConnectionInterfaceTest : public testing::Test { |
| 676 protected: | 661 protected: |
| 677 PeerConnectionInterfaceTest() { | 662 PeerConnectionInterfaceTest() { |
| 678 #ifdef WEBRTC_ANDROID | 663 #ifdef WEBRTC_ANDROID |
| 679 webrtc::InitializeAndroidObjects(); | 664 webrtc::InitializeAndroidObjects(); |
| 680 #endif | 665 #endif |
| 681 } | 666 } |
| 682 | 667 |
| (...skipping 2628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3311 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); | 3296 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); |
| 3312 EXPECT_TRUE(DoSetLocalDescription(answer.release())); | 3297 EXPECT_TRUE(DoSetLocalDescription(answer.release())); |
| 3313 } | 3298 } |
| 3314 | 3299 |
| 3315 class PeerConnectionMediaConfigTest : public testing::Test { | 3300 class PeerConnectionMediaConfigTest : public testing::Test { |
| 3316 protected: | 3301 protected: |
| 3317 void SetUp() override { | 3302 void SetUp() override { |
| 3318 pcf_ = new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); | 3303 pcf_ = new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); |
| 3319 pcf_->Initialize(); | 3304 pcf_->Initialize(); |
| 3320 } | 3305 } |
| 3321 const cricket::MediaConfig& TestCreatePeerConnection( | 3306 const cricket::MediaConfig TestCreatePeerConnection( |
| 3322 const PeerConnectionInterface::RTCConfiguration& config, | 3307 const PeerConnectionInterface::RTCConfiguration& config, |
| 3323 const MediaConstraintsInterface *constraints) { | 3308 const MediaConstraintsInterface *constraints) { |
| 3324 pcf_->create_media_controller_called_ = false; | |
| 3325 | 3309 |
| 3326 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( | 3310 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( |
| 3327 config, constraints, nullptr, nullptr, &observer_)); | 3311 config, constraints, nullptr, nullptr, &observer_)); |
| 3328 EXPECT_TRUE(pc.get()); | 3312 EXPECT_TRUE(pc.get()); |
| 3329 EXPECT_TRUE(pcf_->create_media_controller_called_); | 3313 return pc->GetConfiguration().media_config; |
| 3330 return pcf_->create_media_controller_config_; | |
| 3331 } | 3314 } |
| 3332 | 3315 |
| 3333 rtc::scoped_refptr<PeerConnectionFactoryForTest> pcf_; | 3316 rtc::scoped_refptr<PeerConnectionFactoryForTest> pcf_; |
| 3334 MockPeerConnectionObserver observer_; | 3317 MockPeerConnectionObserver observer_; |
| 3335 }; | 3318 }; |
| 3336 | 3319 |
| 3337 // This test verifies the default behaviour with no constraints and a | 3320 // This test verifies the default behaviour with no constraints and a |
| 3338 // default RTCConfiguration. | 3321 // default RTCConfiguration. |
| 3339 TEST_F(PeerConnectionMediaConfigTest, TestDefaults) { | 3322 TEST_F(PeerConnectionMediaConfigTest, TestDefaults) { |
| 3340 PeerConnectionInterface::RTCConfiguration config; | 3323 PeerConnectionInterface::RTCConfiguration config; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3599 EXPECT_NE(a, f); | 3582 EXPECT_NE(a, f); |
| 3600 | 3583 |
| 3601 PeerConnectionInterface::RTCConfiguration g; | 3584 PeerConnectionInterface::RTCConfiguration g; |
| 3602 g.disable_ipv6 = true; | 3585 g.disable_ipv6 = true; |
| 3603 EXPECT_NE(a, g); | 3586 EXPECT_NE(a, g); |
| 3604 | 3587 |
| 3605 PeerConnectionInterface::RTCConfiguration h( | 3588 PeerConnectionInterface::RTCConfiguration h( |
| 3606 PeerConnectionInterface::RTCConfigurationType::kAggressive); | 3589 PeerConnectionInterface::RTCConfigurationType::kAggressive); |
| 3607 EXPECT_NE(a, h); | 3590 EXPECT_NE(a, h); |
| 3608 } | 3591 } |
| OLD | NEW |