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