OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 // |dtls_identity_store|. | 403 // |dtls_identity_store|. |
404 void Init( | 404 void Init( |
405 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, | 405 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, |
406 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | 406 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
407 ASSERT_TRUE(session_.get() == NULL); | 407 ASSERT_TRUE(session_.get() == NULL); |
408 session_.reset(new WebRtcSessionForTest( | 408 session_.reset(new WebRtcSessionForTest( |
409 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), | 409 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), |
410 allocator_.get(), &observer_)); | 410 allocator_.get(), &observer_)); |
411 session_->SignalDataChannelOpenMessage.connect( | 411 session_->SignalDataChannelOpenMessage.connect( |
412 this, &WebRtcSessionTest::OnDataChannelOpenMessage); | 412 this, &WebRtcSessionTest::OnDataChannelOpenMessage); |
413 session_->GetOnDestroyedSignal()->connect( | |
414 this, &WebRtcSessionTest::OnSessionDestroyed); | |
413 | 415 |
414 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 416 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
415 observer_.ice_connection_state_); | 417 observer_.ice_connection_state_); |
416 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 418 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
417 observer_.ice_gathering_state_); | 419 observer_.ice_gathering_state_); |
418 | 420 |
419 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), | 421 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), |
420 std::move(dtls_identity_store), | 422 std::move(dtls_identity_store), |
421 rtc_configuration)); | 423 rtc_configuration)); |
422 session_->set_metrics_observer(metrics_observer_); | 424 session_->set_metrics_observer(metrics_observer_); |
423 } | 425 } |
424 | 426 |
425 void OnDataChannelOpenMessage(const std::string& label, | 427 void OnDataChannelOpenMessage(const std::string& label, |
426 const InternalDataChannelInit& config) { | 428 const InternalDataChannelInit& config) { |
427 last_data_channel_label_ = label; | 429 last_data_channel_label_ = label; |
428 last_data_channel_config_ = config; | 430 last_data_channel_config_ = config; |
429 } | 431 } |
430 | 432 |
433 void OnSessionDestroyed() { session_destroyed_ = true; } | |
434 | |
431 void Init() { | 435 void Init() { |
432 PeerConnectionInterface::RTCConfiguration configuration; | 436 PeerConnectionInterface::RTCConfiguration configuration; |
433 Init(nullptr, configuration); | 437 Init(nullptr, configuration); |
434 } | 438 } |
435 | 439 |
436 void InitWithIceTransport( | 440 void InitWithIceTransport( |
437 PeerConnectionInterface::IceTransportsType ice_transport_type) { | 441 PeerConnectionInterface::IceTransportsType ice_transport_type) { |
438 PeerConnectionInterface::RTCConfiguration configuration; | 442 PeerConnectionInterface::RTCConfiguration configuration; |
439 configuration.type = ice_transport_type; | 443 configuration.type = ice_transport_type; |
440 Init(nullptr, configuration); | 444 Init(nullptr, configuration); |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1466 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; | 1470 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; |
1467 // The following flags affect options created for CreateOffer/CreateAnswer. | 1471 // The following flags affect options created for CreateOffer/CreateAnswer. |
1468 bool send_stream_1_ = false; | 1472 bool send_stream_1_ = false; |
1469 bool send_stream_2_ = false; | 1473 bool send_stream_2_ = false; |
1470 bool send_audio_ = false; | 1474 bool send_audio_ = false; |
1471 bool send_video_ = false; | 1475 bool send_video_ = false; |
1472 rtc::scoped_refptr<DataChannel> data_channel_; | 1476 rtc::scoped_refptr<DataChannel> data_channel_; |
1473 // Last values received from data channel creation signal. | 1477 // Last values received from data channel creation signal. |
1474 std::string last_data_channel_label_; | 1478 std::string last_data_channel_label_; |
1475 InternalDataChannelInit last_data_channel_config_; | 1479 InternalDataChannelInit last_data_channel_config_; |
1480 bool session_destroyed_; | |
joachim
2016/01/21 13:10:54
Just driving by, this should IMHO be initialized t
Taylor Brandstetter
2016/01/21 18:21:07
Good catch, thanks!
| |
1476 }; | 1481 }; |
1477 | 1482 |
1478 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) { | 1483 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) { |
1479 InitWithDtls(GetParam()); | 1484 InitWithDtls(GetParam()); |
1480 // SDES is disabled when DTLS is on. | 1485 // SDES is disabled when DTLS is on. |
1481 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); | 1486 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); |
1482 } | 1487 } |
1483 | 1488 |
1484 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { | 1489 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { |
1485 Init(); | 1490 Init(); |
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4306 // must have received a notification which, so the only invalid state | 4311 // must have received a notification which, so the only invalid state |
4307 // is kInit. | 4312 // is kInit. |
4308 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 4313 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
4309 } | 4314 } |
4310 } | 4315 } |
4311 | 4316 |
4312 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { | 4317 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { |
4313 TestPacketOptions(); | 4318 TestPacketOptions(); |
4314 } | 4319 } |
4315 | 4320 |
4321 // Make sure the signal from "GetOnDestroyedSignal()" fires when the session | |
4322 // is destroyed. | |
4323 TEST_F(WebRtcSessionTest, TestOnDestroyedSignal) { | |
4324 Init(); | |
4325 session_.reset(); | |
4326 EXPECT_TRUE(session_destroyed_); | |
4327 } | |
4328 | |
4316 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4329 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4317 // currently fails because upon disconnection and reconnection OnIceComplete is | 4330 // currently fails because upon disconnection and reconnection OnIceComplete is |
4318 // called more than once without returning to IceGatheringGathering. | 4331 // called more than once without returning to IceGatheringGathering. |
4319 | 4332 |
4320 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4333 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4321 WebRtcSessionTest, | 4334 WebRtcSessionTest, |
4322 testing::Values(ALREADY_GENERATED, | 4335 testing::Values(ALREADY_GENERATED, |
4323 DTLS_IDENTITY_STORE)); | 4336 DTLS_IDENTITY_STORE)); |
OLD | NEW |