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 <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Sameer Vijaykar <samvi@google.com>
Cr-Commit-Position: refs/heads/main@{#39180}
This commit is contained in:
Sameer Vijaykar 2023-01-23 16:31:29 +01:00 committed by WebRTC LUCI CQ
parent ace52a821c
commit 0793ee7552
14 changed files with 145 additions and 72 deletions

View File

@ -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" ]
}

View File

@ -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<rtc::PacketSocketFactory> factory)
: FakePortAllocator(network_thread, nullptr, std::move(factory)) {}
std::unique_ptr<rtc::PacketSocketFactory> 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<rtc::PacketSocketFactory> owned_factory)
std::unique_ptr<rtc::PacketSocketFactory> 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<rtc::PacketSocketFactory> factory_;
const webrtc::FieldTrialsView* field_trials_;
bool mdns_obfuscation_enabled_ = false;
};

View File

@ -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<rtc::SocketServer> 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<rtc::SocketServer> 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<rtc::SocketServer> 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);

View File

@ -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<rtc::BasicPacketSocketFactory>(vss_.get())),
allocator_(std::make_unique<cricket::FakePortAllocator>(
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<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_;
std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory_;

View File

@ -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<rtc::BasicPacketSocketFactory>(vss_.get())),
allocator_(std::make_unique<cricket::FakePortAllocator>(
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<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread thread_;
std::unique_ptr<cricket::IceTransportInternal> ice_transport_;

View File

@ -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<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_;
@ -50,7 +53,8 @@ TEST_F(IceTransportTest, CreateSelfDeletingTransport) {
std::unique_ptr<cricket::FakePortAllocator> port_allocator(
std::make_unique<cricket::FakePortAllocator>(
nullptr,
std::make_unique<rtc::BasicPacketSocketFactory>(socket_server())));
std::make_unique<rtc::BasicPacketSocketFactory>(socket_server()),
&field_trials_));
IceTransportInit init;
init.set_port_allocator(port_allocator.get());
auto ice_transport = CreateIceTransport(std::move(init));

View File

@ -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<rtc::RTCCertificateGeneratorInterface> cert_gen) {
auto fake_port_allocator = std::make_unique<cricket::FakePortAllocator>(
rtc::Thread::Current(),
std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get()));
std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get()),
&field_trials_);
auto observer = std::make_unique<MockPeerConnectionObserver>();
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<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_;

View File

@ -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<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory_;

View File

@ -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<cricket::FakePortAllocator>(
rtc::Thread::Current(),
std::make_unique<rtc::BasicPacketSocketFactory>(socket_server_.get()));
std::make_unique<rtc::BasicPacketSocketFactory>(socket_server_.get()),
&field_trials_);
auto observer = std::make_unique<MockPeerConnectionObserver>();
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<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_;
std::vector<RtpHeaderExtensionCapability> extensions_;

View File

@ -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<cricket::FakePortAllocator> 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<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_ = nullptr;

View File

@ -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<cricket::FakePortAllocator> port_allocator(
new cricket::FakePortAllocator(
rtc::Thread::Current(),
std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get())));
std::make_unique<rtc::BasicPacketSocketFactory>(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<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_;
rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_;
cricket::FakePortAllocator* port_allocator_ = nullptr;
FakeRTCCertificateGenerator* fake_certificate_generator_ = nullptr;
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_;
rtc::scoped_refptr<PeerConnectionFactoryForTest> pc_factory_for_test_;
rtc::scoped_refptr<PeerConnectionInterface> pc_;
MockPeerConnectionObserver observer_;
rtc::scoped_refptr<StreamCollection> reference_collection_;
@ -1367,8 +1367,8 @@ TEST_P(PeerConnectionInterfaceTest,
std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory(
new rtc::BasicPacketSocketFactory(socket_server()));
std::unique_ptr<cricket::FakePortAllocator> 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

View File

@ -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<cricket::FakePortAllocator>(
rtc::Thread::Current(),
std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get()));
std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get()),
&field_trials_);
auto observer = std::make_unique<MockPeerConnectionObserver>();
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<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_;
const SdpSemantics sdp_semantics_;

View File

@ -104,7 +104,8 @@ bool PeerConnectionTestWrapper::CreatePc(
std::unique_ptr<cricket::PortAllocator> port_allocator(
new cricket::FakePortAllocator(
network_thread_,
std::make_unique<rtc::BasicPacketSocketFactory>(socket_server_)));
std::make_unique<rtc::BasicPacketSocketFactory>(socket_server_),
&field_trials_));
RTC_DCHECK_RUN_ON(&pc_thread_checker_);

View File

@ -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_;