diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index b7fd49a0b0..422ffff822 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -7448,8 +7448,12 @@ class P2PTransportChannelTestDtlsInStun : public P2PTransportChannelTestBase { if (ep2_support) { ep2_ch1()->SetDtlsDataToPiggyback(dtls_data); } - EXPECT_TRUE_SIMULATED_WAIT(CheckConnected(ep1_ch1(), ep2_ch1()), - kDefaultTimeout, clock_); + EXPECT_THAT( + webrtc::WaitUntil( + [&] { return CheckConnected(ep1_ch1(), ep2_ch1()); }, IsTrue(), + {.timeout = webrtc::TimeDelta::Millis(kDefaultTimeout), + .clock = &clock_}), + webrtc::IsRtcOk()); } rtc::ScopedFakeClock clock_; diff --git a/p2p/dtls/dtls_ice_integrationtest.cc b/p2p/dtls/dtls_ice_integrationtest.cc index c21bb3bc64..664535b723 100644 --- a/p2p/dtls/dtls_ice_integrationtest.cc +++ b/p2p/dtls/dtls_ice_integrationtest.cc @@ -17,6 +17,8 @@ #include "api/candidate.h" #include "api/crypto/crypto_options.h" #include "api/scoped_refptr.h" +#include "api/test/rtc_error_matchers.h" +#include "api/units/time_delta.h" #include "p2p/base/basic_packet_socket_factory.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/p2p_transport_channel.h" @@ -26,7 +28,6 @@ #include "p2p/dtls/dtls_transport.h" #include "rtc_base/fake_clock.h" #include "rtc_base/fake_network.h" -#include "rtc_base/gunit.h" #include "rtc_base/rtc_certificate.h" #include "rtc_base/socket_address.h" #include "rtc_base/ssl_fingerprint.h" @@ -35,7 +36,9 @@ #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" +#include "test/gmock.h" #include "test/gtest.h" +#include "test/wait_until.h" namespace { constexpr int kDefaultTimeout = 10000; @@ -56,6 +59,8 @@ void SetRemoteFingerprintFromCert( namespace cricket { +using ::testing::IsTrue; + class DtlsIceIntegrationTest : public ::testing::TestWithParam>, public sigslot::has_slots<> { @@ -172,8 +177,13 @@ TEST_P(DtlsIceIntegrationTest, SmokeTest) { server_ice_->MaybeStartGathering(); // Note: this only reaches the pending piggybacking state. - EXPECT_TRUE_SIMULATED_WAIT(client_dtls_.writable() && server_dtls_.writable(), - kDefaultTimeout, fake_clock_); + EXPECT_THAT( + webrtc::WaitUntil( + [&] { return client_dtls_.writable() && server_dtls_.writable(); }, + IsTrue(), + {.timeout = webrtc::TimeDelta::Millis(kDefaultTimeout), + .clock = &fake_clock_}), + webrtc::IsRtcOk()); EXPECT_EQ(client_ice_->IsDtlsPiggybackSupportedByPeer(), client_dtls_stun_piggyback_ && server_dtls_stun_piggyback_); EXPECT_EQ(server_ice_->IsDtlsPiggybackSupportedByPeer(), diff --git a/pc/sdp_offer_answer_unittest.cc b/pc/sdp_offer_answer_unittest.cc index 1546db04d5..3eb61ac44e 100644 --- a/pc/sdp_offer_answer_unittest.cc +++ b/pc/sdp_offer_answer_unittest.cc @@ -32,7 +32,9 @@ #include "api/rtp_transceiver_direction.h" #include "api/rtp_transceiver_interface.h" #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" @@ -54,12 +56,12 @@ #include "pc/test/fake_rtc_certificate_generator.h" #include "pc/test/integration_test_helpers.h" #include "pc/test/mock_peer_connection_observers.h" -#include "rtc_base/gunit.h" #include "rtc_base/string_encode.h" #include "rtc_base/thread.h" #include "system_wrappers/include/metrics.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/wait_until.h" // This file contains unit tests that relate to the behavior of the // SdpOfferAnswer module. @@ -69,6 +71,8 @@ namespace webrtc { +using ::testing::Eq; +using ::testing::IsTrue; using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; using ::testing::ElementsAre; using ::testing::Pair; @@ -1554,18 +1558,30 @@ TEST_F(SdpOfferAnswerMungingTest, DISABLED_ReportUMAMetricsWithNoMunging) { metrics::Samples("WebRTC.PeerConnection.SdpMunging.Answer.Initial"), ElementsAre(Pair(SdpMungingType::kNoModification, 1))); - EXPECT_TRUE_WAIT(caller->IsIceGatheringDone(), kDefaultTimeout); - EXPECT_TRUE_WAIT(callee->IsIceGatheringDone(), kDefaultTimeout); + 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()); for (const auto& candidate : caller->observer()->GetAllCandidates()) { callee->pc()->AddIceCandidate(candidate); } for (const auto& candidate : callee->observer()->GetAllCandidates()) { caller->pc()->AddIceCandidate(candidate); } - EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kConnected, - caller->pc()->peer_connection_state(), kDefaultTimeout); - EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kConnected, - callee->pc()->peer_connection_state(), kDefaultTimeout); + EXPECT_THAT( + WaitUntil([&] { return caller->pc()->peer_connection_state(); }, + Eq(PeerConnectionInterface::PeerConnectionState::kConnected), + {.timeout = webrtc::TimeDelta::Millis(kDefaultTimeout)}), + IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return callee->pc()->peer_connection_state(); }, + Eq(PeerConnectionInterface::PeerConnectionState::kConnected), + {.timeout = webrtc::TimeDelta::Millis(kDefaultTimeout)}), + IsRtcOk()); caller->pc()->Close(); callee->pc()->Close();