commit 22e5e0a639b7bb36bb2a450d86e115e25b0c3744
parent 649a32d11467b99171e93f16bb0882da437adf4c
Author: Dan Baker <dbaker@mozilla.com>
Date: Thu, 23 Oct 2025 16:51:00 -0600
Bug 1995393 - Vendor libwebrtc from 9f8cbef761
Upstream commit: https://webrtc.googlesource.com/src/+/9f8cbef7614296cf537e393c44c4d56f9f834a48
Use injected clock in p2p_transport_channel_unittest
Stops using the global clock methods from time_utils.
This CL was uploaded by an experimental version of git cl split
(https://crbug.com/389069356).
R=danilchap@webrtc.org, hta@webrtc.org
Bug: webrtc:42223992
Change-Id: I1953e1bb5d17be23c169a712b65b5e3480546755
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/404962
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45365}
Diffstat:
2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor
@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-23T22:47:13.640748+00:00.
+libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-23T22:50:47.856457+00:00.
# base of lastest vendoring
-21209d505a
+9f8cbef761
diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc
@@ -696,7 +696,7 @@ class P2PTransportChannelTestBase : public ::testing::Test,
void Test(const Environment& env, const Result& expected) {
ScopedFakeClock clock;
- int64_t connect_start = TimeMillis();
+ int64_t connect_start = env.clock().TimeInMilliseconds();
int64_t connect_time;
// Create the channels and wait for them to connect.
@@ -704,7 +704,7 @@ class P2PTransportChannelTestBase : public ::testing::Test,
EXPECT_TRUE(WaitUntil(
[&] { return CheckConnected(ep1_ch1(), ep2_ch1()); },
{.timeout = expected.connect_wait + kShortTimeout, .clock = &clock}));
- connect_time = TimeMillis() - connect_start;
+ connect_time = env.clock().TimeInMilliseconds() - connect_start;
if (connect_time < expected.connect_wait.ms()) {
RTC_LOG(LS_INFO) << "Connect time: " << connect_time << " ms";
} else {
@@ -715,7 +715,7 @@ class P2PTransportChannelTestBase : public ::testing::Test,
// Allow a few turns of the crank for the selected connections to emerge.
// This may take up to 2 seconds.
if (ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection()) {
- int64_t converge_start = TimeMillis();
+ int64_t converge_start = env.clock().TimeInMilliseconds();
int64_t converge_time;
// Verifying local and remote channel selected connection information.
// This is done only for the RFC 5245 as controlled agent will use
@@ -730,7 +730,7 @@ class P2PTransportChannelTestBase : public ::testing::Test,
ExpectCandidate1(expected);
ExpectCandidate2(expected);
- converge_time = TimeMillis() - converge_start;
+ converge_time = env.clock().TimeInMilliseconds() - converge_start;
int64_t converge_wait = 2000;
if (converge_time < converge_wait) {
RTC_LOG(LS_INFO) << "Converge time: " << converge_time << " ms";
@@ -4198,8 +4198,8 @@ TEST_F(P2PTransportChannelPingTest, TestReceivingStateChange) {
clock.AdvanceTime(TimeDelta::Seconds(1));
conn1->ReceivedPing();
- conn1->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("ABC", 3, TimeMicros()));
+ conn1->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "ABC", 3, env.clock().TimeInMicroseconds()));
EXPECT_TRUE(WaitUntil([&] { return ch.receiving(); },
{.timeout = kShortTimeout, .clock = &clock}));
@@ -4540,8 +4540,8 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
ASSERT_TRUE(conn2 != nullptr);
conn2->ReceivedPingResponse(LOW_RTT, "id"); // Become writable and receiving.
- conn2->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("ABC", 3, TimeMicros()));
+ conn2->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "ABC", 3, env.clock().TimeInMicroseconds()));
EXPECT_EQ(conn2, ch.selected_connection());
conn2->ReceivedPingResponse(LOW_RTT, "id"); // Become writable.
@@ -4570,8 +4570,8 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
// selected connection was nominated by the controlling side.
conn2->ReceivedPing();
conn2->ReceivedPingResponse(LOW_RTT, "id");
- conn2->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("XYZ", 3, TimeMicros()));
+ conn2->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "XYZ", 3, env.clock().TimeInMicroseconds()));
EXPECT_THAT(WaitUntil([&] { return ch.selected_connection(); }, Eq(conn3),
{.timeout = kDefaultTimeout}),
IsRtcOk());
@@ -4605,14 +4605,14 @@ TEST_F(P2PTransportChannelPingTest,
// conn2 is larger.
SIMULATED_WAIT(false, 1, clock);
- conn2->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("XYZ", 3, TimeMicros()));
+ conn2->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "XYZ", 3, env.clock().TimeInMicroseconds()));
EXPECT_EQ(1, reset_selected_candidate_pair_switches());
EXPECT_TRUE(CandidatePairMatchesNetworkRoute(conn2));
// conn1 also receives data; it becomes selected due to priority again.
- conn1->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("ABC", 3, TimeMicros()));
+ conn1->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "ABC", 3, env.clock().TimeInMicroseconds()));
EXPECT_EQ(1, reset_selected_candidate_pair_switches());
EXPECT_TRUE(CandidatePairMatchesNetworkRoute(conn2));
@@ -4621,8 +4621,8 @@ TEST_F(P2PTransportChannelPingTest,
SIMULATED_WAIT(false, 1, clock);
// Need to become writable again because it was pruned.
conn2->ReceivedPingResponse(LOW_RTT, "id");
- conn2->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("ABC", 3, TimeMicros()));
+ conn2->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "ABC", 3, env.clock().TimeInMicroseconds()));
EXPECT_EQ(1, reset_selected_candidate_pair_switches());
EXPECT_TRUE(CandidatePairMatchesNetworkRoute(conn2));
@@ -4655,8 +4655,8 @@ TEST_F(P2PTransportChannelPingTest,
// Advance the clock to have a non-zero last-data-receiving time.
SIMULATED_WAIT(false, 1, clock);
- conn1->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("XYZ", 3, TimeMicros()));
+ conn1->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "XYZ", 3, env.clock().TimeInMicroseconds()));
EXPECT_EQ(1, reset_selected_candidate_pair_switches());
EXPECT_TRUE(CandidatePairMatchesNetworkRoute(conn1));
@@ -4758,8 +4758,8 @@ TEST_F(P2PTransportChannelPingTest, TestEstimatedDisconnectedTime) {
{
clock.AdvanceTime(TimeDelta::Seconds(1));
// This will not parse as STUN, and is considered data
- conn1->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("XYZ", 3, TimeMicros()));
+ conn1->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "XYZ", 3, env.clock().TimeInMicroseconds()));
clock.AdvanceTime(TimeDelta::Seconds(2));
// conn2 is nominated; it becomes selected.
@@ -4771,8 +4771,8 @@ TEST_F(P2PTransportChannelPingTest, TestEstimatedDisconnectedTime) {
{
clock.AdvanceTime(TimeDelta::Seconds(1));
- conn2->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("XYZ", 3, TimeMicros()));
+ conn2->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "XYZ", 3, env.clock().TimeInMicroseconds()));
clock.AdvanceTime(TimeDelta::Seconds(2));
ReceivePingOnConnection(conn2, kIceUfrag[1], 1, nomination++);
@@ -4957,8 +4957,8 @@ TEST_F(P2PTransportChannelPingTest, TestDontPruneHighPriorityConnections) {
// conn2.
NominateConnection(conn1);
SIMULATED_WAIT(false, 1, clock);
- conn1->OnReadPacket(
- ReceivedIpPacket::CreateFromLegacy("XYZ", 3, TimeMicros()));
+ conn1->OnReadPacket(ReceivedIpPacket::CreateFromLegacy(
+ "XYZ", 3, env.clock().TimeInMicroseconds()));
SIMULATED_WAIT(conn2->pruned(), 100, clock);
EXPECT_FALSE(conn2->pruned());
}