Chromium Code Reviews| Index: webrtc/pc/webrtcsdp_unittest.cc |
| diff --git a/webrtc/pc/webrtcsdp_unittest.cc b/webrtc/pc/webrtcsdp_unittest.cc |
| index f5cac8921f3a3fddadf0672f372ce9f2c4713d1d..75c8a1e419e806ce95d5396c5d17ca5a5dc2890a 100644 |
| --- a/webrtc/pc/webrtcsdp_unittest.cc |
| +++ b/webrtc/pc/webrtcsdp_unittest.cc |
| @@ -92,8 +92,14 @@ static const int kExtmapId = 1; |
| static const char kExtmapUri[] = "http://example.com/082005/ext.htm#ttime"; |
| static const char kExtmap[] = |
| "a=extmap:1 http://example.com/082005/ext.htm#ttime\r\n"; |
| +static const char kExtmapEncrypted[] = |
| + "a=extmap:1 urn:ietf:params:rtp-hdrext:encrypt " |
| + "http://example.com/082005/ext.htm#ttime\r\n"; |
| static const char kExtmapWithDirectionAndAttribute[] = |
| "a=extmap:1/sendrecv http://example.com/082005/ext.htm#ttime a1 a2\r\n"; |
| +static const char kExtmapWithDirectionAndAttributeEncrypted[] = |
| + "a=extmap:1/sendrecv urn:ietf:params:rtp-hdrext:encrypt " |
| + "http://example.com/082005/ext.htm#ttime a1 a2\r\n"; |
| static const uint8_t kIdentityDigest[] = { |
| 0x4A, 0xAD, 0xB9, 0xB1, 0x3F, 0x82, 0x18, 0x3B, 0x54, 0x02, |
| @@ -1210,6 +1216,7 @@ class WebRtcSdpTest : public testing::Test { |
| const RtpExtension ext2 = cd2->rtp_header_extensions().at(i); |
| EXPECT_EQ(ext1.uri, ext2.uri); |
| EXPECT_EQ(ext1.id, ext2.id); |
| + EXPECT_EQ(ext1.encrypted, ext2.encrypted); |
| } |
| } |
| @@ -1431,13 +1438,15 @@ class WebRtcSdpTest : public testing::Test { |
| cricket::CONNECTIONROLE_NONE, &fingerprint)))); |
| } |
| - void AddExtmap() { |
| + void AddExtmap(bool encrypted) { |
| audio_desc_ = static_cast<AudioContentDescription*>( |
| audio_desc_->Copy()); |
| video_desc_ = static_cast<VideoContentDescription*>( |
| video_desc_->Copy()); |
| - audio_desc_->AddRtpHeaderExtension(RtpExtension(kExtmapUri, kExtmapId)); |
| - video_desc_->AddRtpHeaderExtension(RtpExtension(kExtmapUri, kExtmapId)); |
| + audio_desc_->AddRtpHeaderExtension( |
| + RtpExtension(kExtmapUri, kExtmapId, encrypted)); |
| + video_desc_->AddRtpHeaderExtension( |
| + RtpExtension(kExtmapUri, kExtmapId, encrypted)); |
| desc_.RemoveContentByName(kAudioContentName); |
| desc_.RemoveContentByName(kVideoContentName); |
| desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); |
| @@ -1575,8 +1584,9 @@ class WebRtcSdpTest : public testing::Test { |
| return true; |
| } |
| - void TestDeserializeExtmap(bool session_level, bool media_level) { |
| - AddExtmap(); |
| + void TestDeserializeExtmap(bool session_level, bool media_level, |
| + bool encrypted) { |
| + AddExtmap(encrypted); |
| JsepSessionDescription new_jdesc("dummy"); |
| ASSERT_TRUE(new_jdesc.Initialize(desc_.Copy(), |
| jdesc_.session_id(), |
| @@ -1584,13 +1594,19 @@ class WebRtcSdpTest : public testing::Test { |
| JsepSessionDescription jdesc_with_extmap("dummy"); |
| std::string sdp_with_extmap = kSdpString; |
| if (session_level) { |
| - InjectAfter(kSessionTime, kExtmapWithDirectionAndAttribute, |
| + InjectAfter(kSessionTime, |
| + encrypted ? kExtmapWithDirectionAndAttributeEncrypted |
| + : kExtmapWithDirectionAndAttribute, |
| &sdp_with_extmap); |
| } |
| if (media_level) { |
| - InjectAfter(kAttributeIcePwdVoice, kExtmapWithDirectionAndAttribute, |
| + InjectAfter(kAttributeIcePwdVoice, |
| + encrypted ? kExtmapWithDirectionAndAttributeEncrypted |
| + : kExtmapWithDirectionAndAttribute, |
| &sdp_with_extmap); |
| - InjectAfter(kAttributeIcePwdVideo, kExtmapWithDirectionAndAttribute, |
| + InjectAfter(kAttributeIcePwdVideo, |
| + encrypted ? kExtmapWithDirectionAndAttributeEncrypted |
| + : kExtmapWithDirectionAndAttribute, |
| &sdp_with_extmap); |
| } |
| // The extmap can't be present at the same time in both session level and |
| @@ -2129,7 +2145,8 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { |
| } |
| TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { |
| - AddExtmap(); |
| + bool encrypted = false; |
| + AddExtmap(encrypted); |
| JsepSessionDescription desc_with_extmap("dummy"); |
| ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(), |
| kSessionId, kSessionVersion)); |
| @@ -2144,6 +2161,23 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { |
| EXPECT_EQ(sdp_with_extmap, message); |
| } |
| +TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmapEncrypted) { |
| + bool encrypted = true; |
| + AddExtmap(encrypted); |
| + JsepSessionDescription desc_with_extmap("dummy"); |
| + ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(), |
| + kSessionId, kSessionVersion)); |
| + std::string message = webrtc::SdpSerialize(desc_with_extmap, false); |
| + |
| + std::string sdp_with_extmap = kSdpString; |
| + InjectAfter("a=mid:audio_content_name\r\n", |
| + kExtmapEncrypted, &sdp_with_extmap); |
| + InjectAfter("a=mid:video_content_name\r\n", |
| + kExtmapEncrypted, &sdp_with_extmap); |
| + |
| + EXPECT_EQ(sdp_with_extmap, message); |
|
Taylor Brandstetter
2017/03/22 18:00:11
nit: Tests for SDP string equality are fragile sin
joachim
2017/03/23 00:04:34
I based my test on "SerializeSessionDescriptionWit
|
| +} |
| + |
| TEST_F(WebRtcSdpTest, SerializeCandidates) { |
| std::string message = webrtc::SdpSerializeCandidate(*jcandidate_); |
| EXPECT_EQ(std::string(kRawCandidate), message); |
| @@ -2789,18 +2823,32 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsAndBandwidth) { |
| EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_with_bandwidth)); |
| } |
| -TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithSessionLevelExtmap) { |
| - TestDeserializeExtmap(true, false); |
| +class WebRtcSdpExtmapTest |
| + : public WebRtcSdpTest, public testing::WithParamInterface<bool> { |
| +}; |
| + |
| +TEST_P(WebRtcSdpExtmapTest, |
| + DeserializeSessionDescriptionWithSessionLevelExtmap) { |
| + bool encrypted = GetParam(); |
| + TestDeserializeExtmap(true, false, encrypted); |
| } |
| -TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithMediaLevelExtmap) { |
| - TestDeserializeExtmap(false, true); |
| +TEST_P(WebRtcSdpExtmapTest, |
| + DeserializeSessionDescriptionWithMediaLevelExtmap) { |
| + bool encrypted = GetParam(); |
| + TestDeserializeExtmap(false, true, encrypted); |
| } |
| -TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithInvalidExtmap) { |
| - TestDeserializeExtmap(true, true); |
| +TEST_P(WebRtcSdpExtmapTest, |
| + DeserializeSessionDescriptionWithInvalidExtmap) { |
| + bool encrypted = GetParam(); |
| + TestDeserializeExtmap(true, true, encrypted); |
| } |
| +INSTANTIATE_TEST_CASE_P(Encrypted, |
| + WebRtcSdpExtmapTest, |
| + ::testing::Values(false, true)); |
| + |
| TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutEndLineBreak) { |
| JsepSessionDescription jdesc(kDummyString); |
| std::string sdp = kSdpFullString; |