Add test coverage for P2PTransportChannel refactor (#8/8)

This converts all P2PTransportChannel unit tests to parameterized tests, with a string parameter for the field_trials which is used to enable the refactor. This adds a variation of each existing test using the refactored code path.

Tests are initialized twice, once for legacy and refactored path each, to strike a balance between file name length and descriptiveness.

Bug: webrtc:14367, webrtc:14131
Change-Id: I0469550d571ed389804eb486fe5bd22504e59373
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/275303
Commit-Queue: Sameer Vijaykar <samvi@google.com>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38162}
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index 85ac605..33f3414 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -297,6 +297,7 @@
       "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:socket",
       "../rtc_base:socket_address",
+      "../rtc_base:stringutils",
       "../rtc_base:testclient",
       "../rtc_base:threading",
       "../rtc_base:timeutils",
diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc
index 928e9b2..b969705 100644
--- a/p2p/base/p2p_transport_channel_unittest.cc
+++ b/p2p/base/p2p_transport_channel_unittest.cc
@@ -12,8 +12,11 @@
 
 #include <list>
 #include <memory>
+#include <string>
+#include <tuple>
 #include <utility>
 
+#include "absl/algorithm/container.h"
 #include "absl/strings/string_view.h"
 #include "api/test/mock_async_dns_resolver.h"
 #include "p2p/base/active_ice_controller_factory_interface.h"
@@ -45,6 +48,7 @@
 #include "rtc_base/proxy_server.h"
 #include "rtc_base/socket_address.h"
 #include "rtc_base/ssl_adapter.h"
+#include "rtc_base/strings/string_builder.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/virtual_socket_server.h"
 #include "system_wrappers/include/metrics.h"
@@ -55,6 +59,7 @@
 using rtc::SocketAddress;
 using ::testing::_;
 using ::testing::Assign;
+using ::testing::Combine;
 using ::testing::Contains;
 using ::testing::DoAll;
 using ::testing::InSequence;
@@ -65,6 +70,9 @@
 using ::testing::SaveArg;
 using ::testing::SetArgPointee;
 using ::testing::SizeIs;
+using ::testing::TestWithParam;
+using ::testing::Values;
+using ::testing::WithParamInterface;
 using ::webrtc::PendingTaskSafetyFlag;
 using ::webrtc::SafeTask;
 
@@ -193,15 +201,15 @@
  public:
   ResolverFactoryFixture() {
     mock_async_dns_resolver_ = std::make_unique<webrtc::MockAsyncDnsResolver>();
-    ON_CALL(*mock_async_dns_resolver_, Start(_, _))
-        .WillByDefault(InvokeArgument<1>());
+    EXPECT_CALL(*mock_async_dns_resolver_, Start(_, _))
+        .WillRepeatedly(InvokeArgument<1>());
     EXPECT_CALL(*mock_async_dns_resolver_, result())
         .WillOnce(ReturnRef(mock_async_dns_resolver_result_));
 
     // A default action for GetResolvedAddress. Will be overruled
     // by SetAddressToReturn.
-    ON_CALL(mock_async_dns_resolver_result_, GetResolvedAddress(_, _))
-        .WillByDefault(Return(true));
+    EXPECT_CALL(mock_async_dns_resolver_result_, GetResolvedAddress(_, _))
+        .WillRepeatedly(Return(true));
 
     EXPECT_CALL(mock_async_dns_resolver_result_, GetError())
         .WillOnce(Return(0));
@@ -264,8 +272,9 @@
 class P2PTransportChannelTestBase : public ::testing::Test,
                                     public sigslot::has_slots<> {
  public:
-  P2PTransportChannelTestBase()
-      : vss_(new rtc::VirtualSocketServer()),
+  explicit P2PTransportChannelTestBase(absl::string_view field_trials)
+      : field_trials_(field_trials),
+        vss_(new rtc::VirtualSocketServer()),
         nss_(new rtc::NATSocketServer(vss_.get())),
         ss_(new rtc::FirewallSocketServer(nss_.get())),
         main_(ss_.get()),
@@ -294,6 +303,9 @@
     webrtc::metrics::Reset();
   }
 
+  P2PTransportChannelTestBase()
+      : P2PTransportChannelTestBase(absl::string_view()) {}
+
  protected:
   enum Config {
     OPEN,                         // Open to the Internet
@@ -1100,8 +1112,12 @@
 // Test the matrix of all the connectivity types we expect to see in the wild.
 // Just test every combination of the configs in the Config enum.
 class P2PTransportChannelTest : public P2PTransportChannelTestBase {
+ public:
+  P2PTransportChannelTest() : P2PTransportChannelTestBase() {}
+  explicit P2PTransportChannelTest(absl::string_view field_trials)
+      : P2PTransportChannelTestBase(field_trials) {}
+
  protected:
-  static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS];
   void ConfigureEndpoints(Config config1,
                           Config config2,
                           int allocator_flags1,
@@ -1186,6 +1202,20 @@
   }
 };
 
+class P2PTransportChannelTestWithFieldTrials
+    : public P2PTransportChannelTest,
+      public WithParamInterface<std::string> {
+ public:
+  P2PTransportChannelTestWithFieldTrials()
+      : P2PTransportChannelTest(GetParam()) {}
+};
+
+class P2PTransportChannelMatrixTest
+    : public P2PTransportChannelTestWithFieldTrials {
+ protected:
+  static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS];
+};
+
 // Shorthands for use in the test matrix.
 #define LULU &kLocalUdpToLocalUdp
 #define LUSU &kLocalUdpToStunUdp
@@ -1210,8 +1240,8 @@
 // TODO(?): Fix NULLs caused by lack of TCP support in NATSocket.
 // TODO(?): Fix NULLs caused by no HTTP proxy support.
 // TODO(?): Rearrange rows/columns from best to worst.
-const P2PTransportChannelTest::Result*
-    P2PTransportChannelTest::kMatrix[NUM_CONFIGS][NUM_CONFIGS] = {
+const P2PTransportChannelMatrixTest::Result*
+    P2PTransportChannelMatrixTest::kMatrix[NUM_CONFIGS][NUM_CONFIGS] = {
         //      OPEN  CONE  ADDR  PORT  SYMM  2CON  SCON  !UDP  !TCP  HTTP  PRXH
         //      PRXS
         /*OP*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, LTPT, LTPT, LSRS,
@@ -1251,26 +1281,16 @@
          LTRT},
 };
 
-class P2PTransportChannelTestWithFieldTrials
-    : public P2PTransportChannelTest,
-      public ::testing::WithParamInterface<std::string> {
- public:
-  void Test(const Result& expected) override {
-    webrtc::test::ScopedKeyValueConfig field_trials(field_trials_, GetParam());
-    P2PTransportChannelTest::Test(expected);
-  }
-};
-
 // The actual tests that exercise all the various configurations.
 // Test names are of the form P2PTransportChannelTest_TestOPENToNAT_FULL_CONE
-#define P2P_TEST_DECLARATION(x, y, z)                                 \
-  TEST_P(P2PTransportChannelTestWithFieldTrials, z##Test##x##To##y) { \
-    ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_SOCKET,      \
-                       PORTALLOCATOR_ENABLE_SHARED_SOCKET);           \
-    if (kMatrix[x][y] != NULL)                                        \
-      Test(*kMatrix[x][y]);                                           \
-    else                                                              \
-      RTC_LOG(LS_WARNING) << "Not yet implemented";                   \
+#define P2P_TEST_DECLARATION(x, y, z)                            \
+  TEST_P(P2PTransportChannelMatrixTest, z##Test##x##To##y) {     \
+    ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_SOCKET, \
+                       PORTALLOCATOR_ENABLE_SHARED_SOCKET);      \
+    if (kMatrix[x][y] != NULL)                                   \
+      Test(*kMatrix[x][y]);                                      \
+    else                                                         \
+      RTC_LOG(LS_WARNING) << "Not yet implemented";              \
   }
 
 #define P2P_TEST(x, y) P2P_TEST_DECLARATION(x, y, /* empty argument */)
@@ -1303,14 +1323,28 @@
 P2P_TEST_SET(PROXY_SOCKS)
 
 INSTANTIATE_TEST_SUITE_P(
-    P2PTransportChannelTestWithFieldTrials,
-    P2PTransportChannelTestWithFieldTrials,
+    Legacy,
+    P2PTransportChannelMatrixTest,
     // Each field-trial is ~144 tests (some return not-yet-implemented).
-    testing::Values("", "WebRTC-IceFieldTrials/enable_goog_ping:true/"));
+    Values("", "WebRTC-IceFieldTrials/enable_goog_ping:true/"));
+INSTANTIATE_TEST_SUITE_P(
+    Active,
+    P2PTransportChannelMatrixTest,
+    // Each field-trial is ~144 tests (some return not-yet-implemented).
+    Values("WebRTC-UseActiveIceController/Enabled/",
+           "WebRTC-IceFieldTrials/enable_goog_ping:true/"
+           "WebRTC-UseActiveIceController/Enabled/"));
+
+INSTANTIATE_TEST_SUITE_P(Legacy,
+                         P2PTransportChannelTestWithFieldTrials,
+                         Values(""));
+INSTANTIATE_TEST_SUITE_P(Active,
+                         P2PTransportChannelTestWithFieldTrials,
+                         Values("WebRTC-UseActiveIceController/Enabled/"));
 
 // Test that we restart candidate allocation when local ufrag&pwd changed.
 // Standard Ice protocol is used.
