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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/pc/peerconnection.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/pc/peerconnectioninterface_unittest.cc
diff --git a/webrtc/pc/peerconnectioninterface_unittest.cc b/webrtc/pc/peerconnectioninterface_unittest.cc
index ead950cca7f37542669770c01ad2f6cc6c34c826..c23a79d597b4fe8bdaec83edbd867df52ef3f3f5 100644
--- a/webrtc/pc/peerconnectioninterface_unittest.cc
+++ b/webrtc/pc/peerconnectioninterface_unittest.cc
@@ -3771,6 +3771,53 @@ TEST_F(PeerConnectionInterfaceTest,
EXPECT_TRUE(video_content->rejected);
}
+// This test ensures OnRenegotiationNeeded is called when we add track with
+// MediaStream -> AddTrack in the same way it is called when we add track with
+// PeerConnection -> AddTrack.
+// The test can be removed once addStream is rewritten in terms of addTrack
+// https://bugs.chromium.org/p/webrtc/issues/detail?id=7815
+TEST_F(PeerConnectionInterfaceTest, MediaStreamAddTrackRemoveTrackRenegotiate) {
+ CreatePeerConnectionWithoutDtls();
+ rtc::scoped_refptr<MediaStreamInterface> stream(
+ pc_factory_->CreateLocalMediaStream(kStreamLabel1));
+ pc_->AddStream(stream);
+ rtc::scoped_refptr<AudioTrackInterface> audio_track(
+ pc_factory_->CreateAudioTrack("audio_track", nullptr));
+ rtc::scoped_refptr<VideoTrackInterface> video_track(
+ pc_factory_->CreateVideoTrack(
+ "video_track", pc_factory_->CreateVideoSource(
+ std::unique_ptr<cricket::VideoCapturer>(
+ new cricket::FakeVideoCapturer()))));
+ stream->AddTrack(audio_track);
+ EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
+ observer_.renegotiation_needed_ = false;
+
+ stream->AddTrack(video_track);
+ EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
+ observer_.renegotiation_needed_ = false;
+
+ stream->RemoveTrack(audio_track);
+ EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
+ observer_.renegotiation_needed_ = false;
+
+ stream->RemoveTrack(video_track);
+ EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
+ observer_.renegotiation_needed_ = false;
+}
+
+// Tests that creating answer would fail gracefully without being crashed if the
+// remote description is unset.
+TEST_F(PeerConnectionInterfaceTest, CreateAnswerWithoutRemoteDescription) {
+ CreatePeerConnection();
+ // Creating answer fails because the remote description is unset.
+ std::unique_ptr<SessionDescriptionInterface> answer;
+ EXPECT_FALSE(DoCreateAnswer(&answer, nullptr));
+
+ // Createing answer succeeds when the remote description is set.
+ CreateOfferAsRemoteDescription();
+ EXPECT_TRUE(DoCreateAnswer(&answer, nullptr));
+}
+
class PeerConnectionMediaConfigTest : public testing::Test {
protected:
void SetUp() override {
@@ -3891,37 +3938,3 @@ TEST(RTCConfigurationTest, ComparisonOperators) {
PeerConnectionInterface::RTCConfigurationType::kAggressive);
EXPECT_NE(a, h);
}
-
-// This test ensures OnRenegotiationNeeded is called when we add track with
-// MediaStream -> AddTrack in the same way it is called when we add track with
-// PeerConnection -> AddTrack.
-// The test can be removed once addStream is rewritten in terms of addTrack
-// https://bugs.chromium.org/p/webrtc/issues/detail?id=7815
-TEST_F(PeerConnectionInterfaceTest, MediaStreamAddTrackRemoveTrackRenegotiate) {
- CreatePeerConnectionWithoutDtls();
- rtc::scoped_refptr<MediaStreamInterface> stream(
- pc_factory_->CreateLocalMediaStream(kStreamLabel1));
- pc_->AddStream(stream);
- rtc::scoped_refptr<AudioTrackInterface> audio_track(
- pc_factory_->CreateAudioTrack("audio_track", nullptr));
- rtc::scoped_refptr<VideoTrackInterface> video_track(
- pc_factory_->CreateVideoTrack(
- "video_track", pc_factory_->CreateVideoSource(
- std::unique_ptr<cricket::VideoCapturer>(
- new cricket::FakeVideoCapturer()))));
- stream->AddTrack(audio_track);
- EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
- observer_.renegotiation_needed_ = false;
-
- stream->AddTrack(video_track);
- EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
- observer_.renegotiation_needed_ = false;
-
- stream->RemoveTrack(audio_track);
- EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
- observer_.renegotiation_needed_ = false;
-
- stream->RemoveTrack(video_track);
- EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
- observer_.renegotiation_needed_ = false;
-}
« 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