| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 * This file includes unit tests for the RtcpPacket. | 10 * This file includes unit tests for the RtcpPacket. |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
| 18 #include "webrtc/test/rtcp_packet_parser.h" | 19 #include "webrtc/test/rtcp_packet_parser.h" |
| 19 | 20 |
| 20 using ::testing::ElementsAre; | 21 using ::testing::ElementsAre; |
| 21 | 22 |
| 22 using webrtc::rtcp::App; | 23 using webrtc::rtcp::App; |
| 23 using webrtc::rtcp::Bye; | 24 using webrtc::rtcp::Bye; |
| 24 using webrtc::rtcp::Dlrr; | 25 using webrtc::rtcp::Dlrr; |
| 25 using webrtc::rtcp::Empty; | 26 using webrtc::rtcp::Empty; |
| 26 using webrtc::rtcp::Fir; | 27 using webrtc::rtcp::Fir; |
| 27 using webrtc::rtcp::Nack; | 28 using webrtc::rtcp::Nack; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 rtc::scoped_ptr<RawPacket> packet(sr.Build()); | 565 rtc::scoped_ptr<RawPacket> packet(sr.Build()); |
| 565 RtcpPacketParser parser; | 566 RtcpPacketParser parser; |
| 566 parser.Parse(packet->Buffer(), packet->Length()); | 567 parser.Parse(packet->Buffer(), packet->Length()); |
| 567 EXPECT_EQ(1, parser.sender_report()->num_packets()); | 568 EXPECT_EQ(1, parser.sender_report()->num_packets()); |
| 568 EXPECT_EQ(1, parser.receiver_report()->num_packets()); | 569 EXPECT_EQ(1, parser.receiver_report()->num_packets()); |
| 569 EXPECT_EQ(1, parser.report_block()->num_packets()); | 570 EXPECT_EQ(1, parser.report_block()->num_packets()); |
| 570 EXPECT_EQ(1, parser.bye()->num_packets()); | 571 EXPECT_EQ(1, parser.bye()->num_packets()); |
| 571 EXPECT_EQ(1, parser.fir()->num_packets()); | 572 EXPECT_EQ(1, parser.fir()->num_packets()); |
| 572 } | 573 } |
| 573 | 574 |
| 574 TEST(RtcpPacketTest, Bye) { | |
| 575 Bye bye; | |
| 576 bye.From(kSenderSsrc); | |
| 577 | |
| 578 rtc::scoped_ptr<RawPacket> packet(bye.Build()); | |
| 579 RtcpPacketParser parser; | |
| 580 parser.Parse(packet->Buffer(), packet->Length()); | |
| 581 EXPECT_EQ(1, parser.bye()->num_packets()); | |
| 582 EXPECT_EQ(kSenderSsrc, parser.bye()->Ssrc()); | |
| 583 } | |
| 584 | |
| 585 TEST(RtcpPacketTest, ByeWithCsrcs) { | |
| 586 Fir fir; | |
| 587 Bye bye; | |
| 588 bye.From(kSenderSsrc); | |
| 589 EXPECT_TRUE(bye.WithCsrc(0x22222222)); | |
| 590 EXPECT_TRUE(bye.WithCsrc(0x33333333)); | |
| 591 bye.Append(&fir); | |
| 592 | |
| 593 rtc::scoped_ptr<RawPacket> packet(bye.Build()); | |
| 594 RtcpPacketParser parser; | |
| 595 parser.Parse(packet->Buffer(), packet->Length()); | |
| 596 EXPECT_EQ(1, parser.bye()->num_packets()); | |
| 597 EXPECT_EQ(kSenderSsrc, parser.bye()->Ssrc()); | |
| 598 EXPECT_EQ(1, parser.fir()->num_packets()); | |
| 599 } | |
| 600 | |
| 601 TEST(RtcpPacketTest, ByeWithTooManyCsrcs) { | |
| 602 Bye bye; | |
| 603 bye.From(kSenderSsrc); | |
| 604 const int kMaxCsrcs = (1 << 5) - 2; // 5 bit len, first item is sender SSRC. | |
| 605 for (int i = 0; i < kMaxCsrcs; ++i) { | |
| 606 EXPECT_TRUE(bye.WithCsrc(i)); | |
| 607 } | |
| 608 EXPECT_FALSE(bye.WithCsrc(kMaxCsrcs)); | |
| 609 } | |
| 610 | |
| 611 TEST(RtcpPacketTest, BuildWithInputBuffer) { | 575 TEST(RtcpPacketTest, BuildWithInputBuffer) { |
| 612 Fir fir; | 576 Fir fir; |
| 613 ReportBlock rb; | 577 ReportBlock rb; |
| 614 ReceiverReport rr; | 578 ReceiverReport rr; |
| 615 rr.From(kSenderSsrc); | 579 rr.From(kSenderSsrc); |
| 616 EXPECT_TRUE(rr.WithReportBlock(rb)); | 580 EXPECT_TRUE(rr.WithReportBlock(rb)); |
| 617 rr.Append(&fir); | 581 rr.Append(&fir); |
| 618 | 582 |
| 619 const size_t kRrLength = 8; | 583 const size_t kRrLength = 8; |
| 620 const size_t kReportBlockLength = 24; | 584 const size_t kReportBlockLength = 24; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 EXPECT_TRUE(xr.WithDlrr(&dlrr)); | 999 EXPECT_TRUE(xr.WithDlrr(&dlrr)); |
| 1036 EXPECT_FALSE(xr.WithDlrr(&dlrr)); | 1000 EXPECT_FALSE(xr.WithDlrr(&dlrr)); |
| 1037 | 1001 |
| 1038 VoipMetric voip_metric; | 1002 VoipMetric voip_metric; |
| 1039 for (int i = 0; i < kMaxBlocks; ++i) | 1003 for (int i = 0; i < kMaxBlocks; ++i) |
| 1040 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); | 1004 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); |
| 1041 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); | 1005 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); |
| 1042 } | 1006 } |
| 1043 | 1007 |
| 1044 } // namespace webrtc | 1008 } // namespace webrtc |
| OLD | NEW |