Bug 1438290: Part 2: Added testcases for AddDataChannel, r=bwc
authorJohannes Willbold <j.willbold@mozilla.com>
Thu, 21 Jun 2018 15:48:55 -0700
changeset 423998 afd967c185fe7801bd6786e149ae77d2a28ce8f2
parent 423997 d41ad8a48d4540c0bd9d99a6e5018cfade417151
child 423999 b8ebfd75f50124e4f957e1171a5ec79bfee210fc
push id34197
push usercsabou@mozilla.com
push dateThu, 28 Jun 2018 09:44:02 +0000
treeherdermozilla-central@db455160668d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1438290
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1438290: Part 2: Added testcases for AddDataChannel, r=bwc Added C++ unit test CheckAddDataChannel Added C++ unit test CheckAddDataChannel_Draft05 MozReview-Commit-ID: HsSdFb0nKUe
media/webrtc/signaling/gtest/sdp_unittests.cpp
media/webrtc/signaling/src/sdp/RsdparsaSdpAttributeList.cpp
media/webrtc/signaling/src/sdp/RsdparsaSdpInc.h
media/webrtc/signaling/src/sdp/rsdparsa_capi/src/attribute.rs
--- a/media/webrtc/signaling/gtest/sdp_unittests.cpp
+++ b/media/webrtc/signaling/gtest/sdp_unittests.cpp
@@ -4060,16 +4060,85 @@ TEST_P(NewSdpTest, CheckAddMediaSection)
                           SdpDirectionAttribute::Direction::kSendonly,
                           14006, SdpMediaSection::kTcpTlsRtpSavpf, sdp::kIPv6,
                           "NOT:AN.IP.ADDRESS");
     ASSERT_EQ(5U, mSdp->GetMediaSectionCount())
       << "Wrong number of media sections after adding media section";
   }
 }
 
