Use rtcp::Bye instead of RTCPUtility parser for rtcp_sender_unittest

BUG=webrtc:5565

Review-Url: https://codereview.webrtc.org/2463343002
Cr-Commit-Position: refs/heads/master@{#14876}
This commit is contained in:
danilchap
2016-11-01 06:38:37 -07:00
committed by Commit bot
parent a27172d683
commit b1ed609901

View File

@ -12,8 +12,9 @@
#include "webrtc/base/rate_limiter.h" #include "webrtc/base/rate_limiter.h"
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
#include "webrtc/test/gmock.h" #include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h" #include "webrtc/test/gtest.h"
@ -23,7 +24,6 @@
using ::testing::_; using ::testing::_;
using ::testing::ElementsAre; using ::testing::ElementsAre;
using ::testing::Invoke; using ::testing::Invoke;
using webrtc::RTCPUtility::RtcpCommonHeader;
namespace webrtc { namespace webrtc {
@ -790,17 +790,17 @@ TEST_F(RtcpSenderTest, ByeMustBeLast) {
EXPECT_CALL(mock_transport, SendRtcp(_, _)) EXPECT_CALL(mock_transport, SendRtcp(_, _))
.WillOnce(Invoke([](const uint8_t* data, size_t len) { .WillOnce(Invoke([](const uint8_t* data, size_t len) {
const uint8_t* next_packet = data; const uint8_t* next_packet = data;
while (next_packet < data + len) { const uint8_t* const packet_end = data + len;
RtcpCommonHeader header; rtcp::CommonHeader packet;
RtcpParseCommonHeader(next_packet, len - (next_packet - data), &header); while (next_packet < packet_end) {
next_packet = next_packet + EXPECT_TRUE(packet.Parse(next_packet, packet_end - next_packet));
header.payload_size_bytes + next_packet = packet.NextPacket();
RtcpCommonHeader::kHeaderSizeBytes; if (packet.type() == rtcp::Bye::kPacketType) // Main test expectation.
if (header.packet_type == RTCPUtility::PT_BYE) { EXPECT_EQ(0, packet_end - next_packet)
bool is_last_packet = (data + len == next_packet); << "Bye packet should be last in a compound RTCP packet.";
EXPECT_TRUE(is_last_packet) << if (next_packet == packet_end) // Validate test was set correctly.
"Bye packet should be last in a compound RTCP packet."; EXPECT_EQ(packet.type(), rtcp::Bye::kPacketType)
} << "Last packet in this test expected to be Bye.";
} }
return true; return true;