From 656efbee6f2721b9bab32f7d4bfc4675be645fbd Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Tue, 7 Jul 2020 13:35:28 +0200 Subject: [PATCH] Fix thread usage in PC level tests for getting to the IceConnected state Bug: webrtc:11743 Change-Id: I18a6318c35b350b3d729bbd5ac1d25f035e6ad9d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178809 Reviewed-by: Tommi Reviewed-by: Andrey Logvin Commit-Queue: Tommi Cr-Commit-Position: refs/heads/master@{#31658} --- api/test/time_controller.h | 2 ++ test/pc/e2e/peer_connection_quality_test.cc | 17 ++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/api/test/time_controller.h b/api/test/time_controller.h index 419bd203a3..bd3192ddf2 100644 --- a/api/test/time_controller.h +++ b/api/test/time_controller.h @@ -60,6 +60,8 @@ class TimeController { // Waits until condition() == true, polling condition() in small time // intervals. + // Returns true if condition() was evaluated to true before |max_duration| + // elapsed and false otherwise. bool Wait(const std::function& condition, TimeDelta max_duration = TimeDelta::Seconds(5)); }; diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index 60eaa1e8b4..2027b3b26d 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -578,15 +578,18 @@ void PeerConnectionE2EQualityTest::WaitUntilIceCandidatesGathered( void PeerConnectionE2EQualityTest::WaitUntilPeersAreConnected( rtc::Thread* signaling_thread) { // This means that ICE and DTLS are connected. - time_controller_.Wait( + alice_connected_ = time_controller_.Wait( [&]() { - return signaling_thread->Invoke(RTC_FROM_HERE, [&]() { - return alice_->IsIceConnected() && bob_->IsIceConnected(); - }); + return signaling_thread->Invoke( + RTC_FROM_HERE, [&]() { return alice_->IsIceConnected(); }); }, - 2 * kDefaultTimeout); - alice_connected_ = alice_->IsIceConnected(); - bob_connected_ = bob_->IsIceConnected(); + kDefaultTimeout); + bob_connected_ = time_controller_.Wait( + [&]() { + return signaling_thread->Invoke( + RTC_FROM_HERE, [&]() { return bob_->IsIceConnected(); }); + }, + kDefaultTimeout); } void PeerConnectionE2EQualityTest::ExchangeOfferAnswer(