Fixing flaky test: WebRtcSessionTest.TestPacketOptionsAndOnPacketSent

The test sent a media packet, then verified it was sent by checking the
"last packet sent"'s ID. But the last packet sent may have been
a STUN packet that came *after* the media packet.

BUG=webrtc:5978

Review-Url: https://codereview.webrtc.org/2071573002
Cr-Commit-Position: refs/heads/master@{#13156}
This commit is contained in:
deadbeef 2016-06-15 11:06:57 -07:00 committed by Commit bot
parent a6219cc3ef
commit 14461d42bc
4 changed files with 14 additions and 4 deletions

View File

@ -6,6 +6,3 @@ PeerConnectionEndToEndTest.*
PeerConnectionInterfaceTest.*
# Issue 3453
WebRtcSessionTest.TestReceiveSdesOfferCreateSdesAnswer
# Flakily fails or crashes on Dr Memory Light.
# Issue 5978
WebRtcSessionTest.TestPacketOptionsAndOnPacketSent

View File

@ -1326,7 +1326,8 @@ class WebRtcSessionTest
->SendRtp(test_packet, sizeof(test_packet), options);
const int kPacketTimeout = 2000;
EXPECT_EQ_WAIT(fake_call_.last_sent_packet().packet_id, 10, kPacketTimeout);
EXPECT_EQ_WAIT(10, fake_call_.last_sent_nonnegative_packet_id(),
kPacketTimeout);
EXPECT_GT(fake_call_.last_sent_packet().send_time_ms, -1);
}

View File

@ -465,5 +465,9 @@ void FakeCall::SignalChannelNetworkState(webrtc::MediaType media,
void FakeCall::OnSentPacket(const rtc::SentPacket& sent_packet) {
last_sent_packet_ = sent_packet;
if (sent_packet.packet_id >= 0) {
last_sent_nonnegative_packet_id_ = sent_packet.packet_id;
}
}
} // namespace cricket

View File

@ -177,6 +177,13 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver {
const FakeAudioReceiveStream* GetAudioReceiveStream(uint32_t ssrc);
rtc::SentPacket last_sent_packet() const { return last_sent_packet_; }
// This is useful if we care about the last media packet (with id populated)
// but not the last ICE packet (with -1 ID).
int last_sent_nonnegative_packet_id() const {
return last_sent_nonnegative_packet_id_;
}
webrtc::NetworkState GetNetworkState(webrtc::MediaType media) const;
int GetNumCreatedSendStreams() const;
int GetNumCreatedReceiveStreams() const;
@ -222,6 +229,7 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver {
webrtc::NetworkState audio_network_state_;
webrtc::NetworkState video_network_state_;
rtc::SentPacket last_sent_packet_;
int last_sent_nonnegative_packet_id_ = -1;
webrtc::Call::Stats stats_;
std::vector<FakeVideoSendStream*> video_send_streams_;
std::vector<FakeAudioSendStream*> audio_send_streams_;