Bug 880067 - Part 2: Finish SDP Unit Tests r=ehugg
authorAdam Roach [:abr] <adam@nostrum.com>
Thu, 22 Aug 2013 13:18:38 -0500
changeset 144085 1916191a311c99a476a4695f136ecc2ac805c804
parent 144084 c6a15f08e51eb97d3d70fd49f61ca592d4bd2ade
child 144086 610f5f410e3bedb02a4798a4aba1f8daa417b298
push id32857
push useradam@nostrum.com
push dateFri, 23 Aug 2013 15:14:21 +0000
treeherdermozilla-inbound@610f5f410e3b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehugg
bugs880067
milestone26.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 880067 - Part 2: Finish SDP Unit Tests r=ehugg
media/webrtc/signaling/test/sdp_unittests.cpp
--- a/media/webrtc/signaling/test/sdp_unittests.cpp
+++ b/media/webrtc/signaling/test/sdp_unittests.cpp
@@ -162,17 +162,17 @@ class SdpTest : public ::testing::Test {
       u16 inst_num = 0;
       EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_RTCP_FB,
                                  &inst_num), SDP_SUCCESS);
       EXPECT_EQ(sdp_attr_set_rtcp_fb_nack(sdp_ptr_, level, payload, inst_num,
                                           type), SDP_SUCCESS);
       return inst_num;
     }
 
-    u16 AddNewRtcpTrrInt(int level, u32 interval,
+    u16 AddNewRtcpFbTrrInt(int level, u32 interval,
                          u16 payload = SDP_ALL_PAYLOADS) {
       u16 inst_num = 0;
       EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_RTCP_FB,
                                  &inst_num), SDP_SUCCESS);
       EXPECT_EQ(sdp_attr_set_rtcp_fb_trr_int(sdp_ptr_, level, payload, inst_num,
                                              interval), SDP_SUCCESS);
       return inst_num;
     }
@@ -417,21 +417,47 @@ TEST_F(SdpTest, parseRtcpFbKitchenSink) 
   ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 6),
             SDP_RTCP_FB_CCM_UNKNOWN);
   ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 7),
             SDP_RTCP_FB_CCM_UNKNOWN);
   ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 8),
             SDP_RTCP_FB_CCM_NOT_FOUND);
 }
 
+TEST_F(SdpTest, addRtcpFbAckRpsi) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbAck(level, SDP_RTCP_FB_ACK_RPSI, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 ack rpsi\r\n"), std::string::npos);
+}
 
-/* TODO (abr@mozilla.com) These attribute adding test cases definitely need
-   beefing up; for now, I'm testing the two use cases that we know
-   we need right now.  An exhaustive check of the various permutations
-   will look similar to the parsing tests, above */
+TEST_F(SdpTest, addRtcpFbAckRpsiAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbAck(level, SDP_RTCP_FB_ACK_RPSI);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* ack rpsi\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbAckApp) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbAck(level, SDP_RTCP_FB_ACK_APP, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 ack app\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbAckAppAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbAck(level, SDP_RTCP_FB_ACK_APP);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* ack app\r\n"), std::string::npos);
+}
 
 TEST_F(SdpTest, addRtcpFbNack) {
   InitLocalSdp();
   int level = AddNewMedia(SDP_MEDIA_VIDEO);
   AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_UNSPECIFIED, 120);
   std::string body = SerializeSdp();
   ASSERT_NE(body.find("a=rtcp-fb:120 nack\r\n"), std::string::npos);
 }
@@ -439,16 +465,159 @@ TEST_F(SdpTest, addRtcpFbNack) {
 TEST_F(SdpTest, addRtcpFbNackAllPt) {
   InitLocalSdp();
   int level = AddNewMedia(SDP_MEDIA_VIDEO);
   AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_UNSPECIFIED);
   std::string body = SerializeSdp();
   ASSERT_NE(body.find("a=rtcp-fb:* nack\r\n"), std::string::npos);
 }
 
+TEST_F(SdpTest, addRtcpFbNackSli) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_SLI, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 nack sli\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackSliAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_SLI);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* nack sli\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackPli) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_PLI, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 nack pli\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackPliAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_PLI);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* nack pli\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackRpsi) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_RPSI, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 nack rpsi\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackRpsiAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_RPSI);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* nack rpsi\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackApp) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_APP, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 nack app\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackAppAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_APP);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* nack app\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackRai) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_RAI, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 nack rai\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackRaiAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_RAI);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* nack rai\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackTllei) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_TLLEI, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 nack tllei\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackTlleiAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_TLLEI);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* nack tllei\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackPslei) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_PSLEI, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 nack pslei\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackPsleiAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_PSLEI);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* nack pslei\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackEcn) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_ECN, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 nack ecn\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackEcnAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_ECN);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* nack ecn\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbTrrInt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbTrrInt(level, 12345, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 trr-int 12345\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbNackTrrIntAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbTrrInt(level, 0);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* trr-int 0\r\n"), std::string::npos);
+}
 
 TEST_F(SdpTest, addRtcpFbCcmFir) {
   InitLocalSdp();
   int level = AddNewMedia(SDP_MEDIA_VIDEO);
   AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_FIR, 120);
   std::string body = SerializeSdp();
   ASSERT_NE(body.find("a=rtcp-fb:120 ccm fir\r\n"), std::string::npos);
 }
@@ -456,17 +625,71 @@ TEST_F(SdpTest, addRtcpFbCcmFir) {
 TEST_F(SdpTest, addRtcpFbCcmFirAllPt) {
   InitLocalSdp();
   int level = AddNewMedia(SDP_MEDIA_VIDEO);
   AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_FIR);
   std::string body = SerializeSdp();
   ASSERT_NE(body.find("a=rtcp-fb:* ccm fir\r\n"), std::string::npos);
 }
 
-/* TODO We need to test the pt=* use cases. */
+TEST_F(SdpTest, addRtcpFbCcmTmmbr) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_TMMBR, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 ccm tmmbr\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbCcmTmmbrAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_TMMBR);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* ccm tmmbr\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbCcmTstr) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_TSTR, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 ccm tstr\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbCcmTstrAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_TSTR);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* ccm tstr\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbCcmVbcm) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_VBCM, 120);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:120 ccm vbcm\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, addRtcpFbCcmVbcmAllPt) {
+  InitLocalSdp();
+  int level = AddNewMedia(SDP_MEDIA_VIDEO);
+  AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_VBCM);
+  std::string body = SerializeSdp();
+  ASSERT_NE(body.find("a=rtcp-fb:* ccm vbcm\r\n"), std::string::npos);
+}
+
+TEST_F(SdpTest, parseRtcpFbAllPayloads) {
+  ParseSdp(kVideoSdp + "a=rtcp-fb:* ack rpsi\r\n");
+  for (int i = 0; i < 128; i++) {
+    ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, i, 1),
+              SDP_RTCP_FB_ACK_RPSI);
+  }
+}
 
 } // End namespace test.
 
 int main(int argc, char **argv) {
   test_utils = new MtransportTestUtils();
   NSS_NoDB_Init(NULL);
   NSS_SetDomesticPolicy();