-TEST_F(P2PTransportChannelTest, HandleUfragPwdChange) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, HandleUfragPwdChange) {
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
   CreateChannels();
@@ -1320,7 +1354,8 @@
 
 // Same as above test, but with a symmetric NAT.
 // We should end up with relay<->prflx candidate pairs, with generation "1".
-TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeSymmetricNat) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       HandleUfragPwdChangeSymmetricNat) {
   ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
   CreateChannels();
@@ -1329,7 +1364,7 @@
 }
 
 // Test the operation of GetStats.
-TEST_F(P2PTransportChannelTest, GetStats) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, GetStats) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
@@ -1378,7 +1413,7 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelTest, GetStatsSwitchConnection) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, GetStatsSwitchConnection) {
   rtc::ScopedFakeClock clock;
   IceConfig continual_gathering_config =
       CreateIceConfig(1000, GATHER_CONTINUALLY);
@@ -1450,7 +1485,8 @@
 
 // Tests that UMAs are recorded when ICE restarts while the channel
 // is disconnected.
-TEST_F(P2PTransportChannelTest, TestUMAIceRestartWhileDisconnected) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       TestUMAIceRestartWhileDisconnected) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
 
@@ -1483,7 +1519,8 @@
 
 // Tests that UMAs are recorded when ICE restarts while the channel
 // is connected.
-TEST_F(P2PTransportChannelTest, TestUMAIceRestartWhileConnected) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       TestUMAIceRestartWhileConnected) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
 
@@ -1510,7 +1547,8 @@
 
 // Tests that UMAs are recorded when ICE restarts while the channel
 // is connecting.
-TEST_F(P2PTransportChannelTest, TestUMAIceRestartWhileConnecting) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       TestUMAIceRestartWhileConnecting) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
 
@@ -1536,7 +1574,7 @@
 
 // Tests that a UMA on ICE regathering is recorded when there is a network
 // change if and only if continual gathering is enabled.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        TestIceRegatheringReasonContinualGatheringByNetworkChange) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
@@ -1572,7 +1610,7 @@
 
 // Tests that a UMA on ICE regathering is recorded when there is a network
 // failure if and only if continual gathering is enabled.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        TestIceRegatheringReasonContinualGatheringByNetworkFailure) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
@@ -1605,7 +1643,8 @@
 
 // Test that we properly create a connection on a STUN ping from unknown address
 // when the signaling is slow.
-TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       PeerReflexiveCandidateBeforeSignaling) {
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
   // Emulate no remote parameters coming in.
@@ -1649,7 +1688,8 @@
 // 1. the selected candidate pair accessed via the public API, and
 // 2. the candidate pair stats
 // until we learn the same address from signaling.
-TEST_F(P2PTransportChannelTest, PeerReflexiveRemoteCandidateIsSanitized) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       PeerReflexiveRemoteCandidateIsSanitized) {
   ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
   // Emulate no remote parameters coming in.
   set_remote_ice_parameter_source(FROM_CANDIDATE);
@@ -1713,7 +1753,8 @@
 
 // Test that we properly create a connection on a STUN ping from unknown address
 // when the signaling is slow and the end points are behind NAT.
-TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       PeerReflexiveCandidateBeforeSignalingWithNAT) {
   ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
   // Emulate no remote parameters coming in.
@@ -1762,7 +1803,7 @@
 // not older-generation candidate pairs created by pairing candidates across
 // generations. This resulted in the old-generation prflx candidate being
 // prioritized above new-generation candidate pairs.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        PeerReflexiveCandidateBeforeSignalingWithIceRestart) {
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
@@ -1812,7 +1853,8 @@
 }
 
 // Test that if remote candidates don't have ufrag and pwd, we still work.
-TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       RemoteCandidatesWithoutUfragPwd) {
   rtc::ScopedFakeClock clock;
   set_remote_ice_parameter_source(FROM_SETICEPARAMETERS);
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
@@ -1832,7 +1874,7 @@
 
 // Test that a host behind NAT cannot be reached when incoming_only
 // is set to true.
-TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, IncomingOnlyBlocked) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(NAT_FULL_CONE, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
@@ -1854,7 +1896,7 @@
 
 // Test that a peer behind NAT can connect to a peer that has
 // incoming_only flag set.
-TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, IncomingOnlyOpen) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, NAT_FULL_CONE, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
@@ -1872,7 +1914,8 @@
 // Test that two peers can connect when one can only make outgoing TCP
 // connections. This has been observed in some scenarios involving
 // VPNs/firewalls.
-TEST_F(P2PTransportChannelTest, CanOnlyMakeOutgoingTcpConnections) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       CanOnlyMakeOutgoingTcpConnections) {
   // The PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS flag is required if the
   // application needs this use case to work, since the application must accept
   // the tradeoff that more candidates need to be allocated.
@@ -1895,7 +1938,8 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       TestTcpConnectionsFromActiveToPassive) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0]);
   AddAddress(1, kPublicAddrs[1]);
@@ -1941,7 +1985,7 @@
 }
 
 // Test that tcptype is set on all candidates for a connection running over TCP.
-TEST_F(P2PTransportChannelTest, TestTcpConnectionTcptypeSet) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, TestTcpConnectionTcptypeSet) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(BLOCK_UDP_AND_INCOMING_TCP, OPEN,
                      PORTALLOCATOR_ENABLE_SHARED_SOCKET,
@@ -1963,7 +2007,7 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelTest, TestIceRoleConflict) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, TestIceRoleConflict) {
   AddAddress(0, kPublicAddrs[0]);
   AddAddress(1, kPublicAddrs[1]);
   TestSignalRoleConflict();
@@ -1971,7 +2015,8 @@
 
 // Tests that the ice configs (protocol, tiebreaker and role) can be passed
 // down to ports.
-TEST_F(P2PTransportChannelTest, TestIceConfigWillPassDownToPort) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       TestIceConfigWillPassDownToPort) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0]);
   AddAddress(1, kPublicAddrs[1]);
@@ -2015,7 +2060,7 @@
 }
 
 // Verify that we can set DSCP value and retrieve properly from P2PTC.
-TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, TestDefaultDscpValue) {
   AddAddress(0, kPublicAddrs[0]);
   AddAddress(1, kPublicAddrs[1]);
 
@@ -2034,7 +2079,7 @@
 }
 
 // Verify IPv6 connection is preferred over IPv4.
-TEST_F(P2PTransportChannelTest, TestIPv6Connections) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, TestIPv6Connections) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kIPv6PublicAddrs[0]);
   AddAddress(0, kPublicAddrs[0]);
@@ -2062,7 +2107,7 @@
 }
 
 // Testing forceful TURN connections.
