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

Side by Side Diff: talk/app/webrtc/webrtcsession_unittest.cc

Issue 1288033009: RTCCertificates added to RTCConfiguration, used by WebRtcSession/-DescriptionFactory (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed torbjorng's comment and merged with master Created 5 years, 4 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 | « talk/app/webrtc/webrtcsession.cc ('k') | talk/app/webrtc/webrtcsessiondescriptionfactory.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 * 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
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 {
169 public: 171 public:
170 MockIceObserver() 172 MockIceObserver()
171 : oncandidatesready_(false), 173 : oncandidatesready_(false),
172 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), 174 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew),
173 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { 175 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) {
174 } 176 }
175 177
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 // Successfully init with DTLS; with a certificate generated and supplied or
411 // with a store that generates it for us.
412 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) {
413 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store;
414 PeerConnectionInterface::RTCConfiguration configuration;
415 if (cert_gen_method == ALREADY_GENERATED) {
416 configuration.certificates.push_back(
417 FakeDtlsIdentityStore::GenerateCertificate());
418 } else if (cert_gen_method == DTLS_IDENTITY_STORE) {
419 dtls_identity_store.reset(new FakeDtlsIdentityStore());
420 dtls_identity_store->set_should_fail(false);
421 } else {
422 CHECK(false);
423 }
424 Init(dtls_identity_store.Pass(), configuration);
425 }
426
427 // Init with DTLS with a store that will fail to generate a certificate.
428 void InitWithDtlsIdentityGenFail() {
403 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( 429 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store(
404 new FakeDtlsIdentityStore()); 430 new FakeDtlsIdentityStore());
405 dtls_identity_store->set_should_fail(identity_request_should_fail); 431 dtls_identity_store->set_should_fail(true);
406 PeerConnectionInterface::RTCConfiguration configuration; 432 PeerConnectionInterface::RTCConfiguration configuration;
407 Init(dtls_identity_store.Pass(), configuration); 433 Init(dtls_identity_store.Pass(), configuration);
408 } 434 }
409 435
410 void InitWithDtmfCodec() { 436 void InitWithDtmfCodec() {
411 // Add kTelephoneEventCodec for dtmf test. 437 // Add kTelephoneEventCodec for dtmf test.
412 const cricket::AudioCodec kTelephoneEventCodec( 438 const cricket::AudioCodec kTelephoneEventCodec(
413 106, "telephone-event", 8000, 0, 1, 0); 439 106, "telephone-event", 8000, 0, 1, 0);
414 std::vector<cricket::AudioCodec> codecs; 440 std::vector<cricket::AudioCodec> codecs;
415 codecs.push_back(kTelephoneEventCodec); 441 codecs.push_back(kTelephoneEventCodec);
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 1200
1175 void SetLocalDescriptionWithDataChannel() { 1201 void SetLocalDescriptionWithDataChannel() {
1176 webrtc::InternalDataChannelInit dci; 1202 webrtc::InternalDataChannelInit dci;
1177 dci.reliable = false; 1203 dci.reliable = false;
1178 session_->CreateDataChannel("datachannel", &dci); 1204 session_->CreateDataChannel("datachannel", &dci);
1179 SessionDescriptionInterface* offer = CreateOffer(); 1205 SessionDescriptionInterface* offer = CreateOffer();
1180 SetLocalDescriptionWithoutError(offer); 1206 SetLocalDescriptionWithoutError(offer);
1181 } 1207 }
1182 1208
1183 void VerifyMultipleAsyncCreateDescription( 1209 void VerifyMultipleAsyncCreateDescription(
1210 RTCCertificateGenerationMethod cert_gen_method,
1211 CreateSessionDescriptionRequest::Type type) {
1212 InitWithDtls(cert_gen_method);
1213 VerifyMultipleAsyncCreateDescriptionAfterInit(true, type);
1214 }
1215
1216 void VerifyMultipleAsyncCreateDescriptionIdentityGenFailure(
1217 CreateSessionDescriptionRequest::Type type) {
1218 InitWithDtlsIdentityGenFail();
1219 VerifyMultipleAsyncCreateDescriptionAfterInit(false, type);
1220 }
1221
1222 void VerifyMultipleAsyncCreateDescriptionAfterInit(
1184 bool success, CreateSessionDescriptionRequest::Type type) { 1223 bool success, CreateSessionDescriptionRequest::Type type) {
1185 InitWithDtls(!success); 1224 CHECK(session_);
1186 SetFactoryDtlsSrtp(); 1225 SetFactoryDtlsSrtp();
1187 if (type == CreateSessionDescriptionRequest::kAnswer) { 1226 if (type == CreateSessionDescriptionRequest::kAnswer) {
1188 cricket::MediaSessionOptions options; 1227 cricket::MediaSessionOptions options;
1189 scoped_ptr<JsepSessionDescription> offer( 1228 scoped_ptr<JsepSessionDescription> offer(
1190 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 1229 CreateRemoteOffer(options, cricket::SEC_DISABLED));
1191 ASSERT_TRUE(offer.get() != NULL); 1230 ASSERT_TRUE(offer.get() != NULL);
1192 SetRemoteDescriptionWithoutError(offer.release()); 1231 SetRemoteDescriptionWithoutError(offer.release());
1193 } 1232 }
1194 1233
1195 PeerConnectionInterface::RTCOfferAnswerOptions options; 1234 PeerConnectionInterface::RTCOfferAnswerOptions options;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 PeerConnectionFactoryInterface::Options options_; 1288 PeerConnectionFactoryInterface::Options options_;
1250 rtc::scoped_ptr<FakeConstraints> constraints_; 1289 rtc::scoped_ptr<FakeConstraints> constraints_;
1251 FakeMediaStreamSignaling mediastream_signaling_; 1290 FakeMediaStreamSignaling mediastream_signaling_;
1252 rtc::scoped_ptr<WebRtcSessionForTest> session_; 1291 rtc::scoped_ptr<WebRtcSessionForTest> session_;
1253 MockIceObserver observer_; 1292 MockIceObserver observer_;
1254 cricket::FakeVideoMediaChannel* video_channel_; 1293 cricket::FakeVideoMediaChannel* video_channel_;
1255 cricket::FakeVoiceMediaChannel* voice_channel_; 1294 cricket::FakeVoiceMediaChannel* voice_channel_;
1256 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; 1295 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_;
1257 }; 1296 };
1258 1297
1259 TEST_F(WebRtcSessionTest, TestInitializeWithDtls) { 1298 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) {
1260 InitWithDtls(); 1299 InitWithDtls(GetParam());
1261 // SDES is disabled when DTLS is on. 1300 // SDES is disabled when DTLS is on.
1262 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); 1301 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy());
1263 } 1302 }
1264 1303
1265 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { 1304 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) {
1266 Init(); 1305 Init();
1267 // SDES is required if DTLS is off. 1306 // SDES is required if DTLS is off.
1268 EXPECT_EQ(cricket::SEC_REQUIRED, session_->SdesPolicy()); 1307 EXPECT_EQ(cricket::SEC_REQUIRED, session_->SdesPolicy());
1269 } 1308 }
1270 1309
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 SessionDescriptionInterface* answer = NULL; 1596 SessionDescriptionInterface* answer = NULL;
1558 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer); 1597 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer);
1559 // SetRemoteDescription and SetLocalDescription will take the ownership of 1598 // SetRemoteDescription and SetLocalDescription will take the ownership of
1560 // the offer. 1599 // the offer.
1561 SetLocalDescriptionWithoutError(offer); 1600 SetLocalDescriptionWithoutError(offer);
1562 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); 1601 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer);
1563 } 1602 }
1564 1603
1565 // Test that we accept an offer with a DTLS fingerprint when DTLS is on 1604 // 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. 1605 // and that we return an answer with a DTLS fingerprint.
1567 TEST_F(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { 1606 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) {
1568 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1607 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1569 mediastream_signaling_.SendAudioVideoStream1(); 1608 mediastream_signaling_.SendAudioVideoStream1();
1570 InitWithDtls(); 1609 InitWithDtls(GetParam());
1571 SetFactoryDtlsSrtp(); 1610 SetFactoryDtlsSrtp();
1572 cricket::MediaSessionOptions options; 1611 cricket::MediaSessionOptions options;
1573 options.recv_video = true; 1612 options.recv_video = true;
1574 JsepSessionDescription* offer = 1613 JsepSessionDescription* offer =
1575 CreateRemoteOffer(options, cricket::SEC_DISABLED); 1614 CreateRemoteOffer(options, cricket::SEC_DISABLED);
1576 ASSERT_TRUE(offer != NULL); 1615 ASSERT_TRUE(offer != NULL);
1577 VerifyFingerprintStatus(offer->description(), true); 1616 VerifyFingerprintStatus(offer->description(), true);
1578 VerifyNoCryptoParams(offer->description(), true); 1617 VerifyNoCryptoParams(offer->description(), true);
1579 1618
1580 // SetRemoteDescription will take the ownership of the offer. 1619 // SetRemoteDescription will take the ownership of the offer.
1581 SetRemoteDescriptionWithoutError(offer); 1620 SetRemoteDescriptionWithoutError(offer);
1582 1621
1583 // Verify that we get a crypto fingerprint in the answer. 1622 // Verify that we get a crypto fingerprint in the answer.
1584 SessionDescriptionInterface* answer = CreateAnswer(NULL); 1623 SessionDescriptionInterface* answer = CreateAnswer(NULL);
1585 ASSERT_TRUE(answer != NULL); 1624 ASSERT_TRUE(answer != NULL);
1586 VerifyFingerprintStatus(answer->description(), true); 1625 VerifyFingerprintStatus(answer->description(), true);
1587 // Check that we don't have an a=crypto line in the answer. 1626 // Check that we don't have an a=crypto line in the answer.
1588 VerifyNoCryptoParams(answer->description(), true); 1627 VerifyNoCryptoParams(answer->description(), true);
1589 1628
1590 // Now set the local description, which should work, even without a=crypto. 1629 // Now set the local description, which should work, even without a=crypto.
1591 SetLocalDescriptionWithoutError(answer); 1630 SetLocalDescriptionWithoutError(answer);
1592 } 1631 }
1593 1632
1594 // Test that we set a local offer with a DTLS fingerprint when DTLS is on 1633 // 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. 1634 // and then we accept a remote answer with a DTLS fingerprint successfully.
1596 TEST_F(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { 1635 TEST_P(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) {
1597 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1636 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1598 mediastream_signaling_.SendAudioVideoStream1(); 1637 mediastream_signaling_.SendAudioVideoStream1();
1599 InitWithDtls(); 1638 InitWithDtls(GetParam());
1600 SetFactoryDtlsSrtp(); 1639 SetFactoryDtlsSrtp();
1601 1640
1602 // Verify that we get a crypto fingerprint in the answer. 1641 // Verify that we get a crypto fingerprint in the answer.
1603 SessionDescriptionInterface* offer = CreateOffer(); 1642 SessionDescriptionInterface* offer = CreateOffer();
1604 ASSERT_TRUE(offer != NULL); 1643 ASSERT_TRUE(offer != NULL);
1605 VerifyFingerprintStatus(offer->description(), true); 1644 VerifyFingerprintStatus(offer->description(), true);
1606 // Check that we don't have an a=crypto line in the offer. 1645 // Check that we don't have an a=crypto line in the offer.
1607 VerifyNoCryptoParams(offer->description(), true); 1646 VerifyNoCryptoParams(offer->description(), true);
1608 1647
1609 // Now set the local description, which should work, even without a=crypto. 1648 // Now set the local description, which should work, even without a=crypto.
1610 SetLocalDescriptionWithoutError(offer); 1649 SetLocalDescriptionWithoutError(offer);
1611 1650
1612 cricket::MediaSessionOptions options; 1651 cricket::MediaSessionOptions options;
1613 options.recv_video = true; 1652 options.recv_video = true;
1614 JsepSessionDescription* answer = 1653 JsepSessionDescription* answer =
1615 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); 1654 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED);
1616 ASSERT_TRUE(answer != NULL); 1655 ASSERT_TRUE(answer != NULL);
1617 VerifyFingerprintStatus(answer->description(), true); 1656 VerifyFingerprintStatus(answer->description(), true);
1618 VerifyNoCryptoParams(answer->description(), true); 1657 VerifyNoCryptoParams(answer->description(), true);
1619 1658
1620 // SetRemoteDescription will take the ownership of the answer. 1659 // SetRemoteDescription will take the ownership of the answer.
1621 SetRemoteDescriptionWithoutError(answer); 1660 SetRemoteDescriptionWithoutError(answer);
1622 } 1661 }
1623 1662
1624 // Test that if we support DTLS and the other side didn't offer a fingerprint, 1663 // Test that if we support DTLS and the other side didn't offer a fingerprint,
1625 // we will fail to set the remote description. 1664 // we will fail to set the remote description.
1626 TEST_F(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { 1665 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) {
1627 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1666 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1628 InitWithDtls(); 1667 InitWithDtls(GetParam());
1629 cricket::MediaSessionOptions options; 1668 cricket::MediaSessionOptions options;
1630 options.recv_video = true; 1669 options.recv_video = true;
1631 options.bundle_enabled = true; 1670 options.bundle_enabled = true;
1632 JsepSessionDescription* offer = CreateRemoteOffer( 1671 JsepSessionDescription* offer = CreateRemoteOffer(
1633 options, cricket::SEC_REQUIRED); 1672 options, cricket::SEC_REQUIRED);
1634 ASSERT_TRUE(offer != NULL); 1673 ASSERT_TRUE(offer != NULL);
1635 VerifyFingerprintStatus(offer->description(), false); 1674 VerifyFingerprintStatus(offer->description(), false);
1636 VerifyCryptoParams(offer->description()); 1675 VerifyCryptoParams(offer->description());
1637 1676
1638 // SetRemoteDescription will take the ownership of the offer. 1677 // SetRemoteDescription will take the ownership of the offer.
1639 SetRemoteDescriptionOfferExpectError( 1678 SetRemoteDescriptionOfferExpectError(
1640 kSdpWithoutDtlsFingerprint, offer); 1679 kSdpWithoutDtlsFingerprint, offer);
1641 1680
1642 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED); 1681 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED);
1643 // SetLocalDescription will take the ownership of the offer. 1682 // SetLocalDescription will take the ownership of the offer.
1644 SetLocalDescriptionOfferExpectError( 1683 SetLocalDescriptionOfferExpectError(
1645 kSdpWithoutDtlsFingerprint, offer); 1684 kSdpWithoutDtlsFingerprint, offer);
1646 } 1685 }
1647 1686
1648 // Test that we return a failure when applying a local answer that doesn't have 1687 // Test that we return a failure when applying a local answer that doesn't have
1649 // a DTLS fingerprint when DTLS is required. 1688 // a DTLS fingerprint when DTLS is required.
1650 TEST_F(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) { 1689 TEST_P(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) {
1651 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1690 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1652 InitWithDtls(); 1691 InitWithDtls(GetParam());
1653 SessionDescriptionInterface* offer = NULL; 1692 SessionDescriptionInterface* offer = NULL;
1654 SessionDescriptionInterface* answer = NULL; 1693 SessionDescriptionInterface* answer = NULL;
1655 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer); 1694 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer);
1656 1695
1657 // SetRemoteDescription and SetLocalDescription will take the ownership of 1696 // SetRemoteDescription and SetLocalDescription will take the ownership of
1658 // the offer and answer. 1697 // the offer and answer.
1659 SetRemoteDescriptionWithoutError(offer); 1698 SetRemoteDescriptionWithoutError(offer);
1660 SetLocalDescriptionAnswerExpectError( 1699 SetLocalDescriptionAnswerExpectError(
1661 kSdpWithoutDtlsFingerprint, answer); 1700 kSdpWithoutDtlsFingerprint, answer);
1662 } 1701 }
1663 1702
1664 // Test that we return a failure when applying a remote answer that doesn't have 1703 // Test that we return a failure when applying a remote answer that doesn't have
1665 // a DTLS fingerprint when DTLS is required. 1704 // a DTLS fingerprint when DTLS is required.
1666 TEST_F(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { 1705 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) {
1667 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1706 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1668 // Enable both SDES and DTLS, so that offer won't be outright rejected as a 1707 // 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. 1708 // result of using the "UDP/TLS/RTP/SAVPF" profile.
1670 InitWithDtls(); 1709 InitWithDtls(GetParam());
1671 session_->SetSdesPolicy(cricket::SEC_ENABLED); 1710 session_->SetSdesPolicy(cricket::SEC_ENABLED);
1672 SessionDescriptionInterface* offer = CreateOffer(); 1711 SessionDescriptionInterface* offer = CreateOffer();
1673 cricket::MediaSessionOptions options; 1712 cricket::MediaSessionOptions options;
1674 options.recv_video = true; 1713 options.recv_video = true;
1675 JsepSessionDescription* answer = 1714 JsepSessionDescription* answer =
1676 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); 1715 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED);
1677 1716
1678 // SetRemoteDescription and SetLocalDescription will take the ownership of 1717 // SetRemoteDescription and SetLocalDescription will take the ownership of
1679 // the offer and answer. 1718 // the offer and answer.
1680 SetLocalDescriptionWithoutError(offer); 1719 SetLocalDescriptionWithoutError(offer);
1681 SetRemoteDescriptionAnswerExpectError( 1720 SetRemoteDescriptionAnswerExpectError(
1682 kSdpWithoutDtlsFingerprint, answer); 1721 kSdpWithoutDtlsFingerprint, answer);
1683 } 1722 }
1684 1723
1685 // Test that we create a local offer without SDES or DTLS and accept a remote 1724 // 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. 1725 // answer without SDES or DTLS when encryption is disabled.
1687 TEST_F(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { 1726 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) {
1688 mediastream_signaling_.SendAudioVideoStream1(); 1727 mediastream_signaling_.SendAudioVideoStream1();
1689 options_.disable_encryption = true; 1728 options_.disable_encryption = true;
1690 InitWithDtls(); 1729 InitWithDtls(GetParam());
1691 1730
1692 // Verify that we get a crypto fingerprint in the answer. 1731 // Verify that we get a crypto fingerprint in the answer.
1693 SessionDescriptionInterface* offer = CreateOffer(); 1732 SessionDescriptionInterface* offer = CreateOffer();
1694 ASSERT_TRUE(offer != NULL); 1733 ASSERT_TRUE(offer != NULL);
1695 VerifyFingerprintStatus(offer->description(), false); 1734 VerifyFingerprintStatus(offer->description(), false);
1696 // Check that we don't have an a=crypto line in the offer. 1735 // Check that we don't have an a=crypto line in the offer.
1697 VerifyNoCryptoParams(offer->description(), false); 1736 VerifyNoCryptoParams(offer->description(), false);
1698 1737
1699 // Now set the local description, which should work, even without a=crypto. 1738 // Now set the local description, which should work, even without a=crypto.
1700 SetLocalDescriptionWithoutError(offer); 1739 SetLocalDescriptionWithoutError(offer);
1701 1740
1702 cricket::MediaSessionOptions options; 1741 cricket::MediaSessionOptions options;
1703 options.recv_video = true; 1742 options.recv_video = true;
1704 JsepSessionDescription* answer = 1743 JsepSessionDescription* answer =
1705 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); 1744 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED);
1706 ASSERT_TRUE(answer != NULL); 1745 ASSERT_TRUE(answer != NULL);
1707 VerifyFingerprintStatus(answer->description(), false); 1746 VerifyFingerprintStatus(answer->description(), false);
1708 VerifyNoCryptoParams(answer->description(), false); 1747 VerifyNoCryptoParams(answer->description(), false);
1709 1748
1710 // SetRemoteDescription will take the ownership of the answer. 1749 // SetRemoteDescription will take the ownership of the answer.
1711 SetRemoteDescriptionWithoutError(answer); 1750 SetRemoteDescriptionWithoutError(answer);
1712 } 1751 }
1713 1752
1714 // Test that we create a local answer without SDES or DTLS and accept a remote 1753 // 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. 1754 // offer without SDES or DTLS when encryption is disabled.
1716 TEST_F(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { 1755 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) {
1717 options_.disable_encryption = true; 1756 options_.disable_encryption = true;
1718 InitWithDtls(); 1757 InitWithDtls(GetParam());
1719 1758
1720 cricket::MediaSessionOptions options; 1759 cricket::MediaSessionOptions options;
1721 options.recv_video = true; 1760 options.recv_video = true;
1722 JsepSessionDescription* offer = 1761 JsepSessionDescription* offer =
1723 CreateRemoteOffer(options, cricket::SEC_DISABLED); 1762 CreateRemoteOffer(options, cricket::SEC_DISABLED);
1724 ASSERT_TRUE(offer != NULL); 1763 ASSERT_TRUE(offer != NULL);
1725 VerifyFingerprintStatus(offer->description(), false); 1764 VerifyFingerprintStatus(offer->description(), false);
1726 VerifyNoCryptoParams(offer->description(), false); 1765 VerifyNoCryptoParams(offer->description(), false);
1727 1766
1728 // SetRemoteDescription will take the ownership of the offer. 1767 // SetRemoteDescription will take the ownership of the offer.
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after
3404 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { 3443 TEST_F(WebRtcSessionTest, TestRtpDataChannel) {
3405 constraints_.reset(new FakeConstraints()); 3444 constraints_.reset(new FakeConstraints());
3406 constraints_->AddOptional( 3445 constraints_->AddOptional(
3407 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); 3446 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true);
3408 Init(); 3447 Init();
3409 3448
3410 SetLocalDescriptionWithDataChannel(); 3449 SetLocalDescriptionWithDataChannel();
3411 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); 3450 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type());
3412 } 3451 }
3413 3452
3414 TEST_F(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { 3453 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) {
3415 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3454 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3416 3455
3417 constraints_.reset(new FakeConstraints()); 3456 constraints_.reset(new FakeConstraints());
3418 constraints_->AddOptional( 3457 constraints_->AddOptional(
3419 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); 3458 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true);
3420 options_.disable_sctp_data_channels = false; 3459 options_.disable_sctp_data_channels = false;
3421 3460
3422 InitWithDtls(); 3461 InitWithDtls(GetParam());
3423 3462
3424 SetLocalDescriptionWithDataChannel(); 3463 SetLocalDescriptionWithDataChannel();
3425 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); 3464 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type());
3426 } 3465 }
3427 3466
3428 TEST_F(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { 3467 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) {
3429 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3468 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3430 3469
3431 InitWithDtls(); 3470 InitWithDtls(GetParam());
3432 3471
3433 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3472 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3434 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); 3473 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL);
3435 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); 3474 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL);
3436 } 3475 }
3437 3476
3438 TEST_F(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { 3477 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) {
3439 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3478 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3440 SetFactoryDtlsSrtp(); 3479 SetFactoryDtlsSrtp();
3441 InitWithDtls(); 3480 InitWithDtls(GetParam());
3442 3481
3443 // Create remote offer with SCTP. 3482 // Create remote offer with SCTP.
3444 cricket::MediaSessionOptions options; 3483 cricket::MediaSessionOptions options;
3445 options.data_channel_type = cricket::DCT_SCTP; 3484 options.data_channel_type = cricket::DCT_SCTP;
3446 JsepSessionDescription* offer = 3485 JsepSessionDescription* offer =
3447 CreateRemoteOffer(options, cricket::SEC_DISABLED); 3486 CreateRemoteOffer(options, cricket::SEC_DISABLED);
3448 SetRemoteDescriptionWithoutError(offer); 3487 SetRemoteDescriptionWithoutError(offer);
3449 3488
3450 // Verifies the answer contains SCTP. 3489 // Verifies the answer contains SCTP.
3451 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); 3490 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL));
3452 EXPECT_TRUE(answer != NULL); 3491 EXPECT_TRUE(answer != NULL);
3453 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); 3492 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL);
3454 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); 3493 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL);
3455 } 3494 }
3456 3495
3457 TEST_F(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { 3496 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) {
3458 constraints_.reset(new FakeConstraints()); 3497 constraints_.reset(new FakeConstraints());
3459 constraints_->AddOptional( 3498 constraints_->AddOptional(
3460 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); 3499 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false);
3461 InitWithDtls(); 3500 InitWithDtls(GetParam());
3462 3501
3463 SetLocalDescriptionWithDataChannel(); 3502 SetLocalDescriptionWithDataChannel();
3464 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); 3503 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type());
3465 } 3504 }
3466 3505
3467 TEST_F(WebRtcSessionTest, TestSctpDataChannelWithDtls) { 3506 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) {
3468 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3507 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3469 3508
3470 InitWithDtls(); 3509 InitWithDtls(GetParam());
3471 3510
3472 SetLocalDescriptionWithDataChannel(); 3511 SetLocalDescriptionWithDataChannel();
3473 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); 3512 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type());
3474 } 3513 }
3475 3514
3476 TEST_F(WebRtcSessionTest, TestDisableSctpDataChannels) { 3515 TEST_P(WebRtcSessionTest, TestDisableSctpDataChannels) {
3477 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3516 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3478 options_.disable_sctp_data_channels = true; 3517 options_.disable_sctp_data_channels = true;
3479 InitWithDtls(); 3518 InitWithDtls(GetParam());
3480 3519
3481 SetLocalDescriptionWithDataChannel(); 3520 SetLocalDescriptionWithDataChannel();
3482 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); 3521 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type());
3483 } 3522 }
3484 3523
3485 TEST_F(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { 3524 TEST_P(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) {
3486 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3525 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3487 const int new_send_port = 9998; 3526 const int new_send_port = 9998;
3488 const int new_recv_port = 7775; 3527 const int new_recv_port = 7775;
3489 3528
3490 InitWithDtls(); 3529 InitWithDtls(GetParam());
3491 SetFactoryDtlsSrtp(); 3530 SetFactoryDtlsSrtp();
3492 3531
3493 // By default, don't actually add the codecs to desc_factory_; they don't 3532 // By default, don't actually add the codecs to desc_factory_; they don't
3494 // actually get serialized for SCTP in BuildMediaDescription(). Instead, 3533 // actually get serialized for SCTP in BuildMediaDescription(). Instead,
3495 // let the session description get parsed. That'll get the proper codecs 3534 // let the session description get parsed. That'll get the proper codecs
3496 // into the stream. 3535 // into the stream.
3497 cricket::MediaSessionOptions options; 3536 cricket::MediaSessionOptions options;
3498 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort( 3537 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort(
3499 "stream1", new_send_port, options); 3538 "stream1", new_send_port, options);
3500 3539
(...skipping 28 matching lines...) Expand all
3529 3568
3530 ASSERT_EQ(1UL, ch->recv_codecs().size()); 3569 ASSERT_EQ(1UL, ch->recv_codecs().size());
3531 EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->recv_codecs()[0].id); 3570 EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->recv_codecs()[0].id);
3532 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName, 3571 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName,
3533 ch->recv_codecs()[0].name.c_str())); 3572 ch->recv_codecs()[0].name.c_str()));
3534 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort, 3573 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort,
3535 &portnum)); 3574 &portnum));
3536 EXPECT_EQ(new_recv_port, portnum); 3575 EXPECT_EQ(new_recv_port, portnum);
3537 } 3576 }
3538 3577
3578 // TODO(hbos): Add the following test once RTCCertificate is passed around
3579 // outside of WebRtcSessionDescriptionFactory code and there exists a
3580 // WebRtcSession::certificate().
3581 //TEST_F(WebRtcSessionTest, TestUsesProvidedCertificate) {
3582 // rtc::scoped_refptr<rtc::RTCCertificate> certificate =
3583 // FakeDtlsIdentityStore::GenerateCertificate();
3584 //
3585 // PeerConnectionInterface::RTCConfiguration configuration;
3586 // configuration.certificates.push_back(certificate);
3587 // Init(nullptr, configuration);
3588 // EXPECT_TRUE_WAIT(!session_->waiting_for_identity_for_testing(), 1000);
3589 //
3590 // EXPECT_EQ(session_->certificate(), certificate);
3591 //}
3592
3539 // Verifies that CreateOffer succeeds when CreateOffer is called before async 3593 // Verifies that CreateOffer succeeds when CreateOffer is called before async
3540 // identity generation is finished. 3594 // identity generation is finished (even if a certificate is provided this is
3541 TEST_F(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { 3595 // an async op).
3596 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) {
3542 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3597 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3543 InitWithDtls(); 3598 InitWithDtls(GetParam());
3544 3599
3545 EXPECT_TRUE(session_->waiting_for_identity()); 3600 EXPECT_TRUE(session_->waiting_for_identity_for_testing());
3546 mediastream_signaling_.SendAudioVideoStream1(); 3601 mediastream_signaling_.SendAudioVideoStream1();
3547 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3602 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3548 3603
3549 EXPECT_TRUE(offer != NULL); 3604 EXPECT_TRUE(offer != NULL);
3550 VerifyNoCryptoParams(offer->description(), true); 3605 VerifyNoCryptoParams(offer->description(), true);
3551 VerifyFingerprintStatus(offer->description(), true); 3606 VerifyFingerprintStatus(offer->description(), true);
3552 } 3607 }
3553 3608
3554 // Verifies that CreateAnswer succeeds when CreateOffer is called before async 3609 // Verifies that CreateAnswer succeeds when CreateOffer is called before async
3555 // identity generation is finished. 3610 // identity generation is finished (even if a certificate is provided this is
3556 TEST_F(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { 3611 // an async op).
3612 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) {
3557 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3613 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3558 InitWithDtls(); 3614 InitWithDtls(GetParam());
3559 SetFactoryDtlsSrtp(); 3615 SetFactoryDtlsSrtp();
3560 3616
3561 cricket::MediaSessionOptions options; 3617 cricket::MediaSessionOptions options;
3562 options.recv_video = true; 3618 options.recv_video = true;
3563 scoped_ptr<JsepSessionDescription> offer( 3619 scoped_ptr<JsepSessionDescription> offer(
3564 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 3620 CreateRemoteOffer(options, cricket::SEC_DISABLED));
3565 ASSERT_TRUE(offer.get() != NULL); 3621 ASSERT_TRUE(offer.get() != NULL);
3566 SetRemoteDescriptionWithoutError(offer.release()); 3622 SetRemoteDescriptionWithoutError(offer.release());
3567 3623
3568 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); 3624 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL));
3569 EXPECT_TRUE(answer != NULL); 3625 EXPECT_TRUE(answer != NULL);
3570 VerifyNoCryptoParams(answer->description(), true); 3626 VerifyNoCryptoParams(answer->description(), true);
3571 VerifyFingerprintStatus(answer->description(), true); 3627 VerifyFingerprintStatus(answer->description(), true);
3572 } 3628 }
3573 3629
3574 // Verifies that CreateOffer succeeds when CreateOffer is called after async 3630 // Verifies that CreateOffer succeeds when CreateOffer is called after async
3575 // identity generation is finished. 3631 // identity generation is finished (even if a certificate is provided this is
3576 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { 3632 // an async op).
3633 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) {
3577 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3634 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3578 InitWithDtls(); 3635 InitWithDtls(GetParam());
3579 3636
3580 EXPECT_TRUE_WAIT(!session_->waiting_for_identity(), 1000); 3637 EXPECT_TRUE_WAIT(!session_->waiting_for_identity_for_testing(), 1000);
3581 3638
3582 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3639 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3583 EXPECT_TRUE(offer != NULL); 3640 EXPECT_TRUE(offer != NULL);
3584 } 3641 }
3585 3642
3586 // Verifies that CreateOffer fails when CreateOffer is called after async 3643 // Verifies that CreateOffer fails when CreateOffer is called after async
3587 // identity generation fails. 3644 // identity generation fails.
3588 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) { 3645 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) {
3589 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3646 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3590 InitWithDtls(true); 3647 InitWithDtlsIdentityGenFail();
3591 3648
3592 EXPECT_TRUE_WAIT(!session_->waiting_for_identity(), 1000); 3649 EXPECT_TRUE_WAIT(!session_->waiting_for_identity_for_testing(), 1000);
3593 3650
3594 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3651 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3595 EXPECT_TRUE(offer == NULL); 3652 EXPECT_TRUE(offer == NULL);
3596 } 3653 }
3597 3654
3598 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made 3655 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made
3599 // before async identity generation is finished. 3656 // before async identity generation is finished.
3600 TEST_F(WebRtcSessionTest, 3657 TEST_P(WebRtcSessionTest,
3601 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { 3658 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) {
3602 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3659 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3603 VerifyMultipleAsyncCreateDescription( 3660 VerifyMultipleAsyncCreateDescription(
3604 true, CreateSessionDescriptionRequest::kOffer); 3661 GetParam(), CreateSessionDescriptionRequest::kOffer);
3605 } 3662 }
3606 3663
3607 // Verifies that CreateOffer fails when Multiple CreateOffer calls are made 3664 // Verifies that CreateOffer fails when Multiple CreateOffer calls are made
3608 // before async identity generation fails. 3665 // before async identity generation fails.
3609 TEST_F(WebRtcSessionTest, 3666 TEST_F(WebRtcSessionTest,
3610 TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) { 3667 TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) {
3611 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3668 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3612 VerifyMultipleAsyncCreateDescription( 3669 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure(
3613 false, CreateSessionDescriptionRequest::kOffer); 3670 CreateSessionDescriptionRequest::kOffer);
3614 } 3671 }
3615 3672
3616 // Verifies that CreateAnswer succeeds when Multiple CreateAnswer calls are made 3673 // Verifies that CreateAnswer succeeds when Multiple CreateAnswer calls are made
3617 // before async identity generation is finished. 3674 // before async identity generation is finished.
3618 TEST_F(WebRtcSessionTest, 3675 TEST_P(WebRtcSessionTest,
3619 TestMultipleCreateAnswerBeforeIdentityRequestReturnSuccess) { 3676 TestMultipleCreateAnswerBeforeIdentityRequestReturnSuccess) {
3620 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3677 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3621 VerifyMultipleAsyncCreateDescription( 3678 VerifyMultipleAsyncCreateDescription(
3622 true, CreateSessionDescriptionRequest::kAnswer); 3679 GetParam(), CreateSessionDescriptionRequest::kAnswer);
3623 } 3680 }
3624 3681
3625 // Verifies that CreateAnswer fails when Multiple CreateAnswer calls are made 3682 // Verifies that CreateAnswer fails when Multiple CreateAnswer calls are made
3626 // before async identity generation fails. 3683 // before async identity generation fails.
3627 TEST_F(WebRtcSessionTest, 3684 TEST_F(WebRtcSessionTest,
3628 TestMultipleCreateAnswerBeforeIdentityRequestReturnFailure) { 3685 TestMultipleCreateAnswerBeforeIdentityRequestReturnFailure) {
3629 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3686 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3630 VerifyMultipleAsyncCreateDescription( 3687 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure(
3631 false, CreateSessionDescriptionRequest::kAnswer); 3688 CreateSessionDescriptionRequest::kAnswer);
3632 } 3689 }
3633 3690
3634 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote 3691 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote
3635 // offer has no SDES crypto but only DTLS fingerprint. 3692 // offer has no SDES crypto but only DTLS fingerprint.
3636 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { 3693 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) {
3637 // Init without DTLS. 3694 // Init without DTLS.
3638 Init(); 3695 Init();
3639 // Create a remote offer with secured transport disabled. 3696 // Create a remote offer with secured transport disabled.
3640 cricket::MediaSessionOptions options; 3697 cricket::MediaSessionOptions options;
3641 JsepSessionDescription* offer(CreateRemoteOffer( 3698 JsepSessionDescription* offer(CreateRemoteOffer(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3722 3779
3723 ASSERT_TRUE(voice_channel_ != NULL); 3780 ASSERT_TRUE(voice_channel_ != NULL);
3724 cricket::AudioOptions audio_options; 3781 cricket::AudioOptions audio_options;
3725 EXPECT_TRUE(voice_channel_->GetOptions(&audio_options)); 3782 EXPECT_TRUE(voice_channel_->GetOptions(&audio_options));
3726 EXPECT_TRUE( 3783 EXPECT_TRUE(
3727 audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false)); 3784 audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false));
3728 } 3785 }
3729 3786
3730 // Tests that we can renegotiate new media content with ICE candidates in the 3787 // Tests that we can renegotiate new media content with ICE candidates in the
3731 // new remote SDP. 3788 // new remote SDP.
3732 TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { 3789 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) {
3733 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3790 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3734 InitWithDtls(); 3791 InitWithDtls(GetParam());
3735 SetFactoryDtlsSrtp(); 3792 SetFactoryDtlsSrtp();
3736 3793
3737 mediastream_signaling_.UseOptionsAudioOnly(); 3794 mediastream_signaling_.UseOptionsAudioOnly();
3738 SessionDescriptionInterface* offer = CreateOffer(); 3795 SessionDescriptionInterface* offer = CreateOffer();
3739 SetLocalDescriptionWithoutError(offer); 3796 SetLocalDescriptionWithoutError(offer);
3740 3797
3741 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); 3798 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer);
3742 SetRemoteDescriptionWithoutError(answer); 3799 SetRemoteDescriptionWithoutError(answer);
3743 3800
3744 cricket::MediaSessionOptions options; 3801 cricket::MediaSessionOptions options;
3745 options.recv_video = true; 3802 options.recv_video = true;
3746 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); 3803 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED);
3747 3804
3748 cricket::Candidate candidate1; 3805 cricket::Candidate candidate1;
3749 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); 3806 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000));
3750 candidate1.set_component(1); 3807 candidate1.set_component(1);
3751 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, 3808 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1,
3752 candidate1); 3809 candidate1);
3753 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); 3810 EXPECT_TRUE(offer->AddCandidate(&ice_candidate));
3754 SetRemoteDescriptionWithoutError(offer); 3811 SetRemoteDescriptionWithoutError(offer);
3755 3812
3756 answer = CreateAnswer(NULL); 3813 answer = CreateAnswer(NULL);
3757 SetLocalDescriptionWithoutError(answer); 3814 SetLocalDescriptionWithoutError(answer);
3758 } 3815 }
3759 3816
3760 // Tests that we can renegotiate new media content with ICE candidates separated 3817 // Tests that we can renegotiate new media content with ICE candidates separated
3761 // from the remote SDP. 3818 // from the remote SDP.
3762 TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { 3819 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) {
3763 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3820 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3764 InitWithDtls(); 3821 InitWithDtls(GetParam());
3765 SetFactoryDtlsSrtp(); 3822 SetFactoryDtlsSrtp();
3766 3823
3767 mediastream_signaling_.UseOptionsAudioOnly(); 3824 mediastream_signaling_.UseOptionsAudioOnly();
3768 SessionDescriptionInterface* offer = CreateOffer(); 3825 SessionDescriptionInterface* offer = CreateOffer();
3769 SetLocalDescriptionWithoutError(offer); 3826 SetLocalDescriptionWithoutError(offer);
3770 3827
3771 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); 3828 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer);
3772 SetRemoteDescriptionWithoutError(answer); 3829 SetRemoteDescriptionWithoutError(answer);
3773 3830
3774 cricket::MediaSessionOptions options; 3831 cricket::MediaSessionOptions options;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3868 options.offer_to_receive_audio = 3925 options.offer_to_receive_audio =
3869 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 3926 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
3870 3927
3871 for (auto& o : observers) { 3928 for (auto& o : observers) {
3872 o = new WebRtcSessionCreateSDPObserverForTest(); 3929 o = new WebRtcSessionCreateSDPObserverForTest();
3873 session_->CreateOffer(o, options); 3930 session_->CreateOffer(o, options);
3874 } 3931 }
3875 3932
3876 session_.reset(); 3933 session_.reset();
3877 3934
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
3883 for (auto& o : observers) { 3935 for (auto& o : observers) {
3884 // We expect to have received a notification now even if the session was 3936 // 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 3937 // terminated. The offer creation may or may not have succeeded, but we
3886 // must have received a notification which, so the only invalid state 3938 // must have received a notification which, so the only invalid state
3887 // is kInit. 3939 // is kInit.
3888 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); 3940 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state());
3889 } 3941 }
3890 } 3942 }
3891 3943
3892 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 3944 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
3893 // currently fails because upon disconnection and reconnection OnIceComplete is 3945 // currently fails because upon disconnection and reconnection OnIceComplete is
3894 // called more than once without returning to IceGatheringGathering. 3946 // called more than once without returning to IceGatheringGathering.
3947
3948 INSTANTIATE_TEST_CASE_P(
3949 WebRtcSessionTests, WebRtcSessionTest,
3950 testing::Values(ALREADY_GENERATED, DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « talk/app/webrtc/webrtcsession.cc ('k') | talk/app/webrtc/webrtcsessiondescriptionfactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698