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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 without MID. | 112 // Test that we can add a candidate to a session description. |
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 that we can add and remove candidates to a session description with | 128 TEST_F(JsepSessionDescriptionTest, AddCandidateWithMid) { |
129 // MID. Removing candidates requires MID (transport_name). | |
130 TEST_F(JsepSessionDescriptionTest, AddAndRemoveCandidatesWithMid) { | |
131 // mid and m-line index don't match, in this case mid is preferred. | 129 // mid and m-line index don't match, in this case mid is preferred. |
132 std::string mid = "video"; | 130 JsepIceCandidate jsep_candidate("video", 0, candidate_); |
133 JsepIceCandidate jsep_candidate(mid, 0, candidate_); | |
134 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); | 131 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); |
135 EXPECT_EQ(0u, jsep_desc_->candidates(0)->count()); | 132 EXPECT_EQ(0u, jsep_desc_->candidates(0)->count()); |
136 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(1); | 133 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(1); |
137 ASSERT_TRUE(ice_candidates != NULL); | 134 ASSERT_TRUE(ice_candidates != NULL); |
138 EXPECT_EQ(1u, ice_candidates->count()); | 135 EXPECT_EQ(1u, ice_candidates->count()); |
139 const IceCandidateInterface* ice_candidate = ice_candidates->at(0); | 136 const IceCandidateInterface* ice_candidate = ice_candidates->at(0); |
140 ASSERT_TRUE(ice_candidate != NULL); | 137 ASSERT_TRUE(ice_candidate != NULL); |
141 candidate_.set_username(kCandidateUfragVideo); | 138 candidate_.set_username(kCandidateUfragVideo); |
142 candidate_.set_password(kCandidatePwdVideo); | 139 candidate_.set_password(kCandidatePwdVideo); |
143 EXPECT_TRUE(ice_candidate->candidate().IsEquivalent(candidate_)); | 140 EXPECT_TRUE(ice_candidate->candidate().IsEquivalent(candidate_)); |
144 // The mline index should have been updated according to mid. | 141 // The mline index should have been updated according to mid. |
145 EXPECT_EQ(1, ice_candidate->sdp_mline_index()); | 142 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()); | |
152 } | 143 } |
153 | 144 |
154 TEST_F(JsepSessionDescriptionTest, AddCandidateAlreadyHasUfrag) { | 145 TEST_F(JsepSessionDescriptionTest, AddCandidateAlreadyHasUfrag) { |
155 candidate_.set_username(kCandidateUfrag); | 146 candidate_.set_username(kCandidateUfrag); |
156 candidate_.set_password(kCandidatePwd); | 147 candidate_.set_password(kCandidatePwd); |
157 JsepIceCandidate jsep_candidate("audio", 0, candidate_); | 148 JsepIceCandidate jsep_candidate("audio", 0, candidate_); |
158 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); | 149 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); |
159 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(0); | 150 const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(0); |
160 ASSERT_TRUE(ice_candidates != NULL); | 151 ASSERT_TRUE(ice_candidates != NULL); |
161 EXPECT_EQ(1u, ice_candidates->count()); | 152 EXPECT_EQ(1u, ice_candidates->count()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); | 212 EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); |
222 std::string sdp_with_candidate = Serialize(jsep_desc_.get()); | 213 std::string sdp_with_candidate = Serialize(jsep_desc_.get()); |
223 EXPECT_NE(sdp, sdp_with_candidate); | 214 EXPECT_NE(sdp, sdp_with_candidate); |
224 | 215 |
225 scoped_ptr<SessionDescriptionInterface> parsed_jsep_desc( | 216 scoped_ptr<SessionDescriptionInterface> parsed_jsep_desc( |
226 DeSerialize(sdp_with_candidate)); | 217 DeSerialize(sdp_with_candidate)); |
227 std::string parsed_sdp_with_candidate = Serialize(parsed_jsep_desc.get()); | 218 std::string parsed_sdp_with_candidate = Serialize(parsed_jsep_desc.get()); |
228 | 219 |
229 EXPECT_EQ(sdp_with_candidate, parsed_sdp_with_candidate); | 220 EXPECT_EQ(sdp_with_candidate, parsed_sdp_with_candidate); |
230 } | 221 } |
OLD | NEW |