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

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

Issue 1972493002: Do not create a temporary transport channel when using max-bundle (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Code review feedback Created 4 years, 7 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/webrtcsession.cc ('k') | webrtc/pc/channel.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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 : oncandidatesready_(false), 156 : oncandidatesready_(false),
157 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), 157 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew),
158 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { 158 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) {
159 } 159 }
160 160
161 virtual ~MockIceObserver() = default; 161 virtual ~MockIceObserver() = default;
162 162
163 void OnIceConnectionChange( 163 void OnIceConnectionChange(
164 PeerConnectionInterface::IceConnectionState new_state) override { 164 PeerConnectionInterface::IceConnectionState new_state) override {
165 ice_connection_state_ = new_state; 165 ice_connection_state_ = new_state;
166 ice_connection_state_history_.push_back(new_state);
166 } 167 }
167 void OnIceGatheringChange( 168 void OnIceGatheringChange(
168 PeerConnectionInterface::IceGatheringState new_state) override { 169 PeerConnectionInterface::IceGatheringState new_state) override {
169 // We can never transition back to "new". 170 // We can never transition back to "new".
170 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, new_state); 171 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, new_state);
171 ice_gathering_state_ = new_state; 172 ice_gathering_state_ = new_state;
172 oncandidatesready_ = 173 oncandidatesready_ =
173 new_state == PeerConnectionInterface::kIceGatheringComplete; 174 new_state == PeerConnectionInterface::kIceGatheringComplete;
174 } 175 }
175 176
(...skipping 19 matching lines...) Expand all
195 void OnIceCandidatesRemoved( 196 void OnIceCandidatesRemoved(
196 const std::vector<cricket::Candidate>& candidates) override { 197 const std::vector<cricket::Candidate>& candidates) override {
197 num_candidates_removed_ += candidates.size(); 198 num_candidates_removed_ += candidates.size();
198 } 199 }
199 200
200 bool oncandidatesready_; 201 bool oncandidatesready_;
201 std::vector<cricket::Candidate> mline_0_candidates_; 202 std::vector<cricket::Candidate> mline_0_candidates_;
202 std::vector<cricket::Candidate> mline_1_candidates_; 203 std::vector<cricket::Candidate> mline_1_candidates_;
203 PeerConnectionInterface::IceConnectionState ice_connection_state_; 204 PeerConnectionInterface::IceConnectionState ice_connection_state_;
204 PeerConnectionInterface::IceGatheringState ice_gathering_state_; 205 PeerConnectionInterface::IceGatheringState ice_gathering_state_;
206 std::vector<PeerConnectionInterface::IceConnectionState>
207 ice_connection_state_history_;
205 size_t num_candidates_removed_ = 0; 208 size_t num_candidates_removed_ = 0;
206 }; 209 };
207 210
208 class WebRtcSessionForTest : public webrtc::WebRtcSession { 211 class WebRtcSessionForTest : public webrtc::WebRtcSession {
209 public: 212 public:
210 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller, 213 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller,
211 rtc::Thread* signaling_thread, 214 rtc::Thread* signaling_thread,
212 rtc::Thread* worker_thread, 215 rtc::Thread* worker_thread,
213 cricket::PortAllocator* port_allocator, 216 cricket::PortAllocator* port_allocator,
214 webrtc::IceObserver* ice_observer) 217 webrtc::IceObserver* ice_observer)
(...skipping 3039 matching lines...) Expand 10 before | Expand all | Expand 10 after
3254 PeerConnectionInterface::RTCOfferAnswerOptions options; 3257 PeerConnectionInterface::RTCOfferAnswerOptions options;
3255 options.use_rtp_mux = true; 3258 options.use_rtp_mux = true;
3256 3259
3257 SessionDescriptionInterface* offer = CreateOffer(options); 3260 SessionDescriptionInterface* offer = CreateOffer(options);
3258 SetRemoteDescriptionWithoutError(offer); 3261 SetRemoteDescriptionWithoutError(offer);
3259 3262
3260 EXPECT_EQ(session_->voice_rtp_transport_channel(), 3263 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3261 session_->video_rtp_transport_channel()); 3264 session_->video_rtp_transport_channel());
3262 } 3265 }
3263 3266
3267 // Adding a new channel to a BUNDLE which is already connected should directly
3268 // assign the bundle transport to the channel, without first setting a
3269 // disconnected non-bundle transport and then replacing it. The application
3270 // should not receive any changes in the ICE state.
3271 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) {
3272 LoopbackNetworkConfiguration config;
3273 LoopbackNetworkManager loopback_network_manager(this, config);
3274 // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain
3275 // connected. Disabling either of these two means that we need to wait for the
3276 // answer to find out if more transports are needed.
3277 configuration_.bundle_policy =
3278 PeerConnectionInterface::kBundlePolicyMaxBundle;
3279 configuration_.rtcp_mux_policy =
3280 PeerConnectionInterface::kRtcpMuxPolicyRequire;
3281 options_.disable_encryption = true;
3282 Init();
3283
3284 // Negotiate an audio channel with MAX_BUNDLE enabled.
3285 SendAudioOnlyStream2();
3286 SessionDescriptionInterface* offer = CreateOffer();
3287 SetLocalDescriptionWithoutError(offer);
3288 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
3289 observer_.ice_gathering_state_, kIceCandidatesTimeout);
3290 std::string sdp;
3291 offer->ToString(&sdp);
Taylor Brandstetter 2016/05/16 19:59:47 nit: I know the old tests don't do this, but it wo
3292 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription(
3293 JsepSessionDescription::kAnswer, sdp, nullptr);
3294 ASSERT_TRUE(answer != NULL);
3295 SetRemoteDescriptionWithoutError(answer);
3296
3297 // Wait for the ICE state to stabilize.
3298 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
3299 observer_.ice_connection_state_, kIceCandidatesTimeout);
3300 observer_.ice_connection_state_history_.clear();
3301
3302 // Now add a video channel which should be using the same bundle transport.
3303 SendAudioVideoStream2();
3304 offer = CreateOffer();
3305 offer->ToString(&sdp);
3306 SetLocalDescriptionWithoutError(offer);
3307 answer = webrtc::CreateSessionDescription(JsepSessionDescription::kAnswer,
3308 sdp, nullptr);
3309 ASSERT_TRUE(answer != NULL);
3310 SetRemoteDescriptionWithoutError(answer);
3311
3312 // Wait for ICE state to stabilize
3313 rtc::Thread::Current()->ProcessMessages(0);
3314 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
3315 observer_.ice_connection_state_, kIceCandidatesTimeout);
3316
3317 // No ICE state changes are expected to happen.
3318 EXPECT_EQ(0, observer_.ice_connection_state_history_.size());
3319 }
3320
3264 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { 3321 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) {
3265 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); 3322 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire);
3266 SendAudioVideoStream1(); 3323 SendAudioVideoStream1();
3267 3324
3268 PeerConnectionInterface::RTCOfferAnswerOptions options; 3325 PeerConnectionInterface::RTCOfferAnswerOptions options;
3269 SessionDescriptionInterface* offer = CreateOffer(options); 3326 SessionDescriptionInterface* offer = CreateOffer(options);
3270 SetLocalDescriptionWithoutError(offer); 3327 SetLocalDescriptionWithoutError(offer);
3271 3328
3272 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); 3329 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL);
3273 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); 3330 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL);
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
4358 } 4415 }
4359 4416
4360 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4417 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4361 // currently fails because upon disconnection and reconnection OnIceComplete is 4418 // currently fails because upon disconnection and reconnection OnIceComplete is
4362 // called more than once without returning to IceGatheringGathering. 4419 // called more than once without returning to IceGatheringGathering.
4363 4420
4364 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4421 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4365 WebRtcSessionTest, 4422 WebRtcSessionTest,
4366 testing::Values(ALREADY_GENERATED, 4423 testing::Values(ALREADY_GENERATED,
4367 DTLS_IDENTITY_STORE)); 4424 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession.cc ('k') | webrtc/pc/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698