Add test against crashes in VideoQualityObserver

If there were a lot of pauses in the receive video stream, it may've
caused a crash because of a null rtc::Optional dereferencing.

This is the test reproducing that behaviour.

Bug: webrtc:9338
Change-Id: I1cef72a88a54f762ef27665d372e4a1d1225e059
Reviewed-on: https://webrtc-review.googlesource.com/80161
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23470}
This commit is contained in:
Ilya Nikolaevskiy
2018-05-31 09:47:17 +02:00
committed by Commit Bot
parent 0cedc054a2
commit 879f5a34a5

View File

@ -1046,6 +1046,33 @@ TEST_P(ReceiveStatisticsProxyTest, PausesAreIgnored) {
} }
} }
TEST_P(ReceiveStatisticsProxyTest, ManyPausesAtTheBeginning) {
const VideoContentType content_type = GetParam();
const int kInterFrameDelayMs = 33;
const int kPauseDurationMs = 10000;
for (int i = 0; i <= kMinRequiredSamples; ++i) {
statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight,
content_type);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
statistics_proxy_->OnStreamInactive();
fake_clock_.AdvanceTimeMilliseconds(kPauseDurationMs);
statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight,
content_type);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
statistics_proxy_.reset();
// No freezes should be detected, as all long inter-frame delays were pauses.
if (videocontenttypehelpers::IsScreenshare(content_type)) {
EXPECT_EQ(-1, metrics::MinSample(
"WebRTC.Video.Screenshare.MeanFreezeDurationMs"));
} else {
EXPECT_EQ(-1, metrics::MinSample("WebRTC.Video.MeanFreezeDurationMs"));
}
}
TEST_P(ReceiveStatisticsProxyTest, TimeInHdReported) { TEST_P(ReceiveStatisticsProxyTest, TimeInHdReported) {
const VideoContentType content_type = GetParam(); const VideoContentType content_type = GetParam();
const int kInterFrameDelayMs = 20; const int kInterFrameDelayMs = 20;