-TEST_F(P2PTransportChannelTest, TestForceTurn) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, TestForceTurn) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(
       NAT_PORT_RESTRICTED, NAT_SYMMETRIC,
@@ -2092,7 +2137,7 @@
 
 // Test that if continual gathering is set to true, ICE gathering state will
 // not change to "Complete", and vice versa.
-TEST_F(P2PTransportChannelTest, TestContinualGathering) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, TestContinualGathering) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
@@ -2120,7 +2165,8 @@
 
 // Test that a connection succeeds when the P2PTransportChannel uses a pooled
 // PortAllocatorSession that has not yet finished gathering candidates.
-TEST_F(P2PTransportChannelTest, TestUsingPooledSessionBeforeDoneGathering) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       TestUsingPooledSessionBeforeDoneGathering) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
@@ -2163,7 +2209,8 @@
 
 // Test that a connection succeeds when the P2PTransportChannel uses a pooled
 // PortAllocatorSession that already finished gathering candidates.
-TEST_F(P2PTransportChannelTest, TestUsingPooledSessionAfterDoneGathering) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       TestUsingPooledSessionAfterDoneGathering) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
@@ -2210,7 +2257,7 @@
 // TODO(deadbeef): Move this and other "presumed writable" tests into a test
 // class that operates on a single P2PTransportChannel, once an appropriate one
 // (which supports TURN servers and TURN candidate gathering) is available.
-TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, TurnToTurnPresumedWritable) {
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
   // Only configure one channel so we can control when the remote candidate
@@ -2247,7 +2294,7 @@
 }
 
 // Test that a TURN/peer reflexive candidate pair is also presumed writable.
