Replace gunit.h macros with WaitUntil in pc/
Bug: webrtc:381524905
Change-Id: I15946ab73aaef2e830d6801451636e717708adbf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/373704
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43680}
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index e13a046..b77b976 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -2000,6 +2000,7 @@
"../api:make_ref_counted",
"../api:priority",
"../api:rtc_error",
+ "../api:rtc_error_matchers",
"../api:rtp_headers",
"../api:rtp_parameters",
"../api:rtp_transceiver_direction",
@@ -2013,6 +2014,7 @@
"../api/task_queue:task_queue",
"../api/transport:datagram_transport_interface",
"../api/transport:enums",
+ "../api/units:time_delta",
"../api/video:builtin_video_bitrate_allocator_factory",
"../api/video:recordable_encoded_frame",
"../api/video/test:mock_recordable_encoded_frame",
@@ -2063,7 +2065,9 @@
"../rtc_base:threading",
"../rtc_base:unique_id_generator",
"../rtc_base/containers:flat_set",
+ "../rtc_base/network:ecn_marking",
"../rtc_base/network:received_packet",
+ "../rtc_base/network:sent_packet",
"../rtc_base/third_party/sigslot",
"../system_wrappers:metrics",
"../test:explicit_key_value_config",
@@ -2071,6 +2075,8 @@
"../test:scoped_key_value_config",
"../test:test_main",
"../test:test_support",
+ "../test:wait_until",
+ "//testing/gmock",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/functional:any_invocable",
"//third_party/abseil-cpp/absl/memory",
@@ -2103,8 +2109,10 @@
"../api:audio_options_api",
"../api:create_peerconnection_factory",
"../api:libjingle_peerconnection_api",
+ "../api:make_ref_counted",
"../api:media_stream_interface",
"../api:rtc_error",
+ "../api:rtc_error_matchers",
"../api:rtc_stats_api",
"../api:scoped_refptr",
"../api/audio:audio_device",
@@ -2127,6 +2135,7 @@
"../api/video_codecs:video_encoder_factory_template_libvpx_vp9_adapter",
"../api/video_codecs:video_encoder_factory_template_open_h264_adapter",
"../media:rtc_media_tests_utils",
+ "../p2p:basic_packet_socket_factory",
"../p2p:basic_port_allocator",
"../p2p:connection",
"../p2p:p2p_test_utils",
@@ -2143,6 +2152,8 @@
"../rtc_base:threading",
"../system_wrappers",
"../test:test_support",
+ "../test:wait_until",
+ "//testing/gmock",
]
}
@@ -2157,8 +2168,10 @@
":sdp_utils",
"../api:function_view",
"../api:libjingle_peerconnection_api",
+ "../api:make_ref_counted",
"../api:media_stream_interface",
"../api:rtc_error",
+ "../api:rtc_error_matchers",
"../api:rtc_stats_api",
"../api:rtp_parameters",
"../api:rtp_sender_interface",
@@ -2167,6 +2180,8 @@
"../rtc_base:gunit_helpers",
"../rtc_base:logging",
"../test:test_support",
+ "../test:wait_until",
+ "//testing/gmock",
]
}
@@ -2178,6 +2193,7 @@
":pc_test_utils",
"../api:dtmf_sender_interface",
"../api:libjingle_peerconnection_api",
+ "../api:rtc_error_matchers",
"../api:scoped_refptr",
"../api/units:time_delta",
"../p2p:connection",
@@ -2192,6 +2208,7 @@
"../rtc_base:ssl",
"../test:test_main",
"../test:test_support",
+ "../test:wait_until",
"../test/time_controller:time_controller",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/strings",
@@ -2329,6 +2346,7 @@
"../api:rtp_sender_interface",
"../api:rtp_transceiver_direction",
"../api:scoped_refptr",
+ "../api:sequence_checker",
"../api/adaptation:resource_adaptation_api",
"../api/audio:audio_device",
"../api/audio:audio_mixer_api",
@@ -2343,6 +2361,8 @@
"../api/rtc_event_log:rtc_event_log_factory",
"../api/task_queue",
"../api/task_queue:default_task_queue_factory",
+ "../api/task_queue:pending_task_safety_flag",
+ "../api/transport:bitrate_settings",
"../api/transport:datagram_transport_interface",
"../api/transport:enums",
"../api/transport:field_trial_based_config",
@@ -2373,6 +2393,7 @@
"../media:stream_params",
"../modules/audio_processing:mocks",
"../modules/rtp_rtcp:rtp_rtcp_format",
+ "../p2p:basic_packet_socket_factory",
"../p2p:basic_port_allocator",
"../p2p:connection",
"../p2p:connection_info",
@@ -2407,6 +2428,7 @@
"../rtc_base:rtc_certificate_generator",
"../rtc_base:rtc_json",
"../rtc_base:socket_address",
+ "../rtc_base:socket_server",
"../rtc_base:ssl",
"../rtc_base:ssl_adapter",
"../rtc_base:stringutils",
@@ -2424,6 +2446,7 @@
"../test:scoped_key_value_config",
"../test:wait_until",
"../test/pc/sctp:fake_sctp_transport",
+ "//testing/gmock",
"//testing/gtest",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory",
@@ -2564,6 +2587,7 @@
"../api:mock_rtp",
"../api:packet_socket_factory",
"../api:rtc_error",
+ "../api:rtc_error_matchers",
"../api:rtc_stats_api",
"../api:rtp_parameters",
"../api:rtp_sender_interface",
@@ -2639,6 +2663,7 @@
"../test:rtp_test_utils",
"../test:scoped_key_value_config",
"../test:test_support",
+ "../test:wait_until",
"../test/pc/sctp:fake_sctp_transport",
"../test/time_controller",
"//third_party/abseil-cpp/absl/algorithm:container",
@@ -2720,6 +2745,7 @@
"../api:media_stream_interface",
"../api:priority",
"../api:rtc_error",
+ "../api:rtc_error_matchers",
"../api:rtc_stats_api",
"../api:rtp_parameters",
"../api:scoped_refptr",
@@ -2758,6 +2784,7 @@
"../modules/audio_device",
"../modules/audio_processing",
"../modules/rtp_rtcp:rtp_rtcp_format",
+ "../p2p:basic_packet_socket_factory",
"../p2p:connection",
"../p2p:fake_port_allocator",
"../p2p:p2p_test_utils",
@@ -2767,6 +2794,7 @@
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:rtc_certificate_generator",
+ "../rtc_base:socket_server",
"../rtc_base:ssl",
"../rtc_base:stringutils",
"../rtc_base:task_queue_for_test",
@@ -2779,6 +2807,8 @@
"../test:frame_generator_capturer",
"../test:scoped_key_value_config",
"../test:test_support",
+ "../test:wait_until",
+ "//testing/gmock",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/strings",
]
diff --git a/pc/audio_rtp_receiver_unittest.cc b/pc/audio_rtp_receiver_unittest.cc
index e031f90..f983eb0 100644
--- a/pc/audio_rtp_receiver_unittest.cc
+++ b/pc/audio_rtp_receiver_unittest.cc
@@ -11,17 +11,24 @@
#include "pc/audio_rtp_receiver.h"
#include <atomic>
+#include <cstdint>
+#include <string>
+#include <vector>
+#include "api/make_ref_counted.h"
+#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
#include "pc/test/mock_voice_media_receive_channel_interface.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/run_loop.h"
+#include "test/wait_until.h"
using ::testing::_;
+using ::testing::Eq;
using ::testing::InvokeWithoutArgs;
-using ::testing::Mock;
static const int kTimeOut = 100;
static const double kDefaultVolume = 1;
@@ -76,7 +83,9 @@
}));
receiver_->OnSetVolume(kVolume);
- EXPECT_TRUE_WAIT(set_volume_calls == 2, kTimeOut);
+ EXPECT_THAT(WaitUntil([&] { return set_volume_calls.load(); }, Eq(2),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeOut)}),
+ IsRtcOk());
}
TEST_F(AudioRtpReceiverTest, VolumesSetBeforeStartingAreRespected) {
diff --git a/pc/congestion_control_integrationtest.cc b/pc/congestion_control_integrationtest.cc
index d0cb4e0..55d880f 100644
--- a/pc/congestion_control_integrationtest.cc
+++ b/pc/congestion_control_integrationtest.cc
@@ -15,15 +15,18 @@
#include "absl/strings/str_cat.h"
#include "api/peer_connection_interface.h"
+#include "api/test/rtc_error_matchers.h"
#include "pc/test/integration_test_helpers.h"
-#include "rtc_base/gunit.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
using testing::Eq;
+using ::testing::Gt;
using testing::HasSubstr;
+using ::testing::IsTrue;
using testing::Not;
class PeerConnectionCongestionControlTest
@@ -48,7 +51,8 @@
ConnectFakeSignalingForSdpOnly();
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
// Check that the callee parsed it.
auto parsed_contents =
callee()->pc()->remote_description()->description()->contents();
@@ -74,14 +78,20 @@
ConnectFakeSignaling();
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudio();
media_expectations.CalleeExpectsSomeVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
auto pc_internal = caller()->pc_internal();
- EXPECT_TRUE_WAIT(pc_internal->FeedbackAccordingToRfc8888CountForTesting() > 0,
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return pc_internal->FeedbackAccordingToRfc8888CountForTesting();
+ },
+ Gt(0)),
+ IsRtcOk());
// There should be no transport-cc generated.
EXPECT_THAT(pc_internal->FeedbackAccordingToTransportCcCountForTesting(),
Eq(0));
@@ -93,15 +103,20 @@
ConnectFakeSignaling();
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudio();
media_expectations.CalleeExpectsSomeVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
auto pc_internal = caller()->pc_internal();
- EXPECT_TRUE_WAIT(
- pc_internal->FeedbackAccordingToTransportCcCountForTesting() > 0,
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return pc_internal->FeedbackAccordingToTransportCcCountForTesting();
+ },
+ Gt(0)),
+ IsRtcOk());
// Test that RFC 8888 feedback is NOT generated when field trial disabled.
EXPECT_THAT(pc_internal->FeedbackAccordingToRfc8888CountForTesting(), Eq(0));
}
diff --git a/pc/data_channel_integrationtest.cc b/pc/data_channel_integrationtest.cc
index 27caf11..d4d559ae 100644
--- a/pc/data_channel_integrationtest.cc
+++ b/pc/data_channel_integrationtest.cc
@@ -30,6 +30,7 @@
#include "api/sctp_transport_interface.h"
#include "api/stats/rtc_stats_report.h"
#include "api/stats/rtcstats_objects.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/units/time_delta.h"
#include "p2p/base/transport_description.h"
#include "p2p/base/transport_info.h"
@@ -44,15 +45,21 @@
#include "rtc_base/gunit.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
+#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/virtual_socket_server.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
namespace {
+using ::testing::Eq;
+using ::testing::IsTrue;
+using ::testing::Ne;
+
// All tests in this file require SCTP support.
#ifdef WEBRTC_HAVE_SCTP
@@ -133,23 +140,31 @@
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_observer(); }, IsTrue()),
+ IsRtcOk());
std::string data1 = "hello first";
caller()->data_channel()->Send(DataBuffer(data1));
- EXPECT_EQ_WAIT(data1, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data1)),
+ IsRtcOk());
// Cause a network outage
virtual_socket_server()->set_drop_probability(1.0);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected,
- caller()->standardized_ice_connection_state(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->standardized_ice_connection_state(); },
+ Eq(PeerConnectionInterface::kIceConnectionDisconnected),
+ {.timeout = TimeDelta::Seconds(10)}),
+ IsRtcOk());
std::string data2 = "hello second";
caller()->data_channel()->Send(DataBuffer(data2));
// Remove the network outage. The connection should reestablish.
virtual_socket_server()->set_drop_probability(0.0);
- EXPECT_EQ_WAIT(data2, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data2)),
+ IsRtcOk());
}
// This test causes a PeerConnection to enter Disconnected state,
@@ -161,17 +176,23 @@
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_observer(); }, IsTrue()),
+ IsRtcOk());
std::string data1 = "hello first";
caller()->data_channel()->Send(DataBuffer(data1));
- EXPECT_EQ_WAIT(data1, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data1)),
+ IsRtcOk());
// Cause a network outage
virtual_socket_server()->set_drop_probability(1.0);
- ASSERT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected,
- caller()->standardized_ice_connection_state(),
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->standardized_ice_connection_state(); },
+ Eq(PeerConnectionInterface::kIceConnectionDisconnected),
+ {.timeout = TimeDelta::Seconds(10)}),
+ IsRtcOk());
std::string data2 = "hello second";
caller()->data_channel()->Send(DataBuffer(data2));
@@ -179,11 +200,14 @@
// the network outage.
caller()->SetOfferAnswerOptions(IceRestartOfferAnswerOptions());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
// Remove the network outage. The connection should reestablish.
virtual_socket_server()->set_drop_probability(0.0);
- EXPECT_EQ_WAIT(data2, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data2)),
+ IsRtcOk());
}
// This test sets up a call between two parties with audio, video and an SCTP
@@ -199,7 +223,8 @@
callee()->AddAudioVideoTracks();
}
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
if (allow_media()) {
// Ensure the existence of the SCTP data channel didn't impede audio/video.
MediaExpectations media_expectations;
@@ -209,18 +234,27 @@
// Caller data channel should already exist (it created one). Callee data
// channel may not exist yet, since negotiation happens in-band, not in SDP.
ASSERT_NE(nullptr, caller()->data_channel());
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- EXPECT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
// Ensure data can be sent in both directions.
std::string data = "hello world";
caller()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
callee()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, caller()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
}
// This test sets up a call between two parties with an SCTP
@@ -233,39 +267,55 @@
// well.
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
// Caller data channel should already exist (it created one). Callee data
// channel may not exist yet, since negotiation happens in-band, not in SDP.
ASSERT_NE(nullptr, caller()->data_channel());
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- EXPECT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
for (int message_size = 1; message_size < 100000; message_size *= 2) {
std::string data(message_size, 'a');
caller()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
callee()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, caller()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
}
// Specifically probe the area around the MTU size.
for (int message_size = 1100; message_size < 1300; message_size += 1) {
std::string data(message_size, 'a');
caller()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
callee()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, caller()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
}
caller()->data_channel()->Close();
- EXPECT_EQ_WAIT(caller()->data_observer()->state(),
- webrtc::DataChannelInterface::kClosed, kDefaultTimeout);
- EXPECT_EQ_WAIT(callee()->data_observer()->state(),
- webrtc::DataChannelInterface::kClosed, kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return caller()->data_observer()->state(); },
+ Eq(webrtc::DataChannelInterface::kClosed)),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return callee()->data_observer()->state(); },
+ Eq(webrtc::DataChannelInterface::kClosed)),
+ IsRtcOk());
}
// This test sets up a call between two parties with an SCTP
@@ -279,13 +329,19 @@
// well.
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
// Caller data channel should already exist (it created one). Callee data
// channel may not exist yet, since negotiation happens in-band, not in SDP.
ASSERT_NE(nullptr, caller()->data_channel());
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- EXPECT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
std::string data(256 * 1024, 'a');
for (size_t queued_size = 0;
@@ -304,13 +360,16 @@
// Debug data channels are very slow, use a long timeout for those slow,
// heavily parallelized runs.
- EXPECT_EQ_WAIT(DataChannelInterface::DataState::kClosed,
- caller()->data_observer()->state(), kLongTimeout);
+ EXPECT_THAT(WaitUntil([&] { return caller()->data_observer()->state(); },
+ Eq(DataChannelInterface::DataState::kClosed),
+ {.timeout = webrtc::TimeDelta::Millis(kLongTimeout)}),
+ IsRtcOk());
EXPECT_THAT(caller()->data_observer()->states(),
::testing::ElementsAreArray(expected_states));
- EXPECT_EQ_WAIT(DataChannelInterface::DataState::kClosed,
- callee()->data_observer()->state(), kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return callee()->data_observer()->state(); },
+ Eq(DataChannelInterface::DataState::kClosed)),
+ IsRtcOk());
EXPECT_THAT(callee()->data_observer()->states(),
::testing::ElementsAreArray(expected_states));
}
@@ -325,38 +384,56 @@
// well.
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
// Caller data channel should already exist (it created one). Callee data
// channel may not exist yet, since negotiation happens in-band, not in SDP.
ASSERT_NE(nullptr, caller()->data_channel());
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- EXPECT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
// Ensure data can be sent in both directions.
// Sending empty string data
std::string data = "";
caller()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(1u, callee()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return callee()->data_observer()->received_message_count(); },
+ Eq(1u)),
+ IsRtcOk());
EXPECT_TRUE(callee()->data_observer()->last_message().empty());
EXPECT_FALSE(callee()->data_observer()->messages().back().binary);
callee()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(1u, caller()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return caller()->data_observer()->received_message_count(); },
+ Eq(1u)),
+ IsRtcOk());
EXPECT_TRUE(caller()->data_observer()->last_message().empty());
EXPECT_FALSE(caller()->data_observer()->messages().back().binary);
// Sending empty binary data
rtc::CopyOnWriteBuffer empty_buffer;
caller()->data_channel()->Send(DataBuffer(empty_buffer, true));
- EXPECT_EQ_WAIT(2u, callee()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return callee()->data_observer()->received_message_count(); },
+ Eq(2u)),
+ IsRtcOk());
EXPECT_TRUE(callee()->data_observer()->last_message().empty());
EXPECT_TRUE(callee()->data_observer()->messages().back().binary);
callee()->data_channel()->Send(DataBuffer(empty_buffer, true));
- EXPECT_EQ_WAIT(2u, caller()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return caller()->data_observer()->received_message_count(); },
+ Eq(2u)),
+ IsRtcOk());
EXPECT_TRUE(caller()->data_observer()->last_message().empty());
EXPECT_TRUE(caller()->data_observer()->messages().back().binary);
}
@@ -375,23 +452,33 @@
// well.
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
// Caller data channel should already exist (it created one). Callee data
// channel may not exist yet, since negotiation happens in-band, not in SDP.
ASSERT_NE(nullptr, caller()->data_channel());
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- EXPECT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
virtual_socket_server()->set_max_udp_payload(kLowestSafePayloadSizeLimit);
for (int message_size = 1140; message_size < 1240; message_size += 1) {
std::string data(message_size, 'a');
caller()->data_channel()->Send(DataBuffer(data));
- ASSERT_EQ_WAIT(data, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
callee()->data_channel()->Send(DataBuffer(data));
- ASSERT_EQ_WAIT(data, caller()->data_observer()->last_message(),
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
}
}
@@ -410,11 +497,17 @@
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
ASSERT_NE(nullptr, caller()->data_channel());
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- EXPECT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
if (caller()->tls_version() == rtc::kDtls13VersionBytes) {
ASSERT_EQ(caller()->tls_version(), rtc::kDtls13VersionBytes);
@@ -457,11 +550,17 @@
callee()->AddAudioVideoTracks();
}
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
ASSERT_NE(nullptr, caller()->data_channel());
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
// Close the data channel on the callee side, and wait for it to reach the
// "closed" state on both sides.
@@ -473,13 +572,15 @@
DataChannelInterface::DataState::kClosing,
DataChannelInterface::DataState::kClosed};
- EXPECT_EQ_WAIT(DataChannelInterface::DataState::kClosed,
- caller()->data_observer()->state(), kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return caller()->data_observer()->state(); },
+ Eq(DataChannelInterface::DataState::kClosed)),
+ IsRtcOk());
EXPECT_THAT(caller()->data_observer()->states(),
::testing::ElementsAreArray(expected_states));
- EXPECT_EQ_WAIT(DataChannelInterface::DataState::kClosed,
- callee()->data_observer()->state(), kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return callee()->data_observer()->state(); },
+ Eq(DataChannelInterface::DataState::kClosed)),
+ IsRtcOk());
EXPECT_THAT(callee()->data_observer()->states(),
::testing::ElementsAreArray(expected_states));
}
@@ -496,9 +597,13 @@
callee()->AddAudioVideoTracks();
}
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
// Since "negotiated" is false, the "id" parameter should be ignored.
EXPECT_NE(init.id, callee()->data_channel()->id());
EXPECT_EQ("data-channel", callee()->data_channel()->label());
@@ -522,11 +627,17 @@
init.ordered = false;
caller()->CreateDataChannel(&init);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
ASSERT_NE(nullptr, caller()->data_channel());
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
static constexpr int kNumMessages = 100;
// Deliberately chosen to be larger than the MTU so messages get fragmented.
@@ -544,12 +655,16 @@
}
// Wait for all messages to be received.
- EXPECT_EQ_WAIT(rtc::checked_cast<size_t>(kNumMessages),
- caller()->data_observer()->received_message_count(),
- kDefaultTimeout);
- EXPECT_EQ_WAIT(rtc::checked_cast<size_t>(kNumMessages),
- callee()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return caller()->data_observer()->received_message_count(); },
+ Eq(rtc::checked_cast<size_t>(kNumMessages))),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return callee()->data_observer()->received_message_count(); },
+ Eq(rtc::checked_cast<size_t>(kNumMessages))),
+ IsRtcOk());
// Sort and compare to make sure none of the messages were corrupted.
std::vector<std::string> caller_received_messages;
@@ -593,22 +708,28 @@
if (!has_negotiated) {
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
has_negotiated = true;
}
for (size_t i = 0; i < kChannelCount; ++i) {
- ASSERT_EQ_WAIT(caller()->data_channels()[i]->state(),
- DataChannelInterface::DataState::kOpen, kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_channels()[i]->state(); },
+ Eq(DataChannelInterface::DataState::kOpen)),
+ IsRtcOk());
RTC_LOG(LS_INFO) << "Caller Channel "
<< caller()->data_channels()[i]->label() << " with id "
<< caller()->data_channels()[i]->id() << " is open.";
}
- ASSERT_EQ_WAIT(callee()->data_channels().size(), kChannelCount,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channels().size(); },
+ Eq(kChannelCount)),
+ IsRtcOk());
for (size_t i = 0; i < kChannelCount; ++i) {
- ASSERT_EQ_WAIT(callee()->data_channels()[i]->state(),
- DataChannelInterface::DataState::kOpen, kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_channels()[i]->state(); },
+ Eq(DataChannelInterface::DataState::kOpen)),
+ IsRtcOk());
RTC_LOG(LS_INFO) << "Callee Channel "
<< callee()->data_channels()[i]->label() << " with id "
<< callee()->data_channels()[i]->id() << " is open.";
@@ -627,10 +748,14 @@
}
for (size_t i = 0; i < kChannelCount; ++i) {
- ASSERT_EQ_WAIT(caller()->data_channels()[i]->state(),
- DataChannelInterface::DataState::kClosed, kDefaultTimeout);
- ASSERT_EQ_WAIT(callee()->data_channels()[i]->state(),
- DataChannelInterface::DataState::kClosed, kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_channels()[i]->state(); },
+ Eq(DataChannelInterface::DataState::kClosed)),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_channels()[i]->state(); },
+ Eq(DataChannelInterface::DataState::kClosed)),
+ IsRtcOk());
}
caller()->data_channels().clear();
@@ -670,22 +795,28 @@
if (!has_negotiated) {
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
has_negotiated = true;
}
for (size_t i = 0; i < kChannelCount; ++i) {
- ASSERT_EQ_WAIT(caller()->data_channels()[i]->state(),
- DataChannelInterface::DataState::kOpen, kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_channels()[i]->state(); },
+ Eq(DataChannelInterface::DataState::kOpen)),
+ IsRtcOk());
RTC_LOG(LS_INFO) << "Caller Channel "
<< caller()->data_channels()[i]->label() << " with id "
<< caller()->data_channels()[i]->id() << " is open.";
}
- ASSERT_EQ_WAIT(callee()->data_channels().size(), kChannelCount,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channels().size(); },
+ Eq(kChannelCount)),
+ IsRtcOk());
for (size_t i = 0; i < kChannelCount; ++i) {
- ASSERT_EQ_WAIT(callee()->data_channels()[i]->state(),
- DataChannelInterface::DataState::kOpen, kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_channels()[i]->state(); },
+ Eq(DataChannelInterface::DataState::kOpen)),
+ IsRtcOk());
RTC_LOG(LS_INFO) << "Callee Channel "
<< callee()->data_channels()[i]->label() << " with id "
<< callee()->data_channels()[i]->id() << " is open.";
@@ -704,10 +835,14 @@
}
for (size_t i = 0; i < kChannelCount; ++i) {
- ASSERT_EQ_WAIT(caller()->data_channels()[i]->state(),
- DataChannelInterface::DataState::kClosed, kDefaultTimeout);
- ASSERT_EQ_WAIT(callee()->data_channels()[i]->state(),
- DataChannelInterface::DataState::kClosed, kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_channels()[i]->state(); },
+ Eq(DataChannelInterface::DataState::kClosed)),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_channels()[i]->state(); },
+ Eq(DataChannelInterface::DataState::kClosed)),
+ IsRtcOk());
}
caller()->data_channels().clear();
@@ -730,25 +865,36 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
// Create data channel and do new offer and answer.
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
// Caller data channel should already exist (it created one). Callee data
// channel may not exist yet, since negotiation happens in-band, not in SDP.
ASSERT_NE(nullptr, caller()->data_channel());
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- EXPECT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
// Ensure data can be sent in both directions.
std::string data = "hello world";
caller()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
callee()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, caller()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
}
// Set up a connection initially just using SCTP data channels, later
@@ -765,18 +911,25 @@
// Do initial offer/answer with just data channel.
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
// Wait until data can be sent over the data channel.
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
// Do subsequent offer/answer with two-way audio and video. Audio and video
// should end up bundled on the DTLS/ICE transport already used for data.
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -802,19 +955,29 @@
caller()->CreateDataChannel();
caller()->SetGeneratedSdpMunger(MakeSpecCompliantSctpOffer);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
- EXPECT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
// Ensure data can be sent in both directions.
std::string data = "hello world";
caller()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
callee()->data_channel()->Send(DataBuffer(data));
- EXPECT_EQ_WAIT(data, caller()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->last_message(); },
+ Eq(data)),
+ IsRtcOk());
}
// Test that after closing PeerConnections, they stop sending any packets
@@ -830,7 +993,8 @@
caller()->AddAudioVideoTracks();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -849,8 +1013,11 @@
caller()->CreateDataChannel();
ASSERT_FALSE(caller()->pc()->GetSctpTransport());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
ASSERT_TRUE(caller()->pc()->GetSctpTransport());
ASSERT_TRUE(
caller()->pc()->GetSctpTransport()->Information().dtls_transport());
@@ -889,8 +1056,11 @@
caller()->CreateDataChannel();
callee()->SetReceivedSdpMunger(MakeActiveSctpOffer);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
EXPECT_TRUE(caller()
->pc()
->GetSctpTransport()
@@ -932,10 +1102,17 @@
callee()->CreateDataChannel();
});
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->data_observer()->IsOpen(), kDefaultTimeout);
- ASSERT_EQ_WAIT(callee()->data_channels().size(), 2U, kDefaultTimeout);
- ASSERT_EQ_WAIT(caller()->data_channels().size(), 2U, kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_channels().size(); }, Eq(2U)),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->data_channels().size(); }, Eq(2U)),
+ IsRtcOk());
EXPECT_TRUE(caller()
->pc()
->GetSctpTransport()
@@ -979,8 +1156,10 @@
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_channel(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, IsTrue()),
+ IsRtcOk());
auto caller_report = caller()->NewGetStats();
EXPECT_EQ(1u, caller_report->GetStatsOfType<RTCTransportStats>().size());
@@ -993,24 +1172,36 @@
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_channel(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, IsTrue()),
+ IsRtcOk());
caller()->data_channel()->Send(DataBuffer("hello first"));
- ASSERT_EQ_WAIT(1u, callee()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return callee()->data_observer()->received_message_count(); },
+ Eq(1u)),
+ IsRtcOk());
// Cause a temporary network outage
virtual_socket_server()->set_drop_probability(1.0);
for (int i = 1; i <= 10; i++) {
caller()->data_channel()->Send(DataBuffer("Sent while blocked"));
}
// Nothing should be delivered during outage. Short wait.
- EXPECT_EQ_WAIT(1u, callee()->data_observer()->received_message_count(), 10);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return callee()->data_observer()->received_message_count(); },
+ Eq(1u)),
+ IsRtcOk());
// Reverse outage
virtual_socket_server()->set_drop_probability(0.0);
// All packets should be delivered.
- EXPECT_EQ_WAIT(11u, callee()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return callee()->data_observer()->received_message_count(); },
+ Eq(11u)),
+ IsRtcOk());
}
TEST_P(DataChannelIntegrationTest, QueuedPacketsGetDroppedInUnreliableMode) {
@@ -1021,11 +1212,16 @@
init.ordered = false;
caller()->CreateDataChannel(&init);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_channel(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, IsTrue()),
+ IsRtcOk());
caller()->data_channel()->Send(DataBuffer("hello first"));
- ASSERT_EQ_WAIT(1u, callee()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return callee()->data_observer()->received_message_count(); },
+ Eq(1u)),
+ IsRtcOk());
// Cause a temporary network outage
virtual_socket_server()->set_drop_probability(1.0);
// Send a few packets. Note that all get dropped only when all packets
@@ -1042,8 +1238,10 @@
virtual_socket_server()->set_drop_probability(0.0);
// Send a new packet, and wait for it to be delivered.
caller()->data_channel()->Send(DataBuffer("After block"));
- EXPECT_EQ_WAIT("After block", callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq("After block")),
+ IsRtcOk());
// Some messages should be lost, but first and last message should have
// been delivered.
// First, check that the protocol guarantee is preserved.
@@ -1062,11 +1260,16 @@
init.ordered = false;
caller()->CreateDataChannel(&init);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_channel(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, IsTrue()),
+ IsRtcOk());
caller()->data_channel()->Send(DataBuffer("hello first"));
- ASSERT_EQ_WAIT(1u, callee()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return callee()->data_observer()->received_message_count(); },
+ Eq(1u)),
+ IsRtcOk());
// Cause a temporary network outage
virtual_socket_server()->set_drop_probability(1.0);
for (int i = 1; i <= 200; i++) {
@@ -1081,8 +1284,10 @@
virtual_socket_server()->set_drop_probability(0.0);
// Send a new packet, and wait for it to be delivered.
caller()->data_channel()->Send(DataBuffer("After block"));
- EXPECT_EQ_WAIT("After block", callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq("After block")),
+ IsRtcOk());
// Some messages should be lost, but first and last message should have
// been delivered.
// First, check that the protocol guarantee is preserved.
@@ -1102,11 +1307,16 @@
init.ordered = false;
caller()->CreateDataChannel(&init);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_channel(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, IsTrue()),
+ IsRtcOk());
caller()->data_channel()->Send(DataBuffer("hello first"));
- ASSERT_EQ_WAIT(1u, callee()->data_observer()->received_message_count(),
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return callee()->data_observer()->received_message_count(); },
+ Eq(1u)),
+ IsRtcOk());
// Cause a temporary network outage
virtual_socket_server()->set_drop_probability(1.0);
// Fill the SCTP socket buffer until queued data starts to build.
@@ -1132,8 +1342,10 @@
virtual_socket_server()->set_drop_probability(0.0);
// Send a new packet, and wait for it to be delivered.
caller()->data_channel()->Send(DataBuffer("After block"));
- EXPECT_EQ_WAIT("After block", callee()->data_observer()->last_message(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->last_message(); },
+ Eq("After block")),
+ IsRtcOk());
// Some messages should be lost, but first and last message should have
// been delivered.
// Due to the fact that retransmissions are only counted when the packet
@@ -1170,13 +1382,23 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->pc()->GetSctpTransport(), kDefaultTimeout);
- ASSERT_EQ_WAIT(SctpTransportState::kConnected,
- caller()->pc()->GetSctpTransport()->Information().state(),
- kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_channel(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->pc()->GetSctpTransport(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil(
+ [&] {
+ return caller()->pc()->GetSctpTransport()->Information().state();
+ },
+ Eq(SctpTransportState::kConnected)),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
}
TEST_F(DataChannelIntegrationTestUnifiedPlan,
@@ -1185,9 +1407,13 @@
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_channel(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
ASSERT_TRUE(caller()->data_observer()->IsOpen());
}
@@ -1196,11 +1422,17 @@
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_observer(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
caller()->data_channel()->Close();
- ASSERT_TRUE_WAIT(!callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return !callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
}
TEST_F(DataChannelIntegrationTestUnifiedPlan,
@@ -1209,11 +1441,17 @@
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_observer(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
callee()->data_channel()->Close();
- ASSERT_TRUE_WAIT(!caller()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return !caller()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
}
TEST_F(DataChannelIntegrationTestUnifiedPlan,
@@ -1222,11 +1460,17 @@
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee()->data_observer(); }, IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
caller()->pc()->Close();
- ASSERT_TRUE_WAIT(!callee()->data_observer()->IsOpen(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return !callee()->data_observer()->IsOpen(); }, IsTrue()),
+ IsRtcOk());
}
TEST_F(DataChannelIntegrationTestUnifiedPlan, DtlsRestart) {
@@ -1270,10 +1514,12 @@
PeerConnectionInterface::kHaveRemotePrAnswer);
EXPECT_EQ(callee()->pc()->signaling_state(),
PeerConnectionInterface::kHaveLocalPrAnswer);
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen, caller()->data_channel()->state(),
- kDefaultTimeout);
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen, callee()->data_channel()->state(),
- kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return caller()->data_channel()->state(); },
+ Eq(DataChannelInterface::kOpen)),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return callee()->data_channel()->state(); },
+ Eq(DataChannelInterface::kOpen)),
+ IsRtcOk());
callee2->set_signaling_message_receiver(caller());
@@ -1321,17 +1567,27 @@
PeerConnectionInterface::kStable);
EXPECT_EQ(callee2->pc()->signaling_state(), PeerConnectionInterface::kStable);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kConnected,
- caller()->pc()->peer_connection_state(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kConnected,
- callee2->pc()->peer_connection_state(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->pc()->peer_connection_state(); },
+ Eq(PeerConnectionInterface::PeerConnectionState::kConnected)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee2->pc()->peer_connection_state(); },
+ Eq(PeerConnectionInterface::PeerConnectionState::kConnected)),
+ IsRtcOk());
- ASSERT_TRUE_WAIT(caller_sent_on_dc.load() != 0, kDefaultTimeout);
- ASSERT_TRUE_WAIT(callee2_sent_on_dc.load() != 0, kDefaultTimeout);
- EXPECT_EQ_WAIT("KENT", caller()->data_observer()->last_message(),
- kDefaultTimeout);
- EXPECT_EQ_WAIT("KESO", callee2->data_observer()->last_message(),
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return caller_sent_on_dc.load(); }, Ne(0)),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee2_sent_on_dc.load(); }, Ne(0)),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->data_observer()->last_message(); },
+ Eq("KENT")),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee2->data_observer()->last_message(); },
+ Eq("KESO")),
+ IsRtcOk());
}
#endif // WEBRTC_HAVE_SCTP
diff --git a/pc/data_channel_unittest.cc b/pc/data_channel_unittest.cc
index f16ed42..b977b47 100644
--- a/pc/data_channel_unittest.cc
+++ b/pc/data_channel_unittest.cc
@@ -12,26 +12,32 @@
#include <string.h>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
#include "api/data_channel_interface.h"
+#include "api/make_ref_counted.h"
#include "api/priority.h"
#include "api/rtc_error.h"
#include "api/scoped_refptr.h"
+#include "api/sequence_checker.h"
+#include "api/task_queue/pending_task_safety_flag.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/transport/data_channel_transport_interface.h"
-#include "media/base/media_channel.h"
#include "media/sctp/sctp_transport_internal.h"
#include "pc/sctp_data_channel.h"
#include "pc/sctp_utils.h"
#include "pc/test/fake_data_channel_controller.h"
+#include "rtc_base/checks.h"
#include "rtc_base/copy_on_write_buffer.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/null_socket_server.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/thread.h"
+#include "test/gmock.h"
#include "test/gtest.h"
#include "test/run_loop.h"
+#include "test/wait_until.h"
#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
#include "test/testsupport/rtc_expect_death.h"
@@ -41,7 +47,7 @@
namespace {
-static constexpr int kDefaultTimeout = 10000;
+using ::testing::Eq;
class FakeDataChannelObserver : public DataChannelObserver {
public:
@@ -257,7 +263,9 @@
controller_->CreateDataChannel("test1", init);
auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
+ EXPECT_THAT(WaitUntil([&] { return proxy->state(); },
+ Eq(DataChannelInterface::kOpen)),
+ IsRtcOk());
// Sends a message and verifies it's ordered.
DataBuffer buffer("some data");
@@ -286,7 +294,9 @@
controller_->CreateDataChannel("test1", init);
auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
+ EXPECT_THAT(WaitUntil([&] { return proxy->state(); },
+ Eq(DataChannelInterface::kOpen)),
+ IsRtcOk());
// Sends a message and verifies it's ordered.
DataBuffer buffer("some data");
@@ -315,7 +325,9 @@
controller_->CreateDataChannel("test1", init);
auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
+ EXPECT_THAT(WaitUntil([&] { return proxy->state(); },
+ Eq(DataChannelInterface::kOpen)),
+ IsRtcOk());
// Emulates receiving a DATA message.
DataBuffer buffer("data");
@@ -338,7 +350,9 @@
controller_->CreateDataChannel("test1", init);
auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
+ EXPECT_THAT(WaitUntil([&] { return proxy->state(); },
+ Eq(DataChannelInterface::kOpen)),
+ IsRtcOk());
// Emulates receiving a DATA message.
DataBuffer buffer("data");
@@ -397,7 +411,9 @@
controller_->CreateDataChannel("test1", config);
auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
+ EXPECT_THAT(WaitUntil([&] { return proxy->state(); },
+ Eq(DataChannelInterface::kOpen)),
+ IsRtcOk());
EXPECT_EQ(0, controller_->last_sid());
}
@@ -462,7 +478,9 @@
controller_->CreateDataChannel("test1", config);
auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
+ EXPECT_THAT(WaitUntil([&] { return proxy->state(); },
+ Eq(DataChannelInterface::kOpen)),
+ IsRtcOk());
EXPECT_EQ(config.id, controller_->last_sid());
EXPECT_EQ(DataMessageType::kControl,
@@ -586,8 +604,9 @@
network_thread_.BlockingCall(
[&] { inner_channel_->OnTransportChannelClosed(error); });
controller_.reset(nullptr);
- EXPECT_EQ_WAIT(DataChannelInterface::kClosed, channel_->state(),
- kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return channel_->state(); },
+ Eq(DataChannelInterface::kClosed)),
+ IsRtcOk());
EXPECT_FALSE(channel_->error().ok());
EXPECT_EQ(RTCErrorType::OPERATION_ERROR_WITH_DATA, channel_->error().type());
EXPECT_EQ(RTCErrorDetailType::SCTP_FAILURE, channel_->error().error_detail());
@@ -607,8 +626,9 @@
network_thread_.BlockingCall(
[&] { inner_channel_->OnTransportChannelClosed(error); });
controller_.reset(nullptr);
- EXPECT_EQ_WAIT(DataChannelInterface::kClosed, channel_->state(),
- kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return channel_->state(); },
+ Eq(DataChannelInterface::kClosed)),
+ IsRtcOk());
EXPECT_FALSE(channel_->error().ok());
EXPECT_EQ(RTCErrorType::OPERATION_ERROR_WITH_DATA, channel_->error().type());
EXPECT_EQ(RTCErrorDetailType::SCTP_FAILURE, channel_->error().error_detail());
diff --git a/pc/dtls_srtp_transport_integrationtest.cc b/pc/dtls_srtp_transport_integrationtest.cc
index 4d8d88e..20c60b4 100644
--- a/pc/dtls_srtp_transport_integrationtest.cc
+++ b/pc/dtls_srtp_transport_integrationtest.cc
@@ -17,6 +17,8 @@
#include "api/crypto/crypto_options.h"
#include "api/dtls_transport_interface.h"
#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
#include "call/rtp_demuxer.h"
#include "media/base/fake_rtp.h"
#include "p2p/base/fake_ice_transport.h"
@@ -30,15 +32,16 @@
#include "rtc_base/buffer.h"
#include "rtc_base/copy_on_write_buffer.h"
#include "rtc_base/fake_clock.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/ssl_fingerprint.h"
#include "rtc_base/ssl_identity.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/thread.h"
+#include "test/gmock.h"
#include "test/gtest.h"
#include "test/scoped_key_value_config.h"
+#include "test/wait_until.h"
const int kRtpAuthTagLen = 10;
static const int kTimeout = 10000;
@@ -122,9 +125,15 @@
client_ice_transport_->SetDestination(server_ice_transport_.get());
// Wait for the DTLS connection to be up.
- EXPECT_TRUE_SIMULATED_WAIT(client_dtls_transport_->writable() &&
- server_dtls_transport_->writable(),
- kTimeout, fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] {
+ return client_dtls_transport_->writable() &&
+ server_dtls_transport_->writable();
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
EXPECT_EQ(client_dtls_transport_->dtls_state(),
webrtc::DtlsTransportState::kConnected);
EXPECT_EQ(server_dtls_transport_->dtls_state(),
@@ -174,8 +183,12 @@
EXPECT_TRUE(srtp_transport_.SendRtpPacket(&packet, options,
cricket::PF_SRTP_BYPASS));
- EXPECT_TRUE_SIMULATED_WAIT(dtls_srtp_transport_observer_.rtp_count() == 1,
- kTimeout, fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return dtls_srtp_transport_observer_.rtp_count(); },
+ ::testing::Eq(1),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
EXPECT_EQ(1, dtls_srtp_transport_observer_.rtp_count());
ASSERT_TRUE(dtls_srtp_transport_observer_.last_recv_rtp_packet().data());
EXPECT_EQ(
@@ -190,8 +203,12 @@
EXPECT_TRUE(dtls_srtp_transport_.SendRtpPacket(&packet, options,
cricket::PF_SRTP_BYPASS));
- EXPECT_TRUE_SIMULATED_WAIT(srtp_transport_observer_.rtp_count() == 1,
- kTimeout, fake_clock_);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return srtp_transport_observer_.rtp_count(); },
+ ::testing::Eq(1),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
EXPECT_EQ(1, srtp_transport_observer_.rtp_count());
ASSERT_TRUE(srtp_transport_observer_.last_recv_rtp_packet().data());
EXPECT_EQ(
diff --git a/pc/dtls_transport_unittest.cc b/pc/dtls_transport_unittest.cc
index 0160c9d..8a97011 100644
--- a/pc/dtls_transport_unittest.cc
+++ b/pc/dtls_transport_unittest.cc
@@ -19,24 +19,24 @@
#include "api/make_ref_counted.h"
#include "api/rtc_error.h"
#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
#include "p2p/base/p2p_constants.h"
#include "p2p/dtls/fake_dtls_transport.h"
#include "rtc_base/fake_ssl_identity.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/ssl_identity.h"
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
-constexpr int kDefaultTimeout = 1000; // milliseconds
+namespace webrtc {
+
constexpr int kNonsenseCipherSuite = 1234;
using cricket::FakeDtlsTransport;
using ::testing::ElementsAre;
-namespace webrtc {
-
class TestDtlsTransportObserver : public DtlsTransportObserverInterface {
public:
void OnStateChange(DtlsTransportInformation info) override {
@@ -48,7 +48,7 @@
void OnError(RTCError error) override {}
DtlsTransportState state() {
- if (states_.size() > 0) {
+ if (!states_.empty()) {
return states_[states_.size() - 1];
} else {
return DtlsTransportState::kNew;
@@ -111,7 +111,9 @@
CreateTransport();
transport()->RegisterObserver(observer());
CompleteDtlsHandshake();
- ASSERT_TRUE_WAIT(observer_.state_change_called_, kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.state_change_called_; },
+ ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_THAT(
observer_.states_,
ElementsAre( // FakeDtlsTransport doesn't signal the "connecting" state.
@@ -124,11 +126,13 @@
CreateTransport();
transport()->RegisterObserver(observer());
CompleteDtlsHandshake();
- ASSERT_TRUE_WAIT(observer_.state() == DtlsTransportState::kConnected,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.state(); },
+ ::testing::Eq(DtlsTransportState::kConnected)),
+ IsRtcOk());
transport()->Clear();
- ASSERT_TRUE_WAIT(observer_.state() == DtlsTransportState::kClosed,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.state(); },
+ ::testing::Eq(DtlsTransportState::kClosed)),
+ IsRtcOk());
}
TEST_F(DtlsTransportTest, RoleAppearsOnConnect) {
@@ -137,8 +141,9 @@
transport()->RegisterObserver(observer());
EXPECT_FALSE(transport()->Information().role());
CompleteDtlsHandshake();
- ASSERT_TRUE_WAIT(observer_.state() == DtlsTransportState::kConnected,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.state(); },
+ ::testing::Eq(DtlsTransportState::kConnected)),
+ IsRtcOk());
EXPECT_TRUE(observer_.info_.role());
EXPECT_TRUE(transport()->Information().role());
EXPECT_EQ(transport()->Information().role(), DtlsTransportTlsRole::kClient);
@@ -149,8 +154,9 @@
CreateTransport(&fake_certificate);
transport()->RegisterObserver(observer());
CompleteDtlsHandshake();
- ASSERT_TRUE_WAIT(observer_.state() == DtlsTransportState::kConnected,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.state(); },
+ ::testing::Eq(DtlsTransportState::kConnected)),
+ IsRtcOk());
EXPECT_TRUE(observer_.info_.remote_ssl_certificates() != nullptr);
}
@@ -159,12 +165,14 @@
CreateTransport(&fake_certificate);
transport()->RegisterObserver(observer());
CompleteDtlsHandshake();
- ASSERT_TRUE_WAIT(observer_.state() == DtlsTransportState::kConnected,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.state(); },
+ ::testing::Eq(DtlsTransportState::kConnected)),
+ IsRtcOk());
EXPECT_TRUE(observer_.info_.remote_ssl_certificates() != nullptr);
transport()->Clear();
- ASSERT_TRUE_WAIT(observer_.state() == DtlsTransportState::kClosed,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.state(); },
+ ::testing::Eq(DtlsTransportState::kClosed)),
+ IsRtcOk());
EXPECT_FALSE(observer_.info_.remote_ssl_certificates());
}
@@ -172,13 +180,15 @@
CreateTransport();
transport()->RegisterObserver(observer());
CompleteDtlsHandshake();
- ASSERT_TRUE_WAIT(observer_.state() == DtlsTransportState::kConnected,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.state(); },
+ ::testing::Eq(DtlsTransportState::kConnected)),
+ IsRtcOk());
ASSERT_TRUE(observer_.info_.ssl_cipher_suite());
EXPECT_EQ(kNonsenseCipherSuite, *observer_.info_.ssl_cipher_suite());
transport()->Clear();
- ASSERT_TRUE_WAIT(observer_.state() == DtlsTransportState::kClosed,
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.state(); },
+ ::testing::Eq(DtlsTransportState::kClosed)),
+ IsRtcOk());
EXPECT_FALSE(observer_.info_.ssl_cipher_suite());
}
diff --git a/pc/dtmf_sender_unittest.cc b/pc/dtmf_sender_unittest.cc
index ab5ba9e..9c981cb 100644
--- a/pc/dtmf_sender_unittest.cc
+++ b/pc/dtmf_sender_unittest.cc
@@ -12,14 +12,21 @@
#include <stddef.h>
+#include <cstdint>
#include <memory>
#include <string>
#include <vector>
+#include "api/dtmf_sender_interface.h"
+#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
#include "rtc_base/fake_clock.h"
-#include "rtc_base/gunit.h"
+#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
+#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
using webrtc::DtmfProviderInterface;
using webrtc::DtmfSender;
@@ -55,7 +62,7 @@
const std::vector<std::string>& tones_from_single_argument_callback() const {
return tones_from_single_argument_callback_;
}
- const std::string tones_remaining() { return tones_remaining_; }
+ std::string tones_remaining() { return tones_remaining_; }
bool completed() const { return completed_; }
private:
@@ -117,7 +124,7 @@
}
~DtmfSenderTest() {
- if (dtmf_.get()) {
+ if (dtmf_) {
dtmf_->UnregisterObserver();
}
}
@@ -225,7 +232,11 @@
int duration = 100;
int inter_tone_gap = 50;
EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap));
- EXPECT_TRUE_SIMULATED_WAIT(observer_->completed(), kMaxWaitMs, fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->completed(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
// The unrecognized characters should be ignored.
std::string known_tones = "1a*";
@@ -241,14 +252,21 @@
EXPECT_TRUE(dtmf_->InsertDtmf(tones1, duration, inter_tone_gap));
VerifyExpectedState(tones1, duration, inter_tone_gap);
// Wait until the first tone got sent.
- EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs,
- fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->tones().size(); }, ::testing::Eq(1),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
VerifyExpectedState("2", duration, inter_tone_gap);
// Insert with another tone buffer.
EXPECT_TRUE(dtmf_->InsertDtmf(tones2, duration, inter_tone_gap));
VerifyExpectedState(tones2, duration, inter_tone_gap);
// Wait until it's completed.
- EXPECT_TRUE_SIMULATED_WAIT(observer_->completed(), kMaxWaitMs, fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->completed(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
std::vector<FakeDtmfProvider::DtmfInfo> dtmf_queue_ref;
GetDtmfInfoFromString("1", duration, inter_tone_gap, &dtmf_queue_ref);
@@ -263,13 +281,16 @@
int inter_tone_gap = 50;
EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap));
// Wait until the first tone got sent.
- EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs,
- fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->tones().size(); }, ::testing::Eq(1),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
// Delete provider.
dtmf_->OnDtmfProviderDestroyed();
provider_.reset();
// The queue should be discontinued so no more tone callbacks.
- SIMULATED_WAIT(false, 200, fake_clock_);
+ fake_clock_.AdvanceTime(webrtc::TimeDelta::Millis(200));
EXPECT_EQ(1U, observer_->tones().size());
}
@@ -279,12 +300,15 @@
int inter_tone_gap = 50;
EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap));
// Wait until the first tone got sent.
- EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs,
- fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->tones().size(); }, ::testing::Eq(1),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
// Delete the sender.
dtmf_ = NULL;
// The queue should be discontinued so no more tone callbacks.
- SIMULATED_WAIT(false, 200, fake_clock_);
+ fake_clock_.AdvanceTime(webrtc::TimeDelta::Millis(200));
EXPECT_EQ(1U, observer_->tones().size());
}
@@ -295,12 +319,19 @@
int inter_tone_gap = 50;
EXPECT_TRUE(dtmf_->InsertDtmf(tones1, duration, inter_tone_gap));
// Wait until the first tone got sent.
- EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs,
- fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->tones().size(); }, ::testing::Eq(1),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
// Insert with another tone buffer.
EXPECT_TRUE(dtmf_->InsertDtmf(tones2, duration, inter_tone_gap));
// Wait until it's completed.
- EXPECT_TRUE_SIMULATED_WAIT(observer_->completed(), kMaxWaitMs, fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->completed(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
std::vector<FakeDtmfProvider::DtmfInfo> dtmf_queue_ref;
GetDtmfInfoFromString("1", duration, inter_tone_gap, &dtmf_queue_ref);
@@ -315,7 +346,11 @@
int default_comma_delay = webrtc::DtmfSender::kDtmfDefaultCommaDelayMs;
EXPECT_EQ(dtmf_->comma_delay(), default_comma_delay);
EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap));
- EXPECT_TRUE_SIMULATED_WAIT(observer_->completed(), kMaxWaitMs, fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->completed(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
VerifyOnProvider(tones, duration, inter_tone_gap);
VerifyOnObserver(tones);
@@ -330,7 +365,11 @@
int comma_delay = 500;
EXPECT_EQ(dtmf_->comma_delay(), default_comma_delay);
EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap, comma_delay));
- EXPECT_TRUE_SIMULATED_WAIT(observer_->completed(), kMaxWaitMs, fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->completed(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
VerifyOnProvider(tones, duration, inter_tone_gap, comma_delay);
VerifyOnObserver(tones);
@@ -365,7 +404,10 @@
EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap));
VerifyExpectedState("ABC", duration, inter_tone_gap);
// Wait until the first tone got sent.
- EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs,
- fake_clock_);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return observer_->tones().size(); }, ::testing::Eq(1),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs),
+ .clock = &fake_clock_}),
+ webrtc::IsRtcOk());
VerifyExpectedState("BC", duration, inter_tone_gap);
}
diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc
index b16c7b1..a3a706d 100644
--- a/pc/jsep_transport_controller_unittest.cc
+++ b/pc/jsep_transport_controller_unittest.cc
@@ -27,8 +27,10 @@
#include "api/make_ref_counted.h"
#include "api/peer_connection_interface.h"
#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/transport/data_channel_transport_interface.h"
#include "api/transport/enums.h"
+#include "api/units/time_delta.h"
#include "call/payload_type_picker.h"
#include "p2p/base/candidate_pair_interface.h"
#include "p2p/base/fake_ice_transport.h"
@@ -47,7 +49,6 @@
#include "rtc_base/checks.h"
#include "rtc_base/copy_on_write_buffer.h"
#include "rtc_base/fake_ssl_identity.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
#include "rtc_base/socket_address.h"
@@ -57,13 +58,14 @@
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread.h"
+#include "test/gmock.h"
#include "test/gtest.h"
#include "test/scoped_key_value_config.h"
+#include "test/wait_until.h"
using cricket::Candidate;
using cricket::Candidates;
using cricket::FakeDtlsTransport;
-using webrtc::SdpType;
static const int kTimeout = 100;
static const char kIceUfrag1[] = "u0001";
@@ -562,7 +564,10 @@
// After setting the local description, we should be able to start gathering
// candidates.
transport_controller_->MaybeStartGathering();
- EXPECT_EQ_WAIT(cricket::kIceGatheringGathering, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringGathering; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, gathering_state_signal_count_);
}
@@ -713,13 +718,23 @@
fake_ice->SetConnectionCount(1);
// The connection stats will be failed if there is no active connection.
fake_ice->SetConnectionCount(0);
- EXPECT_EQ_WAIT(cricket::kIceConnectionFailed, connection_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceConnectionFailed; },
+ ::testing::Eq(connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionFailed,
- ice_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return PeerConnectionInterface::kIceConnectionFailed; },
+ ::testing::Eq(ice_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, ice_connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kFailed,
- combined_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return PeerConnectionInterface::PeerConnectionState::kFailed; },
+ ::testing::Eq(combined_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, combined_connection_state_signal_count_);
}
@@ -748,13 +763,23 @@
fake_video_dtls->fake_ice_transport()->SetConnectionCount(0);
fake_video_dtls->fake_ice_transport()->SetCandidatesGatheringComplete();
- EXPECT_EQ_WAIT(cricket::kIceConnectionFailed, connection_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceConnectionFailed; },
+ ::testing::Eq(connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionFailed,
- ice_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return PeerConnectionInterface::kIceConnectionFailed; },
+ ::testing::Eq(ice_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, ice_connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kFailed,
- combined_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return PeerConnectionInterface::PeerConnectionState::kFailed; },
+ ::testing::Eq(combined_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, combined_connection_state_signal_count_);
fake_audio_dtls->SetDtlsState(DtlsTransportState::kConnected);
@@ -763,13 +788,26 @@
// the transport state to be STATE_CONNECTING.
fake_video_dtls->fake_ice_transport()->SetConnectionCount(2);
fake_video_dtls->SetWritable(true);
- EXPECT_EQ_WAIT(cricket::kIceConnectionConnected, connection_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceConnectionConnected; },
+ ::testing::Eq(connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- ice_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return PeerConnectionInterface::kIceConnectionConnected; },
+ ::testing::Eq(ice_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(3, ice_connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kConnected,
- combined_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return PeerConnectionInterface::PeerConnectionState::kConnected;
+ },
+ ::testing::Eq(combined_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(3, combined_connection_state_signal_count_);
}
@@ -795,24 +833,43 @@
fake_audio_dtls->SetWritable(true);
fake_audio_dtls->fake_ice_transport()->SetCandidatesGatheringComplete();
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking,
- ice_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return PeerConnectionInterface::kIceConnectionChecking; },
+ ::testing::Eq(ice_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, ice_connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kConnecting,
- combined_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return PeerConnectionInterface::PeerConnectionState::kConnecting;
+ },
+ ::testing::Eq(combined_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, combined_connection_state_signal_count_);
fake_video_dtls->fake_ice_transport()->SetTransportState(
IceTransportState::kFailed, cricket::IceTransportState::STATE_FAILED);
fake_video_dtls->fake_ice_transport()->SetCandidatesGatheringComplete();
- EXPECT_EQ_WAIT(cricket::kIceConnectionFailed, connection_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceConnectionFailed; },
+ ::testing::Eq(connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionFailed,
- ice_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return PeerConnectionInterface::kIceConnectionFailed; },
+ ::testing::Eq(ice_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, ice_connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kFailed,
- combined_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return PeerConnectionInterface::PeerConnectionState::kFailed; },
+ ::testing::Eq(combined_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, combined_connection_state_signal_count_);
fake_audio_dtls->SetDtlsState(DtlsTransportState::kConnected);
@@ -823,13 +880,26 @@
IceTransportState::kCompleted,
cricket::IceTransportState::STATE_COMPLETED);
fake_video_dtls->SetWritable(true);
- EXPECT_EQ_WAIT(cricket::kIceConnectionCompleted, connection_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceConnectionCompleted; },
+ ::testing::Eq(connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(3, connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- ice_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return PeerConnectionInterface::kIceConnectionCompleted; },
+ ::testing::Eq(ice_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(3, ice_connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kConnected,
- combined_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return PeerConnectionInterface::PeerConnectionState::kConnected;
+ },
+ ::testing::Eq(combined_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(3, combined_connection_state_signal_count_);
}
@@ -845,7 +915,10 @@
transport_controller_->GetDtlsTransport(kAudioMid1));
fake_audio_dtls->fake_ice_transport()->MaybeStartGathering();
// Should be in the gathering state as soon as any transport starts gathering.
- EXPECT_EQ_WAIT(cricket::kIceGatheringGathering, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringGathering; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, gathering_state_signal_count_);
}
@@ -863,7 +936,10 @@
transport_controller_->GetDtlsTransport(kVideoMid1));
fake_audio_dtls->fake_ice_transport()->MaybeStartGathering();
- EXPECT_EQ_WAIT(cricket::kIceGatheringGathering, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringGathering; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, gathering_state_signal_count_);
// Have one transport finish gathering, to make sure gathering
@@ -872,11 +948,17 @@
EXPECT_EQ(1, gathering_state_signal_count_);
fake_video_dtls->fake_ice_transport()->MaybeStartGathering();
- EXPECT_EQ_WAIT(cricket::kIceGatheringGathering, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringGathering; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, gathering_state_signal_count_);
fake_video_dtls->fake_ice_transport()->SetCandidatesGatheringComplete();
- EXPECT_EQ_WAIT(cricket::kIceGatheringComplete, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringComplete; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, gathering_state_signal_count_);
}
@@ -900,7 +982,10 @@
EXPECT_NE(fake_audio_dtls, fake_video_dtls);
fake_audio_dtls->fake_ice_transport()->MaybeStartGathering();
- EXPECT_EQ_WAIT(cricket::kIceGatheringGathering, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringGathering; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, gathering_state_signal_count_);
// Let the audio transport complete.
@@ -920,12 +1005,18 @@
fake_video_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kVideoMid1));
EXPECT_EQ(fake_audio_dtls, fake_video_dtls);
- EXPECT_EQ_WAIT(cricket::kIceConnectionCompleted, connection_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceConnectionCompleted; },
+ ::testing::Eq(connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(PeerConnectionInterface::kIceConnectionCompleted,
ice_connection_state_);
EXPECT_EQ(PeerConnectionInterface::PeerConnectionState::kConnected,
combined_connection_state_);
- EXPECT_EQ_WAIT(cricket::kIceGatheringComplete, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringComplete; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, gathering_state_signal_count_);
}
@@ -955,13 +1046,25 @@
fake_audio_dtls->fake_ice_transport()->SetTransportState(
IceTransportState::kChecking,
cricket::IceTransportState::STATE_CONNECTING);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking,
- ice_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return PeerConnectionInterface::kIceConnectionChecking; },
+ ::testing::Eq(ice_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, ice_connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kConnecting,
- combined_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return PeerConnectionInterface::PeerConnectionState::kConnecting;
+ },
+ ::testing::Eq(combined_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, combined_connection_state_signal_count_);
- EXPECT_EQ_WAIT(cricket::kIceGatheringGathering, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringGathering; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1, gathering_state_signal_count_);
// Reject m= section which should disconnect the transport and return states
@@ -971,25 +1074,47 @@
->SetRemoteDescription(SdpType::kOffer, description.get(),
description.get())
.ok());
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionNew,
- ice_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return PeerConnectionInterface::kIceConnectionNew; },
+ ::testing::Eq(ice_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, ice_connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kNew,
- combined_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return PeerConnectionInterface::PeerConnectionState::kNew; },
+ ::testing::Eq(combined_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, combined_connection_state_signal_count_);
- EXPECT_EQ_WAIT(cricket::kIceGatheringNew, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringNew; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, gathering_state_signal_count_);
// For good measure, rollback the offer and verify that states return to
// their previous values.
EXPECT_TRUE(transport_controller_->RollbackTransports().ok());
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking,
- ice_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return PeerConnectionInterface::kIceConnectionChecking; },
+ ::testing::Eq(ice_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(3, ice_connection_state_signal_count_);
- EXPECT_EQ_WAIT(PeerConnectionInterface::PeerConnectionState::kConnecting,
- combined_connection_state_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return PeerConnectionInterface::PeerConnectionState::kConnecting;
+ },
+ ::testing::Eq(combined_connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(3, combined_connection_state_signal_count_);
- EXPECT_EQ_WAIT(cricket::kIceGatheringGathering, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringGathering; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(3, gathering_state_signal_count_);
}
@@ -1006,7 +1131,10 @@
transport_controller_->GetDtlsTransport(kAudioMid1));
fake_audio_dtls->fake_ice_transport()->SignalCandidateGathered(
fake_audio_dtls->fake_ice_transport(), CreateCandidate(kAudioMid1, 1));
- EXPECT_EQ_WAIT(1, candidates_signal_count_, kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return 1; }, ::testing::Eq(candidates_signal_count_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(1u, candidates_[kAudioMid1].size());
}
@@ -1020,15 +1148,27 @@
CreateLocalDescriptionAndCompleteConnectionOnNetworkThread();
// connecting --> connected --> completed
- EXPECT_EQ_WAIT(cricket::kIceConnectionCompleted, connection_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceConnectionCompleted; },
+ ::testing::Eq(connection_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, connection_state_signal_count_);
// new --> gathering --> complete
- EXPECT_EQ_WAIT(cricket::kIceGatheringComplete, gathering_state_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return cricket::kIceGatheringComplete; },
+ ::testing::Eq(gathering_state_),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, gathering_state_signal_count_);
- EXPECT_EQ_WAIT(1u, candidates_[kAudioMid1].size(), kTimeout);
- EXPECT_EQ_WAIT(1u, candidates_[kVideoMid1].size(), kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return candidates_[kAudioMid1].size(); },
+ ::testing::Eq(1u),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return candidates_[kVideoMid1].size(); },
+ ::testing::Eq(1u),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_EQ(2, candidates_signal_count_);
EXPECT_EQ(ice_signaled_on_thread_, network_thread_.get());
diff --git a/pc/peer_connection_adaptation_integrationtest.cc b/pc/peer_connection_adaptation_integrationtest.cc
index 93aa1eb..3ed90a0 100644
--- a/pc/peer_connection_adaptation_integrationtest.cc
+++ b/pc/peer_connection_adaptation_integrationtest.cc
@@ -12,33 +12,33 @@
#include <memory>
#include <optional>
-#include <string>
#include "api/adaptation/resource.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
+#include "api/make_ref_counted.h"
#include "api/media_stream_interface.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_error.h"
#include "api/rtp_parameters.h"
#include "api/rtp_sender_interface.h"
#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/video/video_source_interface.h"
#include "call/adaptation/test/fake_resource.h"
#include "pc/test/fake_periodic_video_source.h"
#include "pc/test/fake_periodic_video_track_source.h"
#include "pc/test/peer_connection_test_wrapper.h"
#include "rtc_base/checks.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
#include "rtc_base/virtual_socket_server.h"
+#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
-const int64_t kDefaultTimeoutMs = 5000;
-
struct TrackWithPeriodicSource {
rtc::scoped_refptr<VideoTrackInterface> track;
rtc::scoped_refptr<FakePeriodicVideoTrackSource> periodic_track_source;
@@ -132,10 +132,13 @@
// Inject a fake resource and spam kOveruse until resolution becomes limited.
auto fake_resource = FakeResource::Create("FakeResource");
caller->AddAdaptationResource(fake_resource);
- EXPECT_TRUE_WAIT(
- TriggerOveruseAndGetSinkWants(fake_resource, source).max_pixel_count <
- pixel_count_before_overuse,
- kDefaultTimeoutMs);
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return TriggerOveruseAndGetSinkWants(fake_resource, source)
+ .max_pixel_count;
+ },
+ ::testing::Lt(pixel_count_before_overuse)),
+ IsRtcOk());
}
TEST_F(PeerConnectionAdaptationIntegrationTest,
@@ -163,10 +166,13 @@
int pixel_count_before_overuse = source.wants().max_pixel_count;
// Spam kOveruse until resolution becomes limited.
- EXPECT_TRUE_WAIT(
- TriggerOveruseAndGetSinkWants(fake_resource, source).max_pixel_count <
- pixel_count_before_overuse,
- kDefaultTimeoutMs);
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return TriggerOveruseAndGetSinkWants(fake_resource, source)
+ .max_pixel_count;
+ },
+ ::testing::Lt(pixel_count_before_overuse)),
+ IsRtcOk());
}
} // namespace webrtc
diff --git a/pc/peer_connection_bundle_unittest.cc b/pc/peer_connection_bundle_unittest.cc
index 7208ba0..ff3cf59 100644
--- a/pc/peer_connection_bundle_unittest.cc
+++ b/pc/peer_connection_bundle_unittest.cc
@@ -10,18 +10,14 @@
#include <stddef.h>
-#include <cstdint>
#include <memory>
#include <ostream>
#include <string>
#include <tuple>
-#include <type_traits>
#include <utility>
#include <vector>
#include "api/audio/audio_device.h"
-#include "api/audio/audio_mixer.h"
-#include "api/audio/audio_processing.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/candidate.h"
@@ -33,9 +29,9 @@
#include "api/rtp_sender_interface.h"
#include "api/rtp_transceiver_interface.h"
#include "api/scoped_refptr.h"
-#include "api/stats/rtc_stats.h"
#include "api/stats/rtc_stats_report.h"
#include "api/stats/rtcstats_objects.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/video_codecs/video_decoder_factory_template.h"
#include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
@@ -47,8 +43,8 @@
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
#include "media/base/stream_params.h"
+#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/base/p2p_constants.h"
-#include "p2p/base/port.h"
#include "p2p/base/port_allocator.h"
#include "p2p/base/transport_info.h"
#include "p2p/client/basic_port_allocator.h"
@@ -66,16 +62,15 @@
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
#include "rtc_base/network.h"
-#include "rtc_base/rtc_certificate_generator.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/thread.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
#ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h"
#endif
#include "pc/test/fake_audio_capture_module.h"
#include "rtc_base/fake_network.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/virtual_socket_server.h"
#include "test/gmock.h"
@@ -87,7 +82,6 @@
using RtcpMuxPolicy = PeerConnectionInterface::RtcpMuxPolicy;
using rtc::SocketAddress;
using ::testing::Combine;
-using ::testing::ElementsAre;
using ::testing::UnorderedElementsAre;
using ::testing::Values;
@@ -356,7 +350,9 @@
ASSERT_TRUE(caller->SetRemoteDescription(std::move(answer)));
// Check that caller has separate RTP and RTCP candidates for each media.
- EXPECT_TRUE_WAIT(caller->IsIceGatheringDone(), kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return caller->IsIceGatheringDone(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_THAT(
GetCandidateComponents(caller->observer()->GetCandidatesByMline(0)),
UnorderedElementsAre(cricket::ICE_CANDIDATE_COMPONENT_RTP,
@@ -367,7 +363,9 @@
cricket::ICE_CANDIDATE_COMPONENT_RTCP));
// Check that callee has separate RTP and RTCP candidates for each media.
- EXPECT_TRUE_WAIT(callee->IsIceGatheringDone(), kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return callee->IsIceGatheringDone(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_THAT(
GetCandidateComponents(callee->observer()->GetCandidatesByMline(0)),
UnorderedElementsAre(cricket::ICE_CANDIDATE_COMPONENT_RTP,
@@ -394,7 +392,9 @@
ASSERT_TRUE(
caller->SetRemoteDescription(callee->CreateAnswer(options_no_bundle)));
- EXPECT_TRUE_WAIT(caller->IsIceGatheringDone(), kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return caller->IsIceGatheringDone(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_EQ(1u, caller->observer()->GetCandidatesByMline(0).size());
EXPECT_EQ(1u, caller->observer()->GetCandidatesByMline(1).size());
@@ -415,7 +415,9 @@
ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()));
ASSERT_TRUE(caller->SetRemoteDescription(callee->CreateAnswer()));
- EXPECT_TRUE_WAIT(caller->IsIceGatheringDone(), kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return caller->IsIceGatheringDone(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_EQ(1u, caller->observer()->GetCandidatesByMline(0).size());
EXPECT_EQ(0u, caller->observer()->GetCandidatesByMline(1).size());
@@ -692,10 +694,20 @@
ASSERT_TRUE(caller->AddIceCandidateToMedia(&audio_candidate2,
cricket::MEDIA_TYPE_AUDIO));
- EXPECT_TRUE_WAIT(caller->HasConnectionWithRemoteAddress(kAudioAddress1),
- kDefaultTimeout);
- EXPECT_TRUE_WAIT(caller->HasConnectionWithRemoteAddress(kAudioAddress2),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return caller->HasConnectionWithRemoteAddress(kAudioAddress1);
+ },
+ ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return caller->HasConnectionWithRemoteAddress(kAudioAddress2);
+ },
+ ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_FALSE(caller->HasConnectionWithRemoteAddress(kVideoAddress));
}
diff --git a/pc/peer_connection_crypto_unittest.cc b/pc/peer_connection_crypto_unittest.cc
index 83c308d..0ff67ec 100644
--- a/pc/peer_connection_crypto_unittest.cc
+++ b/pc/peer_connection_crypto_unittest.cc
@@ -11,25 +11,22 @@
#include <stddef.h>
#include <memory>
-#include <optional>
#include <ostream>
#include <string>
#include <tuple>
-#include <type_traits>
#include <utility>
#include <vector>
-#include "api/audio/audio_device.h"
-#include "api/audio/audio_mixer.h"
-#include "api/audio/audio_processing.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h"
-#include "api/crypto/crypto_options.h"
#include "api/field_trials.h"
#include "api/jsep.h"
+#include "api/make_ref_counted.h"
#include "api/peer_connection_interface.h"
#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
#include "api/video_codecs/video_decoder_factory_template.h"
#include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
@@ -40,8 +37,8 @@
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
+#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/base/fake_port_allocator.h"
-#include "p2p/base/port_allocator.h"
#include "p2p/base/transport_description.h"
#include "p2p/base/transport_info.h"
#include "pc/media_protocol_names.h"
@@ -57,12 +54,12 @@
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
#ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h"
#endif
#include "pc/test/fake_audio_capture_module.h"
#include "pc/test/fake_rtc_certificate_generator.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/virtual_socket_server.h"
namespace webrtc {
@@ -383,10 +380,15 @@
pc->SetRemoteDescription(caller->CreateOfferAndSetAsLocal());
}
if (cert_gen_time_ == CertGenTime::kBefore) {
- ASSERT_TRUE_WAIT(fake_certificate_generator->generated_certificates() +
- fake_certificate_generator->generated_failures() >
- 0,
- kGenerateCertTimeout);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] {
+ return fake_certificate_generator->generated_certificates() +
+ fake_certificate_generator->generated_failures();
+ },
+ ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kGenerateCertTimeout)}),
+ IsRtcOk());
} else {
ASSERT_EQ(fake_certificate_generator->generated_certificates(), 0);
fake_certificate_generator->set_should_wait(false);
@@ -406,7 +408,9 @@
}
}
for (auto& observer : observers) {
- EXPECT_TRUE_WAIT(observer->called(), 1000);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
if (cert_gen_result_ == CertGenResult::kSucceed) {
EXPECT_TRUE(observer->result());
} else {
diff --git a/pc/peer_connection_end_to_end_unittest.cc b/pc/peer_connection_end_to_end_unittest.cc
index cc57c7b..34bc5d4 100644
--- a/pc/peer_connection_end_to_end_unittest.cc
+++ b/pc/peer_connection_end_to_end_unittest.cc
@@ -15,7 +15,6 @@
#include <memory>
#include <optional>
#include <string>
-#include <type_traits>
#include <utility>
#include <vector>
@@ -35,19 +34,23 @@
#include "api/audio_options.h"
#include "api/data_channel_interface.h"
#include "api/environment/environment.h"
+#include "api/make_ref_counted.h"
#include "api/media_stream_interface.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_error.h"
+#include "api/rtp_parameters.h"
#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
#include "media/sctp/sctp_transport_internal.h"
#include "rtc_base/checks.h"
#include "rtc_base/copy_on_write_buffer.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/physical_socket_server.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
#ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h"
@@ -66,7 +69,6 @@
using ::testing::Values;
using ::webrtc::DataChannelInterface;
using ::webrtc::Environment;
-using ::webrtc::MediaStreamInterface;
using ::webrtc::PeerConnectionInterface;
using ::webrtc::SdpSemantics;
@@ -184,14 +186,24 @@
}
EXPECT_TRUE(dc1->Send(buffer));
- EXPECT_EQ_WAIT(buffer.data,
- rtc::CopyOnWriteBuffer(dc2_observer->last_message()),
- kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil(
+ [&] {
+ return rtc::CopyOnWriteBuffer(dc2_observer->last_message());
+ },
+ ::testing::Eq(buffer.data),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
EXPECT_TRUE(dc2->Send(buffer));
- EXPECT_EQ_WAIT(buffer.data,
- rtc::CopyOnWriteBuffer(dc1_observer->last_message()),
- kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil(
+ [&] {
+ return rtc::CopyOnWriteBuffer(dc1_observer->last_message());
+ },
+ ::testing::Eq(buffer.data),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
EXPECT_EQ(1U, dc1_observer->received_message_count());
EXPECT_EQ(size, dc1_observer->last_message().length());
@@ -202,11 +214,22 @@
void WaitForDataChannelsToOpen(DataChannelInterface* local_dc,
const DataChannelList& remote_dc_list,
size_t remote_dc_index) {
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen, local_dc->state(), kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return local_dc->state(); },
+ ::testing::Eq(DataChannelInterface::kOpen),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
- ASSERT_TRUE_WAIT(remote_dc_list.size() > remote_dc_index, kMaxWait);
- EXPECT_EQ_WAIT(DataChannelInterface::kOpen,
- remote_dc_list[remote_dc_index]->state(), kMaxWait);
+ ASSERT_THAT(
+ webrtc::WaitUntil([&] { return remote_dc_list.size(); },
+ ::testing::Gt(remote_dc_index),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return remote_dc_list[remote_dc_index]->state(); },
+ ::testing::Eq(DataChannelInterface::kOpen),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
EXPECT_EQ(local_dc->id(), remote_dc_list[remote_dc_index]->id());
}
@@ -214,9 +237,16 @@
const DataChannelList& remote_dc_list,
size_t remote_dc_index) {
local_dc->Close();
- EXPECT_EQ_WAIT(DataChannelInterface::kClosed, local_dc->state(), kMaxWait);
- EXPECT_EQ_WAIT(DataChannelInterface::kClosed,
- remote_dc_list[remote_dc_index]->state(), kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return local_dc->state(); },
+ ::testing::Eq(DataChannelInterface::kClosed),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return remote_dc_list[remote_dc_index]->state(); },
+ ::testing::Eq(DataChannelInterface::kClosed),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
}
protected:
@@ -648,10 +678,18 @@
const std::string message_2 = "hello 2";
caller_dc_1->Send(webrtc::DataBuffer(message_1));
- EXPECT_EQ_WAIT(message_1, dc_1_observer->last_message(), kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return dc_1_observer->last_message(); },
+ ::testing::Eq(message_1),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
caller_dc_2->Send(webrtc::DataBuffer(message_2));
- EXPECT_EQ_WAIT(message_2, dc_2_observer->last_message(), kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return dc_2_observer->last_message(); },
+ ::testing::Eq(message_2),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
EXPECT_EQ(1U, dc_1_observer->received_message_count());
EXPECT_EQ(1U, dc_2_observer->received_message_count());
@@ -679,7 +717,11 @@
// Previously, the channel on which Close is called reported being closed
// prematurely, and this caused issues; see bugs.webrtc.org/4453.
caller_dc->Close();
- EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return caller_dc->state(); },
+ ::testing::Eq(DataChannelInterface::kClosed),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
// Create a new channel and ensure it works after closing the previous one.
caller_dc = caller_->CreateDataChannel("data2", init);
@@ -712,7 +754,11 @@
// This removes the reference to the remote data channel that we hold.
callee_signaled_data_channels_.clear();
caller_dc->Close();
- EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return caller_dc->state(); },
+ ::testing::Eq(DataChannelInterface::kClosed),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
// Wait for a bit longer so the remote data channel will receive the
// close message and be destroyed.
@@ -733,8 +779,11 @@
}
Negotiate();
WaitForConnection();
- EXPECT_EQ_WAIT(callee_signaled_data_channels_.size(),
- static_cast<size_t>(cricket::kMaxSctpStreams / 2), kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return callee_signaled_data_channels_; },
+ ::testing::SizeIs(cricket::kMaxSctpStreams / 2),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
EXPECT_EQ(DataChannelInterface::kOpen,
channels[(cricket::kMaxSctpStreams / 2) - 1]->state());
EXPECT_EQ(DataChannelInterface::kClosed,
diff --git a/pc/peer_connection_histogram_unittest.cc b/pc/peer_connection_histogram_unittest.cc
index 0697c67..d1e6ccb 100644
--- a/pc/peer_connection_histogram_unittest.cc
+++ b/pc/peer_connection_histogram_unittest.cc
@@ -17,13 +17,13 @@
#include "api/jsep.h"
#include "api/jsep_session_description.h"
+#include "api/make_ref_counted.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_error.h"
#include "api/scoped_refptr.h"
#include "api/task_queue/default_task_queue_factory.h"
-#include "api/task_queue/task_queue_factory.h"
#include "api/test/mock_async_dns_resolver.h"
-#include "media/base/media_engine.h"
+#include "api/test/rtc_error_matchers.h"
#include "p2p/base/port_allocator.h"
#include "p2p/client/basic_port_allocator.h"
#include "pc/peer_connection.h"
@@ -40,20 +40,19 @@
#include "rtc_base/fake_mdns_responder.h"
#include "rtc_base/fake_network.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/mdns_responder_interface.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/thread.h"
#include "rtc_base/virtual_socket_server.h"
#include "system_wrappers/include/metrics.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
using RTCConfiguration = PeerConnectionInterface::RTCConfiguration;
using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
using ::testing::NiceMock;
-using ::testing::Values;
static const char kUsagePatternMetric[] = "WebRTC.PeerConnection.UsagePattern";
static constexpr int kDefaultTimeout = 10000;
@@ -206,7 +205,9 @@
if (!set_local_offer) {
return false;
}
- EXPECT_TRUE_WAIT(observer()->ice_gathering_complete_, kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer()->ice_gathering_complete_; },
+ ::testing::IsTrue()),
+ IsRtcOk());
return true;
}
@@ -386,8 +387,10 @@
auto pc = CreatePeerConnectionWithImmediateReport();
int expected_fingerprint = MakeUsageFingerprint({});
- EXPECT_METRIC_EQ_WAIT(1, metrics::NumSamples(kUsagePatternMetric),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return metrics::NumSamples(kUsagePatternMetric); },
+ ::testing::Eq(1)),
+ IsRtcOk());
EXPECT_METRIC_EQ(
1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint));
}
@@ -512,7 +515,9 @@
auto callee = CreatePeerConnection();
caller->CreateDataChannel("foodata");
ASSERT_TRUE(caller->ConnectTo(callee.get()));
- ASSERT_TRUE_WAIT(callee->HaveDataChannel(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return callee->HaveDataChannel(); }, ::testing::IsTrue()),
+ IsRtcOk());
caller->pc()->Close();
callee->pc()->Close();
int expected_fingerprint = MakeUsageFingerprint(
@@ -658,8 +663,10 @@
ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
// Wait until the gathering completes so that the session description would
// have contained ICE candidates.
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
- caller->ice_gathering_state(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller->ice_gathering_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete)),
+ IsRtcOk());
EXPECT_TRUE(caller->observer()->candidate_gathered());
// Get the current offer that contains candidates and pass it to the callee.
//
@@ -680,11 +687,18 @@
auto answer = callee->CreateAnswer();
callee->SetLocalDescription(CloneSessionDescription(answer.get()));
caller->SetRemoteDescription(std::move(answer));
- EXPECT_TRUE_WAIT(caller->IsConnected(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(callee->IsConnected(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller->IsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee->IsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
// The callee needs to process the open message to have the data channel open.
- EXPECT_TRUE_WAIT(callee->observer()->last_datachannel_ != nullptr,
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return callee->observer()->last_datachannel_ != nullptr; },
+ ::testing::IsTrue()),
+ IsRtcOk());
caller->pc()->Close();
callee->pc()->Close();
@@ -741,8 +755,10 @@
UsageEvent::CANDIDATE_COLLECTED});
EXPECT_METRIC_EQ(0, metrics::NumSamples(kUsagePatternMetric));
caller->GetInternalPeerConnection()->RequestUsagePatternReportForTesting();
- EXPECT_METRIC_EQ_WAIT(1, metrics::NumSamples(kUsagePatternMetric),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return metrics::NumSamples(kUsagePatternMetric); },
+ ::testing::Eq(1)),
+ IsRtcOk());
EXPECT_METRIC_TRUE(
expected_fingerprint == ObservedFingerprint() ||
(expected_fingerprint |
@@ -765,8 +781,10 @@
EXPECT_METRIC_EQ(1, metrics::NumSamples(kUsagePatternMetric));
caller->GetInternalPeerConnection()->RequestUsagePatternReportForTesting();
caller->observer()->ClearInterestingUsageDetector();
- EXPECT_METRIC_EQ_WAIT(2, metrics::NumSamples(kUsagePatternMetric),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return metrics::NumSamples(kUsagePatternMetric); },
+ ::testing::Eq(2)),
+ IsRtcOk());
EXPECT_METRIC_TRUE(
expected_fingerprint == ObservedFingerprint() ||
(expected_fingerprint |
diff --git a/pc/peer_connection_ice_unittest.cc b/pc/peer_connection_ice_unittest.cc
index 613736a..d7736a7 100644
--- a/pc/peer_connection_ice_unittest.cc
+++ b/pc/peer_connection_ice_unittest.cc
@@ -15,25 +15,26 @@
#include <optional>
#include <string>
#include <tuple>
-#include <type_traits>
#include <utility>
#include <vector>
#include "api/audio/audio_device.h"
-#include "api/audio/audio_mixer.h"
-#include "api/audio/audio_processing.h"
#include "api/candidate.h"
#include "api/field_trials.h"
#include "api/ice_transport_interface.h"
#include "api/jsep.h"
+#include "api/make_ref_counted.h"
#include "api/media_types.h"
+#include "api/packet_socket_factory.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_error.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/fake_port_allocator.h"
#include "p2p/base/ice_transport_internal.h"
#include "p2p/base/p2p_constants.h"
-#include "p2p/base/port.h"
#include "p2p/base/port_allocator.h"
#include "p2p/base/transport_description.h"
#include "p2p/base/transport_info.h"
@@ -51,10 +52,11 @@
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
-#include "rtc_base/rtc_certificate_generator.h"
#include "rtc_base/socket_address.h"
+#include "rtc_base/socket_server.h"
#include "rtc_base/thread.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
#ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h"
#endif
@@ -76,7 +78,6 @@
#include "pc/test/fake_audio_capture_module.h"
#include "pc/test/mock_peer_connection_observers.h"
#include "rtc_base/fake_network.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/virtual_socket_server.h"
#include "system_wrappers/include/metrics.h"
@@ -103,7 +104,7 @@
cricket::Candidate* candidate) {
RTC_DCHECK(pc()->remote_description());
const auto* desc = pc()->remote_description()->description();
- RTC_DCHECK(desc->contents().size() > 0);
+ RTC_DCHECK(!desc->contents().empty());
const auto& first_content = desc->contents()[0];
candidate->set_transport_name(first_content.name);
return CreateIceCandidate(first_content.name, -1, *candidate);
@@ -251,7 +252,7 @@
cricket::TransportDescription* GetFirstTransportDescription(
SessionDescriptionInterface* sdesc) {
auto* desc = sdesc->description();
- RTC_DCHECK(desc->contents().size() > 0);
+ RTC_DCHECK(!desc->contents().empty());
auto* transport_info =
desc->GetTransportInfoByName(desc->contents()[0].name);
RTC_DCHECK(transport_info);
@@ -261,7 +262,7 @@
const cricket::TransportDescription* GetFirstTransportDescription(
const SessionDescriptionInterface* sdesc) {
auto* desc = sdesc->description();
- RTC_DCHECK(desc->contents().size() > 0);
+ RTC_DCHECK(!desc->contents().empty());
auto* transport_info =
desc->GetTransportInfoByName(desc->contents()[0].name);
RTC_DCHECK(transport_info);
@@ -309,7 +310,7 @@
bool AddCandidateToFirstTransport(cricket::Candidate* candidate,
SessionDescriptionInterface* sdesc) {
auto* desc = sdesc->description();
- RTC_DCHECK(desc->contents().size() > 0);
+ RTC_DCHECK(!desc->contents().empty());
const auto& first_content = desc->contents()[0];
candidate->set_transport_name(first_content.name);
std::unique_ptr<IceCandidateInterface> jsep_candidate =
@@ -382,7 +383,11 @@
// Start ICE candidate gathering by setting the local offer.
ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
- EXPECT_TRUE_WAIT(caller->IsIceGatheringDone(), kIceCandidatesTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller->IsIceGatheringDone(); },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}),
+ IsRtcOk());
auto offer = caller->CreateOffer();
EXPECT_LT(0u, caller->observer()->GetCandidatesByMline(0).size());
@@ -403,7 +408,11 @@
ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()));
ASSERT_TRUE(callee->SetLocalDescription(callee->CreateAnswer()));
- EXPECT_TRUE_WAIT(callee->IsIceGatheringDone(), kIceCandidatesTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee->IsIceGatheringDone(); },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}),
+ IsRtcOk());
auto* answer = callee->pc()->local_description();
EXPECT_LT(0u, caller->observer()->GetCandidatesByMline(0).size());
@@ -723,7 +732,11 @@
caller->network()->AddInterface(kLocalAddress2);
caller->CreateOfferAndSetAsLocal();
- EXPECT_TRUE_WAIT(caller->IsIceGatheringDone(), kIceCandidatesTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller->IsIceGatheringDone(); },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}),
+ IsRtcOk());
auto candidates = caller->observer()->GetCandidatesByMline(0);
EXPECT_PRED_FORMAT2(AssertIpInCandidates, kLocalAddress1, candidates);
@@ -787,7 +800,10 @@
EXPECT_TRUE(result.ok());
operation_completed = true;
});
- EXPECT_TRUE_WAIT(operation_completed, kWaitTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return operation_completed; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
auto candidates = callee->GetIceCandidatesFromRemoteDescription();
ASSERT_EQ(1u, candidates.size());
@@ -836,7 +852,10 @@
// The operation will not be able to complete until we EXPECT_TRUE_WAIT()
// allowing CreateAnswer() to complete.
EXPECT_FALSE(operation_completed);
- EXPECT_TRUE_WAIT(answer_observer->called(), kWaitTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return answer_observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
// As soon as it does, AddIceCandidate() will execute without delay, so it
// must also have completed.
EXPECT_TRUE(operation_completed);
@@ -858,7 +877,10 @@
std::string("The remote description was null"));
operation_completed = true;
});
- EXPECT_TRUE_WAIT(operation_completed, kWaitTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return operation_completed; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
}
TEST_P(PeerConnectionIceTest,
@@ -892,7 +914,10 @@
EXPECT_FALSE(operation_completed);
// This should delete the callee PC.
callee = nullptr;
- EXPECT_TRUE_WAIT(operation_completed, kWaitTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return operation_completed; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
}
TEST_P(PeerConnectionIceTest, LocalDescriptionUpdatedWhenContinualGathering) {
@@ -909,9 +934,14 @@
ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
// Since we're using continual gathering, we won't get "gathering done".
- EXPECT_TRUE_WAIT(
- caller->pc()->local_description()->candidates(0)->count() > 0,
- kIceCandidatesTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return caller->pc()->local_description()->candidates(0)->count();
+ },
+ ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}),
+ IsRtcOk());
}
// Test that when continual gathering is enabled, and a network interface goes
@@ -931,16 +961,27 @@
// Start ICE candidate gathering by setting the local offer.
ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
- EXPECT_TRUE_WAIT(
- caller->pc()->local_description()->candidates(0)->count() > 0,
- kIceCandidatesTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return caller->pc()->local_description()->candidates(0)->count();
+ },
+ ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}),
+ IsRtcOk());
// Remove the only network interface, causing the PeerConnection to signal
// the removal of all candidates derived from this interface.
caller->network()->RemoveInterface(kLocalAddress);
- EXPECT_EQ_WAIT(0u, caller->pc()->local_description()->candidates(0)->count(),
- kIceCandidatesTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return caller->pc()->local_description()->candidates(0)->count();
+ },
+ ::testing::Eq(0u),
+ {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}),
+ IsRtcOk());
EXPECT_LT(0, caller->observer()->num_candidates_removed_);
}
@@ -957,7 +998,11 @@
// Start ICE candidate gathering by setting the local offer.
ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
- EXPECT_TRUE_WAIT(caller->IsIceGatheringDone(), kIceCandidatesTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller->IsIceGatheringDone(); },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}),
+ IsRtcOk());
caller->network()->RemoveInterface(kLocalAddress);
diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc
index 4babd92..bdc7e66 100644
--- a/pc/peer_connection_integrationtest.cc
+++ b/pc/peer_connection_integrationtest.cc
@@ -22,6 +22,7 @@
#include <optional>
#include <string>
#include <tuple>
+#include <unordered_set>
#include <utility>
#include <vector>
@@ -31,26 +32,25 @@
#include "api/candidate.h"
#include "api/crypto/crypto_options.h"
#include "api/dtmf_sender_interface.h"
-#include "api/ice_transport_interface.h"
#include "api/jsep.h"
+#include "api/make_ref_counted.h"
#include "api/media_stream_interface.h"
#include "api/media_types.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_error.h"
#include "api/rtc_event_log/rtc_event.h"
#include "api/rtc_event_log/rtc_event_log.h"
-#include "api/rtc_event_log_output.h"
#include "api/rtp_parameters.h"
#include "api/rtp_receiver_interface.h"
#include "api/rtp_sender_interface.h"
#include "api/rtp_transceiver_direction.h"
#include "api/rtp_transceiver_interface.h"
#include "api/scoped_refptr.h"
-#include "api/stats/rtc_stats.h"
#include "api/stats/rtc_stats_report.h"
#include "api/stats/rtcstats_objects.h"
#include "api/test/mock_async_dns_resolver.h"
#include "api/test/mock_encoder_selector.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/transport/rtp/rtp_source.h"
#include "api/uma_metrics.h"
#include "api/units/time_delta.h"
@@ -64,20 +64,17 @@
#include "p2p/base/port_allocator.h"
#include "p2p/base/port_interface.h"
#include "p2p/base/test_stun_server.h"
-#include "p2p/base/test_turn_customizer.h"
#include "p2p/base/test_turn_server.h"
#include "p2p/base/transport_description.h"
#include "p2p/base/transport_info.h"
-#include "pc/channel.h"
#include "pc/media_session.h"
#include "pc/peer_connection.h"
#include "pc/peer_connection_factory.h"
-#include "pc/rtp_transceiver.h"
#include "pc/session_description.h"
#include "pc/test/fake_periodic_video_source.h"
#include "pc/test/integration_test_helpers.h"
#include "pc/test/mock_peer_connection_observers.h"
-#include "rtc_base/crypto_random.h"
+#include "rtc_base/checks.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/fake_mdns_responder.h"
#include "rtc_base/fake_network.h"
@@ -86,18 +83,17 @@
#include "rtc_base/logging.h"
#include "rtc_base/random.h"
#include "rtc_base/socket_address.h"
-#include "rtc_base/ssl_certificate.h"
#include "rtc_base/ssl_fingerprint.h"
#include "rtc_base/ssl_identity.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/test_certificate_verifier.h"
-#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
#include "rtc_base/virtual_socket_server.h"
#include "system_wrappers/include/metrics.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
@@ -166,23 +162,35 @@
callee()->AddAudioVideoTracks();
// Start offer/answer exchange and wait for it to complete.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Should be one receiver each for audio/video.
EXPECT_EQ(2U, caller()->rtp_receiver_observers().size());
EXPECT_EQ(2U, callee()->rtp_receiver_observers().size());
// Wait for all "first packet received" callbacks to be fired.
- EXPECT_TRUE_WAIT(
- absl::c_all_of(caller()->rtp_receiver_observers(),
- [](const std::unique_ptr<MockRtpReceiverObserver>& o) {
- return o->first_packet_received();
- }),
- kMaxWaitForFramesMs);
- EXPECT_TRUE_WAIT(
- absl::c_all_of(callee()->rtp_receiver_observers(),
- [](const std::unique_ptr<MockRtpReceiverObserver>& o) {
- return o->first_packet_received();
- }),
- kMaxWaitForFramesMs);
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return absl::c_all_of(
+ caller()->rtp_receiver_observers(),
+ [](const std::unique_ptr<MockRtpReceiverObserver>& o) {
+ return o->first_packet_received();
+ });
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return absl::c_all_of(
+ callee()->rtp_receiver_observers(),
+ [](const std::unique_ptr<MockRtpReceiverObserver>& o) {
+ return o->first_packet_received();
+ });
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// If new observers are set after the first packet was already received, the
// callback should still be invoked.
caller()->ResetRtpReceiverObservers();
@@ -208,23 +216,35 @@
callee()->AddAudioVideoTracks();
// Start offer/answer exchange and wait for it to complete.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Should be one sender each for audio/video.
EXPECT_EQ(2U, caller()->rtp_sender_observers().size());
EXPECT_EQ(2U, callee()->rtp_sender_observers().size());
// Wait for all "first packet sent" callbacks to be fired.
- EXPECT_TRUE_WAIT(
- absl::c_all_of(caller()->rtp_sender_observers(),
- [](const std::unique_ptr<MockRtpSenderObserver>& o) {
- return o->first_packet_sent();
- }),
- kMaxWaitForFramesMs);
- EXPECT_TRUE_WAIT(
- absl::c_all_of(callee()->rtp_sender_observers(),
- [](const std::unique_ptr<MockRtpSenderObserver>& o) {
- return o->first_packet_sent();
- }),
- kMaxWaitForFramesMs);
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return absl::c_all_of(
+ caller()->rtp_sender_observers(),
+ [](const std::unique_ptr<MockRtpSenderObserver>& o) {
+ return o->first_packet_sent();
+ });
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return absl::c_all_of(
+ callee()->rtp_sender_observers(),
+ [](const std::unique_ptr<MockRtpSenderObserver>& o) {
+ return o->first_packet_sent();
+ });
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// If new observers are set after the first packet was already sent, the
// callback should still be invoked.
caller()->ResetRtpSenderObservers();
@@ -278,7 +298,9 @@
EXPECT_TRUE(dtmf_sender->CanInsertDtmf());
EXPECT_TRUE(dtmf_sender->InsertDtmf("1a", 100, 50));
- EXPECT_TRUE_WAIT(observer.completed(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer.completed(); }, ::testing::IsTrue()),
+ IsRtcOk());
std::vector<std::string> tones = {"1", "a", ""};
EXPECT_EQ(tones, observer.tones());
dtmf_sender->UnregisterObserver();
@@ -294,9 +316,12 @@
caller()->AddAudioTrack();
callee()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// DTLS must finish before the DTMF sender can be used reliably.
- ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
TestDtmfFromSenderToReceiver(caller(), callee());
TestDtmfFromSenderToReceiver(callee(), caller());
}
@@ -312,7 +337,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -337,7 +364,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -361,9 +390,15 @@
// Do normal offer/answer and wait for at least one frame to be received in
// each direction.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(caller()->min_video_frames_received_per_track() > 0 &&
- callee()->min_video_frames_received_per_track() > 0,
- kMaxWaitForFramesMs);
+ ASSERT_THAT(WaitUntil(
+ [&] {
+ return caller()->min_video_frames_received_per_track() >
+ 0 &&
+ callee()->min_video_frames_received_per_track() > 0;
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// Check rendered aspect ratio.
EXPECT_EQ(16.0 / 9, caller()->local_rendered_aspect_ratio());
@@ -400,7 +435,9 @@
options.offer_to_receive_video = 0;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u);
// Expect video to be received in one direction.
@@ -425,7 +462,9 @@
options.offer_to_receive_video = 1;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(caller()->pc()->GetReceivers().size(), 1u);
// Expect video to be received in one direction.
@@ -445,14 +484,18 @@
caller()->CreateLocalVideoTrack();
caller()->AddTrack(caller_track);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Add receive video.
rtc::scoped_refptr<VideoTrackInterface> callee_track =
callee()->CreateLocalVideoTrack();
callee()->AddTrack(callee_track);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Ensure that video frames are received end-to-end.
MediaExpectations media_expectations;
@@ -469,14 +512,18 @@
callee()->CreateLocalVideoTrack();
callee()->AddTrack(callee_track);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Add send video.
rtc::scoped_refptr<VideoTrackInterface> caller_track =
caller()->CreateLocalVideoTrack();
caller()->AddTrack(caller_track);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Expect video to be received in one direction.
MediaExpectations media_expectations;
@@ -500,13 +547,17 @@
rtc::scoped_refptr<RtpSenderInterface> callee_sender =
callee()->AddTrack(callee_track);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Remove receive video (i.e., callee sender track).
callee()->pc()->RemoveTrackOrError(callee_sender);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Expect one-directional video.
MediaExpectations media_expectations;
@@ -532,13 +583,17 @@
rtc::scoped_refptr<RtpSenderInterface> callee_sender =
callee()->AddTrack(callee_track);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Remove send video (i.e., caller sender track).
caller()->pc()->RemoveTrackOrError(caller_sender);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Expect one-directional video.
MediaExpectations media_expectations;
@@ -571,7 +626,9 @@
}
// Do offer/answer and make sure audio is still received end-to-end.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
{
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudio();
@@ -608,7 +665,9 @@
});
}
callee()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
{
// Expect additional audio frames to be received after the upgrade.
MediaExpectations media_expectations;
@@ -626,12 +685,16 @@
caller()->AddVideoTrack();
callee()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Now add an audio track and do another offer/answer.
caller()->AddAudioTrack();
callee()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Ensure both audio and video frames are received end-to-end.
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
@@ -653,7 +716,9 @@
sdp->description()->RemoveGroupByName("BUNDLE");
});
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
{
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
@@ -663,7 +728,9 @@
callee()->SetReceivedSdpMunger(nullptr);
caller()->SetOfferAnswerOptions(IceRestartOfferAnswerOptions());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Expect additional frames to be received after the ICE restart.
{
@@ -688,10 +755,18 @@
// Wait for video frames to be received by both sides.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->min_video_frames_received_per_track() > 0 &&
- callee()->min_video_frames_received_per_track() > 0,
- kMaxWaitForFramesMs);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil(
+ [&] {
+ return caller()->min_video_frames_received_per_track() >
+ 0 &&
+ callee()->min_video_frames_received_per_track() > 0;
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// Ensure that the aspect ratio is unmodified.
// TODO(deadbeef): Where does 4:3 come from? Should be explicit in the test,
@@ -725,10 +800,18 @@
});
// Wait for video frames to be received by both sides.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->min_video_frames_received_per_track() > 0 &&
- callee()->min_video_frames_received_per_track() > 0,
- kMaxWaitForFramesMs);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil(
+ [&] {
+ return caller()->min_video_frames_received_per_track() >
+ 0 &&
+ callee()->min_video_frames_received_per_track() > 0;
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// Expect that the aspect ratio is inversed to account for the 90/270 degree
// rotation.
@@ -767,7 +850,9 @@
callee()->AddTrack(callee()->CreateLocalVideoTrack());
// Do offer/answer and wait for successful end-to-end video frames.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalVideo();
media_expectations.ExpectNoAudio();
@@ -811,7 +896,9 @@
callee()->AddTrack(callee()->CreateLocalAudioTrack());
// Do offer/answer and wait for successful end-to-end audio frames.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudio();
media_expectations.ExpectNoVideo();
@@ -857,7 +944,9 @@
}
// Do offer/answer and wait for stable signaling state.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Sanity check that the callee's description has rejected m= sections.
ASSERT_NE(nullptr, callee()->pc()->local_description());
@@ -881,7 +970,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
{
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
@@ -903,7 +994,11 @@
->StopInternal();
}
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kMaxWaitForActivationMs);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return SignalingStateStable(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}),
+ IsRtcOk());
// Sanity check that the caller's description has a rejected video section.
ASSERT_NE(nullptr, caller()->pc()->local_description());
@@ -933,7 +1028,9 @@
rtc::scoped_refptr<RtpSenderInterface> sender =
caller()->pc()->AddTrack(track, {"stream"}).MoveValue();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Remove audio track, and set offer_to_receive_audio to false to cause the
// m= section to be completely disabled, not just "recvonly".
@@ -942,7 +1039,9 @@
options.offer_to_receive_audio = 0;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Add the audio track again, expecting negotiation to succeed and frames to
// flow.
@@ -950,7 +1049,9 @@
options.offer_to_receive_audio = 1;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudio();
@@ -971,7 +1072,9 @@
// Remove SSRCs and MSIDs from the received offer SDP.
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -992,7 +1095,9 @@
// Remove SSRCs from the received offer SDP.
callee()->SetReceivedSdpMunger(RemoveSsrcsAndKeepMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudio();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -1012,7 +1117,9 @@
auto video_sender =
caller()->pc()->AddTransceiver(track, video_transceiver_init).MoveValue();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Add receive direction.
video_sender->SetDirectionWithError(RtpTransceiverDirection::kSendRecv);
@@ -1022,7 +1129,9 @@
callee()->AddTrack(callee_track);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Ensure that video frames are received end-to-end.
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalVideo();
@@ -1044,7 +1153,9 @@
caller()->SetReceivedSdpMunger(&RemoveSsrcsAndKeepMsids);
callee()->SetReceivedSdpMunger(&RemoveSsrcsAndKeepMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(2u, caller()->pc()->GetReceivers().size());
ASSERT_EQ(2u, callee()->pc()->GetReceivers().size());
@@ -1089,7 +1200,9 @@
caller()->SetReceivedSdpMunger(&RemoveBundleGroupSsrcsAndMidExtension);
callee()->SetReceivedSdpMunger(&RemoveBundleGroupSsrcsAndMidExtension);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(2u, caller()->pc()->GetReceivers().size());
ASSERT_EQ(2u, callee()->pc()->GetReceivers().size());
// Make sure we are not bundled.
@@ -1139,7 +1252,9 @@
caller()->SetReceivedSdpMunger(&RemoveSsrcsAndKeepMsids);
callee()->SetReceivedSdpMunger(&RemoveSsrcsAndKeepMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(2u, caller()->pc()->GetReceivers().size());
ASSERT_EQ(2u, callee()->pc()->GetReceivers().size());
// Make sure we are bundled.
@@ -1158,7 +1273,9 @@
caller()->AddAudioTrack();
caller()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
auto callee_receivers = callee()->pc()->GetReceivers();
ASSERT_EQ(2u, callee_receivers.size());
EXPECT_TRUE(callee_receivers[0]->stream_ids().empty());
@@ -1172,7 +1289,9 @@
caller()->AddVideoTrack();
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
auto callee_receivers = callee()->pc()->GetReceivers();
ASSERT_EQ(2u, callee_receivers.size());
ASSERT_EQ(1u, callee_receivers[0]->stream_ids().size());
@@ -1192,7 +1311,9 @@
caller()->AddAudioVideoTracks();
caller()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(3u, callee()->pc()->GetReceivers().size());
MediaExpectations media_expectations;
@@ -1242,7 +1363,9 @@
// but the first m= section.
callee()->SetReceivedSdpMunger(MakeSpecCompliantMaxBundleOffer);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -1257,12 +1380,17 @@
// Just add an audio track.
caller()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Get the audio output level stats. Note that the level is not available
// until an RTCP packet has been received.
- EXPECT_TRUE_WAIT(callee()->OldGetStats()->AudioOutputLevel() > 0,
- kMaxWaitForFramesMs);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->OldGetStats()->AudioOutputLevel(); },
+ ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
}
// Test that an audio input level is reported.
@@ -1274,12 +1402,17 @@
// Just add an audio track.
caller()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Get the audio input level stats. The level should be available very
// soon after the test starts.
- EXPECT_TRUE_WAIT(caller()->OldGetStats()->AudioInputLevel() > 0,
- kMaxWaitForStatsMs);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->OldGetStats()->AudioInputLevel(); },
+ ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForStatsMs)}),
+ IsRtcOk());
}
// Test that we can get incoming byte counts from both audio and video tracks.
@@ -1289,7 +1422,9 @@
caller()->AddAudioVideoTracks();
// Do offer/answer, wait for the callee to receive some frames.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudioAndVideo();
@@ -1316,7 +1451,9 @@
caller()->AddTrack(video_track);
// Do offer/answer, wait for the callee to receive some frames.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -1339,11 +1476,15 @@
auto audio_sender_2 = caller()->AddAudioTrack();
auto video_sender_2 = caller()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudioAndVideo();
- ASSERT_TRUE_WAIT(ExpectNewFrames(media_expectations), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return ExpectNewFrames(media_expectations); },
+ ::testing::IsTrue()),
+ IsRtcOk());
std::vector<std::string> track_ids = {
audio_sender_1->track()->id(), video_sender_1->track()->id(),
@@ -1366,11 +1507,15 @@
auto audio_sender_2 = caller()->AddAudioTrack();
auto video_sender_2 = caller()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudioAndVideo();
- ASSERT_TRUE_WAIT(ExpectNewFrames(media_expectations), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return ExpectNewFrames(media_expectations); },
+ ::testing::IsTrue()),
+ IsRtcOk());
std::vector<std::string> track_ids = {
audio_sender_1->track()->id(), video_sender_1->track()->id(),
@@ -1433,7 +1578,9 @@
// Remove SSRCs and MSIDs from the received offer SDP.
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudio(1);
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -1458,7 +1605,9 @@
// Remove SSRCs and MSIDs from the received offer SDP.
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Note that, since the old stats implementation associates SSRCs with tracks
// using SDP, when SSRCs aren't signaled in SDP these stats won't have an
@@ -1466,8 +1615,10 @@
//
// Also, we use "EXPECT_TRUE_WAIT" because the stats collector may decide to
// return cached stats if not enough time has passed since the last update.
- EXPECT_TRUE_WAIT(callee()->OldGetStats()->BytesReceived() > 0,
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->OldGetStats()->BytesReceived(); },
+ ::testing::Gt(0)),
+ IsRtcOk());
}
// Test that we can successfully get the media related stats (audio level
@@ -1480,7 +1631,9 @@
// Remove SSRCs and MSIDs from the received offer SDP.
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudio(1);
media_expectations.CalleeExpectsSomeVideo(1);
@@ -1507,7 +1660,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -1523,12 +1678,20 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(rtc::SSLStreamAdapter::IsAcceptableCipher(
- caller()->OldGetStats()->DtlsCipher(), rtc::KT_DEFAULT),
- kDefaultTimeout);
- EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite),
- caller()->OldGetStats()->SrtpCipher(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return rtc::SSLStreamAdapter::IsAcceptableCipher(
+ caller()->OldGetStats()->DtlsCipher(), rtc::KT_DEFAULT);
+ },
+ ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return caller()->OldGetStats()->SrtpCipher(); },
+ ::testing::Eq(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite))),
+ IsRtcOk());
}
// Test getting cipher stats and UMA metrics when DTLS 1.2 is negotiated.
@@ -1541,12 +1704,20 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
- EXPECT_TRUE_WAIT(rtc::SSLStreamAdapter::IsAcceptableCipher(
- caller()->OldGetStats()->DtlsCipher(), rtc::KT_DEFAULT),
- kDefaultTimeout);
- EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite),
- caller()->OldGetStats()->SrtpCipher(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return rtc::SSLStreamAdapter::IsAcceptableCipher(
+ caller()->OldGetStats()->DtlsCipher(), rtc::KT_DEFAULT);
+ },
+ ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return caller()->OldGetStats()->SrtpCipher(); },
+ ::testing::Eq(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite))),
+ IsRtcOk());
}
// Test that DTLS 1.0 can be used if the caller supports DTLS 1.2 and the
@@ -1564,7 +1735,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -1585,7 +1758,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -1664,7 +1839,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -1679,20 +1856,32 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
- caller()->ice_gathering_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
- callee()->ice_gathering_state(), kMaxWaitForFramesMs);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->ice_gathering_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->ice_gathering_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// After the best candidate pair is selected and all candidates are signaled,
// the ICE connection state should reach "complete".
// TODO(deadbeef): Currently, the ICE "controlled" agent (the
// answerer/"callee" by default) only reaches "connected". When this is
// fixed, this test should be updated.
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- callee()->ice_connection_state(), kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(
+ PeerConnectionInterface::kIceConnectionCompleted)),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); },
+ ::testing::Eq(
+ PeerConnectionInterface::kIceConnectionConnected)),
+ IsRtcOk());
}
constexpr int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN |
@@ -1754,11 +1943,17 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- callee()->ice_connection_state(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(
+ PeerConnectionInterface::kIceConnectionCompleted)),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); },
+ ::testing::Eq(
+ PeerConnectionInterface::kIceConnectionConnected)),
+ IsRtcOk());
// Part of reporting the stats will occur on the network thread, so flush it
// before checking NumEvents.
@@ -1862,9 +2057,13 @@
// peer should consider the other side to have rejected the connection. This
// is signaled by the state transitioning to "failed".
constexpr int kConsentTimeout = 30000;
- ASSERT_EQ_SIMULATED_WAIT(PeerConnectionInterface::kIceConnectionFailed,
- caller()->standardized_ice_connection_state(),
- kConsentTimeout, FakeClock());
+ 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}),
+ IsRtcOk());
}
#endif // !defined(THREAD_SANITIZER)
@@ -1886,11 +2085,17 @@
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- callee()->ice_connection_state(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(
+ PeerConnectionInterface::kIceConnectionCompleted)),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); },
+ ::testing::Eq(
+ PeerConnectionInterface::kIceConnectionConnected)),
+ IsRtcOk());
// Part of reporting the stats will occur on the network thread, so flush it
// before checking NumEvents.
@@ -1955,11 +2160,19 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- callee()->ice_connection_state(), kMaxWaitForFramesMs);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// To verify that the ICE restart actually occurs, get
// ufrag/password/candidates before and after restart.
@@ -1988,11 +2201,19 @@
// Have the caller initiate an ICE restart.
caller()->SetOfferAnswerOptions(IceRestartOfferAnswerOptions());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- callee()->ice_connection_state(), kMaxWaitForFramesMs);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// Grab the ufrags/candidates again.
audio_candidates_caller = caller()->pc()->local_description()->candidates(0);
@@ -2036,7 +2257,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Sanity check that ICE renomination was actually negotiated.
const cricket::SessionDescription* desc =
caller()->pc()->local_description()->description();
@@ -2074,15 +2297,21 @@
caller()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(
+ PeerConnectionInterface::kIceConnectionCompleted)),
+ IsRtcOk());
caller()->clear_ice_connection_state_history();
caller()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_EQ(0u, caller()->ice_connection_state_history().size());
}
@@ -2099,7 +2328,9 @@
// video and audio recvonly "m=" sections.
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Negotiate again, disabling the video "m=" section (the callee will set the
// port to 0 due to offer_to_receive_video = 0).
@@ -2115,7 +2346,9 @@
});
}
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Sanity check that video "m=" section was actually rejected.
const ContentInfo* answer_video_content = cricket::GetFirstVideoContent(
callee()->pc()->local_description()->description());
@@ -2138,7 +2371,9 @@
callee()->AddVideoTrack();
callee()->SetRemoteOfferHandler(nullptr);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Verify the caller receives frames from the newly added stream, and the
// callee receives additional frames from the re-enabled video m= section.
@@ -2164,12 +2399,22 @@
auto callee_video_sender =
callee()->pc()->CreateSender("video", "callee_stream");
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kMaxWaitForActivationMs);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return SignalingStateStable(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}),
+ IsRtcOk());
// Wait for ICE to complete, without any tracks being set.
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- callee()->ice_connection_state(), kMaxWaitForFramesMs);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// Now set the tracks, and expect frames to immediately start flowing.
EXPECT_TRUE(
caller_audio_sender->SetTrack(caller()->CreateLocalAudioTrack().get()));
@@ -2205,12 +2450,22 @@
RtpTransceiverDirection::kSendRecv);
});
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kMaxWaitForActivationMs);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return SignalingStateStable(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}),
+ IsRtcOk());
// Wait for ICE to complete, without any tracks being set.
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- callee()->ice_connection_state(), kMaxWaitForFramesMs);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// Now set the tracks, and expect frames to immediately start flowing.
auto callee_audio_sender = callee()->pc()->GetSenders()[0];
auto callee_video_sender = callee()->pc()->GetSenders()[1];
@@ -2237,14 +2492,22 @@
// Just send a video track from the caller.
caller()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kMaxWaitForActivationMs);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return SignalingStateStable(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}),
+ IsRtcOk());
ASSERT_EQ(1U, callee()->remote_streams()->count());
// Echo the stream back, and do a new offer/anwer (initiated by callee this
// time).
callee()->pc()->AddStream(callee()->remote_streams()->at(0));
callee()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kMaxWaitForActivationMs);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return SignalingStateStable(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForActivationMs)}),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalVideo();
@@ -2336,8 +2599,11 @@
options.offer_to_receive_video = 1;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
- EXPECT_TRUE_SIMULATED_WAIT(DtlsConnected(), total_connection_time_ms,
- FakeClock());
+ EXPECT_THAT(
+ WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(total_connection_time_ms),
+ .clock = &FakeClock()}),
+ IsRtcOk());
// Closing the PeerConnections destroys the ports before the ScopedFakeClock.
// If this is not done a DCHECK can be hit in ports.cc, because a large
// negative number is calculated for the rtt due to the global clock changing.
@@ -2383,8 +2649,9 @@
// Start candidate gathering and wait for it to complete. Candidates are not
// signalled.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_SIMULATED_WAIT(caller()->IceGatheringStateComplete(),
- kDefaultTimeout, FakeClock());
+ ASSERT_THAT(WaitUntil([&] { return caller()->IceGatheringStateComplete(); },
+ ::testing::IsTrue(), {.clock = &FakeClock()}),
+ IsRtcOk());
// Call getStats, assert there are no candidates.
rtc::scoped_refptr<const RTCStatsReport> first_report =
@@ -2402,7 +2669,9 @@
"candidate:2214029314 1 udp 2122260223 127.0.0.1 49152 typ host",
nullptr)),
[&result](RTCError r) { result = r; });
- ASSERT_TRUE_WAIT(result.has_value(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return result.has_value(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_TRUE(result.value().ok());
// Call getStats again, assert there is a remote candidate now.
@@ -2468,7 +2737,8 @@
options.offer_to_receive_video = 1;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
ExpectTurnCustomizerCountersIncremented(customizer1);
ExpectTurnCustomizerCountersIncremented(customizer2);
@@ -2506,9 +2776,14 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- callee()->ice_connection_state(), kMaxWaitForFramesMs);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
@@ -2574,7 +2849,8 @@
options.offer_to_receive_video = 1;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_GT(client_1_cert_verifier->call_count_, 0u);
EXPECT_GT(client_2_cert_verifier->call_count_, 0u);
@@ -2615,37 +2891,41 @@
// Remove all but one audio/video codec (opus and VP8), and change the
// casing of the caller's generated offer.
- caller()->SetGeneratedSdpMunger([](std::unique_ptr<
- SessionDescriptionInterface>& sdp) {
- cricket::AudioContentDescription* audio =
- GetFirstAudioContentDescription(sdp->description());
- ASSERT_NE(nullptr, audio);
- auto audio_codecs = audio->codecs();
- audio_codecs.erase(std::remove_if(audio_codecs.begin(), audio_codecs.end(),
- [](const cricket::Codec& codec) {
- return codec.name != "opus";
- }),
- audio_codecs.end());
- ASSERT_EQ(1u, audio_codecs.size());
- audio_codecs[0].name = "OpUs";
- audio->set_codecs(audio_codecs);
+ caller()->SetGeneratedSdpMunger(
+ [](std::unique_ptr<SessionDescriptionInterface>& sdp) {
+ cricket::AudioContentDescription* audio =
+ GetFirstAudioContentDescription(sdp->description());
+ ASSERT_NE(nullptr, audio);
+ auto audio_codecs = audio->codecs();
+ audio_codecs.erase(
+ std::remove_if(audio_codecs.begin(), audio_codecs.end(),
+ [](const cricket::Codec& codec) {
+ return codec.name != "opus";
+ }),
+ audio_codecs.end());
+ ASSERT_EQ(1u, audio_codecs.size());
+ audio_codecs[0].name = "OpUs";
+ audio->set_codecs(audio_codecs);
- cricket::VideoContentDescription* video =
- GetFirstVideoContentDescription(sdp->description());
- ASSERT_NE(nullptr, video);
- auto video_codecs = video->codecs();
- video_codecs.erase(std::remove_if(video_codecs.begin(), video_codecs.end(),
- [](const cricket::Codec& codec) {
- return codec.name != "VP8";
- }),
- video_codecs.end());
- ASSERT_EQ(1u, video_codecs.size());
- video_codecs[0].name = "vP8";
- video->set_codecs(video_codecs);
- });
+ cricket::VideoContentDescription* video =
+ GetFirstVideoContentDescription(sdp->description());
+ ASSERT_NE(nullptr, video);
+ auto video_codecs = video->codecs();
+ video_codecs.erase(
+ std::remove_if(video_codecs.begin(), video_codecs.end(),
+ [](const cricket::Codec& codec) {
+ return codec.name != "VP8";
+ }),
+ video_codecs.end());
+ ASSERT_EQ(1u, video_codecs.size());
+ video_codecs[0].name = "vP8";
+ video->set_codecs(video_codecs);
+ });
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Verify frames are still received end-to-end.
MediaExpectations media_expectations;
@@ -2658,7 +2938,9 @@
ConnectFakeSignaling();
caller()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Wait for one audio frame to be received by the callee.
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudio(1);
@@ -2678,7 +2960,9 @@
ConnectFakeSignaling();
caller()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Wait for two video frames to be received by the callee.
// TODO: https://issues.webrtc.org/42220900 - wait for only one frame again
MediaExpectations media_expectations;
@@ -2701,15 +2985,21 @@
caller()->AddAudioTrack();
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u);
auto receiver = callee()->pc()->GetReceivers()[0];
std::vector<RtpSource> sources;
- EXPECT_TRUE_WAIT(([&receiver, &sources]() {
- sources = receiver->GetSources();
- return !sources.empty();
- })(),
- kDefaultTimeout);
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return ([&receiver, &sources]() {
+ sources = receiver->GetSources();
+ return !sources.empty();
+ })();
+ },
+ ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_GT(sources.size(), 0u);
EXPECT_EQ(RtpSourceType::SSRC, sources[0].source_type());
}
@@ -2720,15 +3010,21 @@
caller()->AddVideoTrack();
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u);
auto receiver = callee()->pc()->GetReceivers()[0];
std::vector<RtpSource> sources;
- EXPECT_TRUE_WAIT(([&receiver, &sources]() {
- sources = receiver->GetSources();
- return !sources.empty();
- })(),
- kDefaultTimeout);
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return ([&receiver, &sources]() {
+ sources = receiver->GetSources();
+ return !sources.empty();
+ })();
+ },
+ ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_GT(sources.size(), 0u);
EXPECT_EQ(RtpSourceType::SSRC, sources[0].source_type());
}
@@ -2745,7 +3041,9 @@
caller()->AddVideoTrack();
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Wait for one video frame to be received by the callee.
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeVideo(1);
@@ -2764,16 +3062,22 @@
caller()->AddAudioTrack();
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u);
auto receiver = callee()->pc()->GetReceivers()[0];
RtpParameters parameters;
- EXPECT_TRUE_WAIT(([&receiver, ¶meters]() {
- parameters = receiver->GetParameters();
- return !parameters.encodings.empty() &&
- parameters.encodings[0].ssrc.has_value();
- })(),
- kDefaultTimeout);
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return ([&receiver, ¶meters]() {
+ parameters = receiver->GetParameters();
+ return !parameters.encodings.empty() &&
+ parameters.encodings[0].ssrc.has_value();
+ })();
+ },
+ ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(parameters.encodings.size(), 1u);
EXPECT_TRUE(parameters.encodings[0].ssrc.has_value());
}
@@ -2784,16 +3088,22 @@
caller()->AddVideoTrack();
callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u);
auto receiver = callee()->pc()->GetReceivers()[0];
RtpParameters parameters;
- EXPECT_TRUE_WAIT(([&receiver, ¶meters]() {
- parameters = receiver->GetParameters();
- return !parameters.encodings.empty() &&
- parameters.encodings[0].ssrc.has_value();
- })(),
- kDefaultTimeout);
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return ([&receiver, ¶meters]() {
+ parameters = receiver->GetParameters();
+ return !parameters.encodings.empty() &&
+ parameters.encodings[0].ssrc.has_value();
+ })();
+ },
+ ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(parameters.encodings.size(), 1u);
EXPECT_TRUE(parameters.encodings[0].ssrc.has_value());
}
@@ -2823,7 +3133,9 @@
rtc::scoped_refptr<RtpSenderInterface> sender =
caller()->AddTrack(track, {"stream_1"});
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
{
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudio(1);
@@ -2833,7 +3145,9 @@
caller()->pc()->RemoveTrackOrError(sender);
sender = caller()->AddTrack(track, {"stream_2"});
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Wait for additional audio frames to be received by the callee.
{
MediaExpectations media_expectations;
@@ -2855,7 +3169,9 @@
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
}
TEST_P(PeerConnectionIntegrationTest, RtcEventLogOutputWriteCalledOnStop) {
@@ -2879,7 +3195,9 @@
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
caller()->pc()->StopRtcEventLog();
test_is_complete.Call();
@@ -2906,7 +3224,9 @@
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
caller()->pc()->Close();
test_is_complete.Call();
@@ -2927,15 +3247,21 @@
caller()->CreateAndSetAndSignalOffer();
// Wait for all candidates to be gathered on both the caller and callee.
- ASSERT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
- caller()->ice_gathering_state(), kDefaultTimeout);
- ASSERT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
- callee()->ice_gathering_state(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->ice_gathering_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete)),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return callee()->ice_gathering_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete)),
+ IsRtcOk());
// The candidates will now be included in the session description, so
// signaling them will start the ICE connection.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Ensure that media flows in both directions.
MediaExpectations media_expectations;
@@ -2959,7 +3285,9 @@
caller()->AddAudioTrack();
callee()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Pump messages for a second.
WAIT(false, 1000);
@@ -3002,10 +3330,15 @@
caller()->pc()->SetAudioPlayout(false);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Wait for the callee to receive audio stats.
- EXPECT_TRUE_WAIT(GetAudioEnergyStat(caller()) > 0, kMaxWaitForFramesMs);
+ EXPECT_THAT(
+ WaitUntil([&] { return GetAudioEnergyStat(caller()); }, ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
}
#endif // !defined(THREAD_SANITIZER)
@@ -3023,7 +3356,9 @@
caller()->AddAudioTrack();
callee()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Pump messages for a second.
WAIT(false, 1000);
@@ -3049,7 +3384,8 @@
options.offer_to_receive_audio = 1;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_NE(nullptr, caller()->event_log_factory());
ASSERT_NE(nullptr, callee()->event_log_factory());
FakeRtcEventLog* caller_event_log =
@@ -3104,15 +3440,21 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Since we are doing continual gathering, the ICE transport does not reach
// kIceGatheringComplete (see
// P2PTransportChannel::OnCandidatesAllocationDone), and consequently not
// kIceConnectionComplete.
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- caller()->ice_connection_state(), kDefaultTimeout);
- EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
- callee()->ice_connection_state(), kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(
+ PeerConnectionInterface::kIceConnectionConnected)),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); },
+ ::testing::Eq(
+ PeerConnectionInterface::kIceConnectionConnected)),
+ IsRtcOk());
// Note that we cannot use the metric
// `WebRTC.PeerConnection.CandidatePairType_UDP` in this test since this
// metric is only populated when we reach kIceConnectionComplete in the
@@ -3125,15 +3467,19 @@
caller_config.type = PeerConnectionInterface::kAll;
caller()->pc()->SetConfiguration(caller_config);
// We should have gathered a new host candidate.
- EXPECT_TRUE_WAIT(caller()->last_candidate_gathered().is_local(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller()->last_candidate_gathered().is_local(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
// Loosen the callee's candidate filter.
callee_config = callee()->pc()->GetConfiguration();
callee_config.type = PeerConnectionInterface::kAll;
callee()->pc()->SetConfiguration(callee_config);
- EXPECT_TRUE_WAIT(callee()->last_candidate_gathered().is_local(),
- kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee()->last_candidate_gathered().is_local(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
// Create an offer and verify that it does not contain an ICE restart (i.e new
// ice credentials).
@@ -3183,8 +3529,12 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(401, caller()->error_event().error_code, kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return caller()->error_event().error_code; },
+ ::testing::Eq(401)),
+ IsRtcOk());
EXPECT_EQ("Unauthorized", caller()->error_event().error_text);
EXPECT_EQ("turn:88.88.88.0:3478?transport=udp", caller()->error_event().url);
EXPECT_NE(caller()->error_event().address, "");
@@ -3214,8 +3564,12 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(701, caller()->error_event().error_code, kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return caller()->error_event().error_code; },
+ ::testing::Eq(701)),
+ IsRtcOk());
EXPECT_EQ(caller()->error_event().address, "");
}
@@ -3231,7 +3585,9 @@
caller()->AddAudioTrack();
callee()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudio();
ASSERT_TRUE(ExpectNewFrames(media_expectations));
@@ -3241,9 +3597,13 @@
auto observer = rtc::make_ref_counted<MockSetSessionDescriptionObserver>();
callee()->pc()->SetLocalDescription(observer.get(),
callee()->CreateOfferAndWait().release());
- EXPECT_TRUE_WAIT(observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
caller()->CreateAndSetAndSignalOffer(); // Implicit rollback.
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_TRUE(ExpectNewFrames(media_expectations));
}
@@ -3259,14 +3619,18 @@
rtc::make_ref_counted<MockSetSessionDescriptionObserver>();
callee()->pc()->SetLocalDescription(sld_observer.get(),
callee()->CreateOfferAndWait().release());
- EXPECT_TRUE_WAIT(sld_observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return sld_observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_EQ(sld_observer->error(), "");
auto srd_observer =
rtc::make_ref_counted<MockSetSessionDescriptionObserver>();
callee()->pc()->SetRemoteDescription(
srd_observer.get(), caller()->CreateOfferAndWait().release());
- EXPECT_TRUE_WAIT(srd_observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return srd_observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_EQ(srd_observer->error(), "");
EXPECT_THAT(callee()->peer_connection_signaling_state_history(),
@@ -3302,7 +3666,9 @@
// Munge remote answer for SRD.
caller()->SetReceivedSdpMunger(munger);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Observe that after munging the parameter is present in generated SDP.
caller()->SetGeneratedSdpMunger(
[](std::unique_ptr<SessionDescriptionInterface>& sdp) {
@@ -3328,7 +3694,9 @@
caller()->pc()->AddTransceiver(cricket::MEDIA_TYPE_AUDIO);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
int current_size = caller()->pc()->GetTransceivers().size();
// Add more tracks until we get close to having issues.
// Issues have been seen at:
@@ -3344,7 +3712,9 @@
auto start_time_ms = rtc::TimeMillis();
caller()->CreateAndSetAndSignalOffer();
// We want to stop when the time exceeds one second.
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
auto elapsed_time_ms = rtc::TimeMillis() - start_time_ms;
RTC_LOG(LS_INFO) << "Renegotiating took " << elapsed_time_ms << " ms";
ASSERT_GT(1000, elapsed_time_ms)
@@ -3362,7 +3732,9 @@
caller()->pc()->AddTransceiver(cricket::MEDIA_TYPE_VIDEO);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
int current_size = caller()->pc()->GetTransceivers().size();
// Add more tracks until we get close to having issues.
// Issues have been seen at:
@@ -3380,7 +3752,9 @@
auto start_time_ms = rtc::TimeMillis();
caller()->CreateAndSetAndSignalOffer();
// We want to stop when the time exceeds one second.
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
auto elapsed_time_ms = rtc::TimeMillis() - start_time_ms;
RTC_LOG(LS_INFO) << "Renegotiating took " << elapsed_time_ms << " ms";
ASSERT_GT(1000, elapsed_time_ms)
@@ -3398,7 +3772,9 @@
caller()->AddAudioTrack();
callee()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Wait until we can see the audio flowing.
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudio();
@@ -3422,7 +3798,9 @@
auto start_time_ms = rtc::TimeMillis();
caller()->CreateAndSetAndSignalOffer();
// We want to stop when the time exceeds one second.
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
auto elapsed_time_ms = rtc::TimeMillis() - start_time_ms;
RTC_LOG(LS_INFO) << "Renegotiating took " << elapsed_time_ms << " ms";
// This is a guard against the test using excessive amounts of time.
@@ -3495,7 +3873,9 @@
ConnectFakeSignaling();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
}
TEST_P(PeerConnectionIntegrationInteropTest, OneAudioLocalToNoMediaRemote) {
@@ -3504,7 +3884,9 @@
auto audio_sender = caller()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Verify that one audio receiver has been created on the remote and that it
// has the same track ID as the sending track.
@@ -3525,7 +3907,9 @@
auto audio_sender = caller()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Verify that one audio and one video receiver have been created on the
// remote and that they have the same track IDs as the sending tracks.
@@ -3551,7 +3935,9 @@
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
@@ -3566,7 +3952,9 @@
callee()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Verify that only the audio track has been negotiated.
EXPECT_EQ(0u, caller()->GetReceiversOfType(cricket::MEDIA_TYPE_VIDEO).size());
@@ -3574,7 +3962,9 @@
// Reverse roles.
callee()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
MediaExpectations media_expectations;
media_expectations.CallerExpectsSomeVideo();
@@ -3587,13 +3977,18 @@
ConnectFakeSignaling();
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
caller()->ExpectCandidates(0);
callee()->ExpectCandidates(0);
caller()->AddAudioTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
}
TEST_P(PeerConnectionIntegrationTest, MediaCallWithoutMediaEngineFails) {
@@ -3621,7 +4016,9 @@
caller()->AddVideoTrack();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Verify that there is only one receiver and it corresponds to the first
// added track.
@@ -3652,7 +4049,9 @@
auto audio_transceiver = audio_transceiver_or_error.MoveValue();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
{
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeAudio();
@@ -3663,7 +4062,9 @@
caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
{
MediaExpectations media_expectations;
media_expectations.CalleeExpectsSomeVideo();
@@ -3682,11 +4083,15 @@
auto audio_transceiver = audio_transceiver_or_error.MoveValue();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
audio_transceiver->StopStandard();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(0U, caller()->pc()->GetTransceivers().size());
EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew,
caller()->pc()->ice_gathering_state());
@@ -3707,12 +4112,16 @@
auto caller_transceiver = audio_transceiver_or_error.MoveValue();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
caller_transceiver->StopStandard();
auto callee_transceiver = callee()->pc()->GetTransceivers()[0];
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_EQ(0U, caller()->pc()->GetTransceivers().size());
EXPECT_EQ(0U, callee()->pc()->GetTransceivers().size());
EXPECT_EQ(0U, caller()->pc()->GetSenders().size());
@@ -3734,14 +4143,18 @@
auto audio_transceiver = audio_transceiver_or_error.MoveValue();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
auto caller_track = audio_transceiver->receiver()->track();
auto callee_track = callee()->pc()->GetReceivers()[0]->track();
audio_transceiver->StopStandard();
EXPECT_EQ(MediaStreamTrackInterface::TrackState::kEnded,
caller_track->state());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_EQ(MediaStreamTrackInterface::TrackState::kEnded,
callee_track->state());
}
@@ -3757,14 +4170,18 @@
auto audio_transceiver = audio_transceiver_or_error.MoveValue();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
auto caller_track = audio_transceiver->receiver()->track();
auto callee_track = callee()->pc()->GetReceivers()[0]->track();
audio_transceiver->StopStandard();
EXPECT_EQ(MediaStreamTrackInterface::TrackState::kEnded,
caller_track->state());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_EQ(MediaStreamTrackInterface::TrackState::kEnded,
callee_track->state());
}
@@ -3781,7 +4198,9 @@
options.offer_to_receive_video = 0;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u);
std::unique_ptr<MockEncoderSelector> encoder_selector =
@@ -3869,12 +4288,16 @@
// Wait until callee has sent at least one NACK.
// Note that due to stats caching, this might only be visible 50 ms
// after the nack was in fact sent.
- EXPECT_TRUE_WAIT(NacksSentCount(*callee()) > 0, kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return NacksSentCount(*callee()); }, ::testing::Gt(0)),
+ IsRtcOk());
ASSERT_FALSE(HasFailure());
virtual_socket_server()->set_drop_probability(0.0);
// Wait until caller has received at least one NACK
- EXPECT_TRUE_WAIT(NacksReceivedCount(*caller()) > 0, kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return NacksReceivedCount(*caller()); },
+ ::testing::Gt(0)),
+ IsRtcOk());
}
TEST_F(PeerConnectionIntegrationTestUnifiedPlan, VideoPacketLossCausesNack) {
@@ -3893,7 +4316,7 @@
cricket::MediaContentDescription* media = content.media_description();
std::vector<cricket::Codec> codecs = media->codecs();
std::vector<cricket::Codec> codecs_out;
- for (cricket::Codec codec : codecs) {
+ for (const cricket::Codec& codec : codecs) {
if (codec.name == "VP8") {
ASSERT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)));
@@ -3918,11 +4341,15 @@
// Wait until callee has sent at least one NACK.
// Note that due to stats caching, this might only be visible 50 ms
// after the nack was in fact sent.
- EXPECT_TRUE_WAIT(NacksSentCount(*callee()) > 0, kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return NacksSentCount(*callee()); }, ::testing::Gt(0)),
+ IsRtcOk());
ASSERT_FALSE(HasFailure());
// Wait until caller has received at least one NACK
- EXPECT_TRUE_WAIT(NacksReceivedCount(*caller()) > 0, kDefaultTimeout);
+ EXPECT_THAT(WaitUntil([&] { return NacksReceivedCount(*caller()); },
+ ::testing::Gt(0)),
+ IsRtcOk());
}
TEST_F(PeerConnectionIntegrationTestUnifiedPlan, PrAnswerStateTransitions) {
@@ -4057,10 +4484,10 @@
void SetNewFingerprint(std::unique_ptr<SessionDescriptionInterface>& sdp) {
auto identity = rtc::SSLIdentity::Create("NewIdentity", rtc::KT_DEFAULT);
auto new_fingerprint =
- rtc::SSLFingerprint::CreateUnique("sha-256", *identity.get());
+ rtc::SSLFingerprint::CreateUnique("sha-256", *identity);
for (auto& transport_info : sdp->description()->transport_infos()) {
transport_info.description.identity_fingerprint =
- absl::WrapUnique(new rtc::SSLFingerprint(*new_fingerprint.get()));
+ absl::WrapUnique(new rtc::SSLFingerprint(*new_fingerprint));
}
}
@@ -4129,10 +4556,19 @@
caller()->NegotiateCorruptionDetectionHeader();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->GetCorruptionScoreCount() > 0, kMaxWaitForStatsMs);
- ASSERT_TRUE_WAIT(callee()->GetCorruptionScoreCount() == 0,
- kMaxWaitForStatsMs);
+ 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());
for (const auto& pair : {caller(), callee()}) {
rtc::scoped_refptr<const RTCStatsReport> report = pair->NewGetStats();
@@ -4174,7 +4610,6 @@
ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(config, config));
ConnectFakeSignaling();
-
// Do normal offer/answer and wait for some frames to be received in each
// direction, and `corruption_score` to be aggregated.
caller()->AddAudioVideoTracks();
@@ -4187,9 +4622,19 @@
callee()->NegotiateCorruptionDetectionHeader();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->GetCorruptionScoreCount() > 0, kMaxWaitForStatsMs);
- ASSERT_TRUE_WAIT(callee()->GetCorruptionScoreCount() > 0, kMaxWaitForStatsMs);
+ 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());
for (const auto& pair : {caller(), callee()}) {
rtc::scoped_refptr<const RTCStatsReport> report = pair->NewGetStats();
@@ -4234,11 +4679,19 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- ASSERT_TRUE_WAIT(caller()->GetCorruptionScoreCount() == 0,
- kMaxWaitForStatsMs);
- ASSERT_TRUE_WAIT(callee()->GetCorruptionScoreCount() == 0,
- kMaxWaitForStatsMs);
+ 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());
for (const auto& pair : {caller(), callee()}) {
rtc::scoped_refptr<const RTCStatsReport> report = pair->NewGetStats();
@@ -4274,7 +4727,9 @@
ASSERT_TRUE(transceiver->SetHeaderExtensionsToNegotiate(extensions).ok());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
const auto& negotiated_header_extensions = caller()
->pc()
->remote_description()
@@ -4285,14 +4740,23 @@
ASSERT_TRUE(RtpExtension::FindHeaderExtensionByUri(
negotiated_header_extensions, RtpExtension::kAbsoluteCaptureTimeUri,
RtpExtension::kDiscardEncryptedExtension));
- ASSERT_TRUE_WAIT(
- metrics::NumSamples("WebRTC.Call.AbsCapture.ExtensionWait") > 0,
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] {
+ return metrics::NumSamples("WebRTC.Call.AbsCapture.ExtensionWait");
+ },
+ ::testing::Gt(0)),
+ IsRtcOk());
// Observed deltas are more than 100 msec. Use 1 minute as tolerance;
// this is a check against wrong timebase.
EXPECT_LT(metrics::MinSample("WebRTC.Call.AbsCapture.Delta"), 60'000'000);
- ASSERT_TRUE_WAIT(metrics::NumSamples("WebRTC.Call.AbsCapture.OffsetWait") > 0,
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] {
+ return metrics::NumSamples("WebRTC.Call.AbsCapture.OffsetWait");
+ },
+ ::testing::Gt(0)),
+ IsRtcOk());
// On a point-to-point call, we expect the offset to be zero.
EXPECT_LT(metrics::MinSample("WebRTC.Call.AbsCapture.Offset"), 2);
}
diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc
index 63900dc..2e02444 100644
--- a/pc/peer_connection_interface_unittest.cc
+++ b/pc/peer_connection_interface_unittest.cc
@@ -13,15 +13,16 @@
#include <limits.h>
#include <stdint.h>
+#include <cstddef>
+#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "absl/strings/str_replace.h"
+#include "absl/strings/string_view.h"
#include "api/audio/audio_device.h"
-#include "api/audio/audio_mixer.h"
-#include "api/audio/audio_processing.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h"
@@ -29,18 +30,25 @@
#include "api/enable_media_with_defaults.h"
#include "api/field_trials.h"
#include "api/jsep.h"
+#include "api/make_ref_counted.h"
#include "api/media_stream_interface.h"
#include "api/media_types.h"
+#include "api/packet_socket_factory.h"
#include "api/rtc_error.h"
#include "api/rtc_event_log/rtc_event_log.h"
#include "api/rtc_event_log/rtc_event_log_factory.h"
#include "api/rtc_event_log_output.h"
+#include "api/rtp_parameters.h"
#include "api/rtp_receiver_interface.h"
#include "api/rtp_sender_interface.h"
#include "api/rtp_transceiver_direction.h"
#include "api/scoped_refptr.h"
#include "api/task_queue/default_task_queue_factory.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/transport/bitrate_settings.h"
+#include "api/transport/enums.h"
#include "api/transport/field_trial_based_config.h"
+#include "api/units/time_delta.h"
#include "api/video_codecs/video_decoder_factory_template.h"
#include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
@@ -53,9 +61,7 @@
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
#include "media/base/codec.h"
#include "media/base/media_config.h"
-#include "media/base/media_engine.h"
#include "media/base/stream_params.h"
-#include "media/engine/webrtc_media_engine.h"
#include "media/sctp/sctp_transport_internal.h"
#include "p2p/base/fake_port_allocator.h"
#include "p2p/base/p2p_constants.h"
@@ -79,13 +85,14 @@
#include "pc/test/test_sdp_strings.h"
#include "pc/video_track.h"
#include "rtc_base/checks.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/rtc_certificate_generator.h"
#include "rtc_base/socket_address.h"
+#include "rtc_base/socket_server.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"
#ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h"
@@ -857,7 +864,10 @@
pc_->CreateAnswer(observer.get(),
options ? *options : RTCOfferAnswerOptions());
}
- EXPECT_EQ_WAIT(true, observer->called(), kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
*desc = observer->MoveDescription();
return observer->result();
}
@@ -882,7 +892,10 @@
pc_->SetRemoteDescription(observer.get(), desc.release());
}
if (pc_->signaling_state() != PeerConnectionInterface::kClosed) {
- EXPECT_EQ_WAIT(true, observer->called(), kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
}
return observer->result();
}
@@ -905,7 +918,10 @@
if (!pc_->GetStats(observer.get(), track,
PeerConnectionInterface::kStatsOutputLevelStandard))
return false;
- EXPECT_TRUE_WAIT(observer->called(), kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
return observer->called();
}
@@ -913,7 +929,10 @@
bool DoGetRTCStats() {
auto callback = rtc::make_ref_counted<MockRTCStatsCollectorCallback>();
pc_->GetStats(callback.get());
- EXPECT_TRUE_WAIT(callback->called(), kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callback->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
return callback->called();
}
@@ -1019,7 +1038,10 @@
EXPECT_TRUE(DoSetLocalDescription(std::move(new_offer)));
EXPECT_EQ(PeerConnectionInterface::kHaveLocalOffer, observer_.state_);
// Wait for the ice_complete message, so that SDP will have candidates.
- EXPECT_TRUE_WAIT(observer_.ice_gathering_complete_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer_.ice_gathering_complete_; },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
}
void CreateAnswerAsRemoteDescription(const std::string& sdp) {
@@ -1049,9 +1071,16 @@
void WaitAndVerifyOnAddStream(const std::string& stream_id,
int expected_num_tracks) {
// Verify that both OnAddStream and OnAddTrack are called.
- EXPECT_EQ_WAIT(stream_id, observer_.GetLastAddedStreamId(), kTimeout);
- EXPECT_EQ_WAIT(expected_num_tracks,
- observer_.CountAddTrackEventsForStream(stream_id), kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer_.GetLastAddedStreamId(); },
+ ::testing::Eq(stream_id),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return observer_.CountAddTrackEventsForStream(stream_id); },
+ ::testing::Eq(expected_num_tracks),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
}
// Creates an offer and applies it as a local session description.
@@ -1167,7 +1196,10 @@
auto observer =
rtc::make_ref_counted<MockCreateSessionDescriptionObserver>();
pc_->CreateOffer(observer.get(), offer_answer_options);
- EXPECT_EQ_WAIT(true, observer->called(), kTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
return observer->MoveDescription();
}
@@ -1759,8 +1791,14 @@
EXPECT_TRUE(DoCreateAnswer(&answer, nullptr));
EXPECT_TRUE(DoSetLocalDescription(std::move(answer)));
- EXPECT_TRUE_WAIT(observer_.last_candidate() != nullptr, kTimeout);
- EXPECT_TRUE_WAIT(observer_.ice_gathering_complete_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer_.last_candidate(); },
+ ::testing::Ne(nullptr),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return observer_.ice_gathering_complete_; },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate()));
}
@@ -2444,10 +2482,14 @@
ASSERT_TRUE(audio_receiver);
ASSERT_TRUE(video_receiver);
// Track state may be updated asynchronously.
- EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded,
- audio_receiver->track()->state(), kTimeout);
- EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded,
- video_receiver->track()->state(), kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return audio_receiver->track()->state(); },
+ ::testing::Eq(MediaStreamTrackInterface::kEnded),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return video_receiver->track()->state(); },
+ ::testing::Eq(MediaStreamTrackInterface::kEnded),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
} else {
ASSERT_FALSE(audio_receiver);
ASSERT_FALSE(video_receiver);
@@ -2567,10 +2609,14 @@
EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(),
reference_collection_.get()));
// Track state may be updated asynchronously.
- EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, audio_track2->state(),
- kTimeout);
- EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, video_track2->state(),
- kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return audio_track2->state(); },
+ ::testing::Eq(MediaStreamTrackInterface::kEnded),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return video_track2->state(); },
+ ::testing::Eq(MediaStreamTrackInterface::kEnded),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
}
// This tests that remote tracks are ended if a local session description is set
@@ -2614,10 +2660,14 @@
audio_info->rejected = true;
EXPECT_TRUE(DoSetLocalDescription(std::move(local_offer)));
// Track state may be updated asynchronously.
- EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, remote_audio->state(),
- kTimeout);
- EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, remote_video->state(),
- kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return remote_audio->state(); },
+ ::testing::Eq(MediaStreamTrackInterface::kEnded),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil([&] { return remote_video->state(); },
+ ::testing::Eq(MediaStreamTrackInterface::kEnded),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
}
// This tests that we won't crash if the remote track has been removed outside
@@ -3603,22 +3653,34 @@
rtc::scoped_refptr<VideoTrackInterface> video_track(
CreateVideoTrack("video_track"));
stream->AddTrack(audio_track);
- EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
observer_.renegotiation_needed_ = false;
CreateOfferReceiveAnswer();
stream->AddTrack(video_track);
- EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
observer_.renegotiation_needed_ = false;
CreateOfferReceiveAnswer();
stream->RemoveTrack(audio_track);
- EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
observer_.renegotiation_needed_ = false;
CreateOfferReceiveAnswer();
stream->RemoveTrack(video_track);
- EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kTimeout)}),
+ IsRtcOk());
observer_.renegotiation_needed_ = false;
}
@@ -3704,7 +3766,7 @@
void SetUp() override {
pcf_ = PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest();
}
- const cricket::MediaConfig TestCreatePeerConnection(
+ cricket::MediaConfig TestCreatePeerConnection(
const RTCConfiguration& config) {
PeerConnectionDependencies pc_dependencies(&observer_);
auto result =
diff --git a/pc/peer_connection_rampup_tests.cc b/pc/peer_connection_rampup_tests.cc
index 4bea516..d6546e6 100644
--- a/pc/peer_connection_rampup_tests.cc
+++ b/pc/peer_connection_rampup_tests.cc
@@ -15,13 +15,12 @@
#include <vector>
#include "api/audio/audio_device.h"
-#include "api/audio/audio_mixer.h"
-#include "api/audio/audio_processing.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/audio_options.h"
#include "api/create_peerconnection_factory.h"
#include "api/jsep.h"
+#include "api/make_ref_counted.h"
#include "api/media_stream_interface.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_error.h"
@@ -31,6 +30,7 @@
#include "api/stats/rtcstats_objects.h"
#include "api/test/metrics/global_metrics_logger_and_exporter.h"
#include "api/test/metrics/metric.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/video_codecs/video_decoder_factory_template.h"
#include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
@@ -41,6 +41,7 @@
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
+#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/base/port_allocator.h"
#include "p2p/base/port_interface.h"
#include "p2p/base/test_turn_server.h"
@@ -54,16 +55,16 @@
#include "rtc_base/crypto_random.h"
#include "rtc_base/fake_network.h"
#include "rtc_base/firewall_socket_server.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/socket_factory.h"
-#include "rtc_base/ssl_certificate.h"
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/test_certificate_verifier.h"
#include "rtc_base/thread.h"
#include "rtc_base/virtual_socket_server.h"
#include "system_wrappers/include/clock.h"
+#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
namespace {
@@ -75,7 +76,6 @@
static const int kDefaultTestTimeMs = 15000;
static const int kRampUpTimeMs = 5000;
static const int kPollIntervalTimeMs = 50;
-static const int kDefaultTimeoutMs = 10000;
static const rtc::SocketAddress kDefaultLocalAddress("1.1.1.1", 0);
static const char kTurnInternalAddress[] = "88.88.88.0";
static const char kTurnExternalAddress[] = "88.88.88.1";
@@ -234,11 +234,15 @@
// Do the SDP negotiation, and also exchange ice candidates.
ASSERT_TRUE(caller_->ExchangeOfferAnswerWith(callee_.get()));
- ASSERT_TRUE_WAIT(
- caller_->signaling_state() == PeerConnectionInterface::kStable,
- kDefaultTimeoutMs);
- ASSERT_TRUE_WAIT(caller_->IsIceGatheringDone(), kDefaultTimeoutMs);
- ASSERT_TRUE_WAIT(callee_->IsIceGatheringDone(), kDefaultTimeoutMs);
+ ASSERT_THAT(WaitUntil([&] { return caller_->signaling_state(); },
+ ::testing::Eq(PeerConnectionInterface::kStable)),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return caller_->IsIceGatheringDone(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return callee_->IsIceGatheringDone(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
// Connect an ICE candidate pairs.
ASSERT_TRUE(
@@ -246,8 +250,12 @@
ASSERT_TRUE(
caller_->AddIceCandidates(callee_->observer()->GetAllCandidates()));
// This means that ICE and DTLS are connected.
- ASSERT_TRUE_WAIT(callee_->IsIceConnected(), kDefaultTimeoutMs);
- ASSERT_TRUE_WAIT(caller_->IsIceConnected(), kDefaultTimeoutMs);
+ ASSERT_THAT(WaitUntil([&] { return callee_->IsIceConnected(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
+ ASSERT_THAT(WaitUntil([&] { return caller_->IsIceConnected(); },
+ ::testing::IsTrue()),
+ IsRtcOk());
}
void CreateTurnServer(cricket::ProtocolType type,
@@ -308,7 +316,7 @@
double GetCallerAvailableBitrateEstimate() {
auto stats = caller_->GetStats();
auto transport_stats = stats->GetStatsOfType<RTCTransportStats>();
- if (transport_stats.size() == 0u ||
+ if (transport_stats.empty() ||
!transport_stats[0]->selected_candidate_pair_id.has_value()) {
return 0;
}
diff --git a/pc/peer_connection_rtp_unittest.cc b/pc/peer_connection_rtp_unittest.cc
index 0bf3961..af28a2d 100644
--- a/pc/peer_connection_rtp_unittest.cc
+++ b/pc/peer_connection_rtp_unittest.cc
@@ -17,13 +17,11 @@
#include <utility>
#include <vector>
-#include "api/audio/audio_device.h"
-#include "api/audio/audio_mixer.h"
-#include "api/audio/audio_processing.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h"
#include "api/jsep.h"
+#include "api/make_ref_counted.h"
#include "api/media_stream_interface.h"
#include "api/media_types.h"
#include "api/peer_connection_interface.h"
@@ -35,7 +33,8 @@
#include "api/rtp_transceiver_interface.h"
#include "api/scoped_refptr.h"
#include "api/set_remote_description_observer_interface.h"
-#include "api/uma_metrics.h"
+#include "api/test/rtc_error_matchers.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"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
@@ -46,8 +45,8 @@
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
+#include "media/base/codec.h"
#include "media/base/stream_params.h"
-#include "p2p/base/port_allocator.h"
#include "pc/media_session.h"
#include "pc/peer_connection_wrapper.h"
#include "pc/sdp_utils.h"
@@ -56,12 +55,11 @@
#include "pc/test/integration_test_helpers.h"
#include "pc/test/mock_peer_connection_observers.h"
#include "rtc_base/checks.h"
-#include "rtc_base/gunit.h"
-#include "rtc_base/rtc_certificate_generator.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 tests for RTP Media API-related behavior of
// `webrtc::PeerConnection`, see https://w3c.github.io/webrtc-pc/#rtp-media-api.
@@ -70,7 +68,6 @@
using RTCConfiguration = PeerConnectionInterface::RTCConfiguration;
using ::testing::ElementsAre;
-using ::testing::Pair;
using ::testing::UnorderedElementsAre;
using ::testing::Values;
@@ -757,8 +754,12 @@
std::move(srd2_sdp),
rtc::make_ref_counted<OnSuccessObserver<decltype(srd2_callback)>>(
srd2_callback));
- EXPECT_TRUE_WAIT(srd1_callback_called, kDefaultTimeout);
- EXPECT_TRUE_WAIT(srd2_callback_called, kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return srd1_callback_called; }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil([&] { return srd2_callback_called; }, ::testing::IsTrue()),
+ IsRtcOk());
}
// Tests that a remote track is created with the signaled MSIDs when they are
diff --git a/pc/peer_connection_signaling_unittest.cc b/pc/peer_connection_signaling_unittest.cc
index 2b85a72..7c76ea0 100644
--- a/pc/peer_connection_signaling_unittest.cc
+++ b/pc/peer_connection_signaling_unittest.cc
@@ -20,18 +20,16 @@
#include <set>
#include <string>
#include <tuple>
-#include <type_traits>
#include <utility>
#include <vector>
#include "api/audio/audio_device.h"
-#include "api/audio/audio_mixer.h"
-#include "api/audio/audio_processing.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h"
#include "api/dtls_transport_interface.h"
#include "api/jsep.h"
+#include "api/make_ref_counted.h"
#include "api/media_types.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_error.h"
@@ -39,8 +37,8 @@
#include "api/rtp_sender_interface.h"
#include "api/rtp_transceiver_interface.h"
#include "api/scoped_refptr.h"
-#include "api/set_local_description_observer_interface.h"
-#include "api/set_remote_description_observer_interface.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
#include "api/video_codecs/video_decoder_factory_template.h"
#include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
@@ -52,7 +50,6 @@
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
#include "media/base/codec.h"
-#include "p2p/base/port_allocator.h"
#include "pc/peer_connection.h"
#include "pc/peer_connection_proxy.h"
#include "pc/peer_connection_wrapper.h"
@@ -60,18 +57,16 @@
#include "pc/session_description.h"
#include "pc/test/mock_peer_connection_observers.h"
#include "rtc_base/checks.h"
-#include "rtc_base/rtc_certificate.h"
-#include "rtc_base/rtc_certificate_generator.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
#ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h"
#endif
#include "pc/test/fake_audio_capture_module.h"
#include "pc/test/fake_rtc_certificate_generator.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/virtual_socket_server.h"
namespace webrtc {
@@ -595,7 +590,10 @@
// We expect to have received a notification now even if the PeerConnection
// was terminated. The offer creation may or may not have succeeded, but we
// must have received a notification.
- EXPECT_TRUE_WAIT(observer->called(), kWaitTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
}
}
@@ -609,7 +607,9 @@
caller->pc()->Close();
caller->pc()->CreateOffer(observer.get(), RTCOfferAnswerOptions());
caller.reset(nullptr);
- EXPECT_TRUE_WAIT(observer->called(), kWaitTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
}
TEST_P(PeerConnectionSignalingTest,
@@ -701,7 +701,9 @@
bool checkpoint_reached = false;
rtc::Thread::Current()->PostTask(
[&checkpoint_reached] { checkpoint_reached = true; });
- EXPECT_TRUE_WAIT(checkpoint_reached, kWaitTimeout);
+ EXPECT_THAT(WaitUntil([&] { return checkpoint_reached; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
// If resolving the observer was pending, it must now have been called.
EXPECT_TRUE(observer->called());
}
@@ -745,7 +747,10 @@
// yet.
EXPECT_EQ(0u, callee->pc()->GetReceivers().size());
// EXPECT_TRUE_WAIT causes messages to be processed...
- EXPECT_TRUE_WAIT(offer_observer->called(), kWaitTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return offer_observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
// Now that the offer has been completed, SetRemoteDescription() will have
// been executed next in the chain.
EXPECT_EQ(2u, callee->pc()->GetReceivers().size());
@@ -765,7 +770,9 @@
EXPECT_EQ(PeerConnection::kStable, caller->signaling_state());
// Wait for messages to be processed.
- EXPECT_TRUE_WAIT(observer->called(), kWaitTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
EXPECT_TRUE(observer->result());
EXPECT_TRUE(caller->pc()->pending_local_description());
EXPECT_EQ(SdpType::kOffer,
@@ -790,7 +797,9 @@
EXPECT_FALSE(callee->pc()->current_local_description());
// Wait for messages to be processed.
- EXPECT_TRUE_WAIT(observer->called(), kWaitTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
EXPECT_TRUE(observer->result());
EXPECT_TRUE(callee->pc()->current_local_description());
EXPECT_EQ(SdpType::kAnswer,
@@ -808,8 +817,11 @@
MockSetSessionDescriptionObserver::Create();
caller->pc()->SetLocalDescription(
caller_set_local_description_observer.get());
- EXPECT_TRUE_WAIT(caller_set_local_description_observer->called(),
- kWaitTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return caller_set_local_description_observer->called(); },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
ASSERT_TRUE(caller->pc()->pending_local_description());
// SetRemoteDescription(offer)
@@ -825,8 +837,11 @@
MockSetSessionDescriptionObserver::Create();
callee->pc()->SetLocalDescription(
callee_set_local_description_observer.get());
- EXPECT_TRUE_WAIT(callee_set_local_description_observer->called(),
- kWaitTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callee_set_local_description_observer->called(); },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
// Chaining guarantees SetRemoteDescription() happened before
// SetLocalDescription().
EXPECT_TRUE(callee_set_remote_description_observer->called());
@@ -839,8 +854,12 @@
caller_set_remote_description_observer.get(),
CloneSessionDescription(callee->pc()->current_local_description())
.release());
- EXPECT_TRUE_WAIT(caller_set_remote_description_observer->called(),
- kWaitTimeout);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return caller_set_remote_description_observer->called(); },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
EXPECT_EQ(PeerConnection::kStable, caller->signaling_state());
EXPECT_EQ(PeerConnection::kStable, callee->signaling_state());
@@ -856,7 +875,9 @@
// The operation should fail asynchronously.
EXPECT_FALSE(observer->called());
- EXPECT_TRUE_WAIT(observer->called(), kWaitTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
EXPECT_FALSE(observer->result());
// This did not affect the signaling state.
EXPECT_EQ(PeerConnection::kClosed, caller->pc()->signaling_state());
@@ -876,7 +897,9 @@
// The operation should fail asynchronously.
EXPECT_FALSE(observer->called());
- EXPECT_TRUE_WAIT(observer->called(), kWaitTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
EXPECT_FALSE(observer->result());
// This did not affect the signaling state.
EXPECT_EQ(PeerConnection::kClosed, caller->pc()->signaling_state());
@@ -1175,7 +1198,10 @@
EXPECT_TRUE(pc->GetTransceivers()[0]->mid().has_value());
});
caller->pc()->CreateOffer(offer_observer.get(), RTCOfferAnswerOptions());
- EXPECT_TRUE_WAIT(offer_observer->was_called(), kWaitTimeout);
+ EXPECT_THAT(WaitUntil([&] { return offer_observer->was_called(); },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
}
// Test that transports are shown in the sender/receiver API after offer/answer.
@@ -1272,7 +1298,9 @@
// When the Operations Chain becomes empty again, a new negotiation needed
// event will be generated that is not suppressed.
- EXPECT_TRUE_WAIT(observer->called(), kWaitTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}),
+ IsRtcOk());
EXPECT_TRUE(caller->observer()->has_negotiation_needed_event());
EXPECT_TRUE(caller->pc()->ShouldFireNegotiationNeededEvent(
caller->observer()->latest_negotiation_needed_event()));
diff --git a/pc/peer_connection_svc_integrationtest.cc b/pc/peer_connection_svc_integrationtest.cc
index 6ab77e1..5366fc5 100644
--- a/pc/peer_connection_svc_integrationtest.cc
+++ b/pc/peer_connection_svc_integrationtest.cc
@@ -13,18 +13,23 @@
#include <stdint.h>
-#include <functional>
+#include <algorithm>
#include <vector>
#include "absl/strings/match.h"
+#include "absl/strings/string_view.h"
+#include "api/media_types.h"
+#include "api/peer_connection_interface.h"
#include "api/rtc_error.h"
#include "api/rtp_parameters.h"
#include "api/rtp_transceiver_interface.h"
#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
+#include "media/base/media_constants.h"
#include "pc/test/integration_test_helpers.h"
-#include "rtc_base/crypto_random.h"
-#include "rtc_base/gunit.h"
+#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
@@ -134,7 +139,9 @@
EXPECT_TRUE(SetCodecPreferences(transceiver, cricket::kVp8CodecName).ok());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
@@ -158,7 +165,9 @@
EXPECT_TRUE(SetCodecPreferences(transceiver, cricket::kVp9CodecName).ok());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
@@ -182,7 +191,9 @@
EXPECT_TRUE(SetCodecPreferences(transceiver, cricket::kVp8CodecName).ok());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
@@ -207,7 +218,9 @@
EXPECT_TRUE(SetCodecPreferences(transceiver, cricket::kVp9CodecName).ok());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
@@ -251,7 +264,9 @@
EXPECT_TRUE(result.ok());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
parameters = caller_transceiver->sender()->GetParameters();
ASSERT_TRUE(parameters.encodings[0].scalability_mode.has_value());
@@ -271,7 +286,9 @@
// Renegotiate to force the new codec list to be used
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Fallback should happen and L3T3 is not used anymore
parameters = caller_transceiver->sender()->GetParameters();
diff --git a/pc/peer_connection_wrapper.cc b/pc/peer_connection_wrapper.cc
index b4842c1..de94cc1 100644
--- a/pc/peer_connection_wrapper.cc
+++ b/pc/peer_connection_wrapper.cc
@@ -12,27 +12,39 @@
#include <stdint.h>
+#include <memory>
#include <optional>
+#include <string>
#include <utility>
#include <vector>
+#include "api/data_channel_interface.h"
#include "api/function_view.h"
-#include "api/set_remote_description_observer_interface.h"
+#include "api/jsep.h"
+#include "api/make_ref_counted.h"
+#include "api/media_stream_interface.h"
+#include "api/media_types.h"
+#include "api/peer_connection_interface.h"
+#include "api/rtc_error.h"
+#include "api/rtp_parameters.h"
+#include "api/rtp_sender_interface.h"
+#include "api/rtp_transceiver_interface.h"
+#include "api/scoped_refptr.h"
+#include "api/stats/rtc_stats_report.h"
+#include "api/test/rtc_error_matchers.h"
#include "pc/sdp_utils.h"
#include "pc/test/fake_video_track_source.h"
+#include "pc/test/mock_peer_connection_observers.h"
#include "rtc_base/checks.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/logging.h"
+#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
-namespace {
-const uint32_t kDefaultTimeout = 10000U;
-}
-
PeerConnectionWrapper::PeerConnectionWrapper(
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory,
rtc::scoped_refptr<PeerConnectionInterface> pc,
@@ -136,7 +148,9 @@
std::string* error_out) {
auto observer = rtc::make_ref_counted<MockCreateSessionDescriptionObserver>();
fn(observer.get());
- EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
if (error_out && !observer->result()) {
*error_out = observer->error();
}
@@ -168,7 +182,9 @@
RTCError* error_out) {
auto observer = rtc::make_ref_counted<FakeSetRemoteDescriptionObserver>();
pc()->SetRemoteDescription(std::move(desc), observer);
- EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
bool ok = observer->error().ok();
if (error_out)
*error_out = std::move(observer->error());
@@ -180,7 +196,9 @@
std::string* error_out) {
auto observer = rtc::make_ref_counted<MockSetSessionDescriptionObserver>();
fn(observer.get());
- EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
if (error_out && !observer->result()) {
*error_out = observer->error();
}
@@ -342,7 +360,9 @@
rtc::scoped_refptr<const RTCStatsReport> PeerConnectionWrapper::GetStats() {
auto callback = rtc::make_ref_counted<MockRTCStatsCollectorCallback>();
pc()->GetStats(callback.get());
- EXPECT_TRUE_WAIT(callback->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callback->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
return callback->report();
}
diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc
index 12fda72..1737f26 100644
--- a/pc/rtc_stats_collector_unittest.cc
+++ b/pc/rtc_stats_collector_unittest.cc
@@ -42,6 +42,7 @@
#include "api/stats/rtc_stats_collector_callback.h"
#include "api/stats/rtc_stats_report.h"
#include "api/stats/rtcstats_objects.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/transport/enums.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
@@ -77,7 +78,6 @@
#include "rtc_base/checks.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/fake_ssl_identity.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/network_constants.h"
#include "rtc_base/ref_counted_object.h"
#include "rtc_base/rtc_certificate.h"
@@ -92,6 +92,7 @@
#include "rtc_base/time_utils.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
using ::testing::_;
using ::testing::Invoke;
@@ -604,7 +605,11 @@
private:
rtc::scoped_refptr<const RTCStatsReport> WaitForReport(
rtc::scoped_refptr<RTCStatsObtainer> callback) {
- EXPECT_TRUE_WAIT(callback->report() != nullptr, kGetStatsReportTimeoutMs);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return callback->report() != nullptr; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
int64_t after = rtc::TimeUTCMicros();
for (const RTCStats& stats : *callback->report()) {
if (stats.type() == RTCRemoteInboundRtpStreamStats::kType ||
@@ -883,7 +888,11 @@
TEST_F(RTCStatsCollectorTest, SingleCallback) {
rtc::scoped_refptr<const RTCStatsReport> result;
stats_->stats_collector()->GetStatsReport(RTCStatsObtainer::Create(&result));
- EXPECT_TRUE_WAIT(result != nullptr, kGetStatsReportTimeoutMs);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return result != nullptr; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
}
TEST_F(RTCStatsCollectorTest, MultipleCallbacks) {
@@ -891,9 +900,21 @@
stats_->stats_collector()->GetStatsReport(RTCStatsObtainer::Create(&a));
stats_->stats_collector()->GetStatsReport(RTCStatsObtainer::Create(&b));
stats_->stats_collector()->GetStatsReport(RTCStatsObtainer::Create(&c));
- EXPECT_TRUE_WAIT(a != nullptr, kGetStatsReportTimeoutMs);
- EXPECT_TRUE_WAIT(b != nullptr, kGetStatsReportTimeoutMs);
- EXPECT_TRUE_WAIT(c != nullptr, kGetStatsReportTimeoutMs);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return a != nullptr; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return b != nullptr; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return c != nullptr; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
EXPECT_EQ(a.get(), b.get());
EXPECT_EQ(b.get(), c.get());
@@ -922,9 +943,21 @@
// Cache is invalidated after 50 ms.
fake_clock_.AdvanceTime(TimeDelta::Millis(51));
stats_->stats_collector()->GetStatsReport(RTCStatsObtainer::Create(&c));
- EXPECT_TRUE_WAIT(a != nullptr, kGetStatsReportTimeoutMs);
- EXPECT_TRUE_WAIT(b != nullptr, kGetStatsReportTimeoutMs);
- EXPECT_TRUE_WAIT(c != nullptr, kGetStatsReportTimeoutMs);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return a != nullptr; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return b != nullptr; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return c != nullptr; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
EXPECT_EQ(a.get(), b.get());
// The act of doing `AdvanceTime` processes all messages. If this was not the
// case we might not require `c` to be fresher than `b`.
@@ -3702,8 +3735,16 @@
auto callback2 = rtc::make_ref_counted<RecursiveCallback>(stats_.get());
stats_->stats_collector()->GetStatsReport(callback1);
stats_->stats_collector()->GetStatsReport(callback2);
- EXPECT_TRUE_WAIT(callback1->called(), kGetStatsReportTimeoutMs);
- EXPECT_TRUE_WAIT(callback2->called(), kGetStatsReportTimeoutMs);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return callback1->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return callback2->called(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
}
class RTCTestStats : public RTCStats {
@@ -3755,7 +3796,11 @@
void VerifyThreadUsageAndResultsMerging() {
GetStatsReport(rtc::scoped_refptr<RTCStatsCollectorCallback>(this));
- EXPECT_TRUE_WAIT(HasVerifiedResults(), kGetStatsReportTimeoutMs);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return HasVerifiedResults(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}),
+ IsRtcOk());
}
bool HasVerifiedResults() {
diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc
index c21ab0e..f28f50a 100644
--- a/pc/rtc_stats_integrationtest.cc
+++ b/pc/rtc_stats_integrationtest.cc
@@ -9,7 +9,6 @@
*/
#include <stdint.h>
-#include <string.h>
#include <memory>
#include <optional>
@@ -23,24 +22,27 @@
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/audio_options.h"
#include "api/data_channel_interface.h"
+#include "api/make_ref_counted.h"
#include "api/peer_connection_interface.h"
#include "api/rtp_receiver_interface.h"
#include "api/rtp_sender_interface.h"
#include "api/scoped_refptr.h"
+#include "api/stats/attribute.h"
#include "api/stats/rtc_stats.h"
#include "api/stats/rtc_stats_report.h"
#include "api/stats/rtcstats_objects.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
#include "pc/rtc_stats_traversal.h"
#include "pc/test/peer_connection_test_wrapper.h"
#include "pc/test/rtc_stats_obtainer.h"
#include "rtc_base/checks.h"
-#include "rtc_base/event_tracer.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/thread.h"
#include "rtc_base/trace_event.h"
#include "rtc_base/virtual_socket_server.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
using ::testing::Contains;
@@ -124,7 +126,11 @@
rtc::scoped_refptr<RTCStatsObtainer> stats_obtainer =
RTCStatsObtainer::Create();
pc->GetStats(stats_obtainer.get());
- EXPECT_TRUE_WAIT(stats_obtainer->report() != nullptr, kGetStatsTimeoutMs);
+ EXPECT_THAT(
+ WaitUntil([&] { return stats_obtainer->report() != nullptr; },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsTimeoutMs)}),
+ IsRtcOk());
return stats_obtainer->report();
}
@@ -135,7 +141,11 @@
rtc::scoped_refptr<RTCStatsObtainer> stats_obtainer =
RTCStatsObtainer::Create();
pc->GetStats(selector, stats_obtainer);
- EXPECT_TRUE_WAIT(stats_obtainer->report() != nullptr, kGetStatsTimeoutMs);
+ EXPECT_THAT(
+ WaitUntil([&] { return stats_obtainer->report() != nullptr; },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kGetStatsTimeoutMs)}),
+ IsRtcOk());
return stats_obtainer->report();
}
@@ -1024,7 +1034,11 @@
inbound_stats.front()->round_trip_time.has_value() &&
inbound_stats.front()->round_trip_time_measurements.has_value();
};
- EXPECT_TRUE_WAIT(GetStatsReportAndReturnTrueIfRttIsDefined(), kMaxWaitMs);
+ EXPECT_THAT(
+ WaitUntil([&] { return GetStatsReportAndReturnTrueIfRttIsDefined(); },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs)}),
+ IsRtcOk());
RTCStatsReportVerifier(report.get()).VerifyReport({});
}
diff --git a/pc/rtp_sender_receiver_unittest.cc b/pc/rtp_sender_receiver_unittest.cc
index 743266c..c1fc8a8 100644
--- a/pc/rtp_sender_receiver_unittest.cc
+++ b/pc/rtp_sender_receiver_unittest.cc
@@ -25,16 +25,17 @@
#include "api/crypto/frame_decryptor_interface.h"
#include "api/crypto/frame_encryptor_interface.h"
#include "api/dtmf_sender_interface.h"
+#include "api/environment/environment.h"
#include "api/environment/environment_factory.h"
#include "api/make_ref_counted.h"
#include "api/media_stream_interface.h"
#include "api/rtc_error.h"
-#include "api/rtc_event_log/rtc_event_log.h"
#include "api/rtp_parameters.h"
#include "api/rtp_receiver_interface.h"
#include "api/scoped_refptr.h"
#include "api/test/fake_frame_decryptor.h"
#include "api/test/fake_frame_encryptor.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/video/builtin_video_bitrate_allocator_factory.h"
#include "api/video/video_bitrate_allocator_factory.h"
#include "api/video/video_codec_constants.h"
@@ -61,19 +62,12 @@
#include "pc/video_rtp_receiver.h"
#include "pc/video_track.h"
#include "rtc_base/checks.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/thread.h"
#include "rtc_base/unique_id_generator.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/run_loop.h"
-
-using ::testing::_;
-using ::testing::ContainerEq;
-using ::testing::Exactly;
-using ::testing::InvokeWithoutArgs;
-using ::testing::Return;
-using RidList = std::vector<std::string>;
+#include "test/wait_until.h"
namespace {
@@ -86,7 +80,6 @@
static const uint32_t kAudioSsrc2 = 101;
static const uint32_t kVideoSsrcSimulcast = 102;
static const uint32_t kVideoSimulcastLayerCount = 2;
-static const int kDefaultTimeout = 10000; // 10 seconds.
class MockSetStreamsObserver
: public webrtc::RtpSenderBase::SetStreamsObserver {
@@ -98,6 +91,9 @@
namespace webrtc {
+using ::testing::ContainerEq;
+using RidList = std::vector<std::string>;
+
class RtpSenderReceiverTest
: public ::testing::Test,
public ::testing::WithParamInterface<std::pair<RidList, RidList>> {
@@ -431,7 +427,7 @@
// This test assumes that some layers have already been disabled.
void RunSetLastLayerAsInactiveTest(VideoRtpSender* sender) {
auto parameters = sender->GetParameters();
- if (parameters.encodings.size() == 0) {
+ if (parameters.encodings.empty()) {
return;
}
@@ -1784,8 +1780,11 @@
dtmf_sender->InsertDtmf("012", expected_duration, 100);
// Verify
- ASSERT_EQ_WAIT(3U, voice_media_send_channel()->dtmf_info_queue().size(),
- kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return voice_media_send_channel()->dtmf_info_queue().size(); },
+ ::testing::Eq(3U)),
+ IsRtcOk());
const uint32_t send_ssrc =
voice_media_send_channel()->send_streams()[0].first_ssrc();
EXPECT_TRUE(CompareDtmfInfo(voice_media_send_channel()->dtmf_info_queue()[0],
diff --git a/pc/rtp_transport_unittest.cc b/pc/rtp_transport_unittest.cc
index d4a0188..0c50709 100644
--- a/pc/rtp_transport_unittest.cc
+++ b/pc/rtp_transport_unittest.cc
@@ -10,17 +10,26 @@
#include "pc/rtp_transport.h"
-#include <utility>
+#include <cerrno>
+#include <cstdint>
+#include <optional>
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
+#include "call/rtp_demuxer.h"
#include "p2p/base/fake_packet_transport.h"
#include "pc/test/rtp_transport_test_util.h"
#include "rtc_base/buffer.h"
#include "rtc_base/containers/flat_set.h"
-#include "rtc_base/gunit.h"
+#include "rtc_base/network/ecn_marking.h"
+#include "rtc_base/network/sent_packet.h"
+#include "rtc_base/network_route.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
#include "test/explicit_key_value_config.h"
+#include "test/gmock.h"
#include "test/gtest.h"
#include "test/run_loop.h"
+#include "test/wait_until.h"
namespace webrtc {
@@ -398,7 +407,10 @@
EXPECT_TRUE(observer.ready_to_send());
EXPECT_EQ(observer.ready_to_send_signal_count(), 1);
// After the wait, the ready-to-send false is observed.
- EXPECT_EQ_WAIT(observer.ready_to_send_signal_count(), 2, kShortTimeout);
+ EXPECT_THAT(WaitUntil([&] { return observer.ready_to_send_signal_count(); },
+ ::testing::Eq(2),
+ {.timeout = webrtc::TimeDelta::Millis(kShortTimeout)}),
+ IsRtcOk());
EXPECT_FALSE(observer.ready_to_send());
}
@@ -423,7 +435,10 @@
rtc::CopyOnWriteBuffer rtp_data(kRtpData, kRtpLen);
transport.SendRtpPacket(&rtp_data, options, flags);
EXPECT_EQ(observer.sent_packet_count(), 1);
- EXPECT_EQ_WAIT(observer.sent_packet_count(), 2, kShortTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer.sent_packet_count(); }, ::testing::Eq(2),
+ {.timeout = webrtc::TimeDelta::Millis(kShortTimeout)}),
+ IsRtcOk());
}
} // namespace webrtc
diff --git a/pc/sctp_transport_unittest.cc b/pc/sctp_transport_unittest.cc
index 293881a..d17ad54 100644
--- a/pc/sctp_transport_unittest.cc
+++ b/pc/sctp_transport_unittest.cc
@@ -24,27 +24,26 @@
#include "api/rtc_error.h"
#include "api/scoped_refptr.h"
#include "api/sctp_transport_interface.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/transport/data_channel_transport_interface.h"
#include "media/sctp/sctp_transport_internal.h"
#include "p2p/base/p2p_constants.h"
-#include "p2p/base/packet_transport_internal.h"
#include "p2p/dtls/dtls_transport_internal.h"
#include "p2p/dtls/fake_dtls_transport.h"
#include "pc/dtls_transport.h"
#include "rtc_base/copy_on_write_buffer.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/thread.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
-constexpr int kDefaultTimeout = 1000; // milliseconds
+namespace webrtc {
+
constexpr int kTestMaxSctpStreams = 1234;
using cricket::FakeDtlsTransport;
using ::testing::ElementsAre;
-namespace webrtc {
-
namespace {
class FakeCricketSctpTransport : public cricket::SctpTransportInternal {
@@ -105,7 +104,7 @@
}
SctpTransportState State() {
- if (states_.size() > 0) {
+ if (!states_.empty()) {
return states_[states_.size() - 1];
} else {
return SctpTransportState::kNew;
@@ -182,8 +181,9 @@
CreateTransport();
transport()->RegisterObserver(observer());
CompleteSctpHandshake();
- ASSERT_EQ_WAIT(SctpTransportState::kConnected, observer_.State(),
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.State(); },
+ ::testing::Eq(SctpTransportState::kConnected)),
+ IsRtcOk());
EXPECT_THAT(observer_.States(), ElementsAre(SctpTransportState::kConnected));
}
@@ -191,11 +191,13 @@
CreateTransport();
transport()->RegisterObserver(observer());
CompleteSctpHandshake();
- ASSERT_EQ_WAIT(SctpTransportState::kConnected, observer_.State(),
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.State(); },
+ ::testing::Eq(SctpTransportState::kConnected)),
+ IsRtcOk());
transport()->Clear();
- ASSERT_EQ_WAIT(SctpTransportState::kClosed, observer_.State(),
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.State(); },
+ ::testing::Eq(SctpTransportState::kClosed)),
+ IsRtcOk());
}
TEST_F(SctpTransportTest, MaxChannelsSignalled) {
@@ -204,8 +206,9 @@
EXPECT_FALSE(transport()->Information().MaxChannels());
EXPECT_FALSE(observer_.LastReceivedInformation().MaxChannels());
CompleteSctpHandshake();
- ASSERT_EQ_WAIT(SctpTransportState::kConnected, observer_.State(),
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.State(); },
+ ::testing::Eq(SctpTransportState::kConnected)),
+ IsRtcOk());
EXPECT_TRUE(transport()->Information().MaxChannels());
EXPECT_EQ(kTestMaxSctpStreams, *(transport()->Information().MaxChannels()));
EXPECT_TRUE(observer_.LastReceivedInformation().MaxChannels());
@@ -217,11 +220,13 @@
CreateTransport();
transport()->RegisterObserver(observer());
CompleteSctpHandshake();
- ASSERT_EQ_WAIT(SctpTransportState::kConnected, observer_.State(),
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.State(); },
+ ::testing::Eq(SctpTransportState::kConnected)),
+ IsRtcOk());
static_cast<cricket::FakeDtlsTransport*>(dtls_transport_->internal())
->SetDtlsState(DtlsTransportState::kClosed);
- ASSERT_EQ_WAIT(SctpTransportState::kClosed, observer_.State(),
- kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return observer_.State(); },
+ ::testing::Eq(SctpTransportState::kClosed)),
+ IsRtcOk());
}
} // namespace webrtc
diff --git a/pc/slow_peer_connection_integration_test.cc b/pc/slow_peer_connection_integration_test.cc
index fae81b5..7fefb5e 100644
--- a/pc/slow_peer_connection_integration_test.cc
+++ b/pc/slow_peer_connection_integration_test.cc
@@ -14,8 +14,8 @@
#include <stdint.h>
#include <memory>
-#include <optional>
#include <string>
+#include <tuple>
#include <utility>
#include <vector>
@@ -25,6 +25,7 @@
#include "api/peer_connection_interface.h"
#include "api/rtp_receiver_interface.h"
#include "api/scoped_refptr.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/units/time_delta.h"
#include "p2p/base/port_allocator.h"
#include "p2p/base/port_interface.h"
@@ -38,10 +39,10 @@
#include "rtc_base/gunit.h"
#include "rtc_base/logging.h"
#include "rtc_base/socket_address.h"
-#include "rtc_base/ssl_certificate.h"
#include "rtc_base/test_certificate_verifier.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
@@ -104,23 +105,35 @@
callee()->AddAudioVideoTracks();
// Start offer/answer exchange and wait for it to complete.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Should be one receiver each for audio/video.
EXPECT_EQ(2U, caller()->rtp_receiver_observers().size());
EXPECT_EQ(2U, callee()->rtp_receiver_observers().size());
// Wait for all "first packet received" callbacks to be fired.
- EXPECT_TRUE_WAIT(
- absl::c_all_of(caller()->rtp_receiver_observers(),
- [](const std::unique_ptr<MockRtpReceiverObserver>& o) {
- return o->first_packet_received();
- }),
- kMaxWaitForFramesMs);
- EXPECT_TRUE_WAIT(
- absl::c_all_of(callee()->rtp_receiver_observers(),
- [](const std::unique_ptr<MockRtpReceiverObserver>& o) {
- return o->first_packet_received();
- }),
- kMaxWaitForFramesMs);
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return absl::c_all_of(
+ caller()->rtp_receiver_observers(),
+ [](const std::unique_ptr<MockRtpReceiverObserver>& o) {
+ return o->first_packet_received();
+ });
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
+ EXPECT_THAT(WaitUntil(
+ [&] {
+ return absl::c_all_of(
+ callee()->rtp_receiver_observers(),
+ [](const std::unique_ptr<MockRtpReceiverObserver>& o) {
+ return o->first_packet_received();
+ });
+ },
+ ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWaitForFramesMs)}),
+ IsRtcOk());
// If new observers are set after the first packet was already received, the
// callback should still be invoked.
caller()->ResetRtpReceiverObservers();
@@ -234,7 +247,9 @@
// Do offer/answer, wait for the callee to receive some frames.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Get the remote audio track created on the receiver, so they can be used as
// GetStats filters.
@@ -244,9 +259,16 @@
// Get the audio output level stats. Note that the level is not available
// until an RTCP packet has been received.
- EXPECT_TRUE_WAIT(callee()->OldGetStatsForTrack(remote_audio_track.get())
- ->CaptureStartNtpTime() > 0,
- 2 * kMaxWaitForFramesMs);
+ EXPECT_THAT(
+ WaitUntil(
+ [&] {
+ return callee()
+ ->OldGetStatsForTrack(remote_audio_track.get())
+ ->CaptureStartNtpTime();
+ },
+ ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(2 * kMaxWaitForFramesMs)}),
+ IsRtcOk());
}
// Test that firewalling the ICE connection causes the clients to identify the
@@ -357,12 +379,16 @@
// background.
caller()->CreateAndSetAndSignalOffer();
- ASSERT_EQ_SIMULATED_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kDefaultTimeout,
- FakeClock());
- ASSERT_EQ_SIMULATED_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->standardized_ice_connection_state(),
- kDefaultTimeout, FakeClock());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted),
+ {.clock = &FakeClock()}),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->standardized_ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted),
+ {.clock = &FakeClock()}),
+ IsRtcOk());
// Verify that the observer was notified of the intermediate transitions.
EXPECT_THAT(caller()->ice_connection_state_history(),
@@ -387,22 +413,33 @@
firewall()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, caller_address);
}
RTC_LOG(LS_INFO) << "Firewall rules applied";
- ASSERT_EQ_SIMULATED_WAIT(PeerConnectionInterface::kIceConnectionDisconnected,
- caller()->ice_connection_state(), kDefaultTimeout,
- FakeClock());
- ASSERT_EQ_SIMULATED_WAIT(PeerConnectionInterface::kIceConnectionDisconnected,
- caller()->standardized_ice_connection_state(),
- kDefaultTimeout, FakeClock());
+ ScopedFakeClock& fake_clock = FakeClock();
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionDisconnected),
+ {.timeout = TimeDelta::Seconds(10), .clock = &fake_clock}),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil(
+ [&] { return caller()->standardized_ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionDisconnected),
+ {.timeout = TimeDelta::Seconds(10), .clock = &fake_clock}),
+ IsRtcOk());
// Let ICE re-establish by removing the firewall rules.
firewall()->ClearRules();
RTC_LOG(LS_INFO) << "Firewall rules cleared";
- ASSERT_EQ_SIMULATED_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->ice_connection_state(), kDefaultTimeout,
- FakeClock());
- ASSERT_EQ_SIMULATED_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
- caller()->standardized_ice_connection_state(),
- kDefaultTimeout, FakeClock());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted),
+ {.clock = &fake_clock}),
+ IsRtcOk());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->standardized_ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted),
+ {.clock = &fake_clock}),
+ IsRtcOk());
// 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
@@ -412,12 +449,18 @@
firewall()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, caller_address);
}
RTC_LOG(LS_INFO) << "Firewall rules applied again";
- ASSERT_EQ_SIMULATED_WAIT(PeerConnectionInterface::kIceConnectionFailed,
- caller()->ice_connection_state(), kConsentTimeout,
- FakeClock());
- ASSERT_EQ_SIMULATED_WAIT(PeerConnectionInterface::kIceConnectionFailed,
- caller()->standardized_ice_connection_state(),
- kConsentTimeout, FakeClock());
+ ASSERT_THAT(
+ WaitUntil([&] { return caller()->ice_connection_state(); },
+ ::testing::Eq(PeerConnectionInterface::kIceConnectionFailed),
+ {.timeout = webrtc::TimeDelta::Millis(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}),
+ IsRtcOk());
}
#endif
@@ -429,7 +472,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Keep the original peer around which will still send packets to the
// receiving client. These SRTP packets will be dropped.
@@ -443,7 +488,9 @@
ConnectFakeSignaling();
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Wait for some additional frames to be transmitted end-to-end.
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
@@ -458,7 +505,9 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Keep the original peer around which will still send packets to the
// receiving client. These SRTP packets will be dropped.
@@ -473,7 +522,9 @@
callee()->AddAudioVideoTracks();
caller()->SetOfferAnswerOptions(IceRestartOfferAnswerOptions());
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+ ASSERT_THAT(
+ WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()),
+ IsRtcOk());
// Wait for some additional frames to be transmitted end-to-end.
MediaExpectations media_expectations;
media_expectations.ExpectBidirectionalAudioAndVideo();
diff --git a/pc/test/fake_audio_capture_module_unittest.cc b/pc/test/fake_audio_capture_module_unittest.cc
index 64141b1..e0b0e50 100644
--- a/pc/test/fake_audio_capture_module_unittest.cc
+++ b/pc/test/fake_audio_capture_module_unittest.cc
@@ -13,11 +13,17 @@
#include <string.h>
#include <algorithm>
+#include <cstdint>
+#include "api/audio/audio_device_defines.h"
#include "api/scoped_refptr.h"
-#include "rtc_base/gunit.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
#include "rtc_base/synchronization/mutex.h"
+#include "rtc_base/thread.h"
+#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
class FakeAdmTest : public ::testing::Test, public webrtc::AudioTransport {
protected:
@@ -151,7 +157,10 @@
EXPECT_EQ(0, fake_audio_capture_module_->PlayoutDelay(&delay_ms));
EXPECT_EQ(0, delay_ms);
- EXPECT_TRUE_WAIT(pull_iterations() > 0, kMsInSecond);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return pull_iterations(); }, ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kMsInSecond)}),
+ webrtc::IsRtcOk());
EXPECT_GE(0, push_iterations());
EXPECT_EQ(0, fake_audio_capture_module_->StopPlayout());
@@ -174,7 +183,10 @@
EXPECT_EQ(0, fake_audio_capture_module_->StartRecording());
EXPECT_TRUE(fake_audio_capture_module_->Recording());
- EXPECT_TRUE_WAIT(push_iterations() > 0, kMsInSecond);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return push_iterations(); }, ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kMsInSecond)}),
+ webrtc::IsRtcOk());
EXPECT_GE(0, pull_iterations());
EXPECT_EQ(0, fake_audio_capture_module_->StopRecording());
@@ -190,8 +202,14 @@
EXPECT_EQ(0, fake_audio_capture_module_->InitRecording());
EXPECT_EQ(0, fake_audio_capture_module_->StartRecording());
- EXPECT_TRUE_WAIT(push_iterations() > 0, kMsInSecond);
- EXPECT_TRUE_WAIT(pull_iterations() > 0, kMsInSecond);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return push_iterations(); }, ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kMsInSecond)}),
+ webrtc::IsRtcOk());
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return pull_iterations(); }, ::testing::Gt(0),
+ {.timeout = webrtc::TimeDelta::Millis(kMsInSecond)}),
+ webrtc::IsRtcOk());
EXPECT_EQ(0, fake_audio_capture_module_->StopPlayout());
EXPECT_EQ(0, fake_audio_capture_module_->StopRecording());
diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h
index 948ea48..2f5aa22 100644
--- a/pc/test/integration_test_helpers.h
+++ b/pc/test/integration_test_helpers.h
@@ -47,6 +47,7 @@
#include "api/rtp_parameters.h"
#include "api/rtp_receiver_interface.h"
#include "api/rtp_sender_interface.h"
+#include "api/rtp_transceiver_direction.h"
#include "api/rtp_transceiver_interface.h"
#include "api/scoped_refptr.h"
#include "api/sequence_checker.h"
@@ -54,6 +55,7 @@
#include "api/stats/rtcstats_objects.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "api/test/mock_async_dns_resolver.h"
+#include "api/test/rtc_error_matchers.h"
#include "api/units/time_delta.h"
#include "api/video/video_rotation.h"
#include "logging/rtc_event_log/fake_rtc_event_log_factory.h"
@@ -81,7 +83,6 @@
#include "rtc_base/fake_mdns_responder.h"
#include "rtc_base/fake_network.h"
#include "rtc_base/firewall_socket_server.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/socket_address.h"
@@ -95,6 +96,7 @@
#include "system_wrappers/include/metrics.h"
#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace webrtc {
@@ -444,7 +446,7 @@
// Return the last observed data channel.
DataChannelInterface* data_channel() {
- if (data_channels_.size() == 0) {
+ if (data_channels_.empty()) {
return nullptr;
}
return data_channels_.back().get();
@@ -455,7 +457,7 @@
}
MockDataChannelObserver* data_observer() const {
- if (data_observers_.size() == 0) {
+ if (data_observers_.empty()) {
return nullptr;
}
return data_observers_.back().get();
@@ -500,7 +502,9 @@
EXPECT_TRUE(peer_connection_->GetStats(
observer.get(), nullptr,
PeerConnectionInterface::kStatsOutputLevelStandard));
- EXPECT_TRUE_WAIT(observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
return observer;
}
@@ -514,7 +518,9 @@
rtc::scoped_refptr<const RTCStatsReport> NewGetStats() {
auto callback = rtc::make_ref_counted<MockRTCStatsCollectorCallback>();
peer_connection_->GetStats(callback.get());
- EXPECT_TRUE_WAIT(callback->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return callback->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
return callback->report();
}
@@ -689,7 +695,9 @@
RTC_LOG(LS_INFO) << debug_name_ << ": SetRemoteDescription SDP:" << desc;
pc()->SetRemoteDescription(std::move(desc), observer); // desc.release());
RemoveUnusedVideoRenderers();
- EXPECT_TRUE_WAIT(observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
auto err = observer->error();
if (!err.ok()) {
RTC_LOG(LS_WARNING) << debug_name_
@@ -849,7 +857,9 @@
std::unique_ptr<SessionDescriptionInterface> WaitForDescriptionFromObserver(
MockCreateSessionDescriptionObserver* observer) {
- EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
if (!observer->result()) {
return nullptr;
}
@@ -878,7 +888,9 @@
// As mentioned above, we need to send the message immediately after
// SetLocalDescription.
SendSdpMessage(type, sdp);
- EXPECT_TRUE_WAIT(observer->called(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()),
+ IsRtcOk());
return true;
}
@@ -980,7 +992,9 @@
pc()->AddIceCandidate(absl::WrapUnique(CreateIceCandidate(
sdp_mid, sdp_mline_index, msg, nullptr)),
[&result](RTCError r) { result = r; });
- EXPECT_TRUE_WAIT(result.has_value(), kDefaultTimeout);
+ EXPECT_THAT(
+ WaitUntil([&] { return result.has_value(); }, ::testing::IsTrue()),
+ IsRtcOk());
EXPECT_TRUE(result.value().ok());
}
@@ -1744,15 +1758,21 @@
}
// Wait for the expected frames.
- EXPECT_TRUE_WAIT(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,
- kMaxWaitForFramesMs);
+ 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());
bool expectations_correct =
caller()->audio_frames_received() >=
total_caller_audio_frames_expected &&
@@ -1831,9 +1851,13 @@
caller()->AddAudioVideoTracks();
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
- ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
- EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(expected_cipher_suite),
- caller()->OldGetStats()->SrtpCipher(), kDefaultTimeout);
+ ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()),
+ IsRtcOk());
+ EXPECT_THAT(
+ WaitUntil(
+ [&] { return caller()->OldGetStats()->SrtpCipher(); },
+ ::testing::Eq(rtc::SrtpCryptoSuiteToName(expected_cipher_suite))),
+ IsRtcOk());
}
void TestGcmNegotiationUsesCipherSuite(bool local_gcm_enabled,
diff --git a/pc/test/peer_connection_test_wrapper.cc b/pc/test/peer_connection_test_wrapper.cc
index aa190b9..1774f1b 100644
--- a/pc/test/peer_connection_test_wrapper.cc
+++ b/pc/test/peer_connection_test_wrapper.cc
@@ -20,19 +20,33 @@
#include "absl/strings/match.h"
#include "api/audio/audio_device.h"
-#include "api/audio/audio_mixer.h"
-#include "api/audio/audio_processing.h"
+#include "api/audio_codecs/audio_decoder_factory.h"
+#include "api/audio_codecs/audio_encoder_factory.h"
+#include "api/audio_options.h"
#include "api/create_peerconnection_factory.h"
+#include "api/data_channel_interface.h"
#include "api/environment/environment.h"
#include "api/field_trials_view.h"
+#include "api/jsep.h"
+#include "api/make_ref_counted.h"
+#include "api/media_stream_interface.h"
#include "api/media_types.h"
+#include "api/peer_connection_interface.h"
+#include "api/rtc_error.h"
+#include "api/rtp_parameters.h"
+#include "api/rtp_receiver_interface.h"
+#include "api/scoped_refptr.h"
#include "api/sequence_checker.h"
-#include "api/video_codecs/video_decoder_factory.h"
+#include "api/test/rtc_error_matchers.h"
+#include "api/units/time_delta.h"
+#include "api/video/resolution.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"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_open_h264_adapter.h"
+#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "api/video_codecs/video_encoder_factory_template.h"
#include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h"
@@ -40,17 +54,23 @@
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
#include "media/engine/simulcast_encoder_adapter.h"
+#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/base/fake_port_allocator.h"
#include "p2p/base/port_allocator.h"
+#include "pc/test/fake_audio_capture_module.h"
#include "pc/test/fake_periodic_video_source.h"
+#include "pc/test/fake_periodic_video_track_source.h"
#include "pc/test/fake_rtc_certificate_generator.h"
+#include "pc/test/fake_video_track_renderer.h"
#include "pc/test/mock_peer_connection_observers.h"
-#include "rtc_base/gunit.h"
#include "rtc_base/logging.h"
#include "rtc_base/rtc_certificate_generator.h"
+#include "rtc_base/socket_server.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/time_utils.h"
+#include "test/gmock.h"
#include "test/gtest.h"
+#include "test/wait_until.h"
namespace {
@@ -226,7 +246,10 @@
}
void PeerConnectionTestWrapper::WaitForNegotiation() {
- EXPECT_TRUE_WAIT(!pending_negotiation_, kMaxWait);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return !pending_negotiation_; }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
}
void PeerConnectionTestWrapper::OnSignalingChange(
@@ -340,7 +363,10 @@
}
bool PeerConnectionTestWrapper::WaitForConnection() {
- EXPECT_TRUE_WAIT(CheckForConnection(), kMaxWait);
+ EXPECT_THAT(webrtc::WaitUntil(
+ [&] { return CheckForConnection(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
if (testing::Test::HasFailure()) {
return false;
}
@@ -356,7 +382,10 @@
}
bool PeerConnectionTestWrapper::WaitForAudio() {
- EXPECT_TRUE_WAIT(CheckForAudio(), kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return CheckForAudio(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
if (testing::Test::HasFailure()) {
return false;
}
@@ -371,7 +400,10 @@
}
bool PeerConnectionTestWrapper::WaitForVideo() {
- EXPECT_TRUE_WAIT(CheckForVideo(), kMaxWait);
+ EXPECT_THAT(
+ webrtc::WaitUntil([&] { return CheckForVideo(); }, ::testing::IsTrue(),
+ {.timeout = webrtc::TimeDelta::Millis(kMaxWait)}),
+ webrtc::IsRtcOk());
if (testing::Test::HasFailure()) {
return false;
}