+TEST_P(NewSdpTest, CheckAddDataChannel_Draft05) {
+  // Parse any valid sdp with a media section
+  ParseSdp("v=0" CRLF
+           "o=- 4294967296 2 IN IP4 127.0.0.1" CRLF
+           "s=SIP Call" CRLF
+           "c=IN IP4 198.51.100.7" CRLF
+           "b=CT:5000" CRLF
+           "t=0 0" CRLF
+           "m=application 56436 DTLS/SCTP 5000" CRLF);
+
+  ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
+  ASSERT_EQ(1U, mSdp->GetMediaSectionCount());
+
+  auto& mediaSection = mSdp->GetMediaSection(0);
+  mediaSection.AddDataChannel("webrtc-datachannel", 6000, 16, 0);
+
+  ASSERT_FALSE(mediaSection.GetAttributeList().
+              HasAttribute(SdpAttribute::kMaxMessageSizeAttribute));
+  ASSERT_TRUE(mediaSection.GetAttributeList().
+              HasAttribute(SdpAttribute::kSctpmapAttribute));
+  ASSERT_TRUE(mediaSection.GetAttributeList().GetSctpmap().HasEntry("6000"));
+  ASSERT_EQ(16U, mediaSection.GetAttributeList().
+                 GetSctpmap().GetFirstEntry().streams);
+  ASSERT_EQ("webrtc-datachannel", mediaSection.GetAttributeList().
+                                  GetSctpmap().GetFirstEntry().name);
+
+  mediaSection.AddDataChannel("webrtc-datachannel", 15000, 8, 1800);
+
+  ASSERT_TRUE(mediaSection.GetAttributeList().
+              HasAttribute(SdpAttribute::kMaxMessageSizeAttribute));
+  ASSERT_EQ(1800U, mediaSection.GetAttributeList().GetMaxMessageSize());
+  ASSERT_TRUE(mediaSection.GetAttributeList().
+              HasAttribute(SdpAttribute::kSctpmapAttribute));
+  ASSERT_TRUE(mediaSection.GetAttributeList().GetSctpmap().HasEntry("15000"));
+  ASSERT_EQ(8U, mediaSection.GetAttributeList().
+                GetSctpmap().GetFirstEntry().streams);
+}
+
+TEST_P(NewSdpTest, CheckAddDataChannel) {
+  ParseSdp("v=0" CRLF
+           "o=- 4294967296 2 IN IP4 127.0.0.1" CRLF
+           "s=SIP Call" CRLF
+           "c=IN IP4 198.51.100.7" CRLF
+           "b=CT:5000" CRLF
+           "t=0 0" CRLF
+           "m=application 56436 UDP/DTLS/SCTP webrtc-datachannel" CRLF);
+
+  ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
+  ASSERT_EQ(1U, mSdp->GetMediaSectionCount());
+
+  auto& mediaSection = mSdp->GetMediaSection(0);
+  mediaSection.AddDataChannel("webrtc-datachannel", 6000, 16, 0);
+
+  ASSERT_FALSE(mediaSection.GetAttributeList().
+              HasAttribute(SdpAttribute::kMaxMessageSizeAttribute));
+  ASSERT_TRUE(mediaSection.GetAttributeList().
+              HasAttribute(SdpAttribute::kSctpPortAttribute));
+  ASSERT_EQ(6000U, mediaSection.GetAttributeList().GetSctpPort());
+
+  mediaSection.AddDataChannel("webrtc-datachannel", 15000, 8, 1800);
+
+  ASSERT_TRUE(mediaSection.GetAttributeList().
+              HasAttribute(SdpAttribute::kMaxMessageSizeAttribute));
+  ASSERT_EQ(1800U, mediaSection.GetAttributeList().GetMaxMessageSize());
+  ASSERT_TRUE(mediaSection.GetAttributeList().
+              HasAttribute(SdpAttribute::kSctpPortAttribute));
+  ASSERT_EQ(15000U, mediaSection.GetAttributeList().GetSctpPort());
+}
+
 TEST(NewSdpTestNoFixture, CheckAttributeTypeSerialize) {
   for (auto a = static_cast<size_t>(SdpAttribute::kFirstAttribute);
        a <= static_cast<size_t>(SdpAttribute::kLastAttribute);
        ++a) {
 
     SdpAttribute::AttributeType type =
       static_cast<SdpAttribute::AttributeType>(a);
 
--- a/media/webrtc/signaling/src/sdp/RsdparsaSdpAttributeList.cpp
+++ b/media/webrtc/signaling/src/sdp/RsdparsaSdpAttributeList.cpp
@@ -811,17 +811,17 @@ RsdparsaSdpAttributeList::LoadFlags(Rust
   if (flags.endOfCandidates) {
     SetAttribute(new SdpFlagAttribute(SdpAttribute::kEndOfCandidatesAttribute));
   }
 }
 
 void
 RsdparsaSdpAttributeList::LoadMaxMessageSize(RustAttributeList* attributeList)
 {
-  int64_t max_msg_size = sdp_get_max_msg_sizse(attributeList);
+  int64_t max_msg_size = sdp_get_max_msg_size(attributeList);
   if (max_msg_size >= 0) {
     SetAttribute(new SdpNumberAttribute(SdpAttribute::kMaxMessageSizeAttribute,
                                         static_cast<uint32_t>(max_msg_size)));
   }
 }
 
 void
 RsdparsaSdpAttributeList::LoadMid(RustAttributeList* attributeList)
--- a/media/webrtc/signaling/src/sdp/RsdparsaSdpInc.h
+++ b/media/webrtc/signaling/src/sdp/RsdparsaSdpInc.h
@@ -328,17 +328,17 @@ size_t sdp_get_rtpmap_count(const RustAt
 void sdp_get_rtpmaps(const RustAttributeList* aList, size_t listSize,
                      RustSdpAttributeRtpmap* ret);
 
 size_t sdp_get_fmtp_count(const RustAttributeList* aList);
 size_t sdp_get_fmtp(const RustAttributeList* aList, size_t listSize,
                     RustSdpAttributeFmtp* ret);
 
 int64_t sdp_get_ptime(const RustAttributeList* aList);
-int64_t sdp_get_max_msg_sizse(const RustAttributeList* aList);
+int64_t sdp_get_max_msg_size(const RustAttributeList* aList);
 int64_t sdp_get_sctp_port(const RustAttributeList* aList);
 
 RustSdpAttributeFlags sdp_get_attribute_flags(const RustAttributeList* aList);
 
 nsresult sdp_get_mid(const RustAttributeList* aList, StringView* ret);
 
 size_t sdp_get_msid_count(const RustAttributeList* aList);
 void sdp_get_msids(const RustAttributeList* aList, size_t listSize,
--- a/media/webrtc/signaling/src/sdp/rsdparsa_capi/src/attribute.rs
+++ b/media/webrtc/signaling/src/sdp/rsdparsa_capi/src/attribute.rs
@@ -435,17 +435,17 @@ pub unsafe extern "C" fn sdp_get_ptime(a
         if let SdpAttribute::Ptime(time) = *attribute {
             return time as int64_t;
         }
     }
     -1
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn sdp_get_max_msg_sizse(attributes: *const Vec<SdpAttribute>) -> int64_t {
+pub unsafe extern "C" fn sdp_get_max_msg_size(attributes: *const Vec<SdpAttribute>) -> int64_t {
     for attribute in (*attributes).iter() {
         if let SdpAttribute::MaxMessageSize(max_msg_size) = *attribute {
             return max_msg_size as int64_t;
         }
     }
     -1
 }