-TEST_F(P2PTransportChannelTest, TurnToPrflxPresumedWritable) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, TurnToPrflxPresumedWritable) {
   rtc::ScopedFakeClock fake_clock;
 
   // We need to add artificial network delay to verify that the connection
@@ -2296,7 +2343,8 @@
 
 // Test that a presumed-writable TURN<->TURN connection is preferred above an
 // unreliable connection (one that has failed to be pinged for some time).
-TEST_F(P2PTransportChannelTest, PresumedWritablePreferredOverUnreliable) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       PresumedWritablePreferredOverUnreliable) {
   rtc::ScopedFakeClock fake_clock;
 
   ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags,
@@ -2336,7 +2384,8 @@
 
 // Ensure that "SignalReadyToSend" is fired as expected with a "presumed
 // writable" connection. Previously this did not work.
-TEST_F(P2PTransportChannelTest, SignalReadyToSendWithPresumedWritable) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       SignalReadyToSendWithPresumedWritable) {
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
   // Only test one endpoint, so we can ensure the connection doesn't receive a
@@ -2374,7 +2423,7 @@
 // Test that role conflict error responses are sent as expected when receiving a
 // ping from an unknown address over a TURN connection. Regression test for
 // crbug.com/webrtc/9034.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        TurnToPrflxSelectedAfterResolvingIceControllingRoleConflict) {
   rtc::ScopedFakeClock clock;
   // Gather only relay candidates.
@@ -2417,7 +2466,7 @@
 
 // Test that the writability can be established with the piggyback
 // acknowledgement in the connectivity check from the remote peer.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        CanConnectWithPiggybackCheckAcknowledgementWhenCheckResponseBlocked) {
   webrtc::test::ScopedKeyValueConfig field_trials(
       field_trials_, "WebRTC-PiggybackIceCheckAcknowledgement/Enabled/");
@@ -2464,7 +2513,11 @@
 // Test what happens when we have 2 users behind the same NAT. This can lead
 // to interesting behavior because the STUN server will only give out the
 // address of the outermost NAT.
-class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase {
+class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase,
+                                       public WithParamInterface<std::string> {
+ public:
+  P2PTransportChannelSameNatTest() : P2PTransportChannelTestBase(GetParam()) {}
+
  protected:
   void ConfigureEndpoints(Config nat_type, Config config1, Config config2) {
     RTC_CHECK_GE(nat_type, NAT_FULL_CONE);
@@ -2492,7 +2545,12 @@
   }
 };
 
-TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) {
+INSTANTIATE_TEST_SUITE_P(Legacy, P2PTransportChannelSameNatTest, Values(""));
+INSTANTIATE_TEST_SUITE_P(Active,
+                         P2PTransportChannelSameNatTest,
+                         Values("WebRTC-UseActiveIceController/Enabled/"));
+
+TEST_P(P2PTransportChannelSameNatTest, TestConesBehindSameCone) {
   ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE);
   Test(
       P2PTransportChannelTestBase::Result("prflx", "udp", "stun", "udp", 1000));
@@ -2501,7 +2559,8 @@
 // Test what happens when we have multiple available pathways.
 // In the future we will try different RTTs and configs for the different
 // interfaces, so that we can simulate a user with Ethernet and VPN networks.
-class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase {
+class P2PTransportChannelMultihomedTest
+    : public P2PTransportChannelTestWithFieldTrials {
  public:
   const Connection* GetConnectionWithRemoteAddress(
       P2PTransportChannel* channel,
@@ -2567,8 +2626,13 @@
   }
 };
 
+INSTANTIATE_TEST_SUITE_P(Legacy, P2PTransportChannelMultihomedTest, Values(""));
+INSTANTIATE_TEST_SUITE_P(Active,
+                         P2PTransportChannelMultihomedTest,
+                         Values("WebRTC-UseActiveIceController/Enabled/"));
+
 // Test that we can establish connectivity when both peers are multihomed.
-TEST_F(P2PTransportChannelMultihomedTest, TestBasic) {
+TEST_P(P2PTransportChannelMultihomedTest, TestBasic) {
   AddAddress(0, kPublicAddrs[0]);
   AddAddress(0, kAlternateAddrs[0]);
   AddAddress(1, kPublicAddrs[1]);
@@ -2578,7 +2642,7 @@
 
 // Test that we can quickly switch links if an interface goes down.
 // The controlled side has two interfaces and one will die.
-TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControlledSide) {
+TEST_P(P2PTransportChannelMultihomedTest, TestFailoverControlledSide) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0]);
   // Simulate failing over from Wi-Fi to cell interface.
@@ -2624,7 +2688,7 @@
 
 // Test that we can quickly switch links if an interface goes down.
 // The controlling side has two interfaces and one will die.
-TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControllingSide) {
+TEST_P(P2PTransportChannelMultihomedTest, TestFailoverControllingSide) {
   rtc::ScopedFakeClock clock;
   // Simulate failing over from Wi-Fi to cell interface.
   AddAddress(0, kPublicAddrs[0], "eth0", rtc::ADAPTER_TYPE_WIFI);
@@ -2661,7 +2725,7 @@
 
 // Tests that we can quickly switch links if an interface goes down when
 // there are many connections.
-TEST_F(P2PTransportChannelMultihomedTest, TestFailoverWithManyConnections) {
+TEST_P(P2PTransportChannelMultihomedTest, TestFailoverWithManyConnections) {
   rtc::ScopedFakeClock clock;
   test_turn_server()->AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP);
   RelayServerConfig turn_server;
@@ -2751,7 +2815,7 @@
 // Test that when the controlling side switches the selected connection,
 // the nomination of the selected connection on the controlled side will
 // increase.
-TEST_F(P2PTransportChannelMultihomedTest, TestIceRenomination) {
+TEST_P(P2PTransportChannelMultihomedTest, TestIceRenomination) {
   rtc::ScopedFakeClock clock;
   // Simulate failing over from Wi-Fi to cell interface.
   AddAddress(0, kPublicAddrs[0], "eth0", rtc::ADAPTER_TYPE_WIFI);
@@ -2807,7 +2871,7 @@
 // The case that it will switch over to the backup connection if the selected
 // connection does not recover after enough time is covered in
 // TestFailoverControlledSide and TestFailoverControllingSide.
-TEST_F(P2PTransportChannelMultihomedTest,
+TEST_P(P2PTransportChannelMultihomedTest,
        TestConnectionSwitchDampeningControlledSide) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0]);
@@ -2860,7 +2924,7 @@
 
 // Test that if an interface fails temporarily and then recovers quickly,
 // the selected connection will not switch.
-TEST_F(P2PTransportChannelMultihomedTest,
+TEST_P(P2PTransportChannelMultihomedTest,
        TestConnectionSwitchDampeningControllingSide) {
   rtc::ScopedFakeClock clock;
   // Simulate failing over from Wi-Fi to cell interface.
@@ -2909,7 +2973,7 @@
 
 // Tests that if the remote side's network failed, it won't cause the local
 // side to switch connections and networks.
-TEST_F(P2PTransportChannelMultihomedTest, TestRemoteFailover) {
+TEST_P(P2PTransportChannelMultihomedTest, TestRemoteFailover) {
   rtc::ScopedFakeClock clock;
   // The interface names are chosen so that `cellular` would have higher
   // candidate priority and higher cost.
@@ -2956,7 +3020,7 @@
 }
 
 // Tests that a Wifi-Wifi connection has the highest precedence.
-TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiToWifiConnection) {
+TEST_P(P2PTransportChannelMultihomedTest, TestPreferWifiToWifiConnection) {
   // The interface names are chosen so that `cellular` would have higher
   // candidate priority if it is not for the network type.
   auto& wifi = kAlternateAddrs;
@@ -2983,7 +3047,7 @@
 
 // Tests that a Wifi-Cellular connection has higher precedence than
 // a Cellular-Cellular connection.
-TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) {
+TEST_P(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) {
   // The interface names are chosen so that `cellular` would have higher
   // candidate priority if it is not for the network type.
   auto& wifi = kAlternateAddrs;
@@ -3007,7 +3071,7 @@
 
 // Test that the backup connection is pinged at a rate no faster than
 // what was configured.
-TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) {
+TEST_P(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) {
   AddAddress(0, kPublicAddrs[0]);
   // Adding alternate address will make sure `kPublicAddrs` has the higher
   // priority than others. This is due to FakeNetwork::AddInterface method.
@@ -3046,7 +3110,7 @@
 
 // Test that the connection is pinged at a rate no faster than
 // what was configured when stable and writable.
-TEST_F(P2PTransportChannelMultihomedTest, TestStableWritableRate) {
+TEST_P(P2PTransportChannelMultihomedTest, TestStableWritableRate) {
   AddAddress(0, kPublicAddrs[0]);
   // Adding alternate address will make sure `kPublicAddrs` has the higher
   // priority than others. This is due to FakeNetwork::AddInterface method.
@@ -3091,7 +3155,7 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelMultihomedTest, TestGetState) {
+TEST_P(P2PTransportChannelMultihomedTest, TestGetState) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kAlternateAddrs[0]);
   AddAddress(0, kPublicAddrs[0]);
@@ -3111,7 +3175,7 @@
 // policy is GATHER_CONTINUALLY, the ports associated with that network
 // will be removed from the port list of the channel, and the respective
 // remote candidates on the other participant will be removed eventually.
-TEST_F(P2PTransportChannelMultihomedTest, TestNetworkBecomesInactive) {
+TEST_P(P2PTransportChannelMultihomedTest, TestNetworkBecomesInactive) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0]);
   AddAddress(1, kPublicAddrs[1]);
@@ -3152,7 +3216,7 @@
 
 // Tests that continual gathering will create new connections when a new
 // interface is added.
-TEST_F(P2PTransportChannelMultihomedTest,
+TEST_P(P2PTransportChannelMultihomedTest,
        TestContinualGatheringOnNewInterface) {
   auto& wifi = kAlternateAddrs;
   auto& cellular = kPublicAddrs;
@@ -3206,7 +3270,7 @@
 }
 
 // Tests that we can switch links via continual gathering.
-TEST_F(P2PTransportChannelMultihomedTest,
+TEST_P(P2PTransportChannelMultihomedTest,
        TestSwitchLinksViaContinualGathering) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0]);
@@ -3248,7 +3312,7 @@
 }
 
 // Tests that the backup connection will be restored after it is destroyed.
-TEST_F(P2PTransportChannelMultihomedTest, TestRestoreBackupConnection) {
+TEST_P(P2PTransportChannelMultihomedTest, TestRestoreBackupConnection) {
   rtc::ScopedFakeClock clock;
   auto& wifi = kAlternateAddrs;
   auto& cellular = kPublicAddrs;
@@ -3284,7 +3348,7 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelMultihomedTest, TestVpnDefault) {
+TEST_P(P2PTransportChannelMultihomedTest, TestVpnDefault) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0], "eth0", rtc::ADAPTER_TYPE_ETHERNET);
   AddAddress(0, kAlternateAddrs[0], "vpn0", rtc::ADAPTER_TYPE_VPN);
@@ -3298,7 +3362,7 @@
       kDefaultTimeout, clock);
 }
 
-TEST_F(P2PTransportChannelMultihomedTest, TestVpnPreferVpn) {
+TEST_P(P2PTransportChannelMultihomedTest, TestVpnPreferVpn) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0], "eth0", rtc::ADAPTER_TYPE_ETHERNET);
   AddAddress(0, kAlternateAddrs[0], "vpn0", rtc::ADAPTER_TYPE_VPN,
@@ -3324,7 +3388,7 @@
       kDefaultTimeout, clock);
 }
 
-TEST_F(P2PTransportChannelMultihomedTest, TestVpnAvoidVpn) {
+TEST_P(P2PTransportChannelMultihomedTest, TestVpnAvoidVpn) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0], "eth0", rtc::ADAPTER_TYPE_CELLULAR);
   AddAddress(0, kAlternateAddrs[0], "vpn0", rtc::ADAPTER_TYPE_VPN,
@@ -3349,7 +3413,7 @@
       kDefaultTimeout, clock);
 }
 
-TEST_F(P2PTransportChannelMultihomedTest, TestVpnNeverVpn) {
+TEST_P(P2PTransportChannelMultihomedTest, TestVpnNeverVpn) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0], "eth0", rtc::ADAPTER_TYPE_CELLULAR);
   AddAddress(0, kAlternateAddrs[0], "vpn0", rtc::ADAPTER_TYPE_VPN,
@@ -3373,7 +3437,7 @@
                              kDefaultTimeout, clock);
 }
 
-TEST_F(P2PTransportChannelMultihomedTest, TestVpnOnlyVpn) {
+TEST_P(P2PTransportChannelMultihomedTest, TestVpnOnlyVpn) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kPublicAddrs[0], "eth0", rtc::ADAPTER_TYPE_CELLULAR);
   AddAddress(0, kAlternateAddrs[0], "vpn0", rtc::ADAPTER_TYPE_VPN,
@@ -3399,11 +3463,12 @@
 
 // A collection of tests which tests a single P2PTransportChannel by sending
 // pings.
-class P2PTransportChannelPingTest : public ::testing::Test,
+class P2PTransportChannelPingTest : public TestWithParam<std::string>,
                                     public sigslot::has_slots<> {
  public:
   P2PTransportChannelPingTest()
-      : vss_(std::make_unique<rtc::VirtualSocketServer>()),
+      : field_trials_(GetParam()),
+        vss_(std::make_unique<rtc::VirtualSocketServer>()),
         packet_socket_factory_(
             std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get())),
         thread_(vss_.get()) {}
@@ -3609,6 +3674,8 @@
     return packet_socket_factory_.get();
   }
 
+  webrtc::test::ScopedKeyValueConfig field_trials_;
+
  private:
   std::unique_ptr<rtc::VirtualSocketServer> vss_;
   std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory_;
@@ -3621,9 +3688,14 @@
   absl::optional<rtc::NetworkRoute> last_network_route_;
 };
 
-TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) {
+INSTANTIATE_TEST_SUITE_P(Legacy, P2PTransportChannelPingTest, Values(""));
+INSTANTIATE_TEST_SUITE_P(Active,
+                         P2PTransportChannelPingTest,
+                         Values("WebRTC-UseActiveIceController/Enabled/"));
+
+TEST_P(P2PTransportChannelPingTest, TestTriggeredChecks) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("trigger checks", 1, &pa);
+  P2PTransportChannel ch("trigger checks", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
   ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1));
@@ -3645,9 +3717,9 @@
   EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch));
 }
 
