OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "webrtc/media/sctp/sctptransportinternal.h" | 44 #include "webrtc/media/sctp/sctptransportinternal.h" |
45 #include "webrtc/p2p/base/packettransportinterface.h" | 45 #include "webrtc/p2p/base/packettransportinterface.h" |
46 #include "webrtc/p2p/base/stunserver.h" | 46 #include "webrtc/p2p/base/stunserver.h" |
47 #include "webrtc/p2p/base/teststunserver.h" | 47 #include "webrtc/p2p/base/teststunserver.h" |
48 #include "webrtc/p2p/base/testturnserver.h" | 48 #include "webrtc/p2p/base/testturnserver.h" |
49 #include "webrtc/p2p/base/transportchannel.h" | 49 #include "webrtc/p2p/base/transportchannel.h" |
50 #include "webrtc/p2p/client/basicportallocator.h" | 50 #include "webrtc/p2p/client/basicportallocator.h" |
51 #include "webrtc/pc/channelmanager.h" | 51 #include "webrtc/pc/channelmanager.h" |
52 #include "webrtc/pc/mediasession.h" | 52 #include "webrtc/pc/mediasession.h" |
53 | 53 |
54 #define MAYBE_SKIP_TEST(feature) \ | |
55 if (!(feature())) { \ | |
56 LOG(LS_INFO) << "Feature disabled... skipping"; \ | |
57 return; \ | |
58 } | |
59 | |
60 using cricket::FakeVoiceMediaChannel; | 54 using cricket::FakeVoiceMediaChannel; |
61 using cricket::TransportInfo; | 55 using cricket::TransportInfo; |
62 using rtc::SocketAddress; | 56 using rtc::SocketAddress; |
63 using rtc::Thread; | 57 using rtc::Thread; |
64 using webrtc::CreateSessionDescription; | 58 using webrtc::CreateSessionDescription; |
65 using webrtc::CreateSessionDescriptionObserver; | 59 using webrtc::CreateSessionDescriptionObserver; |
66 using webrtc::CreateSessionDescriptionRequest; | 60 using webrtc::CreateSessionDescriptionRequest; |
67 using webrtc::DataChannel; | 61 using webrtc::DataChannel; |
68 using webrtc::FakeMetricsObserver; | 62 using webrtc::FakeMetricsObserver; |
69 using webrtc::IceCandidateCollection; | 63 using webrtc::IceCandidateCollection; |
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer); | 1838 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer); |
1845 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1839 // SetRemoteDescription and SetLocalDescription will take the ownership of |
1846 // the offer. | 1840 // the offer. |
1847 SetLocalDescriptionWithoutError(offer); | 1841 SetLocalDescriptionWithoutError(offer); |
1848 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); | 1842 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); |
1849 } | 1843 } |
1850 | 1844 |
1851 // Test that we accept an offer with a DTLS fingerprint when DTLS is on | 1845 // Test that we accept an offer with a DTLS fingerprint when DTLS is on |
1852 // and that we return an answer with a DTLS fingerprint. | 1846 // and that we return an answer with a DTLS fingerprint. |
1853 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { | 1847 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { |
1854 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
1855 SendAudioVideoStream1(); | 1848 SendAudioVideoStream1(); |
1856 InitWithDtls(GetParam()); | 1849 InitWithDtls(GetParam()); |
1857 SetFactoryDtlsSrtp(); | 1850 SetFactoryDtlsSrtp(); |
1858 cricket::MediaSessionOptions options; | 1851 cricket::MediaSessionOptions options; |
1859 options.recv_video = true; | 1852 options.recv_video = true; |
1860 JsepSessionDescription* offer = | 1853 JsepSessionDescription* offer = |
1861 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1854 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
1862 ASSERT_TRUE(offer != NULL); | 1855 ASSERT_TRUE(offer != NULL); |
1863 VerifyFingerprintStatus(offer->description(), true); | 1856 VerifyFingerprintStatus(offer->description(), true); |
1864 VerifyNoCryptoParams(offer->description(), true); | 1857 VerifyNoCryptoParams(offer->description(), true); |
1865 | 1858 |
1866 // SetRemoteDescription will take the ownership of the offer. | 1859 // SetRemoteDescription will take the ownership of the offer. |
1867 SetRemoteDescriptionWithoutError(offer); | 1860 SetRemoteDescriptionWithoutError(offer); |
1868 | 1861 |
1869 // Verify that we get a crypto fingerprint in the answer. | 1862 // Verify that we get a crypto fingerprint in the answer. |
1870 SessionDescriptionInterface* answer = CreateAnswer(); | 1863 SessionDescriptionInterface* answer = CreateAnswer(); |
1871 ASSERT_TRUE(answer != NULL); | 1864 ASSERT_TRUE(answer != NULL); |
1872 VerifyFingerprintStatus(answer->description(), true); | 1865 VerifyFingerprintStatus(answer->description(), true); |
1873 // Check that we don't have an a=crypto line in the answer. | 1866 // Check that we don't have an a=crypto line in the answer. |
1874 VerifyNoCryptoParams(answer->description(), true); | 1867 VerifyNoCryptoParams(answer->description(), true); |
1875 | 1868 |
1876 // Now set the local description, which should work, even without a=crypto. | 1869 // Now set the local description, which should work, even without a=crypto. |
1877 SetLocalDescriptionWithoutError(answer); | 1870 SetLocalDescriptionWithoutError(answer); |
1878 } | 1871 } |
1879 | 1872 |
1880 // Test that we set a local offer with a DTLS fingerprint when DTLS is on | 1873 // Test that we set a local offer with a DTLS fingerprint when DTLS is on |
1881 // and then we accept a remote answer with a DTLS fingerprint successfully. | 1874 // and then we accept a remote answer with a DTLS fingerprint successfully. |
1882 TEST_P(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { | 1875 TEST_P(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { |
1883 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
1884 SendAudioVideoStream1(); | 1876 SendAudioVideoStream1(); |
1885 InitWithDtls(GetParam()); | 1877 InitWithDtls(GetParam()); |
1886 SetFactoryDtlsSrtp(); | 1878 SetFactoryDtlsSrtp(); |
1887 | 1879 |
1888 // Verify that we get a crypto fingerprint in the answer. | 1880 // Verify that we get a crypto fingerprint in the answer. |
1889 SessionDescriptionInterface* offer = CreateOffer(); | 1881 SessionDescriptionInterface* offer = CreateOffer(); |
1890 ASSERT_TRUE(offer != NULL); | 1882 ASSERT_TRUE(offer != NULL); |
1891 VerifyFingerprintStatus(offer->description(), true); | 1883 VerifyFingerprintStatus(offer->description(), true); |
1892 // Check that we don't have an a=crypto line in the offer. | 1884 // Check that we don't have an a=crypto line in the offer. |
1893 VerifyNoCryptoParams(offer->description(), true); | 1885 VerifyNoCryptoParams(offer->description(), true); |
1894 | 1886 |
1895 // Now set the local description, which should work, even without a=crypto. | 1887 // Now set the local description, which should work, even without a=crypto. |
1896 SetLocalDescriptionWithoutError(offer); | 1888 SetLocalDescriptionWithoutError(offer); |
1897 | 1889 |
1898 cricket::MediaSessionOptions options; | 1890 cricket::MediaSessionOptions options; |
1899 options.recv_video = true; | 1891 options.recv_video = true; |
1900 JsepSessionDescription* answer = | 1892 JsepSessionDescription* answer = |
1901 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 1893 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
1902 ASSERT_TRUE(answer != NULL); | 1894 ASSERT_TRUE(answer != NULL); |
1903 VerifyFingerprintStatus(answer->description(), true); | 1895 VerifyFingerprintStatus(answer->description(), true); |
1904 VerifyNoCryptoParams(answer->description(), true); | 1896 VerifyNoCryptoParams(answer->description(), true); |
1905 | 1897 |
1906 // SetRemoteDescription will take the ownership of the answer. | 1898 // SetRemoteDescription will take the ownership of the answer. |
1907 SetRemoteDescriptionWithoutError(answer); | 1899 SetRemoteDescriptionWithoutError(answer); |
1908 } | 1900 } |
1909 | 1901 |
1910 // Test that if we support DTLS and the other side didn't offer a fingerprint, | 1902 // Test that if we support DTLS and the other side didn't offer a fingerprint, |
1911 // we will fail to set the remote description. | 1903 // we will fail to set the remote description. |
1912 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { | 1904 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { |
1913 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
1914 InitWithDtls(GetParam()); | 1905 InitWithDtls(GetParam()); |
1915 cricket::MediaSessionOptions options; | 1906 cricket::MediaSessionOptions options; |
1916 options.recv_video = true; | 1907 options.recv_video = true; |
1917 options.bundle_enabled = true; | 1908 options.bundle_enabled = true; |
1918 JsepSessionDescription* offer = CreateRemoteOffer( | 1909 JsepSessionDescription* offer = CreateRemoteOffer( |
1919 options, cricket::SEC_REQUIRED); | 1910 options, cricket::SEC_REQUIRED); |
1920 ASSERT_TRUE(offer != NULL); | 1911 ASSERT_TRUE(offer != NULL); |
1921 VerifyFingerprintStatus(offer->description(), false); | 1912 VerifyFingerprintStatus(offer->description(), false); |
1922 VerifyCryptoParams(offer->description()); | 1913 VerifyCryptoParams(offer->description()); |
1923 | 1914 |
1924 // SetRemoteDescription will take the ownership of the offer. | 1915 // SetRemoteDescription will take the ownership of the offer. |
1925 SetRemoteDescriptionOfferExpectError( | 1916 SetRemoteDescriptionOfferExpectError( |
1926 kSdpWithoutDtlsFingerprint, offer); | 1917 kSdpWithoutDtlsFingerprint, offer); |
1927 | 1918 |
1928 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED); | 1919 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED); |
1929 // SetLocalDescription will take the ownership of the offer. | 1920 // SetLocalDescription will take the ownership of the offer. |
1930 SetLocalDescriptionOfferExpectError( | 1921 SetLocalDescriptionOfferExpectError( |
1931 kSdpWithoutDtlsFingerprint, offer); | 1922 kSdpWithoutDtlsFingerprint, offer); |
1932 } | 1923 } |
1933 | 1924 |
1934 // Test that we return a failure when applying a local answer that doesn't have | 1925 // Test that we return a failure when applying a local answer that doesn't have |
1935 // a DTLS fingerprint when DTLS is required. | 1926 // a DTLS fingerprint when DTLS is required. |
1936 TEST_P(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) { | 1927 TEST_P(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) { |
1937 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
1938 InitWithDtls(GetParam()); | 1928 InitWithDtls(GetParam()); |
1939 SessionDescriptionInterface* offer = NULL; | 1929 SessionDescriptionInterface* offer = NULL; |
1940 SessionDescriptionInterface* answer = NULL; | 1930 SessionDescriptionInterface* answer = NULL; |
1941 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer); | 1931 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer); |
1942 | 1932 |
1943 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1933 // SetRemoteDescription and SetLocalDescription will take the ownership of |
1944 // the offer and answer. | 1934 // the offer and answer. |
1945 SetRemoteDescriptionWithoutError(offer); | 1935 SetRemoteDescriptionWithoutError(offer); |
1946 SetLocalDescriptionAnswerExpectError( | 1936 SetLocalDescriptionAnswerExpectError( |
1947 kSdpWithoutDtlsFingerprint, answer); | 1937 kSdpWithoutDtlsFingerprint, answer); |
1948 } | 1938 } |
1949 | 1939 |
1950 // Test that we return a failure when applying a remote answer that doesn't have | 1940 // Test that we return a failure when applying a remote answer that doesn't have |
1951 // a DTLS fingerprint when DTLS is required. | 1941 // a DTLS fingerprint when DTLS is required. |
1952 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { | 1942 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { |
1953 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
1954 InitWithDtls(GetParam()); | 1943 InitWithDtls(GetParam()); |
1955 SessionDescriptionInterface* offer = CreateOffer(); | 1944 SessionDescriptionInterface* offer = CreateOffer(); |
1956 cricket::MediaSessionOptions options; | 1945 cricket::MediaSessionOptions options; |
1957 options.recv_video = true; | 1946 options.recv_video = true; |
1958 std::unique_ptr<SessionDescriptionInterface> temp_offer( | 1947 std::unique_ptr<SessionDescriptionInterface> temp_offer( |
1959 CreateRemoteOffer(options, cricket::SEC_ENABLED)); | 1948 CreateRemoteOffer(options, cricket::SEC_ENABLED)); |
1960 JsepSessionDescription* answer = | 1949 JsepSessionDescription* answer = |
1961 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); | 1950 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); |
1962 | 1951 |
1963 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1952 // SetRemoteDescription and SetLocalDescription will take the ownership of |
(...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3920 | 3909 |
3921 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { | 3910 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { |
3922 configuration_.enable_rtp_data_channel = true; | 3911 configuration_.enable_rtp_data_channel = true; |
3923 Init(); | 3912 Init(); |
3924 SetLocalDescriptionWithDataChannel(); | 3913 SetLocalDescriptionWithDataChannel(); |
3925 ASSERT_TRUE(data_engine_); | 3914 ASSERT_TRUE(data_engine_); |
3926 EXPECT_NE(nullptr, data_engine_->GetChannel(0)); | 3915 EXPECT_NE(nullptr, data_engine_->GetChannel(0)); |
3927 } | 3916 } |
3928 | 3917 |
3929 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { | 3918 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { |
3930 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
3931 | |
3932 configuration_.enable_rtp_data_channel = true; | 3919 configuration_.enable_rtp_data_channel = true; |
3933 options_.disable_sctp_data_channels = false; | 3920 options_.disable_sctp_data_channels = false; |
3934 | 3921 |
3935 InitWithDtls(GetParam()); | 3922 InitWithDtls(GetParam()); |
3936 | 3923 |
3937 SetLocalDescriptionWithDataChannel(); | 3924 SetLocalDescriptionWithDataChannel(); |
3938 EXPECT_NE(nullptr, data_engine_->GetChannel(0)); | 3925 EXPECT_NE(nullptr, data_engine_->GetChannel(0)); |
3939 } | 3926 } |
3940 | 3927 |
3941 // Test that sctp_content_name/sctp_transport_name (used for stats) are correct | 3928 // Test that sctp_content_name/sctp_transport_name (used for stats) are correct |
3942 // before and after BUNDLE is negotiated. | 3929 // before and after BUNDLE is negotiated. |
3943 TEST_P(WebRtcSessionTest, SctpContentAndTransportName) { | 3930 TEST_P(WebRtcSessionTest, SctpContentAndTransportName) { |
3944 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
3945 SetFactoryDtlsSrtp(); | 3931 SetFactoryDtlsSrtp(); |
3946 InitWithDtls(GetParam()); | 3932 InitWithDtls(GetParam()); |
3947 | 3933 |
3948 // Initially these fields should be empty. | 3934 // Initially these fields should be empty. |
3949 EXPECT_FALSE(session_->sctp_content_name()); | 3935 EXPECT_FALSE(session_->sctp_content_name()); |
3950 EXPECT_FALSE(session_->sctp_transport_name()); | 3936 EXPECT_FALSE(session_->sctp_transport_name()); |
3951 | 3937 |
3952 // Create offer with audio/video/data. | 3938 // Create offer with audio/video/data. |
3953 // Default bundle policy is "balanced", so data should be using its own | 3939 // Default bundle policy is "balanced", so data should be using its own |
3954 // transport. | 3940 // transport. |
(...skipping 13 matching lines...) Expand all Loading... |
3968 answer_options.data_channel_type = cricket::DCT_SCTP; | 3954 answer_options.data_channel_type = cricket::DCT_SCTP; |
3969 SetRemoteDescriptionWithoutError(CreateRemoteAnswer( | 3955 SetRemoteDescriptionWithoutError(CreateRemoteAnswer( |
3970 session_->local_description(), answer_options, cricket::SEC_DISABLED)); | 3956 session_->local_description(), answer_options, cricket::SEC_DISABLED)); |
3971 ASSERT_TRUE(session_->sctp_content_name()); | 3957 ASSERT_TRUE(session_->sctp_content_name()); |
3972 ASSERT_TRUE(session_->sctp_transport_name()); | 3958 ASSERT_TRUE(session_->sctp_transport_name()); |
3973 EXPECT_EQ("data", *session_->sctp_content_name()); | 3959 EXPECT_EQ("data", *session_->sctp_content_name()); |
3974 EXPECT_EQ("audio", *session_->sctp_transport_name()); | 3960 EXPECT_EQ("audio", *session_->sctp_transport_name()); |
3975 } | 3961 } |
3976 | 3962 |
3977 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { | 3963 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { |
3978 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
3979 | |
3980 InitWithDtls(GetParam()); | 3964 InitWithDtls(GetParam()); |
3981 | 3965 |
3982 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3966 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
3983 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); | 3967 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); |
3984 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); | 3968 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); |
3985 } | 3969 } |
3986 | 3970 |
3987 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { | 3971 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { |
3988 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
3989 SetFactoryDtlsSrtp(); | 3972 SetFactoryDtlsSrtp(); |
3990 InitWithDtls(GetParam()); | 3973 InitWithDtls(GetParam()); |
3991 | 3974 |
3992 // Create remote offer with SCTP. | 3975 // Create remote offer with SCTP. |
3993 cricket::MediaSessionOptions options; | 3976 cricket::MediaSessionOptions options; |
3994 options.data_channel_type = cricket::DCT_SCTP; | 3977 options.data_channel_type = cricket::DCT_SCTP; |
3995 JsepSessionDescription* offer = | 3978 JsepSessionDescription* offer = |
3996 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 3979 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
3997 SetRemoteDescriptionWithoutError(offer); | 3980 SetRemoteDescriptionWithoutError(offer); |
3998 | 3981 |
(...skipping 11 matching lines...) Expand all Loading... |
4010 InitWithDtls(GetParam()); | 3993 InitWithDtls(GetParam()); |
4011 | 3994 |
4012 SetLocalDescriptionWithDataChannel(); | 3995 SetLocalDescriptionWithDataChannel(); |
4013 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); | 3996 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); |
4014 EXPECT_EQ(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); | 3997 EXPECT_EQ(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); |
4015 } | 3998 } |
4016 | 3999 |
4017 // Test that if DTLS is enabled, we end up with an SctpTransport created | 4000 // Test that if DTLS is enabled, we end up with an SctpTransport created |
4018 // (and not an RtpDataChannel). | 4001 // (and not an RtpDataChannel). |
4019 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) { | 4002 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) { |
4020 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4021 | |
4022 InitWithDtls(GetParam()); | 4003 InitWithDtls(GetParam()); |
4023 | 4004 |
4024 SetLocalDescriptionWithDataChannel(); | 4005 SetLocalDescriptionWithDataChannel(); |
4025 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); | 4006 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); |
4026 EXPECT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); | 4007 EXPECT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); |
4027 } | 4008 } |
4028 | 4009 |
4029 // Test that if SCTP is disabled, we don't end up with an SctpTransport | 4010 // Test that if SCTP is disabled, we don't end up with an SctpTransport |
4030 // created (or an RtpDataChannel). | 4011 // created (or an RtpDataChannel). |
4031 TEST_P(WebRtcSessionTest, TestDisableSctpDataChannels) { | 4012 TEST_P(WebRtcSessionTest, TestDisableSctpDataChannels) { |
4032 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4033 options_.disable_sctp_data_channels = true; | 4013 options_.disable_sctp_data_channels = true; |
4034 InitWithDtls(GetParam()); | 4014 InitWithDtls(GetParam()); |
4035 | 4015 |
4036 SetLocalDescriptionWithDataChannel(); | 4016 SetLocalDescriptionWithDataChannel(); |
4037 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); | 4017 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); |
4038 EXPECT_EQ(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); | 4018 EXPECT_EQ(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); |
4039 } | 4019 } |
4040 | 4020 |
4041 TEST_P(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { | 4021 TEST_P(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { |
4042 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4043 const int new_send_port = 9998; | 4022 const int new_send_port = 9998; |
4044 const int new_recv_port = 7775; | 4023 const int new_recv_port = 7775; |
4045 | 4024 |
4046 InitWithDtls(GetParam()); | 4025 InitWithDtls(GetParam()); |
4047 SetFactoryDtlsSrtp(); | 4026 SetFactoryDtlsSrtp(); |
4048 | 4027 |
4049 // By default, don't actually add the codecs to desc_factory_; they don't | 4028 // By default, don't actually add the codecs to desc_factory_; they don't |
4050 // actually get serialized for SCTP in BuildMediaDescription(). Instead, | 4029 // actually get serialized for SCTP in BuildMediaDescription(). Instead, |
4051 // let the session description get parsed. That'll get the proper codecs | 4030 // let the session description get parsed. That'll get the proper codecs |
4052 // into the stream. | 4031 // into the stream. |
(...skipping 21 matching lines...) Expand all Loading... |
4074 fake_sctp_transport_factory_->last_fake_sctp_transport()->local_port()); | 4053 fake_sctp_transport_factory_->last_fake_sctp_transport()->local_port()); |
4075 EXPECT_EQ( | 4054 EXPECT_EQ( |
4076 new_send_port, | 4055 new_send_port, |
4077 fake_sctp_transport_factory_->last_fake_sctp_transport()->remote_port()); | 4056 fake_sctp_transport_factory_->last_fake_sctp_transport()->remote_port()); |
4078 } | 4057 } |
4079 | 4058 |
4080 // Verifies that when a session's SctpTransport receives an OPEN message, | 4059 // Verifies that when a session's SctpTransport receives an OPEN message, |
4081 // WebRtcSession signals the SctpTransport creation request with the expected | 4060 // WebRtcSession signals the SctpTransport creation request with the expected |
4082 // config. | 4061 // config. |
4083 TEST_P(WebRtcSessionTest, TestSctpDataChannelOpenMessage) { | 4062 TEST_P(WebRtcSessionTest, TestSctpDataChannelOpenMessage) { |
4084 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4085 | |
4086 InitWithDtls(GetParam()); | 4063 InitWithDtls(GetParam()); |
4087 | 4064 |
4088 SetLocalDescriptionWithDataChannel(); | 4065 SetLocalDescriptionWithDataChannel(); |
4089 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); | 4066 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); |
4090 ASSERT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); | 4067 ASSERT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); |
4091 | 4068 |
4092 // Make the fake SCTP transport pretend it received an OPEN message. | 4069 // Make the fake SCTP transport pretend it received an OPEN message. |
4093 webrtc::DataChannelInit config; | 4070 webrtc::DataChannelInit config; |
4094 config.id = 1; | 4071 config.id = 1; |
4095 rtc::CopyOnWriteBuffer payload; | 4072 rtc::CopyOnWriteBuffer payload; |
(...skipping 19 matching lines...) Expand all Loading... |
4115 Init(); | 4092 Init(); |
4116 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); | 4093 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); |
4117 | 4094 |
4118 EXPECT_EQ(session_->certificate_for_testing(), certificate); | 4095 EXPECT_EQ(session_->certificate_for_testing(), certificate); |
4119 } | 4096 } |
4120 | 4097 |
4121 // Verifies that CreateOffer succeeds when CreateOffer is called before async | 4098 // Verifies that CreateOffer succeeds when CreateOffer is called before async |
4122 // identity generation is finished (even if a certificate is provided this is | 4099 // identity generation is finished (even if a certificate is provided this is |
4123 // an async op). | 4100 // an async op). |
4124 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { | 4101 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { |
4125 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4126 InitWithDtls(GetParam()); | 4102 InitWithDtls(GetParam()); |
4127 | 4103 |
4128 EXPECT_TRUE(session_->waiting_for_certificate_for_testing()); | 4104 EXPECT_TRUE(session_->waiting_for_certificate_for_testing()); |
4129 SendAudioVideoStream1(); | 4105 SendAudioVideoStream1(); |
4130 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 4106 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
4131 | 4107 |
4132 EXPECT_TRUE(offer != NULL); | 4108 EXPECT_TRUE(offer != NULL); |
4133 VerifyNoCryptoParams(offer->description(), true); | 4109 VerifyNoCryptoParams(offer->description(), true); |
4134 VerifyFingerprintStatus(offer->description(), true); | 4110 VerifyFingerprintStatus(offer->description(), true); |
4135 } | 4111 } |
4136 | 4112 |
4137 // Verifies that CreateAnswer succeeds when CreateOffer is called before async | 4113 // Verifies that CreateAnswer succeeds when CreateOffer is called before async |
4138 // identity generation is finished (even if a certificate is provided this is | 4114 // identity generation is finished (even if a certificate is provided this is |
4139 // an async op). | 4115 // an async op). |
4140 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { | 4116 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { |
4141 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4142 InitWithDtls(GetParam()); | 4117 InitWithDtls(GetParam()); |
4143 SetFactoryDtlsSrtp(); | 4118 SetFactoryDtlsSrtp(); |
4144 | 4119 |
4145 cricket::MediaSessionOptions options; | 4120 cricket::MediaSessionOptions options; |
4146 options.recv_video = true; | 4121 options.recv_video = true; |
4147 std::unique_ptr<JsepSessionDescription> offer( | 4122 std::unique_ptr<JsepSessionDescription> offer( |
4148 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 4123 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
4149 ASSERT_TRUE(offer.get() != NULL); | 4124 ASSERT_TRUE(offer.get() != NULL); |
4150 SetRemoteDescriptionWithoutError(offer.release()); | 4125 SetRemoteDescriptionWithoutError(offer.release()); |
4151 | 4126 |
4152 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 4127 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
4153 EXPECT_TRUE(answer != NULL); | 4128 EXPECT_TRUE(answer != NULL); |
4154 VerifyNoCryptoParams(answer->description(), true); | 4129 VerifyNoCryptoParams(answer->description(), true); |
4155 VerifyFingerprintStatus(answer->description(), true); | 4130 VerifyFingerprintStatus(answer->description(), true); |
4156 } | 4131 } |
4157 | 4132 |
4158 // Verifies that CreateOffer succeeds when CreateOffer is called after async | 4133 // Verifies that CreateOffer succeeds when CreateOffer is called after async |
4159 // identity generation is finished (even if a certificate is provided this is | 4134 // identity generation is finished (even if a certificate is provided this is |
4160 // an async op). | 4135 // an async op). |
4161 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { | 4136 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { |
4162 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4163 InitWithDtls(GetParam()); | 4137 InitWithDtls(GetParam()); |
4164 | 4138 |
4165 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); | 4139 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); |
4166 | 4140 |
4167 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 4141 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
4168 EXPECT_TRUE(offer != NULL); | 4142 EXPECT_TRUE(offer != NULL); |
4169 } | 4143 } |
4170 | 4144 |
4171 // Verifies that CreateOffer fails when CreateOffer is called after async | 4145 // Verifies that CreateOffer fails when CreateOffer is called after async |
4172 // identity generation fails. | 4146 // identity generation fails. |
4173 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) { | 4147 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) { |
4174 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4175 InitWithDtlsIdentityGenFail(); | 4148 InitWithDtlsIdentityGenFail(); |
4176 | 4149 |
4177 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); | 4150 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); |
4178 | 4151 |
4179 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 4152 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
4180 EXPECT_TRUE(offer == NULL); | 4153 EXPECT_TRUE(offer == NULL); |
4181 } | 4154 } |
4182 | 4155 |
4183 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made | 4156 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made |
4184 // before async identity generation is finished. | 4157 // before async identity generation is finished. |
4185 TEST_P(WebRtcSessionTest, | 4158 TEST_P(WebRtcSessionTest, |
4186 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { | 4159 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { |
4187 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4188 VerifyMultipleAsyncCreateDescription(GetParam(), | 4160 VerifyMultipleAsyncCreateDescription(GetParam(), |
4189 CreateSessionDescriptionRequest::kOffer); | 4161 CreateSessionDescriptionRequest::kOffer); |
4190 } | 4162 } |
4191 | 4163 |
4192 // Verifies that CreateOffer fails when Multiple CreateOffer calls are made | 4164 // Verifies that CreateOffer fails when Multiple CreateOffer calls are made |
4193 // before async identity generation fails. | 4165 // before async identity generation fails. |
4194 TEST_F(WebRtcSessionTest, | 4166 TEST_F(WebRtcSessionTest, |
4195 TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) { | 4167 TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) { |
4196 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4197 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure( | 4168 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure( |
4198 CreateSessionDescriptionRequest::kOffer); | 4169 CreateSessionDescriptionRequest::kOffer); |
4199 } | 4170 } |
4200 | 4171 |
4201 // Verifies that CreateAnswer succeeds when Multiple CreateAnswer calls are made | 4172 // Verifies that CreateAnswer succeeds when Multiple CreateAnswer calls are made |
4202 // before async identity generation is finished. | 4173 // before async identity generation is finished. |
4203 TEST_P(WebRtcSessionTest, | 4174 TEST_P(WebRtcSessionTest, |
4204 TestMultipleCreateAnswerBeforeIdentityRequestReturnSuccess) { | 4175 TestMultipleCreateAnswerBeforeIdentityRequestReturnSuccess) { |
4205 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4206 VerifyMultipleAsyncCreateDescription( | 4176 VerifyMultipleAsyncCreateDescription( |
4207 GetParam(), CreateSessionDescriptionRequest::kAnswer); | 4177 GetParam(), CreateSessionDescriptionRequest::kAnswer); |
4208 } | 4178 } |
4209 | 4179 |
4210 // Verifies that CreateAnswer fails when Multiple CreateAnswer calls are made | 4180 // Verifies that CreateAnswer fails when Multiple CreateAnswer calls are made |
4211 // before async identity generation fails. | 4181 // before async identity generation fails. |
4212 TEST_F(WebRtcSessionTest, | 4182 TEST_F(WebRtcSessionTest, |
4213 TestMultipleCreateAnswerBeforeIdentityRequestReturnFailure) { | 4183 TestMultipleCreateAnswerBeforeIdentityRequestReturnFailure) { |
4214 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4215 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure( | 4184 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure( |
4216 CreateSessionDescriptionRequest::kAnswer); | 4185 CreateSessionDescriptionRequest::kAnswer); |
4217 } | 4186 } |
4218 | 4187 |
4219 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote | 4188 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote |
4220 // offer has no SDES crypto but only DTLS fingerprint. | 4189 // offer has no SDES crypto but only DTLS fingerprint. |
4221 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { | 4190 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { |
4222 // Init without DTLS. | 4191 // Init without DTLS. |
4223 Init(); | 4192 Init(); |
4224 // Create a remote offer with secured transport disabled. | 4193 // Create a remote offer with secured transport disabled. |
(...skipping 23 matching lines...) Expand all Loading... |
4248 voice_channel_ = media_engine_->GetVoiceChannel(0); | 4217 voice_channel_ = media_engine_->GetVoiceChannel(0); |
4249 | 4218 |
4250 ASSERT_TRUE(voice_channel_ != NULL); | 4219 ASSERT_TRUE(voice_channel_ != NULL); |
4251 const cricket::AudioOptions& audio_options = voice_channel_->options(); | 4220 const cricket::AudioOptions& audio_options = voice_channel_->options(); |
4252 EXPECT_EQ(rtc::Optional<bool>(true), audio_options.combined_audio_video_bwe); | 4221 EXPECT_EQ(rtc::Optional<bool>(true), audio_options.combined_audio_video_bwe); |
4253 } | 4222 } |
4254 | 4223 |
4255 // Tests that we can renegotiate new media content with ICE candidates in the | 4224 // Tests that we can renegotiate new media content with ICE candidates in the |
4256 // new remote SDP. | 4225 // new remote SDP. |
4257 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { | 4226 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { |
4258 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4259 InitWithDtls(GetParam()); | 4227 InitWithDtls(GetParam()); |
4260 SetFactoryDtlsSrtp(); | 4228 SetFactoryDtlsSrtp(); |
4261 | 4229 |
4262 SendAudioOnlyStream2(); | 4230 SendAudioOnlyStream2(); |
4263 SessionDescriptionInterface* offer = CreateOffer(); | 4231 SessionDescriptionInterface* offer = CreateOffer(); |
4264 SetLocalDescriptionWithoutError(offer); | 4232 SetLocalDescriptionWithoutError(offer); |
4265 | 4233 |
4266 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 4234 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
4267 SetRemoteDescriptionWithoutError(answer); | 4235 SetRemoteDescriptionWithoutError(answer); |
4268 | 4236 |
4269 cricket::MediaSessionOptions options; | 4237 cricket::MediaSessionOptions options; |
4270 options.recv_video = true; | 4238 options.recv_video = true; |
4271 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 4239 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
4272 | 4240 |
4273 cricket::Candidate candidate1; | 4241 cricket::Candidate candidate1; |
4274 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); | 4242 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
4275 candidate1.set_component(1); | 4243 candidate1.set_component(1); |
4276 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, | 4244 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
4277 candidate1); | 4245 candidate1); |
4278 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); | 4246 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
4279 SetRemoteDescriptionWithoutError(offer); | 4247 SetRemoteDescriptionWithoutError(offer); |
4280 | 4248 |
4281 answer = CreateAnswer(); | 4249 answer = CreateAnswer(); |
4282 SetLocalDescriptionWithoutError(answer); | 4250 SetLocalDescriptionWithoutError(answer); |
4283 } | 4251 } |
4284 | 4252 |
4285 // Tests that we can renegotiate new media content with ICE candidates separated | 4253 // Tests that we can renegotiate new media content with ICE candidates separated |
4286 // from the remote SDP. | 4254 // from the remote SDP. |
4287 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { | 4255 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { |
4288 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
4289 InitWithDtls(GetParam()); | 4256 InitWithDtls(GetParam()); |
4290 SetFactoryDtlsSrtp(); | 4257 SetFactoryDtlsSrtp(); |
4291 | 4258 |
4292 SendAudioOnlyStream2(); | 4259 SendAudioOnlyStream2(); |
4293 SessionDescriptionInterface* offer = CreateOffer(); | 4260 SessionDescriptionInterface* offer = CreateOffer(); |
4294 SetLocalDescriptionWithoutError(offer); | 4261 SetLocalDescriptionWithoutError(offer); |
4295 | 4262 |
4296 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 4263 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
4297 SetRemoteDescriptionWithoutError(answer); | 4264 SetRemoteDescriptionWithoutError(answer); |
4298 | 4265 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4443 } | 4410 } |
4444 | 4411 |
4445 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4412 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4446 // currently fails because upon disconnection and reconnection OnIceComplete is | 4413 // currently fails because upon disconnection and reconnection OnIceComplete is |
4447 // called more than once without returning to IceGatheringGathering. | 4414 // called more than once without returning to IceGatheringGathering. |
4448 | 4415 |
4449 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4416 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4450 WebRtcSessionTest, | 4417 WebRtcSessionTest, |
4451 testing::Values(ALREADY_GENERATED, | 4418 testing::Values(ALREADY_GENERATED, |
4452 DTLS_IDENTITY_STORE)); | 4419 DTLS_IDENTITY_STORE)); |
OLD | NEW |