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

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

Issue 1788703003: Reland the CL to remove candidates when doing continual gathering (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 9 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/api/jsepsessiondescription.cc ('k') | webrtc/api/peerconnection.h » ('j') | 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 cricket::Candidate candidate_; 102 cricket::Candidate candidate_;
103 rtc::scoped_ptr<JsepSessionDescription> jsep_desc_; 103 rtc::scoped_ptr<JsepSessionDescription> jsep_desc_;
104 }; 104 };
105 105
106 // Test that number_of_mediasections() returns the number of media contents in 106 // Test that number_of_mediasections() returns the number of media contents in
107 // a session description. 107 // a session description.
108 TEST_F(JsepSessionDescriptionTest, CheckSessionDescription) { 108 TEST_F(JsepSessionDescriptionTest, CheckSessionDescription) {
109 EXPECT_EQ(2u, jsep_desc_->number_of_mediasections()); 109 EXPECT_EQ(2u, jsep_desc_->number_of_mediasections());
110 } 110 }
111 111
112 // Test that we can add a candidate to a session description. 112 // Test that we can add a candidate to a session description without MID.
113 TEST_F(JsepSessionDescriptionTest, AddCandidateWithoutMid) { 113 TEST_F(JsepSessionDescriptionTest, AddCandidateWithoutMid) {
114 JsepIceCandidate jsep_candidate("", 0, candidate_); 114 JsepIceCandidate jsep_candidate("", 0, candidate_);
115 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); 115 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate));
116 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(0); 116 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(0);
117 ASSERT_TRUE(ice_candidates != NULL); 117 ASSERT_TRUE(ice_candidates != NULL);
118 EXPECT_EQ(1u, ice_candidates->count()); 118 EXPECT_EQ(1u, ice_candidates->count());
119 const IceCandidateInterface* ice_candidate = ice_candidates->at(0); 119 const IceCandidateInterface* ice_candidate = ice_candidates->at(0);
120 ASSERT_TRUE(ice_candidate != NULL); 120 ASSERT_TRUE(ice_candidate != NULL);
121 candidate_.set_username(kCandidateUfragVoice); 121 candidate_.set_username(kCandidateUfragVoice);
122 candidate_.set_password(kCandidatePwdVoice); 122 candidate_.set_password(kCandidatePwdVoice);
123 EXPECT_TRUE(ice_candidate->candidate().IsEquivalent(candidate_)); 123 EXPECT_TRUE(ice_candidate->candidate().IsEquivalent(candidate_));
124 EXPECT_EQ(0, ice_candidate->sdp_mline_index()); 124 EXPECT_EQ(0, ice_candidate->sdp_mline_index());
125 EXPECT_EQ(0u, jsep_desc_->candidates(1)->count()); 125 EXPECT_EQ(0u, jsep_desc_->candidates(1)->count());
126 } 126 }
127 127
128 TEST_F(JsepSessionDescriptionTest, AddCandidateWithMid) { 128 // Test that we can add and remove candidates to a session description with
129 // MID. Removing candidates requires MID (transport_name).
130 TEST_F(JsepSessionDescriptionTest, AddAndRemoveCandidatesWithMid) {
129 // mid and m-line index don't match, in this case mid is preferred. 131 // mid and m-line index don't match, in this case mid is preferred.
130 JsepIceCandidate jsep_candidate("video", 0, candidate_); 132 std::string mid = "video";
133 JsepIceCandidate jsep_candidate(mid, 0, candidate_);
131 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); 134 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate));
132 EXPECT_EQ(0u, jsep_desc_->candidates(0)->count()); 135 EXPECT_EQ(0u, jsep_desc_->candidates(0)->count());
133 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(1); 136 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(1);
134 ASSERT_TRUE(ice_candidates != NULL); 137 ASSERT_TRUE(ice_candidates != NULL);
135 EXPECT_EQ(1u, ice_candidates->count()); 138 EXPECT_EQ(1u, ice_candidates->count());
136 const IceCandidateInterface* ice_candidate = ice_candidates->at(0); 139 const IceCandidateInterface* ice_candidate = ice_candidates->at(0);
137 ASSERT_TRUE(ice_candidate != NULL); 140 ASSERT_TRUE(ice_candidate != NULL);
138 candidate_.set_username(kCandidateUfragVideo); 141 candidate_.set_username(kCandidateUfragVideo);
139 candidate_.set_password(kCandidatePwdVideo); 142 candidate_.set_password(kCandidatePwdVideo);
140 EXPECT_TRUE(ice_candidate->candidate().IsEquivalent(candidate_)); 143 EXPECT_TRUE(ice_candidate->candidate().IsEquivalent(candidate_));
141 // The mline index should have been updated according to mid. 144 // The mline index should have been updated according to mid.
142 EXPECT_EQ(1, ice_candidate->sdp_mline_index()); 145 EXPECT_EQ(1, ice_candidate->sdp_mline_index());
146
147 std::vector<cricket::Candidate> candidates(1, candidate_);
148 candidates[0].set_transport_name(mid);
149 EXPECT_EQ(1u, jsep_desc_->RemoveCandidates(candidates));
150 EXPECT_EQ(0u, jsep_desc_->candidates(0)->count());
151 EXPECT_EQ(0u, jsep_desc_->candidates(1)->count());
143 } 152 }
144 153
145 TEST_F(JsepSessionDescriptionTest, AddCandidateAlreadyHasUfrag) { 154 TEST_F(JsepSessionDescriptionTest, AddCandidateAlreadyHasUfrag) {
146 candidate_.set_username(kCandidateUfrag); 155 candidate_.set_username(kCandidateUfrag);
147 candidate_.set_password(kCandidatePwd); 156 candidate_.set_password(kCandidatePwd);
148 JsepIceCandidate jsep_candidate("audio", 0, candidate_); 157 JsepIceCandidate jsep_candidate("audio", 0, candidate_);
149 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); 158 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate));
150 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(0); 159 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(0);
151 ASSERT_TRUE(ice_candidates != NULL); 160 ASSERT_TRUE(ice_candidates != NULL);
152 EXPECT_EQ(1u, ice_candidates->count()); 161 EXPECT_EQ(1u, ice_candidates->count());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); 221 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate));
213 std::string sdp_with_candidate = Serialize(jsep_desc_.get()); 222 std::string sdp_with_candidate = Serialize(jsep_desc_.get());
214 EXPECT_NE(sdp, sdp_with_candidate); 223 EXPECT_NE(sdp, sdp_with_candidate);
215 224
216 scoped_ptr<SessionDescriptionInterface> parsed_jsep_desc( 225 scoped_ptr<SessionDescriptionInterface> parsed_jsep_desc(
217 DeSerialize(sdp_with_candidate)); 226 DeSerialize(sdp_with_candidate));
218 std::string parsed_sdp_with_candidate = Serialize(parsed_jsep_desc.get()); 227 std::string parsed_sdp_with_candidate = Serialize(parsed_jsep_desc.get());
219 228
220 EXPECT_EQ(sdp_with_candidate, parsed_sdp_with_candidate); 229 EXPECT_EQ(sdp_with_candidate, parsed_sdp_with_candidate);
221 } 230 }
OLDNEW
« no previous file with comments | « webrtc/api/jsepsessiondescription.cc ('k') | webrtc/api/peerconnection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698