-TEST_F(P2PTransportChannelPingTest, TestAllConnectionsPingedSufficiently) {
+TEST_P(P2PTransportChannelPingTest, TestAllConnectionsPingedSufficiently) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("ping sufficiently", 1, &pa);
+  P2PTransportChannel ch("ping sufficiently", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
   ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1));
@@ -3668,14 +3740,14 @@
 }
 
 // Verify that the connections are pinged at the right time.
-TEST_F(P2PTransportChannelPingTest, TestStunPingIntervals) {
+TEST_P(P2PTransportChannelPingTest, TestStunPingIntervals) {
   rtc::ScopedFakeClock clock;
   int RTT_RATIO = 4;
   int SCHEDULING_RANGE = 200;
   int RTT_RANGE = 10;
 
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("TestChannel", 1, &pa);
+  P2PTransportChannel ch("TestChannel", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
   ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1));
@@ -3762,11 +3834,11 @@
 
 // Test that we start pinging as soon as we have a connection and remote ICE
 // parameters.
-TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) {
+TEST_P(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) {
   rtc::ScopedFakeClock clock;
 
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("TestChannel", 1, &pa);
+  P2PTransportChannel ch("TestChannel", 1, &pa, &field_trials_);
   ch.SetIceRole(ICEROLE_CONTROLLING);
   ch.SetIceParameters(kIceParams[0]);
   ch.MaybeStartGathering();
@@ -3800,9 +3872,9 @@
   EXPECT_TRUE_SIMULATED_WAIT(conn->num_pings_sent() > 0, 1, clock);
 }
 
-TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) {
+TEST_P(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("trigger checks", 1, &pa);
+  P2PTransportChannel ch("trigger checks", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
   ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1));
@@ -3825,9 +3897,10 @@
   EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch));
 }
 
-TEST_F(P2PTransportChannelPingTest, TestFailedConnectionNotPingable) {
+TEST_P(P2PTransportChannelPingTest, TestFailedConnectionNotPingable) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("Do not ping failed connections", 1, &pa);
+  P2PTransportChannel ch("Do not ping failed connections", 1, &pa,
+                         &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
   ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1));
@@ -3842,9 +3915,9 @@
   EXPECT_TRUE(nullptr == ch.FindNextPingableConnection());
 }
 
-TEST_F(P2PTransportChannelPingTest, TestSignalStateChanged) {
+TEST_P(P2PTransportChannelPingTest, TestSignalStateChanged) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("state change", 1, &pa);
+  P2PTransportChannel ch("state change", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
   ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1));
@@ -3863,9 +3936,9 @@
 // although the ICE pwd in the remote candidate will be set when the ICE
 // parameters arrive. If a remote candidate is added with the current ICE
 // ufrag, its pwd and generation will be set properly.
-TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) {
+TEST_P(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("add candidate", 1, &pa);
+  P2PTransportChannel ch("add candidate", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
   // Add a candidate with a future ufrag.
@@ -3915,9 +3988,9 @@
   }
 }
 
-TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) {
+TEST_P(P2PTransportChannelPingTest, ConnectionResurrection) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("connection resurrection", 1, &pa);
+  P2PTransportChannel ch("connection resurrection", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
 
@@ -3967,10 +4040,10 @@
   EXPECT_EQ(conn3->remote_candidate().priority(), prflx_priority);
 }
 
-TEST_F(P2PTransportChannelPingTest, TestReceivingStateChange) {
+TEST_P(P2PTransportChannelPingTest, TestReceivingStateChange) {
   rtc::ScopedFakeClock clock;
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("receiving state change", 1, &pa);
+  P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   // Default receiving timeout and checking receiving interval should not be too
   // small.
@@ -3997,9 +4070,9 @@
 // "selected connection". Plus, SignalNetworkRouteChanged will be fired if the
 // selected connection changes and SignalReadyToSend will be fired if the new
 // selected connection is writable.
-TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) {
+TEST_P(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("receiving state change", 1, &pa);
+  P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4084,8 +4157,9 @@
 // Test the field trial send_ping_on_nomination_ice_controlled
 // that sends a ping directly when a connection has been nominated
 // i.e on the ICE_CONTROLLED-side.
-TEST_F(P2PTransportChannelPingTest, TestPingOnNomination) {
+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());
   P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials);
@@ -4124,8 +4198,9 @@
 // Test the field trial send_ping_on_switch_ice_controlling
 // that sends a ping directly when switching to a new connection
 // on the ICE_CONTROLLING-side.
-TEST_F(P2PTransportChannelPingTest, TestPingOnSwitch) {
+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());
   P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials);
@@ -4161,8 +4236,9 @@
 // Test the field trial send_ping_on_switch_ice_controlling
 // that sends a ping directly when selecteing a new connection
 // on the ICE_CONTROLLING-side (i.e also initial selection).
-TEST_F(P2PTransportChannelPingTest, TestPingOnSelected) {
+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());
   P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials);
@@ -4191,9 +4267,9 @@
 // address if the request contains the use_candidate attribute. Plus, it will
 // also sends back a ping response and set the ICE pwd in the remote candidate
 // appropriately.
-TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
+TEST_P(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("receiving state change", 1, &pa);
+  P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4268,9 +4344,9 @@
 // based on media received until the controlling side nominates a connection,
 // at which point the controlled side will select that connection as
 // the "selected connection".
-TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
+TEST_P(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("receiving state change", 1, &pa);
+  P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4318,12 +4394,12 @@
   EXPECT_EQ_WAIT(conn3, ch.selected_connection(), kDefaultTimeout);
 }
 
-TEST_F(P2PTransportChannelPingTest,
+TEST_P(P2PTransportChannelPingTest,
        TestControlledAgentDataReceivingTakesHigherPrecedenceThanPriority) {
   rtc::ScopedFakeClock clock;
   clock.AdvanceTime(webrtc::TimeDelta::Seconds(1));
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa);
+  P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4366,13 +4442,13 @@
   EXPECT_EQ(0, reset_selected_candidate_pair_switches());
 }
 
-TEST_F(P2PTransportChannelPingTest,
+TEST_P(P2PTransportChannelPingTest,
        TestControlledAgentNominationTakesHigherPrecedenceThanDataReceiving) {
   rtc::ScopedFakeClock clock;
   clock.AdvanceTime(webrtc::TimeDelta::Seconds(1));
 
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa);
+  P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4406,13 +4482,13 @@
   EXPECT_EQ(0, reset_selected_candidate_pair_switches());
 }
 
-TEST_F(P2PTransportChannelPingTest,
+TEST_P(P2PTransportChannelPingTest,
        TestControlledAgentSelectsConnectionWithHigherNomination) {
   rtc::ScopedFakeClock clock;
   clock.AdvanceTime(webrtc::TimeDelta::Seconds(1));
 
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test", 1, &pa);
+  P2PTransportChannel ch("test", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4453,12 +4529,12 @@
   EXPECT_EQ(0, reset_selected_candidate_pair_switches());
 }
 
-TEST_F(P2PTransportChannelPingTest, TestEstimatedDisconnectedTime) {
+TEST_P(P2PTransportChannelPingTest, TestEstimatedDisconnectedTime) {
   rtc::ScopedFakeClock clock;
   clock.AdvanceTime(webrtc::TimeDelta::Seconds(1));
 
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test", 1, &pa);
+  P2PTransportChannel ch("test", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4511,13 +4587,13 @@
   }
 }
 
-TEST_F(P2PTransportChannelPingTest,
+TEST_P(P2PTransportChannelPingTest,
        TestControlledAgentIgnoresSmallerNomination) {
   rtc::ScopedFakeClock clock;
   clock.AdvanceTime(webrtc::TimeDelta::Seconds(1));
 
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test", 1, &pa);
+  P2PTransportChannel ch("test", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4530,12 +4606,12 @@
   EXPECT_EQ(2U, conn->remote_nomination());
 }
 
-TEST_F(P2PTransportChannelPingTest,
+TEST_P(P2PTransportChannelPingTest,
        TestControlledAgentWriteStateTakesHigherPrecedenceThanNomination) {
   rtc::ScopedFakeClock clock;
 
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa);
+  P2PTransportChannel ch("SwitchSelectedConnection", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4574,9 +4650,9 @@
 
 // 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_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithAddressReuse) {
+TEST_P(P2PTransportChannelPingTest, TestAddRemoteCandidateWithAddressReuse) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("candidate reuse", 1, &pa);
+  P2PTransportChannel ch("candidate reuse", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
   const std::string host_address = "1.1.1.1";
@@ -4612,11 +4688,11 @@
 
 // When the current selected connection is strong, lower-priority connections
 // will be pruned. Otherwise, lower-priority connections are kept.
-TEST_F(P2PTransportChannelPingTest, TestDontPruneWhenWeak) {
+TEST_P(P2PTransportChannelPingTest, TestDontPruneWhenWeak) {
   rtc::ScopedFakeClock clock;
   clock.AdvanceTime(webrtc::TimeDelta::Seconds(1));
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test channel", 1, &pa);
+  P2PTransportChannel ch("test channel", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4649,10 +4725,10 @@
   EXPECT_FALSE(conn3->pruned());
 }
 
-TEST_F(P2PTransportChannelPingTest, TestDontPruneHighPriorityConnections) {
+TEST_P(P2PTransportChannelPingTest, TestDontPruneHighPriorityConnections) {
   rtc::ScopedFakeClock clock;
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test channel", 1, &pa);
+  P2PTransportChannel ch("test channel", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4672,11 +4748,11 @@
 }
 
 // Test that GetState returns the state correctly.
-TEST_F(P2PTransportChannelPingTest, TestGetState) {
+TEST_P(P2PTransportChannelPingTest, TestGetState) {
   rtc::ScopedFakeClock clock;
   clock.AdvanceTime(webrtc::TimeDelta::Seconds(1));
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test channel", 1, &pa);
+  P2PTransportChannel ch("test channel", 1, &pa, &field_trials_);
   EXPECT_EQ(webrtc::IceTransportState::kNew, ch.GetIceTransportState());
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
@@ -4712,12 +4788,12 @@
 
 // Test that when a low-priority connection is pruned, it is not deleted
 // right away, and it can become active and be pruned again.
-TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) {
+TEST_P(P2PTransportChannelPingTest, TestConnectionPrunedAgain) {
   rtc::ScopedFakeClock clock;
   clock.AdvanceTime(webrtc::TimeDelta::Seconds(1));
 
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test channel", 1, &pa);
+  P2PTransportChannel ch("test channel", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   IceConfig config = CreateIceConfig(1000, GATHER_ONCE);
   config.receiving_switching_delay = 800;
@@ -4764,10 +4840,10 @@
 
 // Test that if all connections in a channel has timed out on writing, they
 // will all be deleted. We use Prune to simulate write_time_out.
-TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) {
+TEST_P(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) {
   rtc::ScopedFakeClock clock;
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test channel", 1, &pa);
+  P2PTransportChannel ch("test channel", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
   // Have one connection only but later becomes write-time-out.
@@ -4797,9 +4873,9 @@
 // when a new connection becomes writable and receiving. Also tests that if a
 // connection belonging to an old session becomes writable, it won't stop
 // the current port allocator session.
-TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) {
+TEST_P(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test channel", 1, &pa);
+  P2PTransportChannel ch("test channel", 1, &pa, &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceConfig(CreateIceConfig(2000, GATHER_ONCE));
   ch.MaybeStartGathering();
@@ -4830,9 +4906,10 @@
 // Test that the ICE role is updated even on ports that has been removed.
 // These ports may still have connections that need a correct role, in case that
 // the connections on it may still receive stun pings.
-TEST_F(P2PTransportChannelPingTest, TestIceRoleUpdatedOnRemovedPort) {
+TEST_P(P2PTransportChannelPingTest, TestIceRoleUpdatedOnRemovedPort) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa);
+  P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa,
+                         &field_trials_);
   // Starts with ICEROLE_CONTROLLING.
   PrepareChannel(&ch);
   IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY);
@@ -4855,9 +4932,10 @@
 // These ports may still have connections that need a correct role, for the
 // pings sent by those connections until they're replaced by newer-generation
 // connections.
-TEST_F(P2PTransportChannelPingTest, TestIceRoleUpdatedOnPortAfterIceRestart) {
+TEST_P(P2PTransportChannelPingTest, TestIceRoleUpdatedOnPortAfterIceRestart) {
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa);
+  P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa,
+                         &field_trials_);
   // Starts with ICEROLE_CONTROLLING.
   PrepareChannel(&ch);
   ch.MaybeStartGathering();
@@ -4877,11 +4955,12 @@
 // Test that after some amount of time without receiving data, the connection
 // will be destroyed. The port will only be destroyed after it is marked as
 // "pruned."
-TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) {
+TEST_P(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) {
   rtc::ScopedFakeClock fake_clock;
 
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
-  P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa);
+  P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa,
+                         &field_trials_);
   PrepareChannel(&ch);
   ch.SetIceRole(ICEROLE_CONTROLLED);
   ch.MaybeStartGathering();
@@ -4906,9 +4985,9 @@
   EXPECT_EQ_SIMULATED_WAIT(nullptr, GetPrunedPort(&ch), 1, fake_clock);
 }
 
-TEST_F(P2PTransportChannelPingTest, TestMaxOutstandingPingsFieldTrial) {
+TEST_P(P2PTransportChannelPingTest, TestMaxOutstandingPingsFieldTrial) {
   webrtc::test::ScopedKeyValueConfig field_trials(
-      "WebRTC-IceFieldTrials/max_outstanding_pings:3/");
+      field_trials_, "WebRTC-IceFieldTrials/max_outstanding_pings:3/");
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
   P2PTransportChannel ch("max", 1, &pa, &field_trials);
   ch.SetIceConfig(ch.config());
@@ -4989,13 +5068,21 @@
   std::unique_ptr<P2PTransportChannel> channel_;
 };
 
+INSTANTIATE_TEST_SUITE_P(Legacy,
+                         P2PTransportChannelMostLikelyToWorkFirstTest,
+                         Values(""));
+INSTANTIATE_TEST_SUITE_P(Active,
+                         P2PTransportChannelMostLikelyToWorkFirstTest,
+                         Values("WebRTC-UseActiveIceController/Enabled/"));
+
 // Test that Relay/Relay connections will be pinged first when no other
 // connections have been pinged yet, unless we need to ping a trigger check or
 // we have a selected connection.
-TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest,
+TEST_P(P2PTransportChannelMostLikelyToWorkFirstTest,
        TestRelayRelayFirstWhenNothingPingedYet) {
   const int max_strong_interval = 500;
-  P2PTransportChannel& ch = StartTransportChannel(true, max_strong_interval);
+  P2PTransportChannel& ch =
+      StartTransportChannel(true, max_strong_interval, &field_trials_);
   EXPECT_TRUE_WAIT(ch.ports().size() == 2, kDefaultTimeout);
   EXPECT_EQ(ch.ports()[0]->Type(), LOCAL_PORT_TYPE);
   EXPECT_EQ(ch.ports()[1]->Type(), RELAY_PORT_TYPE);
@@ -5052,9 +5139,9 @@
 // Test that Relay/Relay connections will be pinged first when everything has
 // been pinged even if the Relay/Relay connection wasn't the first to be pinged
 // in the first round.
-TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest,
+TEST_P(P2PTransportChannelMostLikelyToWorkFirstTest,
        TestRelayRelayFirstWhenEverythingPinged) {
-  P2PTransportChannel& ch = StartTransportChannel(true, 500);
+  P2PTransportChannel& ch = StartTransportChannel(true, 500, &field_trials_);
   EXPECT_TRUE_WAIT(ch.ports().size() == 2, kDefaultTimeout);
   EXPECT_EQ(ch.ports()[0]->Type(), LOCAL_PORT_TYPE);
   EXPECT_EQ(ch.ports()[1]->Type(), RELAY_PORT_TYPE);
@@ -5083,9 +5170,9 @@
 
 // Test that when we receive a new remote candidate, they will be tried first
 // before we re-ping Relay/Relay connections again.
-TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest,
+TEST_P(P2PTransportChannelMostLikelyToWorkFirstTest,
        TestNoStarvationOnNonRelayConnection) {
-  P2PTransportChannel& ch = StartTransportChannel(true, 500);
+  P2PTransportChannel& ch = StartTransportChannel(true, 500, &field_trials_);
   EXPECT_TRUE_WAIT(ch.ports().size() == 2, kDefaultTimeout);
   EXPECT_EQ(ch.ports()[0]->Type(), LOCAL_PORT_TYPE);
   EXPECT_EQ(ch.ports()[1]->Type(), RELAY_PORT_TYPE);
@@ -5116,9 +5203,10 @@
 
 // Test skip_relay_to_non_relay_connections field-trial.
 // I.e that we never create connection between relay and non-relay.
-TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest,
+TEST_P(P2PTransportChannelMostLikelyToWorkFirstTest,
        TestSkipRelayToNonRelayConnectionsFieldTrial) {
   webrtc::test::ScopedKeyValueConfig field_trials(
+      field_trials_,
       "WebRTC-IceFieldTrials/skip_relay_to_non_relay_connections:true/");
   P2PTransportChannel& ch = StartTransportChannel(true, 500, &field_trials);
   EXPECT_TRUE_WAIT(ch.ports().size() == 2, kDefaultTimeout);
@@ -5136,7 +5224,7 @@
 
 // Test the ping sequence is UDP Relay/Relay followed by TCP Relay/Relay,
 // followed by the rest.
-TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, TestTcpTurn) {
+TEST_P(P2PTransportChannelMostLikelyToWorkFirstTest, TestTcpTurn) {
   // Add a Tcp Turn server.
   turn_server()->AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP);
   RelayServerConfig config;
@@ -5144,7 +5232,7 @@
   config.ports.push_back(ProtocolAddress(kTurnTcpIntAddr, PROTO_TCP));
   allocator()->AddTurnServer(config);
 
-  P2PTransportChannel& ch = StartTransportChannel(true, 500);
+  P2PTransportChannel& ch = StartTransportChannel(true, 500, &field_trials_);
   EXPECT_TRUE_WAIT(ch.ports().size() == 3, kDefaultTimeout);
   EXPECT_EQ(ch.ports()[0]->Type(), LOCAL_PORT_TYPE);
   EXPECT_EQ(ch.ports()[1]->Type(), RELAY_PORT_TYPE);
@@ -5165,19 +5253,28 @@
   VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE);
 }
 
+class P2PTransportChannelResolverTest : public TestWithParam<std::string> {};
+
+INSTANTIATE_TEST_SUITE_P(Legacy, P2PTransportChannelResolverTest, Values(""));
+INSTANTIATE_TEST_SUITE_P(Active,
+                         P2PTransportChannelResolverTest,
+                         Values("WebRTC-UseActiveIceController/Enabled/"));
+
 // Test that a resolver is created, asked for a result, and destroyed
 // when the address is a hostname. The destruction should happen even
 // if the channel is not destroyed.
-TEST(P2PTransportChannelResolverTest, HostnameCandidateIsResolved) {
+TEST_P(P2PTransportChannelResolverTest, HostnameCandidateIsResolved) {
   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());
   webrtc::IceTransportInit init;
   init.set_port_allocator(&allocator);
   init.set_async_dns_resolver_factory(&resolver_fixture);
+  init.set_field_trials(&field_trials);
   auto channel = P2PTransportChannel::Create("tn", 0, std::move(init));
   Candidate hostname_candidate;
   SocketAddress hostname_address("fake.test", 1000);
@@ -5193,7 +5290,7 @@
 // discovers a prflx remote candidate with the same underlying IP address, the
 // prflx candidate is updated to a host candidate after the name resolution is
 // done.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        PeerReflexiveCandidateBeforeSignalingWithMdnsName) {
   // ep1 and ep2 will only gather host candidates with addresses
   // kPublicAddrs[0] and kPublicAddrs[1], respectively.
@@ -5248,7 +5345,7 @@
 // resolution for a remote hostname candidate, we update the prflx candidate to
 // a host candidate if the hostname candidate turns out to have the same IP
 // address after the resolution completes.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        PeerReflexiveCandidateDuringResolvingHostCandidateWithMdnsName) {
   ResolverFactoryFixture resolver_fixture;
   // Prevent resolution until triggered by FireDelayedResolution.
@@ -5309,7 +5406,8 @@
 // Test that if we only gather and signal a host candidate, the IP address of
 // which is obfuscated by an mDNS name, and if the peer can complete the name
 // resolution with the correct IP address, we can have a p2p connection.
-TEST_F(P2PTransportChannelTest, CanConnectWithHostCandidateWithMdnsName) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       CanConnectWithHostCandidateWithMdnsName) {
   ResolverFactoryFixture resolver_fixture;
 
   // ep1 and ep2 will only gather host candidates with addresses
@@ -5357,7 +5455,7 @@
 // same endpoint. Also, the remote ICE endpoint that successfully resolves a
 // signaled host candidate with an mDNS name should not reveal the address of
 // this remote host candidate in stats.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        CandidatesSanitizedInStatsWhenMdnsObfuscationEnabled) {
   ResolverFactoryFixture resolver_fixture;
 
@@ -5443,7 +5541,7 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        ConnectingIncreasesSelectedCandidatePairChanges) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
@@ -5464,7 +5562,7 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        DisconnectedIncreasesSelectedCandidatePairChanges) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
@@ -5495,7 +5593,7 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        NewSelectionIncreasesSelectedCandidatePairChanges) {
   rtc::ScopedFakeClock clock;
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
@@ -5535,7 +5633,7 @@
 
 // A similar test as above to check the selected candidate pair is sanitized
 // when it is queried via GetSelectedCandidatePair.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        SelectedCandidatePairSanitizedWhenMdnsObfuscationEnabled) {
   ResolverFactoryFixture resolver_fixture;
 
@@ -5582,7 +5680,7 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        NoPairOfLocalRelayCandidateWithRemoteMdnsCandidate) {
   const int kOnlyRelayPorts = cricket::PORTALLOCATOR_DISABLE_UDP |
                               cricket::PORTALLOCATOR_DISABLE_STUN |
@@ -5648,7 +5746,7 @@
               (override));
 };
 
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        SrflxCandidateCanBeGatheredBeforeMdnsCandidateToCreateConnection) {
   // ep1 and ep2 will only gather host and srflx candidates with base addresses
   // kPublicAddrs[0] and kPublicAddrs[1], respectively, and we use a shared
@@ -5689,7 +5787,7 @@
 // restart the other types of candidates that are now enabled and form candidate
 // pairs. Also, we verify that the relay candidates gathered previously are not
 // removed and are still usable for necessary route switching.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        SurfaceHostCandidateOnCandidateFilterChangeFromRelayToAll) {
   rtc::ScopedFakeClock clock;
 
@@ -5755,7 +5853,7 @@
 // A similar test as SurfaceHostCandidateOnCandidateFilterChangeFromRelayToAll,
 // and we should surface server-reflexive candidates that are enabled after
 // changing the candidate filter.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        SurfaceSrflxCandidateOnCandidateFilterChangeFromRelayToNoHost) {
   rtc::ScopedFakeClock clock;
   // We need an actual NAT so that the host candidate is not equivalent to the
@@ -5824,7 +5922,7 @@
 // gathering continually we only gather once, which makes the config
 // `surface_ice_candidates_on_ice_transport_type_changed` ineffective after the
 // gathering stopped.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        CannotSurfaceTheNewlyAllowedOnFilterChangeIfNotGatheringContinually) {
   rtc::ScopedFakeClock clock;
 
@@ -5861,7 +5959,7 @@
 // Test that when the candidate filter is updated to be more restrictive,
 // candidates that 1) have already been gathered and signaled 2) but no longer
 // match the filter, are not removed.
-TEST_F(P2PTransportChannelTest,
+TEST_P(P2PTransportChannelTestWithFieldTrials,
        RestrictingCandidateFilterDoesNotRemoveRegatheredCandidates) {
   rtc::ScopedFakeClock clock;
 
@@ -5932,7 +6030,7 @@
 //
 // i.e surface_ice_candidates_on_ice_transport_type_changed requires
 // coordination outside of webrtc to function properly.
-TEST_F(P2PTransportChannelTest, SurfaceRequiresCoordination) {
+TEST_P(P2PTransportChannelTestWithFieldTrials, SurfaceRequiresCoordination) {
   webrtc::test::ScopedKeyValueConfig field_trials(
       field_trials_,
       "WebRTC-IceFieldTrials/skip_relay_to_non_relay_connections:true/");
@@ -5997,9 +6095,9 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening0) {
+TEST_P(P2PTransportChannelPingTest, TestInitialSelectDampening0) {
   webrtc::test::ScopedKeyValueConfig field_trials(
-      "WebRTC-IceFieldTrials/initial_select_dampening:0/");
+      field_trials_, "WebRTC-IceFieldTrials/initial_select_dampening:0/");
 
   constexpr int kMargin = 10;
   rtc::ScopedFakeClock clock;
@@ -6021,9 +6119,9 @@
   EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), kMargin, clock);
 }
 
-TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening) {
+TEST_P(P2PTransportChannelPingTest, TestInitialSelectDampening) {
   webrtc::test::ScopedKeyValueConfig field_trials(
-      "WebRTC-IceFieldTrials/initial_select_dampening:100/");
+      field_trials_, "WebRTC-IceFieldTrials/initial_select_dampening:100/");
 
   constexpr int kMargin = 10;
   rtc::ScopedFakeClock clock;
@@ -6045,8 +6143,9 @@
   EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), 2 * kMargin, clock);
 }
 
-TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningPingReceived) {
+TEST_P(P2PTransportChannelPingTest, TestInitialSelectDampeningPingReceived) {
   webrtc::test::ScopedKeyValueConfig field_trials(
+      field_trials_,
       "WebRTC-IceFieldTrials/initial_select_dampening_ping_received:100/");
 
   constexpr int kMargin = 10;
@@ -6070,8 +6169,9 @@
   EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), 2 * kMargin, clock);
 }
 
-TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningBoth) {
+TEST_P(P2PTransportChannelPingTest, TestInitialSelectDampeningBoth) {
   webrtc::test::ScopedKeyValueConfig field_trials(
+      field_trials_,
       "WebRTC-IceFieldTrials/"
       "initial_select_dampening:100,initial_select_dampening_ping_received:"
       "50/");
@@ -6098,17 +6198,29 @@
   EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), 2 * kMargin, clock);
 }
 
-TEST(P2PTransportChannel, InjectIceController) {
+class P2PTransportChannelIceControllerTest : public TestWithParam<std::string> {
+};
+
+INSTANTIATE_TEST_SUITE_P(Legacy,
+                         P2PTransportChannelIceControllerTest,
+                         Values(""));
+INSTANTIATE_TEST_SUITE_P(Active,
+                         P2PTransportChannelIceControllerTest,
+                         Values("WebRTC-UseActiveIceController/Enabled/"));
+
+TEST_P(P2PTransportChannelIceControllerTest, InjectIceController) {
   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());
   EXPECT_CALL(factory, RecordIceControllerCreated()).Times(1);
   webrtc::IceTransportInit init;
   init.set_port_allocator(&pa);
   init.set_ice_controller_factory(&factory);
+  init.set_field_trials(&field_trials);
   auto dummy =
       P2PTransportChannel::Create("transport_name",
                                   /* component= */ 77, std::move(init));
@@ -6174,12 +6286,13 @@
   ForgetLearnedStateController* controller_;
 };
 
-TEST_F(P2PTransportChannelPingTest, TestForgetLearnedState) {
+TEST_P(P2PTransportChannelPingTest, TestForgetLearnedState) {
   ForgetLearnedStateControllerFactory factory;
   FakePortAllocator pa(rtc::Thread::Current(), packet_socket_factory());
   webrtc::IceTransportInit init;
   init.set_port_allocator(&pa);
   init.set_ice_controller_factory(&factory);
+  init.set_field_trials(&field_trials_);
   auto ch =
       P2PTransportChannel::Create("ping sufficiently", 1, std::move(init));
 
@@ -6210,7 +6323,8 @@
   EXPECT_EQ_WAIT(false, conn2->writable(), kMediumTimeout);
 }
 
-TEST_F(P2PTransportChannelTest, DisableDnsLookupsWithTransportPolicyRelay) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       DisableDnsLookupsWithTransportPolicyRelay) {
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
   auto* ep1 = GetEndpoint(0);
@@ -6236,7 +6350,8 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelTest, DisableDnsLookupsWithTransportPolicyNone) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       DisableDnsLookupsWithTransportPolicyNone) {
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
   auto* ep1 = GetEndpoint(0);
@@ -6262,7 +6377,8 @@
   DestroyChannels();
 }
 
-TEST_F(P2PTransportChannelTest, EnableDnsLookupsWithTransportPolicyNoHost) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       EnableDnsLookupsWithTransportPolicyNoHost) {
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
                      kDefaultPortAllocatorFlags);
   auto* ep1 = GetEndpoint(0);
@@ -6291,11 +6407,16 @@
   DestroyChannels();
 }
 
-class GatherAfterConnectedTest : public P2PTransportChannelTest,
-                                 public ::testing::WithParamInterface<bool> {};
+class GatherAfterConnectedTest
+    : public P2PTransportChannelTest,
+      public WithParamInterface<std::tuple<bool, std::string>> {
+ public:
+  GatherAfterConnectedTest()
+      : P2PTransportChannelTest(std::get<1>(GetParam())) {}
+};
 
 TEST_P(GatherAfterConnectedTest, GatherAfterConnected) {
-  const bool stop_gather_on_strongly_connected = GetParam();
+  const bool stop_gather_on_strongly_connected = std::get<0>(GetParam());
   const std::string field_trial =
       std::string("WebRTC-IceFieldTrials/stop_gather_on_strongly_connected:") +
       (stop_gather_on_strongly_connected ? "true/" : "false/");
@@ -6356,7 +6477,7 @@
 }
 
 TEST_P(GatherAfterConnectedTest, GatherAfterConnectedMultiHomed) {
-  const bool stop_gather_on_strongly_connected = GetParam();
+  const bool stop_gather_on_strongly_connected = std::get<0>(GetParam());
   const std::string field_trial =
       std::string("WebRTC-IceFieldTrials/stop_gather_on_strongly_connected:") +
       (stop_gather_on_strongly_connected ? "true/" : "false/");
@@ -6417,13 +6538,19 @@
   }
 }
 
-INSTANTIATE_TEST_SUITE_P(GatherAfterConnectedTest,
+INSTANTIATE_TEST_SUITE_P(Legacy,
                          GatherAfterConnectedTest,
-                         ::testing::Values(true, false));
+                         Combine(Values(true, false), Values("")));
+INSTANTIATE_TEST_SUITE_P(
+    Active,
+    GatherAfterConnectedTest,
+    Combine(Values(true, false),
+            Values("WebRTC-UseActiveIceController/Enabled/")));
 
 // Tests no candidates are generated with old ice ufrag/passwd after an ice
 // restart even if continual gathering is enabled.
-TEST_F(P2PTransportChannelTest, TestIceNoOldCandidatesAfterIceRestart) {
+TEST_P(P2PTransportChannelTestWithFieldTrials,
+       TestIceNoOldCandidatesAfterIceRestart) {
   rtc::ScopedFakeClock clock;
   AddAddress(0, kAlternateAddrs[0]);
   ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,