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

Side by Side Diff: webrtc/pc/peerconnection_unittest.cc

Issue 2640513002: Relanding: Removing #defines previously used for building without BoringSSL/OpenSSL. (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/pc/channel_unittest.cc ('k') | webrtc/pc/peerconnectionendtoend_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 28 matching lines...) Expand all
39 #include "webrtc/pc/localaudiosource.h" 39 #include "webrtc/pc/localaudiosource.h"
40 #include "webrtc/pc/mediasession.h" 40 #include "webrtc/pc/mediasession.h"
41 #include "webrtc/pc/peerconnection.h" 41 #include "webrtc/pc/peerconnection.h"
42 #include "webrtc/pc/peerconnectionfactory.h" 42 #include "webrtc/pc/peerconnectionfactory.h"
43 #include "webrtc/pc/test/fakeaudiocapturemodule.h" 43 #include "webrtc/pc/test/fakeaudiocapturemodule.h"
44 #include "webrtc/pc/test/fakeperiodicvideocapturer.h" 44 #include "webrtc/pc/test/fakeperiodicvideocapturer.h"
45 #include "webrtc/pc/test/fakertccertificategenerator.h" 45 #include "webrtc/pc/test/fakertccertificategenerator.h"
46 #include "webrtc/pc/test/fakevideotrackrenderer.h" 46 #include "webrtc/pc/test/fakevideotrackrenderer.h"
47 #include "webrtc/pc/test/mockpeerconnectionobservers.h" 47 #include "webrtc/pc/test/mockpeerconnectionobservers.h"
48 48
49 #define MAYBE_SKIP_TEST(feature) \
50 if (!(feature())) { \
51 LOG(LS_INFO) << "Feature disabled... skipping"; \
52 return; \
53 }
54
55 using cricket::ContentInfo; 49 using cricket::ContentInfo;
56 using cricket::FakeWebRtcVideoDecoder; 50 using cricket::FakeWebRtcVideoDecoder;
57 using cricket::FakeWebRtcVideoDecoderFactory; 51 using cricket::FakeWebRtcVideoDecoderFactory;
58 using cricket::FakeWebRtcVideoEncoder; 52 using cricket::FakeWebRtcVideoEncoder;
59 using cricket::FakeWebRtcVideoEncoderFactory; 53 using cricket::FakeWebRtcVideoEncoderFactory;
60 using cricket::MediaContentDescription; 54 using cricket::MediaContentDescription;
61 using webrtc::DataBuffer; 55 using webrtc::DataBuffer;
62 using webrtc::DataChannelInterface; 56 using webrtc::DataChannelInterface;
63 using webrtc::DtmfSender; 57 using webrtc::DtmfSender;
64 using webrtc::DtmfSenderInterface; 58 using webrtc::DtmfSenderInterface;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 210 }
217 211
218 static PeerConnectionTestClient* CreateClient( 212 static PeerConnectionTestClient* CreateClient(
219 const std::string& id, 213 const std::string& id,
220 const MediaConstraintsInterface* constraints, 214 const MediaConstraintsInterface* constraints,
221 const PeerConnectionFactory::Options* options, 215 const PeerConnectionFactory::Options* options,
222 const PeerConnectionInterface::RTCConfiguration* config, 216 const PeerConnectionInterface::RTCConfiguration* config,
223 rtc::Thread* network_thread, 217 rtc::Thread* network_thread,
224 rtc::Thread* worker_thread) { 218 rtc::Thread* worker_thread) {
225 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( 219 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
226 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? 220 new FakeRTCCertificateGenerator());
227 new FakeRTCCertificateGenerator() : nullptr);
228 221
229 return CreateClientWithDtlsIdentityStore(id, constraints, options, config, 222 return CreateClientWithDtlsIdentityStore(id, constraints, options, config,
230 std::move(cert_generator), true, 223 std::move(cert_generator), true,
231 network_thread, worker_thread); 224 network_thread, worker_thread);
232 } 225 }
233 226
234 static PeerConnectionTestClient* CreateClientPreferNoConstraints( 227 static PeerConnectionTestClient* CreateClientPreferNoConstraints(
235 const std::string& id, 228 const std::string& id,
236 const PeerConnectionFactory::Options* options, 229 const PeerConnectionFactory::Options* options,
237 rtc::Thread* network_thread, 230 rtc::Thread* network_thread,
238 rtc::Thread* worker_thread) { 231 rtc::Thread* worker_thread) {
239 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( 232 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
240 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? 233 new FakeRTCCertificateGenerator());
241 new FakeRTCCertificateGenerator() : nullptr);
242 234
243 return CreateClientWithDtlsIdentityStore(id, nullptr, options, nullptr, 235 return CreateClientWithDtlsIdentityStore(id, nullptr, options, nullptr,
244 std::move(cert_generator), false, 236 std::move(cert_generator), false,
245 network_thread, worker_thread); 237 network_thread, worker_thread);
246 } 238 }
247 239
248 ~PeerConnectionTestClient() { 240 ~PeerConnectionTestClient() {
249 } 241 }
250 242
251 void Negotiate() { Negotiate(true, true); } 243 void Negotiate() { Negotiate(true, true); }
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceGatheringComplete, 1457 EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceGatheringComplete,
1466 receiving_client_->ice_gathering_state(), 1458 receiving_client_->ice_gathering_state(),
1467 kMaxWaitForFramesMs); 1459 kMaxWaitForFramesMs);
1468 1460
1469 // Check that the expected number of frames have arrived. 1461 // Check that the expected number of frames have arrived.
1470 EXPECT_TRUE_WAIT(FramesHaveArrived(audio_frame_count, video_frame_count), 1462 EXPECT_TRUE_WAIT(FramesHaveArrived(audio_frame_count, video_frame_count),
1471 kMaxWaitForFramesMs); 1463 kMaxWaitForFramesMs);
1472 } 1464 }
1473 1465
1474 void SetupAndVerifyDtlsCall() { 1466 void SetupAndVerifyDtlsCall() {
1475 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1476 FakeConstraints setup_constraints; 1467 FakeConstraints setup_constraints;
1477 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, 1468 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
1478 true); 1469 true);
1479 // Disable resolution adaptation, we don't want it interfering with the 1470 // Disable resolution adaptation, we don't want it interfering with the
1480 // test results. 1471 // test results.
1481 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; 1472 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
1482 rtc_config.set_cpu_adaptation(false); 1473 rtc_config.set_cpu_adaptation(false);
1483 1474
1484 ASSERT_TRUE(CreateTestClients(&setup_constraints, nullptr, &rtc_config, 1475 ASSERT_TRUE(CreateTestClients(&setup_constraints, nullptr, &rtc_config,
1485 &setup_constraints, nullptr, &rtc_config)); 1476 &setup_constraints, nullptr, &rtc_config));
1486 LocalP2PTest(); 1477 LocalP2PTest();
1487 VerifyRenderedAspectRatio(640, 480); 1478 VerifyRenderedAspectRatio(640, 480);
1488 } 1479 }
1489 1480
1490 PeerConnectionTestClient* CreateDtlsClientWithAlternateKey() { 1481 PeerConnectionTestClient* CreateDtlsClientWithAlternateKey() {
1491 FakeConstraints setup_constraints; 1482 FakeConstraints setup_constraints;
1492 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, 1483 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
1493 true); 1484 true);
1494 // Disable resolution adaptation, we don't want it interfering with the 1485 // Disable resolution adaptation, we don't want it interfering with the
1495 // test results. 1486 // test results.
1496 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; 1487 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
1497 rtc_config.set_cpu_adaptation(false); 1488 rtc_config.set_cpu_adaptation(false);
1498 1489
1499 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( 1490 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
1500 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? 1491 new FakeRTCCertificateGenerator());
1501 new FakeRTCCertificateGenerator() : nullptr);
1502 cert_generator->use_alternate_key(); 1492 cert_generator->use_alternate_key();
1503 1493
1504 // Make sure the new client is using a different certificate. 1494 // Make sure the new client is using a different certificate.
1505 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( 1495 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore(
1506 "New Peer: ", &setup_constraints, nullptr, &rtc_config, 1496 "New Peer: ", &setup_constraints, nullptr, &rtc_config,
1507 std::move(cert_generator), prefer_constraint_apis_, 1497 std::move(cert_generator), prefer_constraint_apis_,
1508 network_thread_.get(), worker_thread_.get()); 1498 network_thread_.get(), worker_thread_.get());
1509 } 1499 }
1510 1500
1511 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { 1501 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 1677
1688 TEST_F(P2PTestConductor, OneWayMediaCallWithoutConstraints) { 1678 TEST_F(P2PTestConductor, OneWayMediaCallWithoutConstraints) {
1689 ASSERT_TRUE(CreateTestClientsThatPreferNoConstraints()); 1679 ASSERT_TRUE(CreateTestClientsThatPreferNoConstraints());
1690 receiving_client()->set_auto_add_stream(false); 1680 receiving_client()->set_auto_add_stream(false);
1691 LocalP2PTest(); 1681 LocalP2PTest();
1692 } 1682 }
1693 1683
1694 // This test sets up a audio call initially and then upgrades to audio/video, 1684 // This test sets up a audio call initially and then upgrades to audio/video,
1695 // using DTLS. 1685 // using DTLS.
1696 TEST_F(P2PTestConductor, LocalP2PTestDtlsRenegotiate) { 1686 TEST_F(P2PTestConductor, LocalP2PTestDtlsRenegotiate) {
1697 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1698 FakeConstraints setup_constraints; 1687 FakeConstraints setup_constraints;
1699 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, 1688 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
1700 true); 1689 true);
1701 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); 1690 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints));
1702 receiving_client()->SetReceiveAudioVideo(true, false); 1691 receiving_client()->SetReceiveAudioVideo(true, false);
1703 LocalP2PTest(); 1692 LocalP2PTest();
1704 receiving_client()->SetReceiveAudioVideo(true, true); 1693 receiving_client()->SetReceiveAudioVideo(true, true);
1705 receiving_client()->Negotiate(); 1694 receiving_client()->Negotiate();
1706 } 1695 }
1707 1696
1708 // This test sets up a call transfer to a new caller with a different DTLS 1697 // This test sets up a call transfer to a new caller with a different DTLS
1709 // fingerprint. 1698 // fingerprint.
1710 TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCallee) { 1699 TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCallee) {
1711 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1712 SetupAndVerifyDtlsCall(); 1700 SetupAndVerifyDtlsCall();
1713 1701
1714 // Keeping the original peer around which will still send packets to the 1702 // Keeping the original peer around which will still send packets to the
1715 // receiving client. These SRTP packets will be dropped. 1703 // receiving client. These SRTP packets will be dropped.
1716 std::unique_ptr<PeerConnectionTestClient> original_peer( 1704 std::unique_ptr<PeerConnectionTestClient> original_peer(
1717 set_initializing_client(CreateDtlsClientWithAlternateKey())); 1705 set_initializing_client(CreateDtlsClientWithAlternateKey()));
1718 original_peer->pc()->Close(); 1706 original_peer->pc()->Close();
1719 1707
1720 SetSignalingReceivers(); 1708 SetSignalingReceivers();
1721 receiving_client()->SetExpectIceRestart(true); 1709 receiving_client()->SetExpectIceRestart(true);
1722 LocalP2PTest(); 1710 LocalP2PTest();
1723 VerifyRenderedAspectRatio(640, 480); 1711 VerifyRenderedAspectRatio(640, 480);
1724 } 1712 }
1725 1713
1726 // This test sets up a non-bundle call and apply bundle during ICE restart. When 1714 // This test sets up a non-bundle call and apply bundle during ICE restart. When
1727 // bundle is in effect in the restart, the channel can successfully reset its 1715 // bundle is in effect in the restart, the channel can successfully reset its
1728 // DTLS-SRTP context. 1716 // DTLS-SRTP context.
1729 TEST_F(P2PTestConductor, LocalP2PTestDtlsBundleInIceRestart) { 1717 TEST_F(P2PTestConductor, LocalP2PTestDtlsBundleInIceRestart) {
1730 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1731 FakeConstraints setup_constraints; 1718 FakeConstraints setup_constraints;
1732 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, 1719 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
1733 true); 1720 true);
1734 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); 1721 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints));
1735 receiving_client()->RemoveBundleFromReceivedSdp(true); 1722 receiving_client()->RemoveBundleFromReceivedSdp(true);
1736 LocalP2PTest(); 1723 LocalP2PTest();
1737 VerifyRenderedAspectRatio(640, 480); 1724 VerifyRenderedAspectRatio(640, 480);
1738 1725
1739 initializing_client()->IceRestart(); 1726 initializing_client()->IceRestart();
1740 receiving_client()->SetExpectIceRestart(true); 1727 receiving_client()->SetExpectIceRestart(true);
1741 receiving_client()->RemoveBundleFromReceivedSdp(false); 1728 receiving_client()->RemoveBundleFromReceivedSdp(false);
1742 LocalP2PTest(); 1729 LocalP2PTest();
1743 VerifyRenderedAspectRatio(640, 480); 1730 VerifyRenderedAspectRatio(640, 480);
1744 } 1731 }
1745 1732
1746 // This test sets up a call transfer to a new callee with a different DTLS 1733 // This test sets up a call transfer to a new callee with a different DTLS
1747 // fingerprint. 1734 // fingerprint.
1748 TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCaller) { 1735 TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCaller) {
1749 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1750 SetupAndVerifyDtlsCall(); 1736 SetupAndVerifyDtlsCall();
1751 1737
1752 // Keeping the original peer around which will still send packets to the 1738 // Keeping the original peer around which will still send packets to the
1753 // receiving client. These SRTP packets will be dropped. 1739 // receiving client. These SRTP packets will be dropped.
1754 std::unique_ptr<PeerConnectionTestClient> original_peer( 1740 std::unique_ptr<PeerConnectionTestClient> original_peer(
1755 set_receiving_client(CreateDtlsClientWithAlternateKey())); 1741 set_receiving_client(CreateDtlsClientWithAlternateKey()));
1756 original_peer->pc()->Close(); 1742 original_peer->pc()->Close();
1757 1743
1758 SetSignalingReceivers(); 1744 SetSignalingReceivers();
1759 initializing_client()->IceRestart(); 1745 initializing_client()->IceRestart();
(...skipping 13 matching lines...) Expand all
1773 SetCaptureRotation(webrtc::kVideoRotation_90); 1759 SetCaptureRotation(webrtc::kVideoRotation_90);
1774 receiving_client()->RemoveCvoFromReceivedSdp(true); 1760 receiving_client()->RemoveCvoFromReceivedSdp(true);
1775 LocalP2PTest(); 1761 LocalP2PTest();
1776 VerifyRenderedAspectRatio(480, 640, webrtc::kVideoRotation_0); 1762 VerifyRenderedAspectRatio(480, 640, webrtc::kVideoRotation_0);
1777 } 1763 }
1778 1764
1779 // This test sets up a call between two endpoints that are configured to use 1765 // This test sets up a call between two endpoints that are configured to use
1780 // DTLS key agreement. The offerer don't support SDES. As a result, DTLS is 1766 // DTLS key agreement. The offerer don't support SDES. As a result, DTLS is
1781 // negotiated and used for transport. 1767 // negotiated and used for transport.
1782 TEST_F(P2PTestConductor, LocalP2PTestOfferDtlsButNotSdes) { 1768 TEST_F(P2PTestConductor, LocalP2PTestOfferDtlsButNotSdes) {
1783 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1784 FakeConstraints setup_constraints; 1769 FakeConstraints setup_constraints;
1785 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, 1770 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
1786 true); 1771 true);
1787 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); 1772 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints));
1788 receiving_client()->RemoveSdesCryptoFromReceivedSdp(true); 1773 receiving_client()->RemoveSdesCryptoFromReceivedSdp(true);
1789 LocalP2PTest(); 1774 LocalP2PTest();
1790 VerifyRenderedAspectRatio(640, 480); 1775 VerifyRenderedAspectRatio(640, 480);
1791 } 1776 }
1792 1777
1793 #ifdef HAVE_SCTP 1778 #ifdef HAVE_SCTP
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), 2235 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(),
2251 kMaxWaitMs); 2236 kMaxWaitMs);
2252 EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), 2237 EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(),
2253 kMaxWaitMs); 2238 kMaxWaitMs);
2254 } 2239 }
2255 2240
2256 // This test sets up a Jsep call with SCTP DataChannel and verifies the 2241 // This test sets up a Jsep call with SCTP DataChannel and verifies the
2257 // negotiation is completed without error. 2242 // negotiation is completed without error.
2258 #ifdef HAVE_SCTP 2243 #ifdef HAVE_SCTP
2259 TEST_F(P2PTestConductor, CreateOfferWithSctpDataChannel) { 2244 TEST_F(P2PTestConductor, CreateOfferWithSctpDataChannel) {
2260 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
2261 FakeConstraints constraints; 2245 FakeConstraints constraints;
2262 constraints.SetMandatory( 2246 constraints.SetMandatory(
2263 MediaConstraintsInterface::kEnableDtlsSrtp, true); 2247 MediaConstraintsInterface::kEnableDtlsSrtp, true);
2264 ASSERT_TRUE(CreateTestClients(&constraints, &constraints)); 2248 ASSERT_TRUE(CreateTestClients(&constraints, &constraints));
2265 initializing_client()->CreateDataChannel(); 2249 initializing_client()->CreateDataChannel();
2266 initializing_client()->Negotiate(false, false); 2250 initializing_client()->Negotiate(false, false);
2267 } 2251 }
2268 #endif 2252 #endif
2269 2253
2270 // This test sets up a call between two parties with audio, and video. 2254 // This test sets up a call between two parties with audio, and video.
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 servers.push_back(server); 2819 servers.push_back(server);
2836 EXPECT_EQ(webrtc::RTCErrorType::NONE, 2820 EXPECT_EQ(webrtc::RTCErrorType::NONE,
2837 webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); 2821 webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_));
2838 EXPECT_EQ(2U, turn_servers_.size()); 2822 EXPECT_EQ(2U, turn_servers_.size());
2839 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); 2823 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority);
2840 } 2824 }
2841 2825
2842 #endif // if !defined(THREAD_SANITIZER) 2826 #endif // if !defined(THREAD_SANITIZER)
2843 2827
2844 } // namespace 2828 } // namespace
OLDNEW
« no previous file with comments | « webrtc/pc/channel_unittest.cc ('k') | webrtc/pc/peerconnectionendtoend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698