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

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

Issue 1975453002: Add PeerConnection IsClosed check. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Make it an unique_ptr when passing the TransportController to WebRtcSession. Created 4 years, 5 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') | 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 std::vector<cricket::Candidate> mline_1_candidates_; 205 std::vector<cricket::Candidate> mline_1_candidates_;
206 PeerConnectionInterface::IceConnectionState ice_connection_state_; 206 PeerConnectionInterface::IceConnectionState ice_connection_state_;
207 PeerConnectionInterface::IceGatheringState ice_gathering_state_; 207 PeerConnectionInterface::IceGatheringState ice_gathering_state_;
208 std::vector<PeerConnectionInterface::IceConnectionState> 208 std::vector<PeerConnectionInterface::IceConnectionState>
209 ice_connection_state_history_; 209 ice_connection_state_history_;
210 size_t num_candidates_removed_ = 0; 210 size_t num_candidates_removed_ = 0;
211 }; 211 };
212 212
213 class WebRtcSessionForTest : public webrtc::WebRtcSession { 213 class WebRtcSessionForTest : public webrtc::WebRtcSession {
214 public: 214 public:
215 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller, 215 WebRtcSessionForTest(
216 rtc::Thread* network_thread, 216 webrtc::MediaControllerInterface* media_controller,
217 rtc::Thread* worker_thread, 217 rtc::Thread* network_thread,
218 rtc::Thread* signaling_thread, 218 rtc::Thread* worker_thread,
219 cricket::PortAllocator* port_allocator, 219 rtc::Thread* signaling_thread,
220 webrtc::IceObserver* ice_observer) 220 cricket::PortAllocator* port_allocator,
221 webrtc::IceObserver* ice_observer,
222 std::unique_ptr<cricket::TransportController> transport_controller)
221 : WebRtcSession(media_controller, 223 : WebRtcSession(media_controller,
222 network_thread, 224 network_thread,
223 worker_thread, 225 worker_thread,
224 signaling_thread, 226 signaling_thread,
225 port_allocator) { 227 port_allocator,
228 std::move(transport_controller)) {
226 RegisterIceObserver(ice_observer); 229 RegisterIceObserver(ice_observer);
227 } 230 }
228 virtual ~WebRtcSessionForTest() {} 231 virtual ~WebRtcSessionForTest() {}
229 232
230 // Note that these methods are only safe to use if the signaling thread 233 // Note that these methods are only safe to use if the signaling thread
231 // is the same as the worker thread 234 // is the same as the worker thread
232 cricket::TransportChannel* voice_rtp_transport_channel() { 235 cricket::TransportChannel* voice_rtp_transport_channel() {
233 return rtp_transport_channel(voice_channel()); 236 return rtp_transport_channel(voice_channel());
234 } 237 }
235 238
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 382
380 // If |cert_generator| != null or |rtc_configuration| contains |certificates| 383 // If |cert_generator| != null or |rtc_configuration| contains |certificates|
381 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| 384 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration|
382 // options. When DTLS is enabled a certificate will be used if provided, 385 // options. When DTLS is enabled a certificate will be used if provided,
383 // otherwise one will be generated using the |cert_generator|. 386 // otherwise one will be generated using the |cert_generator|.
384 void Init( 387 void Init(
385 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator) { 388 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator) {
386 ASSERT_TRUE(session_.get() == NULL); 389 ASSERT_TRUE(session_.get() == NULL);
387 session_.reset(new WebRtcSessionForTest( 390 session_.reset(new WebRtcSessionForTest(
388 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), 391 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(),
389 rtc::Thread::Current(), allocator_.get(), &observer_)); 392 rtc::Thread::Current(), allocator_.get(), &observer_,
393 std::unique_ptr<cricket::TransportController>(
394 new cricket::TransportController(rtc::Thread::Current(),
395 rtc::Thread::Current(),
396 allocator_.get()))));
390 session_->SignalDataChannelOpenMessage.connect( 397 session_->SignalDataChannelOpenMessage.connect(
391 this, &WebRtcSessionTest::OnDataChannelOpenMessage); 398 this, &WebRtcSessionTest::OnDataChannelOpenMessage);
392 session_->GetOnDestroyedSignal()->connect( 399 session_->GetOnDestroyedSignal()->connect(
393 this, &WebRtcSessionTest::OnSessionDestroyed); 400 this, &WebRtcSessionTest::OnSessionDestroyed);
394 401
395 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, 402 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew,
396 observer_.ice_connection_state_); 403 observer_.ice_connection_state_);
397 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, 404 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew,
398 observer_.ice_gathering_state_); 405 observer_.ice_gathering_state_);
399 406
(...skipping 4019 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 } 4426 }
4420 4427
4421 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4428 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4422 // currently fails because upon disconnection and reconnection OnIceComplete is 4429 // currently fails because upon disconnection and reconnection OnIceComplete is
4423 // called more than once without returning to IceGatheringGathering. 4430 // called more than once without returning to IceGatheringGathering.
4424 4431
4425 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4432 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4426 WebRtcSessionTest, 4433 WebRtcSessionTest,
4427 testing::Values(ALREADY_GENERATED, 4434 testing::Values(ALREADY_GENERATED,
4428 DTLS_IDENTITY_STORE)); 4435 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698