From 20d4547e5db4b48807e151b61da00aa08bf38068 Mon Sep 17 00:00:00 2001 From: brandtr Date: Mon, 2 Jan 2017 00:34:27 -0800 Subject: [PATCH] Make VideoSendStreamTest.DoesNotUtilizeUlpfecForH264WithNackEnabled useful again. This test was inadvertently made useless in https://codereview.webrtc.org/2558303002/. Prior to that CL, at least 100 media packets -- but no ULPFEC packets -- had to be sent before the test claimed that ULPFEC was not utilized. This CL reinstates that behaviour, but instead of counting packets we expect the test to time out when ULPFEC should not be utilized. This solution is simple in code, but increases the test duration from 70 ms to 10000 ms. Note, however, that the 70 ms duration was for a test that didn't test anything interesting... TESTED=Using gtest-parallel locally: 2000 test runs without flakes. BUG=webrtc:6851 Review-Url: https://codereview.webrtc.org/2592693002 Cr-Commit-Position: refs/heads/master@{#15859} --- webrtc/video/video_send_stream_tests.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/webrtc/video/video_send_stream_tests.cc b/webrtc/video/video_send_stream_tests.cc index b3618dad92..87ee1921fa 100644 --- a/webrtc/video/video_send_stream_tests.cc +++ b/webrtc/video/video_send_stream_tests.cc @@ -358,7 +358,7 @@ class UlpfecObserver : public test::EndToEndTest { bool expect_ulpfec, const std::string& codec, VideoEncoder* encoder) - : EndToEndTest(VideoSendStreamTest::kDefaultTimeoutMs), + : EndToEndTest(kTimeoutMs), encoder_(encoder), payload_name_(codec), use_nack_(use_nack), @@ -368,6 +368,10 @@ class UlpfecObserver : public test::EndToEndTest { sent_ulpfec_(false), header_extensions_enabled_(header_extensions_enabled) {} + // Some of the test cases are expected to time out and thus we are using + // a shorter timeout window than the default here. + static constexpr size_t kTimeoutMs = 10000; + private: Action OnSendRtp(const uint8_t* packet, size_t length) override { RTPHeader header; @@ -421,9 +425,8 @@ class UlpfecObserver : public test::EndToEndTest { } } - if (sent_media_) { - if (sent_ulpfec_ || !expect_ulpfec_) - observation_complete_.Set(); + if (sent_media_ && sent_ulpfec_) { + observation_complete_.Set(); } prev_header_ = header; @@ -474,7 +477,8 @@ class UlpfecObserver : public test::EndToEndTest { } void PerformTest() override { - EXPECT_TRUE(Wait()) << "Timed out waiting for ULPFEC and/or media packets."; + EXPECT_EQ(expect_ulpfec_, Wait()) + << "Timed out waiting for ULPFEC and/or media packets."; } std::unique_ptr transport_adapter_;