From 0793ee7552c544ab4864fa1f75fc8a76e144f1e8 Mon Sep 17 00:00:00 2001 From: Sameer Vijaykar Date: Mon, 23 Jan 2023 16:31:29 +0100 Subject: [PATCH] Remove FakePortAllocator's dependency on ScopedKeyValueConfig. Breaking this dependency is required for using FakePortAllocator in chromium tests to make the windows component build work. Bug: chromium:1408420 Change-Id: I4215b92c1d1430156107605e5b054926b30f83f0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291114 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Sameer Vijaykar Cr-Commit-Position: refs/heads/main@{#39180} --- p2p/BUILD.gn | 1 - p2p/base/fake_port_allocator.h | 28 ++-- p2p/base/p2p_transport_channel_unittest.cc | 131 ++++++++++++------ p2p/base/port_allocator_unittest.cc | 5 +- p2p/base/regathering_controller_unittest.cc | 5 +- pc/ice_transport_unittest.cc | 6 +- pc/peer_connection_crypto_unittest.cc | 5 +- pc/peer_connection_factory_unittest.cc | 4 +- ...er_connection_header_extension_unittest.cc | 5 +- pc/peer_connection_ice_unittest.cc | 5 +- pc/peer_connection_interface_unittest.cc | 12 +- pc/peer_connection_media_unittest.cc | 5 +- pc/test/peer_connection_test_wrapper.cc | 3 +- pc/test/peer_connection_test_wrapper.h | 2 + 14 files changed, 145 insertions(+), 72 deletions(-) diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index b152fc6c47..105536b7c0 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -205,7 +205,6 @@ if (rtc_include_tests) { "../rtc_base:task_queue_for_test", "../rtc_base:threading", "../rtc_base/memory:always_valid_pointer", - "../test:scoped_key_value_config", ] absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } diff --git a/p2p/base/fake_port_allocator.h b/p2p/base/fake_port_allocator.h index 48f1efb199..05c631361f 100644 --- a/p2p/base/fake_port_allocator.h +++ b/p2p/base/fake_port_allocator.h @@ -24,7 +24,6 @@ #include "rtc_base/net_helpers.h" #include "rtc_base/task_queue_for_test.h" #include "rtc_base/thread.h" -#include "test/scoped_key_value_config.h" namespace rtc { class SocketFactory; @@ -86,7 +85,7 @@ class FakePortAllocatorSession : public PortAllocatorSession { int component, absl::string_view ice_ufrag, absl::string_view ice_pwd, - const webrtc::FieldTrialsView& field_trials) + const webrtc::FieldTrialsView* field_trials) : PortAllocatorSession(content_name, component, ice_ufrag, @@ -124,7 +123,7 @@ class FakePortAllocatorSession : public PortAllocatorSession { : ipv4_network_; port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, 0, 0, username(), password(), false, - &field_trials_)); + field_trials_)); RTC_DCHECK(port_); port_->SetIceTiebreaker(ice_tiebreaker()); port_->SubscribePortDestroyed( @@ -213,18 +212,23 @@ class FakePortAllocatorSession : public PortAllocatorSession { uint32_t candidate_filter_ = CF_ALL; int transport_info_update_count_ = 0; bool running_ = false; - const webrtc::FieldTrialsView& field_trials_; + const webrtc::FieldTrialsView* field_trials_; }; class FakePortAllocator : public cricket::PortAllocator { public: FakePortAllocator(rtc::Thread* network_thread, - rtc::PacketSocketFactory* factory) - : FakePortAllocator(network_thread, factory, nullptr) {} + rtc::PacketSocketFactory* factory, + webrtc::FieldTrialsView* field_trials) + : FakePortAllocator(network_thread, factory, nullptr, field_trials) {} FakePortAllocator(rtc::Thread* network_thread, - std::unique_ptr factory) - : FakePortAllocator(network_thread, nullptr, std::move(factory)) {} + std::unique_ptr factory, + webrtc::FieldTrialsView* field_trials) + : FakePortAllocator(network_thread, + nullptr, + std::move(factory), + field_trials) {} void SetNetworkIgnoreMask(int network_ignore_mask) override {} @@ -251,9 +255,11 @@ class FakePortAllocator : public cricket::PortAllocator { private: FakePortAllocator(rtc::Thread* network_thread, rtc::PacketSocketFactory* factory, - std::unique_ptr owned_factory) + std::unique_ptr owned_factory, + webrtc::FieldTrialsView* field_trials) : network_thread_(network_thread), - factory_(std::move(owned_factory), factory) { + factory_(std::move(owned_factory), factory), + field_trials_(field_trials) { if (network_thread_ == nullptr) { network_thread_ = rtc::Thread::Current(); Initialize(); @@ -262,9 +268,9 @@ class FakePortAllocator : public cricket::PortAllocator { SendTask(network_thread_, [this] { Initialize(); }); } - webrtc::test::ScopedKeyValueConfig field_trials_; rtc::Thread* network_thread_; const webrtc::AlwaysValidPointerNoDefault factory_; + const webrtc::FieldTrialsView* field_trials_; bool mdns_obfuscation_enabled_ = false; }; diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index c1df1d7520..4d73f013fb 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -3701,7 +3701,8 @@ INSTANTIATE_TEST_SUITE_P(Active, Values("WebRTC-UseActiveIceController/Enabled/")); TEST_P(P2PTransportChannelPingTest, TestTriggeredChecks) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("trigger checks", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -3725,7 +3726,8 @@ TEST_P(P2PTransportChannelPingTest, TestTriggeredChecks) { } TEST_P(P2PTransportChannelPingTest, TestAllConnectionsPingedSufficiently) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("ping sufficiently", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -3753,7 +3755,8 @@ TEST_P(P2PTransportChannelPingTest, TestStunPingIntervals) { int SCHEDULING_RANGE = 200; int RTT_RANGE = 10; - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("TestChannel", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -3844,7 +3847,8 @@ TEST_P(P2PTransportChannelPingTest, TestStunPingIntervals) { TEST_P(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { rtc::ScopedFakeClock clock; - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("TestChannel", 1, &pa, &field_trials_); ch.SetIceRole(ICEROLE_CONTROLLING); ch.SetIceTiebreaker(kTiebreakerDefault); @@ -3881,7 +3885,8 @@ TEST_P(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { } TEST_P(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("trigger checks", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -3906,7 +3911,8 @@ TEST_P(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) { } TEST_P(P2PTransportChannelPingTest, TestFailedConnectionNotPingable) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("Do not ping failed connections", 1, &pa, &field_trials_); PrepareChannel(&ch); @@ -3924,7 +3930,8 @@ TEST_P(P2PTransportChannelPingTest, TestFailedConnectionNotPingable) { } TEST_P(P2PTransportChannelPingTest, TestSignalStateChanged) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("state change", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -3945,7 +3952,8 @@ TEST_P(P2PTransportChannelPingTest, TestSignalStateChanged) { // parameters arrive. If a remote candidate is added with the current ICE // ufrag, its pwd and generation will be set properly. TEST_P(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("add candidate", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -3997,7 +4005,8 @@ TEST_P(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { } TEST_P(P2PTransportChannelPingTest, ConnectionResurrection) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("connection resurrection", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -4050,7 +4059,8 @@ TEST_P(P2PTransportChannelPingTest, ConnectionResurrection) { TEST_P(P2PTransportChannelPingTest, TestReceivingStateChange) { rtc::ScopedFakeClock clock; - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials_); PrepareChannel(&ch); // Default receiving timeout and checking receiving interval should not be too @@ -4079,7 +4089,8 @@ TEST_P(P2PTransportChannelPingTest, TestReceivingStateChange) { // selected connection changes and SignalReadyToSend will be fired if the new // selected connection is writable. TEST_P(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4169,7 +4180,8 @@ TEST_P(P2PTransportChannelPingTest, TestPingOnNomination) { webrtc::test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-IceFieldTrials/send_ping_on_nomination_ice_controlled:true/"); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); @@ -4210,7 +4222,8 @@ TEST_P(P2PTransportChannelPingTest, TestPingOnSwitch) { webrtc::test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-IceFieldTrials/send_ping_on_switch_ice_controlling:true/"); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); @@ -4248,7 +4261,8 @@ TEST_P(P2PTransportChannelPingTest, TestPingOnSelected) { webrtc::test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-IceFieldTrials/send_ping_on_selected_ice_controlling:true/"); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); @@ -4276,7 +4290,8 @@ TEST_P(P2PTransportChannelPingTest, TestPingOnSelected) { // also sends back a ping response and set the ICE pwd in the remote candidate // appropriately. TEST_P(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4353,7 +4368,8 @@ TEST_P(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) { // at which point the controlled side will select that connection as // the "selected connection". TEST_P(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4406,7 +4422,8 @@ TEST_P(P2PTransportChannelPingTest, TestControlledAgentDataReceivingTakesHigherPrecedenceThanPriority) { rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4455,7 +4472,8 @@ TEST_P(P2PTransportChannelPingTest, rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4495,7 +4513,8 @@ TEST_P(P2PTransportChannelPingTest, rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4541,7 +4560,8 @@ TEST_P(P2PTransportChannelPingTest, TestEstimatedDisconnectedTime) { rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4600,7 +4620,8 @@ TEST_P(P2PTransportChannelPingTest, rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4618,7 +4639,8 @@ TEST_P(P2PTransportChannelPingTest, TestControlledAgentWriteStateTakesHigherPrecedenceThanNomination) { rtc::ScopedFakeClock clock; - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4659,7 +4681,8 @@ TEST_P(P2PTransportChannelPingTest, // Test that if a new remote candidate has the same address and port with // an old one, it will be used to create a new connection. TEST_P(P2PTransportChannelPingTest, TestAddRemoteCandidateWithAddressReuse) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("candidate reuse", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -4699,7 +4722,8 @@ TEST_P(P2PTransportChannelPingTest, TestAddRemoteCandidateWithAddressReuse) { TEST_P(P2PTransportChannelPingTest, TestDontPruneWhenWeak) { rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4735,7 +4759,8 @@ TEST_P(P2PTransportChannelPingTest, TestDontPruneWhenWeak) { TEST_P(P2PTransportChannelPingTest, TestDontPruneHighPriorityConnections) { rtc::ScopedFakeClock clock; - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4759,7 +4784,8 @@ TEST_P(P2PTransportChannelPingTest, TestDontPruneHighPriorityConnections) { TEST_P(P2PTransportChannelPingTest, TestGetState) { rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials_); EXPECT_EQ(webrtc::IceTransportState::kNew, ch.GetIceTransportState()); PrepareChannel(&ch); @@ -4800,7 +4826,8 @@ TEST_P(P2PTransportChannelPingTest, TestConnectionPrunedAgain) { rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials_); PrepareChannel(&ch); IceConfig config = CreateIceConfig(1000, GATHER_ONCE); @@ -4850,7 +4877,8 @@ TEST_P(P2PTransportChannelPingTest, TestConnectionPrunedAgain) { // will all be deleted. We use Prune to simulate write_time_out. TEST_P(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) { rtc::ScopedFakeClock clock; - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -4882,7 +4910,8 @@ TEST_P(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) { // connection belonging to an old session becomes writable, it won't stop // the current port allocator session. TEST_P(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials_); PrepareChannel(&ch); ch.SetIceConfig(CreateIceConfig(2000, GATHER_ONCE)); @@ -4915,7 +4944,8 @@ TEST_P(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) { // These ports may still have connections that need a correct role, in case that // the connections on it may still receive stun pings. TEST_P(P2PTransportChannelPingTest, TestIceRoleUpdatedOnRemovedPort) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa, &field_trials_); // Starts with ICEROLE_CONTROLLING. @@ -4941,7 +4971,8 @@ TEST_P(P2PTransportChannelPingTest, TestIceRoleUpdatedOnRemovedPort) { // pings sent by those connections until they're replaced by newer-generation // connections. TEST_P(P2PTransportChannelPingTest, TestIceRoleUpdatedOnPortAfterIceRestart) { - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa, &field_trials_); // Starts with ICEROLE_CONTROLLING. @@ -4966,7 +4997,8 @@ TEST_P(P2PTransportChannelPingTest, TestIceRoleUpdatedOnPortAfterIceRestart) { TEST_P(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) { rtc::ScopedFakeClock fake_clock; - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa, &field_trials_); PrepareChannel(&ch); @@ -4996,7 +5028,8 @@ TEST_P(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) { TEST_P(P2PTransportChannelPingTest, TestMaxOutstandingPingsFieldTrial) { webrtc::test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-IceFieldTrials/max_outstanding_pings:3/"); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("max", 1, &pa, &field_trials); ch.SetIceConfig(ch.config()); PrepareChannel(&ch); @@ -5272,13 +5305,14 @@ INSTANTIATE_TEST_SUITE_P(Active, // when the address is a hostname. The destruction should happen even // if the channel is not destroyed. TEST_P(P2PTransportChannelResolverTest, HostnameCandidateIsResolved) { + webrtc::test::ScopedKeyValueConfig field_trials(GetParam()); ResolverFactoryFixture resolver_fixture; std::unique_ptr socket_server = rtc::CreateDefaultSocketServer(); rtc::AutoSocketServerThread main_thread(socket_server.get()); rtc::BasicPacketSocketFactory packet_socket_factory(socket_server.get()); - FakePortAllocator allocator(rtc::Thread::Current(), &packet_socket_factory); - webrtc::test::ScopedKeyValueConfig field_trials(GetParam()); + FakePortAllocator allocator(rtc::Thread::Current(), &packet_socket_factory, + &field_trials); webrtc::IceTransportInit init; init.set_port_allocator(&allocator); init.set_async_dns_resolver_factory(&resolver_fixture); @@ -6111,7 +6145,8 @@ TEST_P(P2PTransportChannelPingTest, TestInitialSelectDampening0) { rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); @@ -6135,7 +6170,8 @@ TEST_P(P2PTransportChannelPingTest, TestInitialSelectDampening) { rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); @@ -6160,7 +6196,8 @@ TEST_P(P2PTransportChannelPingTest, TestInitialSelectDampeningPingReceived) { rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); @@ -6188,7 +6225,8 @@ TEST_P(P2PTransportChannelPingTest, TestInitialSelectDampeningBoth) { rtc::ScopedFakeClock clock; clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); P2PTransportChannel ch("test channel", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); @@ -6217,13 +6255,14 @@ INSTANTIATE_TEST_SUITE_P(Active, Values("WebRTC-UseActiveIceController/Enabled/")); TEST_P(P2PTransportChannelIceControllerTest, InjectIceController) { + webrtc::test::ScopedKeyValueConfig field_trials(GetParam()); std::unique_ptr socket_server = rtc::CreateDefaultSocketServer(); rtc::AutoSocketServerThread main_thread(socket_server.get()); rtc::BasicPacketSocketFactory packet_socket_factory(socket_server.get()); MockIceControllerFactory factory; - FakePortAllocator pa(rtc::Thread::Current(), &packet_socket_factory); - webrtc::test::ScopedKeyValueConfig field_trials(GetParam()); + FakePortAllocator pa(rtc::Thread::Current(), &packet_socket_factory, + &field_trials); EXPECT_CALL(factory, RecordIceControllerCreated()).Times(1); webrtc::IceTransportInit init; init.set_port_allocator(&pa); @@ -6235,14 +6274,15 @@ TEST_P(P2PTransportChannelIceControllerTest, InjectIceController) { } TEST(P2PTransportChannel, InjectActiveIceController) { + webrtc::test::ScopedKeyValueConfig field_trials( + "WebRTC-UseActiveIceController/Enabled/"); std::unique_ptr socket_server = rtc::CreateDefaultSocketServer(); rtc::AutoSocketServerThread main_thread(socket_server.get()); rtc::BasicPacketSocketFactory packet_socket_factory(socket_server.get()); MockActiveIceControllerFactory factory; - FakePortAllocator pa(rtc::Thread::Current(), &packet_socket_factory); - webrtc::test::ScopedKeyValueConfig field_trials( - "WebRTC-UseActiveIceController/Enabled/"); + FakePortAllocator pa(rtc::Thread::Current(), &packet_socket_factory, + &field_trials); EXPECT_CALL(factory, RecordActiveIceControllerCreated()).Times(1); webrtc::IceTransportInit init; init.set_port_allocator(&pa); @@ -6296,7 +6336,8 @@ class ForgetLearnedStateControllerFactory TEST_P(P2PTransportChannelPingTest, TestForgetLearnedState) { ForgetLearnedStateControllerFactory factory; - FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory()); + FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory(), + &field_trials_); webrtc::IceTransportInit init; init.set_port_allocator(&pa); init.set_ice_controller_factory(&factory); diff --git a/p2p/base/port_allocator_unittest.cc b/p2p/base/port_allocator_unittest.cc index 839df4338b..f70997179e 100644 --- a/p2p/base/port_allocator_unittest.cc +++ b/p2p/base/port_allocator_unittest.cc @@ -17,6 +17,7 @@ #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" static const char kContentName[] = "test content"; // Based on ICE_UFRAG_LENGTH @@ -36,7 +37,8 @@ class PortAllocatorTest : public ::testing::Test, public sigslot::has_slots<> { std::make_unique(vss_.get())), allocator_(std::make_unique( rtc::Thread::Current(), - packet_socket_factory_.get())) { + packet_socket_factory_.get(), + &field_trials_)) { allocator_->SetIceTiebreaker(kTiebreakerDefault); } @@ -85,6 +87,7 @@ class PortAllocatorTest : public ::testing::Test, public sigslot::has_slots<> { return count; } + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr vss_; rtc::AutoSocketServerThread main_; std::unique_ptr packet_socket_factory_; diff --git a/p2p/base/regathering_controller_unittest.cc b/p2p/base/regathering_controller_unittest.cc index e795fee914..91b7270f77 100644 --- a/p2p/base/regathering_controller_unittest.cc +++ b/p2p/base/regathering_controller_unittest.cc @@ -25,6 +25,7 @@ #include "rtc_base/socket_address.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" +#include "test/scoped_key_value_config.h" namespace { @@ -56,7 +57,8 @@ class RegatheringControllerTest : public ::testing::Test, std::make_unique(vss_.get())), allocator_(std::make_unique( rtc::Thread::Current(), - packet_socket_factory_.get())) { + packet_socket_factory_.get(), + &field_trials_)) { allocator_->SetIceTiebreaker(kTiebreakerDefault); BasicRegatheringController::Config regathering_config; regathering_config.regather_on_failed_networks_interval = 0; @@ -109,6 +111,7 @@ class RegatheringControllerTest : public ::testing::Test, } private: + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr vss_; rtc::AutoSocketServerThread thread_; std::unique_ptr ice_transport_; diff --git a/pc/ice_transport_unittest.cc b/pc/ice_transport_unittest.cc index 0b1be27594..aaf9f2e57a 100644 --- a/pc/ice_transport_unittest.cc +++ b/pc/ice_transport_unittest.cc @@ -20,6 +20,7 @@ #include "p2p/base/fake_port_allocator.h" #include "rtc_base/internal/default_socket_server.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -31,6 +32,8 @@ class IceTransportTest : public ::testing::Test { rtc::SocketServer* socket_server() const { return socket_server_.get(); } + webrtc::test::ScopedKeyValueConfig field_trials_; + private: std::unique_ptr socket_server_; rtc::AutoSocketServerThread main_thread_; @@ -50,7 +53,8 @@ TEST_F(IceTransportTest, CreateSelfDeletingTransport) { std::unique_ptr port_allocator( std::make_unique( nullptr, - std::make_unique(socket_server()))); + std::make_unique(socket_server()), + &field_trials_)); IceTransportInit init; init.set_port_allocator(port_allocator.get()); auto ice_transport = CreateIceTransport(std::move(init)); diff --git a/pc/peer_connection_crypto_unittest.cc b/pc/peer_connection_crypto_unittest.cc index 059700c51c..fae74681fc 100644 --- a/pc/peer_connection_crypto_unittest.cc +++ b/pc/peer_connection_crypto_unittest.cc @@ -48,6 +48,7 @@ #include "rtc_base/ssl_fingerprint.h" #include "rtc_base/thread.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" #endif @@ -97,7 +98,8 @@ class PeerConnectionCryptoBaseTest : public ::testing::Test { std::unique_ptr cert_gen) { auto fake_port_allocator = std::make_unique( rtc::Thread::Current(), - std::make_unique(vss_.get())); + std::make_unique(vss_.get()), + &field_trials_); auto observer = std::make_unique(); RTCConfiguration modified_config = config; modified_config.sdp_semantics = sdp_semantics_; @@ -147,6 +149,7 @@ class PeerConnectionCryptoBaseTest : public ::testing::Test { return transport_info->description.connection_role; } + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr vss_; rtc::AutoSocketServerThread main_; rtc::scoped_refptr pc_factory_; diff --git a/pc/peer_connection_factory_unittest.cc b/pc/peer_connection_factory_unittest.cc index 2251990963..6aa7f49079 100644 --- a/pc/peer_connection_factory_unittest.cc +++ b/pc/peer_connection_factory_unittest.cc @@ -40,6 +40,7 @@ #include "rtc_base/time_utils.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" @@ -149,7 +150,7 @@ class PeerConnectionFactoryTest : public ::testing::Test { packet_socket_factory_.reset( new rtc::BasicPacketSocketFactory(socket_server_.get())); port_allocator_.reset(new cricket::FakePortAllocator( - rtc::Thread::Current(), packet_socket_factory_.get())); + rtc::Thread::Current(), packet_socket_factory_.get(), &field_trials_)); raw_port_allocator_ = port_allocator_.get(); } @@ -244,6 +245,7 @@ class PeerConnectionFactoryTest : public ::testing::Test { } } + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr socket_server_; rtc::AutoSocketServerThread main_thread_; rtc::scoped_refptr factory_; diff --git a/pc/peer_connection_header_extension_unittest.cc b/pc/peer_connection_header_extension_unittest.cc index e45a7b2656..1a452b0a1f 100644 --- a/pc/peer_connection_header_extension_unittest.cc +++ b/pc/peer_connection_header_extension_unittest.cc @@ -42,6 +42,7 @@ #include "rtc_base/thread.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -100,7 +101,8 @@ class PeerConnectionHeaderExtensionTest auto fake_port_allocator = std::make_unique( rtc::Thread::Current(), - std::make_unique(socket_server_.get())); + std::make_unique(socket_server_.get()), + &field_trials_); auto observer = std::make_unique(); PeerConnectionInterface::RTCConfiguration config; if (semantics) @@ -115,6 +117,7 @@ class PeerConnectionHeaderExtensionTest pc_factory, result.MoveValue(), std::move(observer)); } + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr socket_server_; rtc::AutoSocketServerThread main_thread_; std::vector extensions_; diff --git a/pc/peer_connection_ice_unittest.cc b/pc/peer_connection_ice_unittest.cc index b0d56fcb97..fc0448bcef 100644 --- a/pc/peer_connection_ice_unittest.cc +++ b/pc/peer_connection_ice_unittest.cc @@ -54,6 +54,7 @@ #include "rtc_base/socket_address.h" #include "rtc_base/thread.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" #endif @@ -1425,7 +1426,8 @@ class PeerConnectionIceConfigTest : public ::testing::Test { new rtc::BasicPacketSocketFactory(socket_server_.get())); std::unique_ptr port_allocator( new cricket::FakePortAllocator(rtc::Thread::Current(), - packet_socket_factory_.get())); + packet_socket_factory_.get(), + &field_trials_)); port_allocator_ = port_allocator.get(); port_allocator_->SetIceTiebreaker(kTiebreakerDefault); PeerConnectionDependencies pc_dependencies(&observer_); @@ -1436,6 +1438,7 @@ class PeerConnectionIceConfigTest : public ::testing::Test { pc_ = result.MoveValue(); } + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr socket_server_; rtc::AutoSocketServerThread main_thread_; rtc::scoped_refptr pc_factory_ = nullptr; diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc index dfca4868b5..f7f408bcc8 100644 --- a/pc/peer_connection_interface_unittest.cc +++ b/pc/peer_connection_interface_unittest.cc @@ -78,6 +78,7 @@ #include "rtc_base/virtual_socket_server.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" @@ -681,8 +682,6 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { webrtc::CreateBuiltinVideoDecoderFactory(), nullptr /* audio_mixer */, nullptr /* audio_processing */); ASSERT_TRUE(pc_factory_); - pc_factory_for_test_ = - PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest(); } void TearDown() override { @@ -733,7 +732,8 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { std::unique_ptr port_allocator( new cricket::FakePortAllocator( rtc::Thread::Current(), - std::make_unique(vss_.get()))); + std::make_unique(vss_.get()), + &field_trials_)); port_allocator_ = port_allocator.get(); port_allocator_->SetIceTiebreaker(kTiebreakerDefault); @@ -1258,13 +1258,13 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { rtc::SocketServer* socket_server() const { return vss_.get(); } + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr vss_; rtc::AutoSocketServerThread main_; rtc::scoped_refptr fake_audio_capture_module_; cricket::FakePortAllocator* port_allocator_ = nullptr; FakeRTCCertificateGenerator* fake_certificate_generator_ = nullptr; rtc::scoped_refptr pc_factory_; - rtc::scoped_refptr pc_factory_for_test_; rtc::scoped_refptr pc_; MockPeerConnectionObserver observer_; rtc::scoped_refptr reference_collection_; @@ -1367,8 +1367,8 @@ TEST_P(PeerConnectionInterfaceTest, std::unique_ptr packet_socket_factory( new rtc::BasicPacketSocketFactory(socket_server())); std::unique_ptr port_allocator( - new cricket::FakePortAllocator(rtc::Thread::Current(), - packet_socket_factory.get())); + new cricket::FakePortAllocator( + rtc::Thread::Current(), packet_socket_factory.get(), &field_trials_)); cricket::FakePortAllocator* raw_port_allocator = port_allocator.get(); // Create RTCConfiguration with some network-related fields relevant to diff --git a/pc/peer_connection_media_unittest.cc b/pc/peer_connection_media_unittest.cc index fab926522f..322540fa23 100644 --- a/pc/peer_connection_media_unittest.cc +++ b/pc/peer_connection_media_unittest.cc @@ -59,6 +59,7 @@ #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/thread.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" #endif @@ -138,7 +139,8 @@ class PeerConnectionMediaBaseTest : public ::testing::Test { auto fake_port_allocator = std::make_unique( rtc::Thread::Current(), - std::make_unique(vss_.get())); + std::make_unique(vss_.get()), + &field_trials_); auto observer = std::make_unique(); auto modified_config = config; modified_config.sdp_semantics = sdp_semantics_; @@ -208,6 +210,7 @@ class PeerConnectionMediaBaseTest : public ::testing::Test { return sdp_semantics_ == SdpSemantics::kUnifiedPlan; } + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr vss_; rtc::AutoSocketServerThread main_; const SdpSemantics sdp_semantics_; diff --git a/pc/test/peer_connection_test_wrapper.cc b/pc/test/peer_connection_test_wrapper.cc index 21396104dd..8325e59510 100644 --- a/pc/test/peer_connection_test_wrapper.cc +++ b/pc/test/peer_connection_test_wrapper.cc @@ -104,7 +104,8 @@ bool PeerConnectionTestWrapper::CreatePc( std::unique_ptr port_allocator( new cricket::FakePortAllocator( network_thread_, - std::make_unique(socket_server_))); + std::make_unique(socket_server_), + &field_trials_)); RTC_DCHECK_RUN_ON(&pc_thread_checker_); diff --git a/pc/test/peer_connection_test_wrapper.h b/pc/test/peer_connection_test_wrapper.h index 6d3e7c77ec..cda3ecb73b 100644 --- a/pc/test/peer_connection_test_wrapper.h +++ b/pc/test/peer_connection_test_wrapper.h @@ -30,6 +30,7 @@ #include "pc/test/fake_video_track_renderer.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" +#include "test/scoped_key_value_config.h" class PeerConnectionTestWrapper : public webrtc::PeerConnectionObserver, @@ -116,6 +117,7 @@ class PeerConnectionTestWrapper const cricket::AudioOptions& audio_options, bool video); + webrtc::test::ScopedKeyValueConfig field_trials_; std::string name_; rtc::SocketServer* const socket_server_; rtc::Thread* const network_thread_;