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

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

Issue 3006723002: Fix the Chromium crash when creating an answer without a remote description. (Closed)
Patch Set: Add a unit test. Created 3 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/peerconnection.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 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 3753 matching lines...) Expand 10 before | Expand all | Expand 10 after
3764 const cricket::ContentInfo* audio_content = 3764 const cricket::ContentInfo* audio_content =
3765 GetFirstAudioContent(answer->description()); 3765 GetFirstAudioContent(answer->description());
3766 const cricket::ContentInfo* video_content = 3766 const cricket::ContentInfo* video_content =
3767 GetFirstVideoContent(answer->description()); 3767 GetFirstVideoContent(answer->description());
3768 ASSERT_NE(nullptr, audio_content); 3768 ASSERT_NE(nullptr, audio_content);
3769 ASSERT_NE(nullptr, video_content); 3769 ASSERT_NE(nullptr, video_content);
3770 EXPECT_TRUE(audio_content->rejected); 3770 EXPECT_TRUE(audio_content->rejected);
3771 EXPECT_TRUE(video_content->rejected); 3771 EXPECT_TRUE(video_content->rejected);
3772 } 3772 }
3773 3773
3774 // This test ensures OnRenegotiationNeeded is called when we add track with
3775 // MediaStream -> AddTrack in the same way it is called when we add track with
3776 // PeerConnection -> AddTrack.
3777 // The test can be removed once addStream is rewritten in terms of addTrack
3778 // https://bugs.chromium.org/p/webrtc/issues/detail?id=7815
3779 TEST_F(PeerConnectionInterfaceTest, MediaStreamAddTrackRemoveTrackRenegotiate) {
3780 CreatePeerConnectionWithoutDtls();
3781 rtc::scoped_refptr<MediaStreamInterface> stream(
3782 pc_factory_->CreateLocalMediaStream(kStreamLabel1));
3783 pc_->AddStream(stream);
3784 rtc::scoped_refptr<AudioTrackInterface> audio_track(
3785 pc_factory_->CreateAudioTrack("audio_track", nullptr));
3786 rtc::scoped_refptr<VideoTrackInterface> video_track(
3787 pc_factory_->CreateVideoTrack(
3788 "video_track", pc_factory_->CreateVideoSource(
3789 std::unique_ptr<cricket::VideoCapturer>(
3790 new cricket::FakeVideoCapturer()))));
3791 stream->AddTrack(audio_track);
3792 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3793 observer_.renegotiation_needed_ = false;
3794
3795 stream->AddTrack(video_track);
3796 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3797 observer_.renegotiation_needed_ = false;
3798
3799 stream->RemoveTrack(audio_track);
3800 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3801 observer_.renegotiation_needed_ = false;
3802
3803 stream->RemoveTrack(video_track);
3804 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3805 observer_.renegotiation_needed_ = false;
3806 }
3807
3808 // Tests that creating answer would fail gracefully without being crashed if the
3809 // remote description is unset.
3810 TEST_F(PeerConnectionInterfaceTest, CreateAnswerWithoutRemoteDescription) {
3811 CreatePeerConnection();
3812 // Creating answer fails because the remote description is unset.
3813 std::unique_ptr<SessionDescriptionInterface> answer;
3814 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr));
3815
3816 // Createing answer succeeds when the remote description is set.
3817 CreateOfferAsRemoteDescription();
3818 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr));
3819 }
3820
3774 class PeerConnectionMediaConfigTest : public testing::Test { 3821 class PeerConnectionMediaConfigTest : public testing::Test {
3775 protected: 3822 protected:
3776 void SetUp() override { 3823 void SetUp() override {
3777 pcf_ = PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest(); 3824 pcf_ = PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest();
3778 pcf_->Initialize(); 3825 pcf_->Initialize();
3779 } 3826 }
3780 const cricket::MediaConfig TestCreatePeerConnection( 3827 const cricket::MediaConfig TestCreatePeerConnection(
3781 const PeerConnectionInterface::RTCConfiguration& config, 3828 const PeerConnectionInterface::RTCConfiguration& config,
3782 const MediaConstraintsInterface* constraints) { 3829 const MediaConstraintsInterface* constraints) {
3783 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( 3830 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3884 EXPECT_NE(a, f); 3931 EXPECT_NE(a, f);
3885 3932
3886 PeerConnectionInterface::RTCConfiguration g; 3933 PeerConnectionInterface::RTCConfiguration g;
3887 g.disable_ipv6 = true; 3934 g.disable_ipv6 = true;
3888 EXPECT_NE(a, g); 3935 EXPECT_NE(a, g);
3889 3936
3890 PeerConnectionInterface::RTCConfiguration h( 3937 PeerConnectionInterface::RTCConfiguration h(
3891 PeerConnectionInterface::RTCConfigurationType::kAggressive); 3938 PeerConnectionInterface::RTCConfigurationType::kAggressive);
3892 EXPECT_NE(a, h); 3939 EXPECT_NE(a, h);
3893 } 3940 }
3894
3895 // This test ensures OnRenegotiationNeeded is called when we add track with
3896 // MediaStream -> AddTrack in the same way it is called when we add track with
3897 // PeerConnection -> AddTrack.
3898 // The test can be removed once addStream is rewritten in terms of addTrack
3899 // https://bugs.chromium.org/p/webrtc/issues/detail?id=7815
3900 TEST_F(PeerConnectionInterfaceTest, MediaStreamAddTrackRemoveTrackRenegotiate) {
3901 CreatePeerConnectionWithoutDtls();
3902 rtc::scoped_refptr<MediaStreamInterface> stream(
3903 pc_factory_->CreateLocalMediaStream(kStreamLabel1));
3904 pc_->AddStream(stream);
3905 rtc::scoped_refptr<AudioTrackInterface> audio_track(
3906 pc_factory_->CreateAudioTrack("audio_track", nullptr));
3907 rtc::scoped_refptr<VideoTrackInterface> video_track(
3908 pc_factory_->CreateVideoTrack(
3909 "video_track", pc_factory_->CreateVideoSource(
3910 std::unique_ptr<cricket::VideoCapturer>(
3911 new cricket::FakeVideoCapturer()))));
3912 stream->AddTrack(audio_track);
3913 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3914 observer_.renegotiation_needed_ = false;
3915
3916 stream->AddTrack(video_track);
3917 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3918 observer_.renegotiation_needed_ = false;
3919
3920 stream->RemoveTrack(audio_track);
3921 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3922 observer_.renegotiation_needed_ = false;
3923
3924 stream->RemoveTrack(video_track);
3925 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3926 observer_.renegotiation_needed_ = false;
3927 }
OLDNEW
« no previous file with comments | « webrtc/pc/peerconnection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698