Fix for flaky test: VideoSendStreamTest.RtcpSenderReportContainsMediaBytesSent.

Only compare media bytes sent if number of sent packets in rtcp packet are equal to sent rtp packets.

BUG=4327
R=pbos@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/34299004

Cr-Commit-Position: refs/heads/master@{#8454}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8454 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
asapersson@webrtc.org 2015-02-23 08:14:07 +00:00
parent 50e28166af
commit 1467421646

View File

@ -1423,14 +1423,17 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
}
TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) {
class RtcpByeTest : public test::SendTest {
class RtcpSenderReportTest : public test::SendTest {
public:
RtcpByeTest() : SendTest(kDefaultTimeoutMs), media_bytes_sent_(0) {}
RtcpSenderReportTest() : SendTest(kDefaultTimeoutMs),
rtp_packets_sent_(0),
media_bytes_sent_(0) {}
private:
virtual Action OnSendRtp(const uint8_t* packet, size_t length) OVERRIDE {
RTPHeader header;
EXPECT_TRUE(parser_->Parse(packet, length, &header));
++rtp_packets_sent_;
media_bytes_sent_ += length - header.headerLength - header.paddingLength;
return SEND_PACKET;
}
@ -1440,15 +1443,17 @@ TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) {
EXPECT_TRUE(parser.IsValid());
RTCPUtility::RTCPPacketTypes packet_type = parser.Begin();
uint32_t sender_octet_count = 0;
while (packet_type != RTCPUtility::kRtcpNotValidCode) {
if (packet_type == RTCPUtility::kRtcpSrCode) {
sender_octet_count = parser.Packet().SR.SenderOctetCount;
EXPECT_EQ(sender_octet_count, media_bytes_sent_);
if (sender_octet_count > 0)
// Only compare sent media bytes if SenderPacketCount matches the
// number of sent rtp packets (a new rtp packet could be sent before
// the rtcp packet).
if (parser.Packet().SR.SenderOctetCount > 0 &&
parser.Packet().SR.SenderPacketCount == rtp_packets_sent_) {
EXPECT_EQ(media_bytes_sent_, parser.Packet().SR.SenderOctetCount);
observation_complete_->Set();
}
}
packet_type = parser.Iterate();
}
@ -1460,6 +1465,7 @@ TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) {
<< "Timed out while waiting for RTCP sender report.";
}
size_t rtp_packets_sent_;
size_t media_bytes_sent_;
} test;