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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 "a=ice-pwd:cMvOlFvQ6ochez1ZOoC2uBEC\r\n" | 149 "a=ice-pwd:cMvOlFvQ6ochez1ZOoC2uBEC\r\n" |
150 "a=mid:video\r\n" | 150 "a=mid:video\r\n" |
151 "a=sendrecv\r\n" | 151 "a=sendrecv\r\n" |
152 "a=rtcp-mux\r\n" | 152 "a=rtcp-mux\r\n" |
153 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 " | 153 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 " |
154 "inline:5/4N5CDvMiyDArHtBByUM71VIkguH17ZNoX60GrA\r\n" | 154 "inline:5/4N5CDvMiyDArHtBByUM71VIkguH17ZNoX60GrA\r\n" |
155 "a=rtpmap:0 fake_video_codec/90000\r\n" | 155 "a=rtpmap:0 fake_video_codec/90000\r\n" |
156 "a=rtpmap:96 rtx/90000\r\n" | 156 "a=rtpmap:96 rtx/90000\r\n" |
157 "a=fmtp:96 apt=0\r\n"; | 157 "a=fmtp:96 apt=0\r\n"; |
158 | 158 |
159 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE }; | |
160 | |
159 // Add some extra |newlines| to the |message| after |line|. | 161 // Add some extra |newlines| to the |message| after |line|. |
160 static void InjectAfter(const std::string& line, | 162 static void InjectAfter(const std::string& line, |
161 const std::string& newlines, | 163 const std::string& newlines, |
162 std::string* message) { | 164 std::string* message) { |
163 const std::string tmp = line + newlines; | 165 const std::string tmp = line + newlines; |
164 rtc::replace_substrs(line.c_str(), line.length(), | 166 rtc::replace_substrs(line.c_str(), line.length(), |
165 tmp.c_str(), tmp.length(), message); | 167 tmp.c_str(), tmp.length(), message); |
166 } | 168 } |
167 | 169 |
168 class MockIceObserver : public webrtc::IceObserver { | 170 class MockIceObserver : public webrtc::IceObserver { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 } | 305 } |
304 void SetSink(Sink* sink) override { sink_ = sink; } | 306 void SetSink(Sink* sink) override { sink_ = sink; } |
305 | 307 |
306 int channel_id() const { return channel_id_; } | 308 int channel_id() const { return channel_id_; } |
307 cricket::AudioRenderer::Sink* sink() const { return sink_; } | 309 cricket::AudioRenderer::Sink* sink() const { return sink_; } |
308 private: | 310 private: |
309 int channel_id_; | 311 int channel_id_; |
310 cricket::AudioRenderer::Sink* sink_; | 312 cricket::AudioRenderer::Sink* sink_; |
311 }; | 313 }; |
312 | 314 |
313 class WebRtcSessionTest : public testing::Test { | 315 class WebRtcSessionTest |
316 : public testing::TestWithParam<RTCCertificateGenerationMethod> { | |
314 protected: | 317 protected: |
315 // TODO Investigate why ChannelManager crashes, if it's created | 318 // TODO Investigate why ChannelManager crashes, if it's created |
316 // after stun_server. | 319 // after stun_server. |
317 WebRtcSessionTest() | 320 WebRtcSessionTest() |
318 : media_engine_(new cricket::FakeMediaEngine()), | 321 : media_engine_(new cricket::FakeMediaEngine()), |
319 data_engine_(new cricket::FakeDataEngine()), | 322 data_engine_(new cricket::FakeDataEngine()), |
320 device_manager_(new cricket::FakeDeviceManager()), | 323 device_manager_(new cricket::FakeDeviceManager()), |
321 channel_manager_(new cricket::ChannelManager( | 324 channel_manager_(new cricket::ChannelManager( |
322 media_engine_, data_engine_, device_manager_, | 325 media_engine_, data_engine_, device_manager_, |
323 new cricket::CaptureManager(), rtc::Thread::Current())), | 326 new cricket::CaptureManager(), rtc::Thread::Current())), |
(...skipping 21 matching lines...) Expand all Loading... | |
345 cricket::PORTALLOCATOR_DISABLE_RELAY); | 348 cricket::PORTALLOCATOR_DISABLE_RELAY); |
346 EXPECT_TRUE(channel_manager_->Init()); | 349 EXPECT_TRUE(channel_manager_->Init()); |
347 desc_factory_->set_add_legacy_streams(false); | 350 desc_factory_->set_add_legacy_streams(false); |
348 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 351 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
349 } | 352 } |
350 | 353 |
351 void AddInterface(const SocketAddress& addr) { | 354 void AddInterface(const SocketAddress& addr) { |
352 network_manager_.AddInterface(addr); | 355 network_manager_.AddInterface(addr); |
353 } | 356 } |
354 | 357 |
358 // If |dtls_identity_store| != null or |rtc_configuration| contains | |
359 // |certificates| then DTLS will be enabled unless explicitly disabled by | |
360 // |rtc_configuration| options. When DTLS is enabled a certificate will be | |
361 // used if provided, otherwise one will be generated using the | |
362 // |dtls_identity_store|. | |
355 void Init( | 363 void Init( |
356 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, | 364 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, |
357 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | 365 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
358 ASSERT_TRUE(session_.get() == NULL); | 366 ASSERT_TRUE(session_.get() == NULL); |
359 session_.reset(new WebRtcSessionForTest( | 367 session_.reset(new WebRtcSessionForTest( |
360 channel_manager_.get(), rtc::Thread::Current(), | 368 channel_manager_.get(), rtc::Thread::Current(), |
361 rtc::Thread::Current(), allocator_.get(), | 369 rtc::Thread::Current(), allocator_.get(), |
362 &observer_, | 370 &observer_, |
363 &mediastream_signaling_)); | 371 &mediastream_signaling_)); |
364 | 372 |
(...skipping 27 matching lines...) Expand all Loading... | |
392 Init(nullptr, configuration); | 400 Init(nullptr, configuration); |
393 } | 401 } |
394 | 402 |
395 void InitWithRtcpMuxPolicy( | 403 void InitWithRtcpMuxPolicy( |
396 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | 404 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { |
397 PeerConnectionInterface::RTCConfiguration configuration; | 405 PeerConnectionInterface::RTCConfiguration configuration; |
398 configuration.rtcp_mux_policy = rtcp_mux_policy; | 406 configuration.rtcp_mux_policy = rtcp_mux_policy; |
399 Init(nullptr, configuration); | 407 Init(nullptr, configuration); |
400 } | 408 } |
401 | 409 |
402 void InitWithDtls(bool identity_request_should_fail = false) { | 410 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) { |
torbjorng (webrtc)
2015/08/21 12:39:19
Argument splits method into disjoints chunks. Cons
hbos
2015/08/24 10:16:44
Done.
| |
411 if (cert_gen_method == ALREADY_GENERATED) { | |
412 PeerConnectionInterface::RTCConfiguration configuration; | |
413 configuration.certificates.push_back( | |
414 FakeDtlsIdentityStore::GenerateCertificate()); | |
415 Init(nullptr, configuration); | |
416 } else if (cert_gen_method == DTLS_IDENTITY_STORE) { | |
417 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( | |
418 new FakeDtlsIdentityStore()); | |
419 dtls_identity_store->set_should_fail(false); | |
420 PeerConnectionInterface::RTCConfiguration configuration; | |
421 Init(dtls_identity_store.Pass(), configuration); | |
422 } else { | |
423 CHECK(false); | |
424 } | |
425 } | |
426 | |
427 void InitWithDtlsIdentityGenFail() { | |
403 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 428 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
404 new FakeDtlsIdentityStore()); | 429 new FakeDtlsIdentityStore()); |
405 dtls_identity_store->set_should_fail(identity_request_should_fail); | 430 dtls_identity_store->set_should_fail(true); |
406 PeerConnectionInterface::RTCConfiguration configuration; | 431 PeerConnectionInterface::RTCConfiguration configuration; |
407 Init(dtls_identity_store.Pass(), configuration); | 432 Init(dtls_identity_store.Pass(), configuration); |
408 } | 433 } |
409 | 434 |
410 void InitWithDtmfCodec() { | 435 void InitWithDtmfCodec() { |
411 // Add kTelephoneEventCodec for dtmf test. | 436 // Add kTelephoneEventCodec for dtmf test. |
412 const cricket::AudioCodec kTelephoneEventCodec( | 437 const cricket::AudioCodec kTelephoneEventCodec( |
413 106, "telephone-event", 8000, 0, 1, 0); | 438 106, "telephone-event", 8000, 0, 1, 0); |
414 std::vector<cricket::AudioCodec> codecs; | 439 std::vector<cricket::AudioCodec> codecs; |
415 codecs.push_back(kTelephoneEventCodec); | 440 codecs.push_back(kTelephoneEventCodec); |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1175 void SetLocalDescriptionWithDataChannel() { | 1200 void SetLocalDescriptionWithDataChannel() { |
1176 webrtc::InternalDataChannelInit dci; | 1201 webrtc::InternalDataChannelInit dci; |
1177 dci.reliable = false; | 1202 dci.reliable = false; |
1178 session_->CreateDataChannel("datachannel", &dci); | 1203 session_->CreateDataChannel("datachannel", &dci); |
1179 SessionDescriptionInterface* offer = CreateOffer(); | 1204 SessionDescriptionInterface* offer = CreateOffer(); |
1180 SetLocalDescriptionWithoutError(offer); | 1205 SetLocalDescriptionWithoutError(offer); |
1181 } | 1206 } |
1182 | 1207 |
1183 void VerifyMultipleAsyncCreateDescription( | 1208 void VerifyMultipleAsyncCreateDescription( |
1184 bool success, CreateSessionDescriptionRequest::Type type) { | 1209 bool success, CreateSessionDescriptionRequest::Type type) { |
1185 InitWithDtls(!success); | 1210 if (success) |
1211 InitWithDtls(DTLS_IDENTITY_STORE); | |
torbjorng (webrtc)
2015/08/21 12:39:19
Should we use both cert sources here (as provided
hbos
2015/08/24 10:16:44
Yeah why not! Done.
| |
1212 else | |
1213 InitWithDtlsIdentityGenFail(); | |
1186 SetFactoryDtlsSrtp(); | 1214 SetFactoryDtlsSrtp(); |
1187 if (type == CreateSessionDescriptionRequest::kAnswer) { | 1215 if (type == CreateSessionDescriptionRequest::kAnswer) { |
1188 cricket::MediaSessionOptions options; | 1216 cricket::MediaSessionOptions options; |
1189 scoped_ptr<JsepSessionDescription> offer( | 1217 scoped_ptr<JsepSessionDescription> offer( |
1190 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 1218 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
1191 ASSERT_TRUE(offer.get() != NULL); | 1219 ASSERT_TRUE(offer.get() != NULL); |
1192 SetRemoteDescriptionWithoutError(offer.release()); | 1220 SetRemoteDescriptionWithoutError(offer.release()); |
1193 } | 1221 } |
1194 | 1222 |
1195 PeerConnectionInterface::RTCOfferAnswerOptions options; | 1223 PeerConnectionInterface::RTCOfferAnswerOptions options; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1249 PeerConnectionFactoryInterface::Options options_; | 1277 PeerConnectionFactoryInterface::Options options_; |
1250 rtc::scoped_ptr<FakeConstraints> constraints_; | 1278 rtc::scoped_ptr<FakeConstraints> constraints_; |
1251 FakeMediaStreamSignaling mediastream_signaling_; | 1279 FakeMediaStreamSignaling mediastream_signaling_; |
1252 rtc::scoped_ptr<WebRtcSessionForTest> session_; | 1280 rtc::scoped_ptr<WebRtcSessionForTest> session_; |
1253 MockIceObserver observer_; | 1281 MockIceObserver observer_; |
1254 cricket::FakeVideoMediaChannel* video_channel_; | 1282 cricket::FakeVideoMediaChannel* video_channel_; |
1255 cricket::FakeVoiceMediaChannel* voice_channel_; | 1283 cricket::FakeVoiceMediaChannel* voice_channel_; |
1256 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; | 1284 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; |
1257 }; | 1285 }; |
1258 | 1286 |
1259 TEST_F(WebRtcSessionTest, TestInitializeWithDtls) { | 1287 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) { |
1260 InitWithDtls(); | 1288 InitWithDtls(GetParam()); |
1261 // SDES is disabled when DTLS is on. | 1289 // SDES is disabled when DTLS is on. |
1262 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); | 1290 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); |
1263 } | 1291 } |
1264 | 1292 |
1265 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { | 1293 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { |
1266 Init(); | 1294 Init(); |
1267 // SDES is required if DTLS is off. | 1295 // SDES is required if DTLS is off. |
1268 EXPECT_EQ(cricket::SEC_REQUIRED, session_->SdesPolicy()); | 1296 EXPECT_EQ(cricket::SEC_REQUIRED, session_->SdesPolicy()); |
1269 } | 1297 } |
1270 | 1298 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1557 SessionDescriptionInterface* answer = NULL; | 1585 SessionDescriptionInterface* answer = NULL; |
1558 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer); | 1586 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer); |
1559 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1587 // SetRemoteDescription and SetLocalDescription will take the ownership of |
1560 // the offer. | 1588 // the offer. |
1561 SetLocalDescriptionWithoutError(offer); | 1589 SetLocalDescriptionWithoutError(offer); |
1562 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); | 1590 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); |
1563 } | 1591 } |
1564 | 1592 |
1565 // Test that we accept an offer with a DTLS fingerprint when DTLS is on | 1593 // Test that we accept an offer with a DTLS fingerprint when DTLS is on |
1566 // and that we return an answer with a DTLS fingerprint. | 1594 // and that we return an answer with a DTLS fingerprint. |
1567 TEST_F(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { | 1595 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { |
1568 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1596 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1569 mediastream_signaling_.SendAudioVideoStream1(); | 1597 mediastream_signaling_.SendAudioVideoStream1(); |
1570 InitWithDtls(); | 1598 InitWithDtls(GetParam()); |
1571 SetFactoryDtlsSrtp(); | 1599 SetFactoryDtlsSrtp(); |
1572 cricket::MediaSessionOptions options; | 1600 cricket::MediaSessionOptions options; |
1573 options.recv_video = true; | 1601 options.recv_video = true; |
1574 JsepSessionDescription* offer = | 1602 JsepSessionDescription* offer = |
1575 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1603 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
1576 ASSERT_TRUE(offer != NULL); | 1604 ASSERT_TRUE(offer != NULL); |
1577 VerifyFingerprintStatus(offer->description(), true); | 1605 VerifyFingerprintStatus(offer->description(), true); |
1578 VerifyNoCryptoParams(offer->description(), true); | 1606 VerifyNoCryptoParams(offer->description(), true); |
1579 | 1607 |
1580 // SetRemoteDescription will take the ownership of the offer. | 1608 // SetRemoteDescription will take the ownership of the offer. |
1581 SetRemoteDescriptionWithoutError(offer); | 1609 SetRemoteDescriptionWithoutError(offer); |
1582 | 1610 |
1583 // Verify that we get a crypto fingerprint in the answer. | 1611 // Verify that we get a crypto fingerprint in the answer. |
1584 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 1612 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
1585 ASSERT_TRUE(answer != NULL); | 1613 ASSERT_TRUE(answer != NULL); |
1586 VerifyFingerprintStatus(answer->description(), true); | 1614 VerifyFingerprintStatus(answer->description(), true); |
1587 // Check that we don't have an a=crypto line in the answer. | 1615 // Check that we don't have an a=crypto line in the answer. |
1588 VerifyNoCryptoParams(answer->description(), true); | 1616 VerifyNoCryptoParams(answer->description(), true); |
1589 | 1617 |
1590 // Now set the local description, which should work, even without a=crypto. | 1618 // Now set the local description, which should work, even without a=crypto. |
1591 SetLocalDescriptionWithoutError(answer); | 1619 SetLocalDescriptionWithoutError(answer); |
1592 } | 1620 } |
1593 | 1621 |
1594 // Test that we set a local offer with a DTLS fingerprint when DTLS is on | 1622 // Test that we set a local offer with a DTLS fingerprint when DTLS is on |
1595 // and then we accept a remote answer with a DTLS fingerprint successfully. | 1623 // and then we accept a remote answer with a DTLS fingerprint successfully. |
1596 TEST_F(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { | 1624 TEST_P(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { |
1597 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1625 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1598 mediastream_signaling_.SendAudioVideoStream1(); | 1626 mediastream_signaling_.SendAudioVideoStream1(); |
1599 InitWithDtls(); | 1627 InitWithDtls(GetParam()); |
1600 SetFactoryDtlsSrtp(); | 1628 SetFactoryDtlsSrtp(); |
1601 | 1629 |
1602 // Verify that we get a crypto fingerprint in the answer. | 1630 // Verify that we get a crypto fingerprint in the answer. |
1603 SessionDescriptionInterface* offer = CreateOffer(); | 1631 SessionDescriptionInterface* offer = CreateOffer(); |
1604 ASSERT_TRUE(offer != NULL); | 1632 ASSERT_TRUE(offer != NULL); |
1605 VerifyFingerprintStatus(offer->description(), true); | 1633 VerifyFingerprintStatus(offer->description(), true); |
1606 // Check that we don't have an a=crypto line in the offer. | 1634 // Check that we don't have an a=crypto line in the offer. |
1607 VerifyNoCryptoParams(offer->description(), true); | 1635 VerifyNoCryptoParams(offer->description(), true); |
1608 | 1636 |
1609 // Now set the local description, which should work, even without a=crypto. | 1637 // Now set the local description, which should work, even without a=crypto. |
1610 SetLocalDescriptionWithoutError(offer); | 1638 SetLocalDescriptionWithoutError(offer); |
1611 | 1639 |
1612 cricket::MediaSessionOptions options; | 1640 cricket::MediaSessionOptions options; |
1613 options.recv_video = true; | 1641 options.recv_video = true; |
1614 JsepSessionDescription* answer = | 1642 JsepSessionDescription* answer = |
1615 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 1643 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
1616 ASSERT_TRUE(answer != NULL); | 1644 ASSERT_TRUE(answer != NULL); |
1617 VerifyFingerprintStatus(answer->description(), true); | 1645 VerifyFingerprintStatus(answer->description(), true); |
1618 VerifyNoCryptoParams(answer->description(), true); | 1646 VerifyNoCryptoParams(answer->description(), true); |
1619 | 1647 |
1620 // SetRemoteDescription will take the ownership of the answer. | 1648 // SetRemoteDescription will take the ownership of the answer. |
1621 SetRemoteDescriptionWithoutError(answer); | 1649 SetRemoteDescriptionWithoutError(answer); |
1622 } | 1650 } |
1623 | 1651 |
1624 // Test that if we support DTLS and the other side didn't offer a fingerprint, | 1652 // Test that if we support DTLS and the other side didn't offer a fingerprint, |
1625 // we will fail to set the remote description. | 1653 // we will fail to set the remote description. |
1626 TEST_F(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { | 1654 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { |
1627 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1655 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1628 InitWithDtls(); | 1656 InitWithDtls(GetParam()); |
1629 cricket::MediaSessionOptions options; | 1657 cricket::MediaSessionOptions options; |
1630 options.recv_video = true; | 1658 options.recv_video = true; |
1631 options.bundle_enabled = true; | 1659 options.bundle_enabled = true; |
1632 JsepSessionDescription* offer = CreateRemoteOffer( | 1660 JsepSessionDescription* offer = CreateRemoteOffer( |
1633 options, cricket::SEC_REQUIRED); | 1661 options, cricket::SEC_REQUIRED); |
1634 ASSERT_TRUE(offer != NULL); | 1662 ASSERT_TRUE(offer != NULL); |
1635 VerifyFingerprintStatus(offer->description(), false); | 1663 VerifyFingerprintStatus(offer->description(), false); |
1636 VerifyCryptoParams(offer->description()); | 1664 VerifyCryptoParams(offer->description()); |
1637 | 1665 |
1638 // SetRemoteDescription will take the ownership of the offer. | 1666 // SetRemoteDescription will take the ownership of the offer. |
1639 SetRemoteDescriptionOfferExpectError( | 1667 SetRemoteDescriptionOfferExpectError( |
1640 kSdpWithoutDtlsFingerprint, offer); | 1668 kSdpWithoutDtlsFingerprint, offer); |
1641 | 1669 |
1642 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED); | 1670 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED); |
1643 // SetLocalDescription will take the ownership of the offer. | 1671 // SetLocalDescription will take the ownership of the offer. |
1644 SetLocalDescriptionOfferExpectError( | 1672 SetLocalDescriptionOfferExpectError( |
1645 kSdpWithoutDtlsFingerprint, offer); | 1673 kSdpWithoutDtlsFingerprint, offer); |
1646 } | 1674 } |
1647 | 1675 |
1648 // Test that we return a failure when applying a local answer that doesn't have | 1676 // Test that we return a failure when applying a local answer that doesn't have |
1649 // a DTLS fingerprint when DTLS is required. | 1677 // a DTLS fingerprint when DTLS is required. |
1650 TEST_F(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) { | 1678 TEST_P(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) { |
1651 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1679 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1652 InitWithDtls(); | 1680 InitWithDtls(GetParam()); |
1653 SessionDescriptionInterface* offer = NULL; | 1681 SessionDescriptionInterface* offer = NULL; |
1654 SessionDescriptionInterface* answer = NULL; | 1682 SessionDescriptionInterface* answer = NULL; |
1655 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer); | 1683 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer); |
1656 | 1684 |
1657 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1685 // SetRemoteDescription and SetLocalDescription will take the ownership of |
1658 // the offer and answer. | 1686 // the offer and answer. |
1659 SetRemoteDescriptionWithoutError(offer); | 1687 SetRemoteDescriptionWithoutError(offer); |
1660 SetLocalDescriptionAnswerExpectError( | 1688 SetLocalDescriptionAnswerExpectError( |
1661 kSdpWithoutDtlsFingerprint, answer); | 1689 kSdpWithoutDtlsFingerprint, answer); |
1662 } | 1690 } |
1663 | 1691 |
1664 // Test that we return a failure when applying a remote answer that doesn't have | 1692 // Test that we return a failure when applying a remote answer that doesn't have |
1665 // a DTLS fingerprint when DTLS is required. | 1693 // a DTLS fingerprint when DTLS is required. |
1666 TEST_F(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { | 1694 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { |
1667 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1695 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1668 // Enable both SDES and DTLS, so that offer won't be outright rejected as a | 1696 // Enable both SDES and DTLS, so that offer won't be outright rejected as a |
1669 // result of using the "UDP/TLS/RTP/SAVPF" profile. | 1697 // result of using the "UDP/TLS/RTP/SAVPF" profile. |
1670 InitWithDtls(); | 1698 InitWithDtls(GetParam()); |
1671 session_->SetSdesPolicy(cricket::SEC_ENABLED); | 1699 session_->SetSdesPolicy(cricket::SEC_ENABLED); |
1672 SessionDescriptionInterface* offer = CreateOffer(); | 1700 SessionDescriptionInterface* offer = CreateOffer(); |
1673 cricket::MediaSessionOptions options; | 1701 cricket::MediaSessionOptions options; |
1674 options.recv_video = true; | 1702 options.recv_video = true; |
1675 JsepSessionDescription* answer = | 1703 JsepSessionDescription* answer = |
1676 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); | 1704 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); |
1677 | 1705 |
1678 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1706 // SetRemoteDescription and SetLocalDescription will take the ownership of |
1679 // the offer and answer. | 1707 // the offer and answer. |
1680 SetLocalDescriptionWithoutError(offer); | 1708 SetLocalDescriptionWithoutError(offer); |
1681 SetRemoteDescriptionAnswerExpectError( | 1709 SetRemoteDescriptionAnswerExpectError( |
1682 kSdpWithoutDtlsFingerprint, answer); | 1710 kSdpWithoutDtlsFingerprint, answer); |
1683 } | 1711 } |
1684 | 1712 |
1685 // Test that we create a local offer without SDES or DTLS and accept a remote | 1713 // Test that we create a local offer without SDES or DTLS and accept a remote |
1686 // answer without SDES or DTLS when encryption is disabled. | 1714 // answer without SDES or DTLS when encryption is disabled. |
1687 TEST_F(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { | 1715 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { |
1688 mediastream_signaling_.SendAudioVideoStream1(); | 1716 mediastream_signaling_.SendAudioVideoStream1(); |
1689 options_.disable_encryption = true; | 1717 options_.disable_encryption = true; |
1690 InitWithDtls(); | 1718 InitWithDtls(GetParam()); |
1691 | 1719 |
1692 // Verify that we get a crypto fingerprint in the answer. | 1720 // Verify that we get a crypto fingerprint in the answer. |
1693 SessionDescriptionInterface* offer = CreateOffer(); | 1721 SessionDescriptionInterface* offer = CreateOffer(); |
1694 ASSERT_TRUE(offer != NULL); | 1722 ASSERT_TRUE(offer != NULL); |
1695 VerifyFingerprintStatus(offer->description(), false); | 1723 VerifyFingerprintStatus(offer->description(), false); |
1696 // Check that we don't have an a=crypto line in the offer. | 1724 // Check that we don't have an a=crypto line in the offer. |
1697 VerifyNoCryptoParams(offer->description(), false); | 1725 VerifyNoCryptoParams(offer->description(), false); |
1698 | 1726 |
1699 // Now set the local description, which should work, even without a=crypto. | 1727 // Now set the local description, which should work, even without a=crypto. |
1700 SetLocalDescriptionWithoutError(offer); | 1728 SetLocalDescriptionWithoutError(offer); |
1701 | 1729 |
1702 cricket::MediaSessionOptions options; | 1730 cricket::MediaSessionOptions options; |
1703 options.recv_video = true; | 1731 options.recv_video = true; |
1704 JsepSessionDescription* answer = | 1732 JsepSessionDescription* answer = |
1705 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 1733 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
1706 ASSERT_TRUE(answer != NULL); | 1734 ASSERT_TRUE(answer != NULL); |
1707 VerifyFingerprintStatus(answer->description(), false); | 1735 VerifyFingerprintStatus(answer->description(), false); |
1708 VerifyNoCryptoParams(answer->description(), false); | 1736 VerifyNoCryptoParams(answer->description(), false); |
1709 | 1737 |
1710 // SetRemoteDescription will take the ownership of the answer. | 1738 // SetRemoteDescription will take the ownership of the answer. |
1711 SetRemoteDescriptionWithoutError(answer); | 1739 SetRemoteDescriptionWithoutError(answer); |
1712 } | 1740 } |
1713 | 1741 |
1714 // Test that we create a local answer without SDES or DTLS and accept a remote | 1742 // Test that we create a local answer without SDES or DTLS and accept a remote |
1715 // offer without SDES or DTLS when encryption is disabled. | 1743 // offer without SDES or DTLS when encryption is disabled. |
1716 TEST_F(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { | 1744 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { |
1717 options_.disable_encryption = true; | 1745 options_.disable_encryption = true; |
1718 InitWithDtls(); | 1746 InitWithDtls(GetParam()); |
1719 | 1747 |
1720 cricket::MediaSessionOptions options; | 1748 cricket::MediaSessionOptions options; |
1721 options.recv_video = true; | 1749 options.recv_video = true; |
1722 JsepSessionDescription* offer = | 1750 JsepSessionDescription* offer = |
1723 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1751 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
1724 ASSERT_TRUE(offer != NULL); | 1752 ASSERT_TRUE(offer != NULL); |
1725 VerifyFingerprintStatus(offer->description(), false); | 1753 VerifyFingerprintStatus(offer->description(), false); |
1726 VerifyNoCryptoParams(offer->description(), false); | 1754 VerifyNoCryptoParams(offer->description(), false); |
1727 | 1755 |
1728 // SetRemoteDescription will take the ownership of the offer. | 1756 // SetRemoteDescription will take the ownership of the offer. |
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3404 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { | 3432 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { |
3405 constraints_.reset(new FakeConstraints()); | 3433 constraints_.reset(new FakeConstraints()); |
3406 constraints_->AddOptional( | 3434 constraints_->AddOptional( |
3407 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); | 3435 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); |
3408 Init(); | 3436 Init(); |
3409 | 3437 |
3410 SetLocalDescriptionWithDataChannel(); | 3438 SetLocalDescriptionWithDataChannel(); |
3411 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3439 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
3412 } | 3440 } |
3413 | 3441 |
3414 TEST_F(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { | 3442 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { |
3415 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3443 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3416 | 3444 |
3417 constraints_.reset(new FakeConstraints()); | 3445 constraints_.reset(new FakeConstraints()); |
3418 constraints_->AddOptional( | 3446 constraints_->AddOptional( |
3419 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); | 3447 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); |
3420 options_.disable_sctp_data_channels = false; | 3448 options_.disable_sctp_data_channels = false; |
3421 | 3449 |
3422 InitWithDtls(); | 3450 InitWithDtls(GetParam()); |
3423 | 3451 |
3424 SetLocalDescriptionWithDataChannel(); | 3452 SetLocalDescriptionWithDataChannel(); |
3425 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3453 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
3426 } | 3454 } |
3427 | 3455 |
3428 TEST_F(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { | 3456 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { |
3429 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3457 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3430 | 3458 |
3431 InitWithDtls(); | 3459 InitWithDtls(GetParam()); |
3432 | 3460 |
3433 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3461 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
3434 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); | 3462 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); |
3435 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); | 3463 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); |
3436 } | 3464 } |
3437 | 3465 |
3438 TEST_F(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { | 3466 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { |
3439 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3467 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3440 SetFactoryDtlsSrtp(); | 3468 SetFactoryDtlsSrtp(); |
3441 InitWithDtls(); | 3469 InitWithDtls(GetParam()); |
3442 | 3470 |
3443 // Create remote offer with SCTP. | 3471 // Create remote offer with SCTP. |
3444 cricket::MediaSessionOptions options; | 3472 cricket::MediaSessionOptions options; |
3445 options.data_channel_type = cricket::DCT_SCTP; | 3473 options.data_channel_type = cricket::DCT_SCTP; |
3446 JsepSessionDescription* offer = | 3474 JsepSessionDescription* offer = |
3447 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 3475 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
3448 SetRemoteDescriptionWithoutError(offer); | 3476 SetRemoteDescriptionWithoutError(offer); |
3449 | 3477 |
3450 // Verifies the answer contains SCTP. | 3478 // Verifies the answer contains SCTP. |
3451 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); | 3479 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); |
3452 EXPECT_TRUE(answer != NULL); | 3480 EXPECT_TRUE(answer != NULL); |
3453 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); | 3481 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); |
3454 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); | 3482 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); |
3455 } | 3483 } |
3456 | 3484 |
3457 TEST_F(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { | 3485 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { |
3458 constraints_.reset(new FakeConstraints()); | 3486 constraints_.reset(new FakeConstraints()); |
3459 constraints_->AddOptional( | 3487 constraints_->AddOptional( |
3460 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); | 3488 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); |
3461 InitWithDtls(); | 3489 InitWithDtls(GetParam()); |
3462 | 3490 |
3463 SetLocalDescriptionWithDataChannel(); | 3491 SetLocalDescriptionWithDataChannel(); |
3464 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); | 3492 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); |
3465 } | 3493 } |
3466 | 3494 |
3467 TEST_F(WebRtcSessionTest, TestSctpDataChannelWithDtls) { | 3495 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) { |
3468 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3496 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3469 | 3497 |
3470 InitWithDtls(); | 3498 InitWithDtls(GetParam()); |
3471 | 3499 |
3472 SetLocalDescriptionWithDataChannel(); | 3500 SetLocalDescriptionWithDataChannel(); |
3473 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); | 3501 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); |
3474 } | 3502 } |
3475 | 3503 |
3476 TEST_F(WebRtcSessionTest, TestDisableSctpDataChannels) { | 3504 TEST_P(WebRtcSessionTest, TestDisableSctpDataChannels) { |
3477 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3505 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3478 options_.disable_sctp_data_channels = true; | 3506 options_.disable_sctp_data_channels = true; |
3479 InitWithDtls(); | 3507 InitWithDtls(GetParam()); |
3480 | 3508 |
3481 SetLocalDescriptionWithDataChannel(); | 3509 SetLocalDescriptionWithDataChannel(); |
3482 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); | 3510 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); |
3483 } | 3511 } |
3484 | 3512 |
3485 TEST_F(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { | 3513 TEST_P(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { |
3486 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3514 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3487 const int new_send_port = 9998; | 3515 const int new_send_port = 9998; |
3488 const int new_recv_port = 7775; | 3516 const int new_recv_port = 7775; |
3489 | 3517 |
3490 InitWithDtls(); | 3518 InitWithDtls(GetParam()); |
3491 SetFactoryDtlsSrtp(); | 3519 SetFactoryDtlsSrtp(); |
3492 | 3520 |
3493 // By default, don't actually add the codecs to desc_factory_; they don't | 3521 // By default, don't actually add the codecs to desc_factory_; they don't |
3494 // actually get serialized for SCTP in BuildMediaDescription(). Instead, | 3522 // actually get serialized for SCTP in BuildMediaDescription(). Instead, |
3495 // let the session description get parsed. That'll get the proper codecs | 3523 // let the session description get parsed. That'll get the proper codecs |
3496 // into the stream. | 3524 // into the stream. |
3497 cricket::MediaSessionOptions options; | 3525 cricket::MediaSessionOptions options; |
3498 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort( | 3526 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort( |
3499 "stream1", new_send_port, options); | 3527 "stream1", new_send_port, options); |
3500 | 3528 |
(...skipping 28 matching lines...) Expand all Loading... | |
3529 | 3557 |
3530 ASSERT_EQ(1UL, ch->recv_codecs().size()); | 3558 ASSERT_EQ(1UL, ch->recv_codecs().size()); |
3531 EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->recv_codecs()[0].id); | 3559 EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->recv_codecs()[0].id); |
3532 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName, | 3560 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName, |
3533 ch->recv_codecs()[0].name.c_str())); | 3561 ch->recv_codecs()[0].name.c_str())); |
3534 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort, | 3562 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort, |
3535 &portnum)); | 3563 &portnum)); |
3536 EXPECT_EQ(new_recv_port, portnum); | 3564 EXPECT_EQ(new_recv_port, portnum); |
3537 } | 3565 } |
3538 | 3566 |
3567 // TODO(hbos): Add the following test once RTCCertificate is passed around | |
3568 // outside of WebRtcSessionDescriptionFactory code and there exists a | |
3569 // WebRtcSession::certificate(). | |
3570 //TEST_F(WebRtcSessionTest, TestUsesProvidedCertificate) { | |
3571 // rtc::scoped_refptr<rtc::RTCCertificate> certificate = | |
3572 // FakeDtlsIdentityStore::GenerateCertificate(); | |
3573 // | |
3574 // PeerConnectionInterface::RTCConfiguration configuration; | |
3575 // configuration.certificates.push_back(certificate); | |
3576 // Init(nullptr, configuration); | |
3577 // EXPECT_TRUE_WAIT(!session_->waiting_for_identity_for_testing(), 1000); | |
3578 // | |
3579 // EXPECT_EQ(session_->certificate(), certificate); | |
3580 //} | |
3581 | |
3539 // Verifies that CreateOffer succeeds when CreateOffer is called before async | 3582 // Verifies that CreateOffer succeeds when CreateOffer is called before async |
3540 // identity generation is finished. | 3583 // identity generation is finished (even if a certificate is provided this is |
3541 TEST_F(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { | 3584 // an async op). |
3585 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { | |
3542 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3586 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3543 InitWithDtls(); | 3587 InitWithDtls(GetParam()); |
3544 | 3588 |
3545 EXPECT_TRUE(session_->waiting_for_identity()); | 3589 EXPECT_TRUE(session_->waiting_for_identity_for_testing()); |
3546 mediastream_signaling_.SendAudioVideoStream1(); | 3590 mediastream_signaling_.SendAudioVideoStream1(); |
3547 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3591 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
3548 | 3592 |
3549 EXPECT_TRUE(offer != NULL); | 3593 EXPECT_TRUE(offer != NULL); |
3550 VerifyNoCryptoParams(offer->description(), true); | 3594 VerifyNoCryptoParams(offer->description(), true); |
3551 VerifyFingerprintStatus(offer->description(), true); | 3595 VerifyFingerprintStatus(offer->description(), true); |
3552 } | 3596 } |
3553 | 3597 |
3554 // Verifies that CreateAnswer succeeds when CreateOffer is called before async | 3598 // Verifies that CreateAnswer succeeds when CreateOffer is called before async |
3555 // identity generation is finished. | 3599 // identity generation is finished (even if a certificate is provided this is |
3556 TEST_F(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { | 3600 // an async op). |
3601 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { | |
3557 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3602 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3558 InitWithDtls(); | 3603 InitWithDtls(GetParam()); |
3559 SetFactoryDtlsSrtp(); | 3604 SetFactoryDtlsSrtp(); |
3560 | 3605 |
3561 cricket::MediaSessionOptions options; | 3606 cricket::MediaSessionOptions options; |
3562 options.recv_video = true; | 3607 options.recv_video = true; |
3563 scoped_ptr<JsepSessionDescription> offer( | 3608 scoped_ptr<JsepSessionDescription> offer( |
3564 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 3609 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
3565 ASSERT_TRUE(offer.get() != NULL); | 3610 ASSERT_TRUE(offer.get() != NULL); |
3566 SetRemoteDescriptionWithoutError(offer.release()); | 3611 SetRemoteDescriptionWithoutError(offer.release()); |
3567 | 3612 |
3568 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); | 3613 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); |
3569 EXPECT_TRUE(answer != NULL); | 3614 EXPECT_TRUE(answer != NULL); |
3570 VerifyNoCryptoParams(answer->description(), true); | 3615 VerifyNoCryptoParams(answer->description(), true); |
3571 VerifyFingerprintStatus(answer->description(), true); | 3616 VerifyFingerprintStatus(answer->description(), true); |
3572 } | 3617 } |
3573 | 3618 |
3574 // Verifies that CreateOffer succeeds when CreateOffer is called after async | 3619 // Verifies that CreateOffer succeeds when CreateOffer is called after async |
3575 // identity generation is finished. | 3620 // identity generation is finished (even if a certificate is provided this is |
3576 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { | 3621 // an async op). |
3622 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { | |
3577 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3623 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3578 InitWithDtls(); | 3624 InitWithDtls(GetParam()); |
3579 | 3625 |
3580 EXPECT_TRUE_WAIT(!session_->waiting_for_identity(), 1000); | 3626 EXPECT_TRUE_WAIT(!session_->waiting_for_identity_for_testing(), 1000); |
3581 | 3627 |
3582 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3628 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
3583 EXPECT_TRUE(offer != NULL); | 3629 EXPECT_TRUE(offer != NULL); |
3584 } | 3630 } |
3585 | 3631 |
3586 // Verifies that CreateOffer fails when CreateOffer is called after async | 3632 // Verifies that CreateOffer fails when CreateOffer is called after async |
3587 // identity generation fails. | 3633 // identity generation fails. |
3588 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) { | 3634 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) { |
3589 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3635 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3590 InitWithDtls(true); | 3636 InitWithDtlsIdentityGenFail(); |
3591 | 3637 |
3592 EXPECT_TRUE_WAIT(!session_->waiting_for_identity(), 1000); | 3638 EXPECT_TRUE_WAIT(!session_->waiting_for_identity_for_testing(), 1000); |
3593 | 3639 |
3594 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3640 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
3595 EXPECT_TRUE(offer == NULL); | 3641 EXPECT_TRUE(offer == NULL); |
3596 } | 3642 } |
3597 | 3643 |
3598 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made | 3644 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made |
3599 // before async identity generation is finished. | 3645 // before async identity generation is finished. |
3600 TEST_F(WebRtcSessionTest, | 3646 TEST_F(WebRtcSessionTest, |
3601 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { | 3647 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { |
3602 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3648 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3722 | 3768 |
3723 ASSERT_TRUE(voice_channel_ != NULL); | 3769 ASSERT_TRUE(voice_channel_ != NULL); |
3724 cricket::AudioOptions audio_options; | 3770 cricket::AudioOptions audio_options; |
3725 EXPECT_TRUE(voice_channel_->GetOptions(&audio_options)); | 3771 EXPECT_TRUE(voice_channel_->GetOptions(&audio_options)); |
3726 EXPECT_TRUE( | 3772 EXPECT_TRUE( |
3727 audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false)); | 3773 audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false)); |
3728 } | 3774 } |
3729 | 3775 |
3730 // Tests that we can renegotiate new media content with ICE candidates in the | 3776 // Tests that we can renegotiate new media content with ICE candidates in the |
3731 // new remote SDP. | 3777 // new remote SDP. |
3732 TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { | 3778 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { |
3733 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3779 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3734 InitWithDtls(); | 3780 InitWithDtls(GetParam()); |
3735 SetFactoryDtlsSrtp(); | 3781 SetFactoryDtlsSrtp(); |
3736 | 3782 |
3737 mediastream_signaling_.UseOptionsAudioOnly(); | 3783 mediastream_signaling_.UseOptionsAudioOnly(); |
3738 SessionDescriptionInterface* offer = CreateOffer(); | 3784 SessionDescriptionInterface* offer = CreateOffer(); |
3739 SetLocalDescriptionWithoutError(offer); | 3785 SetLocalDescriptionWithoutError(offer); |
3740 | 3786 |
3741 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 3787 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
3742 SetRemoteDescriptionWithoutError(answer); | 3788 SetRemoteDescriptionWithoutError(answer); |
3743 | 3789 |
3744 cricket::MediaSessionOptions options; | 3790 cricket::MediaSessionOptions options; |
3745 options.recv_video = true; | 3791 options.recv_video = true; |
3746 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 3792 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
3747 | 3793 |
3748 cricket::Candidate candidate1; | 3794 cricket::Candidate candidate1; |
3749 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); | 3795 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
3750 candidate1.set_component(1); | 3796 candidate1.set_component(1); |
3751 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, | 3797 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
3752 candidate1); | 3798 candidate1); |
3753 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); | 3799 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
3754 SetRemoteDescriptionWithoutError(offer); | 3800 SetRemoteDescriptionWithoutError(offer); |
3755 | 3801 |
3756 answer = CreateAnswer(NULL); | 3802 answer = CreateAnswer(NULL); |
3757 SetLocalDescriptionWithoutError(answer); | 3803 SetLocalDescriptionWithoutError(answer); |
3758 } | 3804 } |
3759 | 3805 |
3760 // Tests that we can renegotiate new media content with ICE candidates separated | 3806 // Tests that we can renegotiate new media content with ICE candidates separated |
3761 // from the remote SDP. | 3807 // from the remote SDP. |
3762 TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { | 3808 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { |
3763 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3809 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3764 InitWithDtls(); | 3810 InitWithDtls(GetParam()); |
3765 SetFactoryDtlsSrtp(); | 3811 SetFactoryDtlsSrtp(); |
3766 | 3812 |
3767 mediastream_signaling_.UseOptionsAudioOnly(); | 3813 mediastream_signaling_.UseOptionsAudioOnly(); |
3768 SessionDescriptionInterface* offer = CreateOffer(); | 3814 SessionDescriptionInterface* offer = CreateOffer(); |
3769 SetLocalDescriptionWithoutError(offer); | 3815 SetLocalDescriptionWithoutError(offer); |
3770 | 3816 |
3771 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 3817 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
3772 SetRemoteDescriptionWithoutError(answer); | 3818 SetRemoteDescriptionWithoutError(answer); |
3773 | 3819 |
3774 cricket::MediaSessionOptions options; | 3820 cricket::MediaSessionOptions options; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3868 options.offer_to_receive_audio = | 3914 options.offer_to_receive_audio = |
3869 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 3915 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
3870 | 3916 |
3871 for (auto& o : observers) { | 3917 for (auto& o : observers) { |
3872 o = new WebRtcSessionCreateSDPObserverForTest(); | 3918 o = new WebRtcSessionCreateSDPObserverForTest(); |
3873 session_->CreateOffer(o, options); | 3919 session_->CreateOffer(o, options); |
3874 } | 3920 } |
3875 | 3921 |
3876 session_.reset(); | 3922 session_.reset(); |
3877 | 3923 |
3878 // Make sure we process pending messages on the current (signaling) thread | |
3879 // before checking we we got our callbacks. Quit() will do this and then | |
3880 // immediately exit. We won't need the queue after this point anyway. | |
3881 rtc::Thread::Current()->Quit(); | |
3882 | |
hbos
2015/08/20 16:06:11
Two things wrong with this, which is why I removed
| |
3883 for (auto& o : observers) { | 3924 for (auto& o : observers) { |
3884 // We expect to have received a notification now even if the session was | 3925 // We expect to have received a notification now even if the session was |
3885 // terminated. The offer creation may or may not have succeeded, but we | 3926 // terminated. The offer creation may or may not have succeeded, but we |
3886 // must have received a notification which, so the only invalid state | 3927 // must have received a notification which, so the only invalid state |
3887 // is kInit. | 3928 // is kInit. |
3888 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 3929 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
3889 } | 3930 } |
3890 } | 3931 } |
3891 | 3932 |
3892 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 3933 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
3893 // currently fails because upon disconnection and reconnection OnIceComplete is | 3934 // currently fails because upon disconnection and reconnection OnIceComplete is |
3894 // called more than once without returning to IceGatheringGathering. | 3935 // called more than once without returning to IceGatheringGathering. |
3936 | |
3937 INSTANTIATE_TEST_CASE_P( | |
3938 WebRtcSessionTests, WebRtcSessionTest, | |
3939 testing::Values(ALREADY_GENERATED, DTLS_IDENTITY_STORE)); | |
OLD | NEW |