From fa73a2ed7920883f2da82d8c540dd0a6fa1ab810 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Mon, 20 Jan 2025 10:18:53 +0000 Subject: [PATCH] Convert timeouts in integration_test_helpers to TimeDelta Bug: webrtc:42223979 Change-Id: Ia77b34c5c30a32fcb520359b993ff0b976be378c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/374880 Commit-Queue: Evan Shrubsole Auto-Submit: Evan Shrubsole Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#43771} --- pc/data_channel_integrationtest.cc | 2 +- pc/peer_connection_histogram_unittest.cc | 11 +- pc/peer_connection_integrationtest.cc | 134 ++++++++------------ pc/sdp_offer_answer_unittest.cc | 19 ++- pc/slow_peer_connection_integration_test.cc | 19 +-- pc/test/integration_test_helpers.h | 38 +++--- 6 files changed, 93 insertions(+), 130 deletions(-) diff --git a/pc/data_channel_integrationtest.cc b/pc/data_channel_integrationtest.cc index d4d559ae6d..e7af1bf4bf 100644 --- a/pc/data_channel_integrationtest.cc +++ b/pc/data_channel_integrationtest.cc @@ -362,7 +362,7 @@ TEST_P(DataChannelIntegrationTest, EndToEndCallWithSctpDataChannelFullBuffer) { // heavily parallelized runs. EXPECT_THAT(WaitUntil([&] { return caller()->data_observer()->state(); }, Eq(DataChannelInterface::DataState::kClosed), - {.timeout = webrtc::TimeDelta::Millis(kLongTimeout)}), + {.timeout = kLongTimeout}), IsRtcOk()); EXPECT_THAT(caller()->data_observer()->states(), ::testing::ElementsAreArray(expected_states)); diff --git a/pc/peer_connection_histogram_unittest.cc b/pc/peer_connection_histogram_unittest.cc index d1e6ccb530..914124670a 100644 --- a/pc/peer_connection_histogram_unittest.cc +++ b/pc/peer_connection_histogram_unittest.cc @@ -55,7 +55,8 @@ using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; using ::testing::NiceMock; static const char kUsagePatternMetric[] = "WebRTC.PeerConnection.UsagePattern"; -static constexpr int kDefaultTimeout = 10000; +static constexpr webrtc::TimeDelta kDefaultTimeout = + webrtc::TimeDelta::Millis(10000); static const rtc::SocketAddress kLocalAddrs[2] = { rtc::SocketAddress("1.1.1.1", 0), rtc::SocketAddress("2.2.2.2", 0)}; static const rtc::SocketAddress kPrivateLocalAddress("10.1.1.1", 0); @@ -185,12 +186,12 @@ class PeerConnectionWrapperForUsageHistogramTest return false; } // Wait until the gathering completes before we signal the candidate. - WAIT(observer()->ice_gathering_complete_, kDefaultTimeout); - WAIT(callee->observer()->ice_gathering_complete_, kDefaultTimeout); + WAIT(observer()->ice_gathering_complete_, kDefaultTimeout.ms()); + WAIT(callee->observer()->ice_gathering_complete_, kDefaultTimeout.ms()); AddBufferedIceCandidates(); callee->AddBufferedIceCandidates(); - WAIT(IsConnected(), kDefaultTimeout); - WAIT(callee->IsConnected(), kDefaultTimeout); + WAIT(IsConnected(), kDefaultTimeout.ms()); + WAIT(callee->IsConnected(), kDefaultTimeout.ms()); return IsConnected() && callee->IsConnected(); } diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index bdc7e662cd..7b6517c9e4 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc @@ -177,8 +177,7 @@ TEST_P(PeerConnectionIntegrationTest, return o->first_packet_received(); }); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT(WaitUntil( [&] { @@ -188,8 +187,7 @@ TEST_P(PeerConnectionIntegrationTest, return o->first_packet_received(); }); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // If new observers are set after the first packet was already received, the // callback should still be invoked. @@ -231,8 +229,7 @@ TEST_P(PeerConnectionIntegrationTest, RtpSenderObserverOnFirstPacketSent) { return o->first_packet_sent(); }); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT(WaitUntil( [&] { @@ -242,8 +239,7 @@ TEST_P(PeerConnectionIntegrationTest, RtpSenderObserverOnFirstPacketSent) { return o->first_packet_sent(); }); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // If new observers are set after the first packet was already sent, the // callback should still be invoked. @@ -396,8 +392,7 @@ TEST_P(PeerConnectionIntegrationTest, 0 && callee()->min_video_frames_received_per_track() > 0; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Check rendered aspect ratio. @@ -764,8 +759,7 @@ TEST_P(PeerConnectionIntegrationTest, RotatedVideoWithCVOExtension) { 0 && callee()->min_video_frames_received_per_track() > 0; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Ensure that the aspect ratio is unmodified. @@ -809,8 +803,7 @@ TEST_P(PeerConnectionIntegrationTest, RotatedVideoWithoutCVOExtension) { 0 && callee()->min_video_frames_received_per_track() > 0; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Expect that the aspect ratio is inversed to account for the 90/270 degree @@ -995,9 +988,8 @@ TEST_P(PeerConnectionIntegrationTest, VideoRejectedInSubsequentOffer) { } caller()->CreateAndSetAndSignalOffer(); ASSERT_THAT( - WaitUntil( - [&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}), + WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), + {.timeout = kMaxWaitForActivation}), IsRtcOk()); // Sanity check that the caller's description has a rejected video section. @@ -1388,8 +1380,7 @@ TEST_P(PeerConnectionIntegrationTest, GetAudioOutputLevelStatsWithOldStatsApi) { // until an RTCP packet has been received. EXPECT_THAT( WaitUntil([&] { return callee()->OldGetStats()->AudioOutputLevel(); }, - ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::Gt(0), {.timeout = kMaxWaitForFrames}), IsRtcOk()); } @@ -1410,8 +1401,7 @@ TEST_P(PeerConnectionIntegrationTest, GetAudioInputLevelStatsWithOldStatsApi) { // soon after the test starts. EXPECT_THAT( WaitUntil([&] { return caller()->OldGetStats()->AudioInputLevel(); }, - ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForStatsMs)}), + ::testing::Gt(0), {.timeout = kMaxWaitForStats}), IsRtcOk()); } @@ -1862,12 +1852,12 @@ TEST_P(PeerConnectionIntegrationTest, IceStatesReachCompletion) { EXPECT_THAT( WaitUntil([&] { return caller()->ice_gathering_state(); }, ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT( WaitUntil([&] { return callee()->ice_gathering_state(); }, ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); // After the best candidate pair is selected and all candidates are signaled, // the ICE connection state should reach "complete". @@ -2056,13 +2046,12 @@ TEST_P(PeerConnectionIntegrationIceStatesTestWithFakeClock, // According to RFC7675, if there is no response within 30 seconds then the // peer should consider the other side to have rejected the connection. This // is signaled by the state transitioning to "failed". - constexpr int kConsentTimeout = 30000; + constexpr TimeDelta kConsentTimeout = TimeDelta::Millis(30000); ScopedFakeClock& fake_clock = FakeClock(); ASSERT_THAT( WaitUntil([&] { return caller()->standardized_ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionFailed), - {.timeout = webrtc::TimeDelta::Millis(kConsentTimeout), - .clock = &fake_clock}), + {.timeout = kConsentTimeout, .clock = &fake_clock}), IsRtcOk()); } @@ -2166,12 +2155,12 @@ TEST_P(PeerConnectionIntegrationTest, MediaContinuesFlowingAfterIceRestart) { EXPECT_THAT( WaitUntil([&] { return caller()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT( WaitUntil([&] { return callee()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); // To verify that the ICE restart actually occurs, get @@ -2207,12 +2196,12 @@ TEST_P(PeerConnectionIntegrationTest, MediaContinuesFlowingAfterIceRestart) { EXPECT_THAT( WaitUntil([&] { return caller()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT( WaitUntil([&] { return callee()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Grab the ufrags/candidates again. @@ -2400,20 +2389,19 @@ TEST_F(PeerConnectionIntegrationTestPlanB, callee()->pc()->CreateSender("video", "callee_stream"); caller()->CreateAndSetAndSignalOffer(); ASSERT_THAT( - WaitUntil( - [&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}), + WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), + {.timeout = kMaxWaitForActivation}), IsRtcOk()); // Wait for ICE to complete, without any tracks being set. EXPECT_THAT( WaitUntil([&] { return caller()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT( WaitUntil([&] { return callee()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Now set the tracks, and expect frames to immediately start flowing. EXPECT_TRUE( @@ -2451,20 +2439,19 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, }); caller()->CreateAndSetAndSignalOffer(); ASSERT_THAT( - WaitUntil( - [&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}), + WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), + {.timeout = kMaxWaitForActivation}), IsRtcOk()); // Wait for ICE to complete, without any tracks being set. EXPECT_THAT( WaitUntil([&] { return caller()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT( WaitUntil([&] { return callee()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Now set the tracks, and expect frames to immediately start flowing. auto callee_audio_sender = callee()->pc()->GetSenders()[0]; @@ -2493,9 +2480,8 @@ TEST_F(PeerConnectionIntegrationTestPlanB, CanSendRemoteVideoTrack) { caller()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); ASSERT_THAT( - WaitUntil( - [&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}), + WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), + {.timeout = kMaxWaitForActivation}), IsRtcOk()); ASSERT_EQ(1U, callee()->remote_streams()->count()); @@ -2504,9 +2490,8 @@ TEST_F(PeerConnectionIntegrationTestPlanB, CanSendRemoteVideoTrack) { callee()->pc()->AddStream(callee()->remote_streams()->at(0)); callee()->CreateAndSetAndSignalOffer(); ASSERT_THAT( - WaitUntil( - [&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}), + WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), + {.timeout = kMaxWaitForActivation}), IsRtcOk()); MediaExpectations media_expectations; @@ -2782,7 +2767,7 @@ TEST_P(PeerConnectionIntegrationTest, TCPUsedForTurnConnections) { EXPECT_THAT( WaitUntil([&] { return callee()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); MediaExpectations media_expectations; @@ -3335,10 +3320,9 @@ TEST_P(PeerConnectionIntegrationTest, IsRtcOk()); // Wait for the callee to receive audio stats. - EXPECT_THAT( - WaitUntil([&] { return GetAudioEnergyStat(caller()); }, ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return GetAudioEnergyStat(caller()); }, + ::testing::Gt(0), {.timeout = kMaxWaitForFrames}), + IsRtcOk()); } #endif // !defined(THREAD_SANITIZER) @@ -4559,16 +4543,12 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, ASSERT_THAT( WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), IsRtcOk()); - ASSERT_THAT( - WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, - ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForStatsMs)}), - IsRtcOk()); - ASSERT_THAT( - WaitUntil([&] { return callee()->GetCorruptionScoreCount(); }, - ::testing::Eq(0), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForStatsMs)}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, + ::testing::Gt(0), {.timeout = kMaxWaitForStats}), + IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return callee()->GetCorruptionScoreCount(); }, + ::testing::Eq(0), {.timeout = kMaxWaitForStats}), + IsRtcOk()); for (const auto& pair : {caller(), callee()}) { rtc::scoped_refptr report = pair->NewGetStats(); @@ -4625,16 +4605,12 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, ASSERT_THAT( WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), IsRtcOk()); - ASSERT_THAT( - WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, - ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForStatsMs)}), - IsRtcOk()); - ASSERT_THAT( - WaitUntil([&] { return callee()->GetCorruptionScoreCount(); }, - ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForStatsMs)}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, + ::testing::Gt(0), {.timeout = kMaxWaitForStats}), + IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return callee()->GetCorruptionScoreCount(); }, + ::testing::Gt(0), {.timeout = kMaxWaitForStats}), + IsRtcOk()); for (const auto& pair : {caller(), callee()}) { rtc::scoped_refptr report = pair->NewGetStats(); @@ -4682,16 +4658,12 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, ASSERT_THAT( WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), IsRtcOk()); - ASSERT_THAT( - WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, - ::testing::Eq(0), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForStatsMs)}), - IsRtcOk()); - ASSERT_THAT( - WaitUntil([&] { return callee()->GetCorruptionScoreCount(); }, - ::testing::Eq(0), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForStatsMs)}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, + ::testing::Eq(0), {.timeout = kMaxWaitForStats}), + IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return callee()->GetCorruptionScoreCount(); }, + ::testing::Eq(0), {.timeout = kMaxWaitForStats}), + IsRtcOk()); for (const auto& pair : {caller(), callee()}) { rtc::scoped_refptr report = pair->NewGetStats(); diff --git a/pc/sdp_offer_answer_unittest.cc b/pc/sdp_offer_answer_unittest.cc index 3eb61ac44e..f21fea7dc1 100644 --- a/pc/sdp_offer_answer_unittest.cc +++ b/pc/sdp_offer_answer_unittest.cc @@ -34,7 +34,6 @@ #include "api/scoped_refptr.h" #include "api/test/rtc_error_matchers.h" #include "api/uma_metrics.h" -#include "api/units/time_delta.h" #include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_decoder_factory_template.h" #include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h" @@ -1558,14 +1557,12 @@ TEST_F(SdpOfferAnswerMungingTest, DISABLED_ReportUMAMetricsWithNoMunging) { metrics::Samples("WebRTC.PeerConnection.SdpMunging.Answer.Initial"), ElementsAre(Pair(SdpMungingType::kNoModification, 1))); - EXPECT_THAT( - WaitUntil([&] { return caller->IsIceGatheringDone(); }, IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kDefaultTimeout)}), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return callee->IsIceGatheringDone(); }, IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kDefaultTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller->IsIceGatheringDone(); }, IsTrue(), + {.timeout = kDefaultTimeout}), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callee->IsIceGatheringDone(); }, IsTrue(), + {.timeout = kDefaultTimeout}), + IsRtcOk()); for (const auto& candidate : caller->observer()->GetAllCandidates()) { callee->pc()->AddIceCandidate(candidate); } @@ -1575,12 +1572,12 @@ TEST_F(SdpOfferAnswerMungingTest, DISABLED_ReportUMAMetricsWithNoMunging) { EXPECT_THAT( WaitUntil([&] { return caller->pc()->peer_connection_state(); }, Eq(PeerConnectionInterface::PeerConnectionState::kConnected), - {.timeout = webrtc::TimeDelta::Millis(kDefaultTimeout)}), + {.timeout = kDefaultTimeout}), IsRtcOk()); EXPECT_THAT( WaitUntil([&] { return callee->pc()->peer_connection_state(); }, Eq(PeerConnectionInterface::PeerConnectionState::kConnected), - {.timeout = webrtc::TimeDelta::Millis(kDefaultTimeout)}), + {.timeout = kDefaultTimeout}), IsRtcOk()); caller->pc()->Close(); diff --git a/pc/slow_peer_connection_integration_test.cc b/pc/slow_peer_connection_integration_test.cc index 7fefb5e8d6..1e010b44d7 100644 --- a/pc/slow_peer_connection_integration_test.cc +++ b/pc/slow_peer_connection_integration_test.cc @@ -120,8 +120,7 @@ TEST_P(PeerConnectionIntegrationTest, return o->first_packet_received(); }); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT(WaitUntil( [&] { @@ -131,8 +130,7 @@ TEST_P(PeerConnectionIntegrationTest, return o->first_packet_received(); }); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // If new observers are set after the first packet was already received, the // callback should still be invoked. @@ -230,7 +228,7 @@ TEST_P(PeerConnectionIntegrationTest, // TODO(bugs.webrtc.org/9219): When IceConnectionState is implemented // properly, should be able to just wait for a state of "failed" instead of // waiting a fixed 10 seconds. - WAIT_(DtlsConnected(), kDefaultTimeout, wait_res); + WAIT_(DtlsConnected(), kDefaultTimeout.ms(), wait_res); ASSERT_FALSE(wait_res); EXPECT_GT(client_1_cert_verifier->call_count_, 0u); @@ -266,8 +264,7 @@ TEST_P(PeerConnectionIntegrationTest, GetCaptureStartNtpTimeWithOldStatsApi) { ->OldGetStatsForTrack(remote_audio_track.get()) ->CaptureStartNtpTime(); }, - ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(2 * kMaxWaitForFramesMs)}), + ::testing::Gt(0), {.timeout = 2 * kMaxWaitForFrames}), IsRtcOk()); } @@ -444,7 +441,7 @@ TEST_P(PeerConnectionIntegrationIceStatesTestWithFakeClock, VerifyIceStates) { // According to RFC7675, if there is no response within 30 seconds then the // peer should consider the other side to have rejected the connection. This // is signaled by the state transitioning to "failed". - constexpr int kConsentTimeout = 30000; + constexpr TimeDelta kConsentTimeout = TimeDelta::Millis(30000); for (const auto& caller_address : CallerAddresses()) { firewall()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, caller_address); } @@ -452,14 +449,12 @@ TEST_P(PeerConnectionIntegrationIceStatesTestWithFakeClock, VerifyIceStates) { ASSERT_THAT( WaitUntil([&] { return caller()->ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionFailed), - {.timeout = webrtc::TimeDelta::Millis(kConsentTimeout), - .clock = &fake_clock}), + {.timeout = kConsentTimeout, .clock = &fake_clock}), IsRtcOk()); ASSERT_THAT( WaitUntil([&] { return caller()->standardized_ice_connection_state(); }, ::testing::Eq(PeerConnectionInterface::kIceConnectionFailed), - {.timeout = webrtc::TimeDelta::Millis(kConsentTimeout), - .clock = &fake_clock}), + {.timeout = kConsentTimeout, .clock = &fake_clock}), IsRtcOk()); } #endif diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h index 2f5aa22c8d..a23da7cfa3 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h @@ -116,11 +116,11 @@ using ::testing::UnorderedElementsAreArray; using ::testing::Values; using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; -static const int kDefaultTimeout = 10000; -static const int kLongTimeout = 60000; -static const int kMaxWaitForStatsMs = 3000; -static const int kMaxWaitForActivationMs = 5000; -static const int kMaxWaitForFramesMs = 10000; +constexpr TimeDelta kDefaultTimeout = TimeDelta::Millis(10000); +constexpr TimeDelta kLongTimeout = TimeDelta::Millis(60000); +constexpr TimeDelta kMaxWaitForStats = TimeDelta::Millis(3000); +constexpr TimeDelta kMaxWaitForActivation = TimeDelta::Millis(5000); +constexpr TimeDelta kMaxWaitForFrames = TimeDelta::Millis(10000); // Default number of audio/video frames to wait for before considering a test // successful. static const int kDefaultExpectedAudioFrameCount = 3; @@ -1758,21 +1758,19 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { } // Wait for the expected frames. - EXPECT_THAT( - WaitUntil( - [&] { - return caller()->audio_frames_received() >= - total_caller_audio_frames_expected && - caller()->min_video_frames_received_per_track() >= - total_caller_video_frames_expected && - callee()->audio_frames_received() >= - total_callee_audio_frames_expected && - callee()->min_video_frames_received_per_track() >= - total_callee_video_frames_expected; - }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil( + [&] { + return caller()->audio_frames_received() >= + total_caller_audio_frames_expected && + caller()->min_video_frames_received_per_track() >= + total_caller_video_frames_expected && + callee()->audio_frames_received() >= + total_callee_audio_frames_expected && + callee()->min_video_frames_received_per_track() >= + total_callee_video_frames_expected; + }, + ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsRtcOk()); bool expectations_correct = caller()->audio_frames_received() >= total_caller_audio_frames_expected &&