Deprecate FieldTrials::CreateNoGlobal
FieldTrials are always no global now, there is no longer need to stress
that in the factory name.
Depending on the context, this function can be replace either with
std::make_unique<FieldTrials>, FieldTrials::Create, or, in WebRTC
unittests with CreateTestFieldTrials
Bug: webrtc:419453427
Change-Id: I1bcdbb699f46a9d259ece5800eec37882fa3a936
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/398440
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45045}
diff --git a/api/field_trials.h b/api/field_trials.h
index 4937b50..09aa1dc 100644
--- a/api/field_trials.h
+++ b/api/field_trials.h
@@ -70,8 +70,8 @@
// Setting empty `group` is valid and removes the `trial`.
void Set(absl::string_view trial, absl::string_view group);
- // TODO: bugs.webrtc.org/42220378 - Deprecate and inline once no longer used
- // within webrtc.
+ // TODO: bugs.webrtc.org/42220378 - Delete after August 1, 2025.
+ [[deprecated]]
static std::unique_ptr<FieldTrials> CreateNoGlobal(absl::string_view s) {
return std::make_unique<FieldTrials>(s);
}
diff --git a/api/voip/BUILD.gn b/api/voip/BUILD.gn
index 36d2e71..b0ae871 100644
--- a/api/voip/BUILD.gn
+++ b/api/voip/BUILD.gn
@@ -72,6 +72,7 @@
"../../modules/audio_device:mock_audio_device",
"../../modules/audio_processing:mocks",
"../../test:audio_codec_mocks",
+ "../../test:create_test_field_trials",
"../../test:test_support",
"../environment:environment_factory",
]
diff --git a/api/voip/test/voip_engine_factory_unittest.cc b/api/voip/test/voip_engine_factory_unittest.cc
index 557dfd9..07ae9db 100644
--- a/api/voip/test/voip_engine_factory_unittest.cc
+++ b/api/voip/test/voip_engine_factory_unittest.cc
@@ -14,10 +14,10 @@
#include <utility>
#include "api/environment/environment_factory.h"
-#include "api/field_trials.h"
#include "api/make_ref_counted.h"
#include "modules/audio_device/include/mock_audio_device.h"
#include "modules/audio_processing/include/mock_audio_processing.h"
+#include "test/create_test_field_trials.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/mock_audio_decoder_factory.h"
@@ -33,7 +33,7 @@
VoipEngineConfig config;
config.encoder_factory = make_ref_counted<MockAudioEncoderFactory>();
config.decoder_factory = make_ref_counted<MockAudioDecoderFactory>();
- config.env = CreateEnvironment(FieldTrials::CreateNoGlobal(""));
+ config.env = CreateEnvironment(CreateTestFieldTrialsPtr());
config.audio_processing_builder =
std::make_unique<NiceMock<test::MockAudioProcessingBuilder>>();
config.audio_device_module = test::MockAudioDeviceModule::CreateNice();
diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn
index f0824fe..090fbd4 100644
--- a/modules/audio_processing/agc/BUILD.gn
+++ b/modules/audio_processing/agc/BUILD.gn
@@ -119,6 +119,7 @@
"../../../rtc_base:safe_minmax",
"../../../rtc_base:stringutils",
"../../../system_wrappers:metrics",
+ "../../../test:create_test_field_trials",
"../../../test:fileutils",
"../../../test:test_support",
"//testing/gtest",
diff --git a/modules/audio_processing/agc/agc_manager_direct_unittest.cc b/modules/audio_processing/agc/agc_manager_direct_unittest.cc
index 49c8c78..742472d 100644
--- a/modules/audio_processing/agc/agc_manager_direct_unittest.cc
+++ b/modules/audio_processing/agc/agc_manager_direct_unittest.cc
@@ -26,7 +26,6 @@
#include "api/audio/audio_processing.h"
#include "api/environment/environment.h"
#include "api/environment/environment_factory.h"
-#include "api/field_trials.h"
#include "modules/audio_processing/agc/agc.h"
#include "modules/audio_processing/agc/gain_control.h"
#include "modules/audio_processing/agc/mock_agc.h"
@@ -34,6 +33,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/numerics/safe_minmax.h"
#include "rtc_base/strings/string_builder.h"
+#include "test/create_test_field_trials.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
@@ -105,8 +105,7 @@
std::unique_ptr<AgcManagerDirect> CreateAgcManagerDirect(
AgcManagerDirectTestParams p = {}) {
auto manager = std::make_unique<AgcManagerDirect>(
- CreateEnvironment(FieldTrials::CreateNoGlobal(p.field_trials)),
- kNumChannels,
+ CreateEnvironment(CreateTestFieldTrialsPtr(p.field_trials)), kNumChannels,
AnalogAgcConfig{.startup_min_volume = kInitialInputVolume,
.clipped_level_min = p.clipped_level_min,
.enable_digital_adaptive = p.enable_digital_adaptive,
@@ -459,7 +458,7 @@
: public ::testing::TestWithParam<std::tuple<std::optional<int>, bool>> {
protected:
AgcManagerDirectParametrizedTest()
- : env_(CreateEnvironment(FieldTrials::CreateNoGlobal(
+ : env_(CreateEnvironment(CreateTestFieldTrialsPtr(
GetAgcMinMicLevelExperimentFieldTrial(std::get<0>(GetParam()))))) {}
bool IsMinMicLevelOverridden() const {
diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc
index 5a20773..cf8494a 100644
--- a/p2p/base/p2p_transport_channel_unittest.cc
+++ b/p2p/base/p2p_transport_channel_unittest.cc
@@ -96,6 +96,7 @@
#include "rtc_base/time_utils.h"
#include "rtc_base/virtual_socket_server.h"
#include "system_wrappers/include/metrics.h"
+#include "test/create_test_field_trials.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/wait_until.h"
@@ -1304,7 +1305,7 @@
#define P2P_TEST_DECLARATION(x, y, z) \
TEST_P(P2PTransportChannelMatrixTest, z##Test##x##To##y) { \
const Environment env = \
- CreateEnvironment(FieldTrials::CreateNoGlobal(GetParam())); \
+ CreateEnvironment(CreateTestFieldTrialsPtr(GetParam())); \
ConfigureEndpoints(env, x, y, PORTALLOCATOR_ENABLE_SHARED_SOCKET, \
PORTALLOCATOR_ENABLE_SHARED_SOCKET); \
if (kMatrix[x][y] != NULL) \
@@ -2568,7 +2569,7 @@
TEST_F(P2PTransportChannelTest,
CanConnectWithPiggybackCheckAcknowledgementWhenCheckResponseBlocked) {
ScopedFakeClock clock;
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-PiggybackIceCheckAcknowledgement/Enabled/"));
ConfigureEndpoints(env, OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts);
IceConfig ep1_config;
@@ -4617,7 +4618,7 @@
// that sends a ping directly when a connection has been nominated
// i.e on the ICE_CONTROLLED-side.
TEST_F(P2PTransportChannelPingTest, TestPingOnNomination) {
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/send_ping_on_nomination_ice_controlled:true/"));
FakePortAllocator pa(env, ss());
P2PTransportChannel ch("receiving state change", 1, &pa, &env.field_trials());
@@ -4663,7 +4664,7 @@
// that sends a ping directly when switching to a new connection
// on the ICE_CONTROLLING-side.
TEST_F(P2PTransportChannelPingTest, TestPingOnSwitch) {
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/send_ping_on_switch_ice_controlling:true/"));
FakePortAllocator pa(env, ss());
P2PTransportChannel ch("receiving state change", 1, &pa, &env.field_trials());
@@ -4706,7 +4707,7 @@
// that sends a ping directly when selecteing a new connection
// on the ICE_CONTROLLING-side (i.e also initial selection).
TEST_F(P2PTransportChannelPingTest, TestPingOnSelected) {
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/send_ping_on_selected_ice_controlling:true/"));
FakePortAllocator pa(env, ss());
P2PTransportChannel ch("receiving state change", 1, &pa, &env.field_trials());
@@ -5570,7 +5571,7 @@
}
TEST_F(P2PTransportChannelPingTest, TestMaxOutstandingPingsFieldTrial) {
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/max_outstanding_pings:3/"));
FakePortAllocator pa(env, ss());
P2PTransportChannel ch("max", 1, &pa, &env.field_trials());
@@ -5831,7 +5832,7 @@
// I.e that we never create connection between relay and non-relay.
TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest,
TestSkipRelayToNonRelayConnectionsFieldTrial) {
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/skip_relay_to_non_relay_connections:true/"));
CreatePortAllocator(env);
P2PTransportChannel& ch = StartTransportChannel(env, true, 500);
@@ -6818,7 +6819,7 @@
// coordination outside of webrtc to function properly.
TEST_F(P2PTransportChannelTest, SurfaceRequiresCoordination) {
ScopedFakeClock clock;
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/skip_relay_to_non_relay_connections:true/"));
ConfigureEndpoints(
@@ -6898,7 +6899,7 @@
constexpr int kMargin = 10;
ScopedFakeClock clock;
clock.AdvanceTime(TimeDelta::Seconds(1));
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/initial_select_dampening:0/"));
FakePortAllocator pa(env, ss());
@@ -6925,7 +6926,7 @@
constexpr int kMargin = 10;
ScopedFakeClock clock;
clock.AdvanceTime(TimeDelta::Seconds(1));
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/initial_select_dampening:100/"));
FakePortAllocator pa(env, ss());
@@ -6952,7 +6953,7 @@
constexpr int kMargin = 10;
ScopedFakeClock clock;
clock.AdvanceTime(TimeDelta::Seconds(1));
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/initial_select_dampening_ping_received:100/"));
FakePortAllocator pa(env, ss());
@@ -6980,7 +6981,7 @@
constexpr int kMargin = 10;
ScopedFakeClock clock;
clock.AdvanceTime(TimeDelta::Seconds(1));
- const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal(
+ const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr(
"WebRTC-IceFieldTrials/"
"initial_select_dampening:100,initial_select_dampening_ping_received:"
"50/"));
@@ -7339,7 +7340,7 @@
ScopedFakeClock clock;
const Environment env =
- CreateEnvironment(FieldTrials::CreateNoGlobal(field_trial));
+ CreateEnvironment(CreateTestFieldTrialsPtr(field_trial));
// Use local + relay
constexpr uint32_t flags =
kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET |
@@ -7419,7 +7420,7 @@
ScopedFakeClock clock;
const Environment env =
- CreateEnvironment(FieldTrials::CreateNoGlobal(field_trial));
+ CreateEnvironment(CreateTestFieldTrialsPtr(field_trial));
// Use local + relay
constexpr uint32_t flags =
diff --git a/p2p/dtls/dtls_ice_integrationtest.cc b/p2p/dtls/dtls_ice_integrationtest.cc
index 536b89e..2d539e2 100644
--- a/p2p/dtls/dtls_ice_integrationtest.cc
+++ b/p2p/dtls/dtls_ice_integrationtest.cc
@@ -48,6 +48,7 @@
#include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread.h"
#include "rtc_base/virtual_socket_server.h"
+#include "test/create_test_field_trials.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/wait_until.h"
@@ -81,7 +82,7 @@
private:
struct Endpoint {
explicit Endpoint(bool dtls_in_stun, bool pqc_)
- : env(CreateEnvironment(FieldTrials::CreateNoGlobal(
+ : env(CreateEnvironment(CreateTestFieldTrialsPtr(
dtls_in_stun ? "WebRTC-IceHandshakeDtls/Enabled/" : ""))),
dtls_stun_piggyback(dtls_in_stun),
pqc(pqc_) {}
diff --git a/pc/sdp_munging_detector_unittest.cc b/pc/sdp_munging_detector_unittest.cc
index 5fa585c..ef09634 100644
--- a/pc/sdp_munging_detector_unittest.cc
+++ b/pc/sdp_munging_detector_unittest.cc
@@ -27,7 +27,6 @@
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h"
-#include "api/field_trials.h"
#include "api/jsep.h"
#include "api/media_types.h"
#include "api/peer_connection_interface.h"
@@ -208,67 +207,63 @@
TEST_F(SdpMungingTest, AllowWithDenyListForRollout) {
// Don't munge and you are good.
EXPECT_TRUE(IsSdpMungingAllowed(SdpMungingType::kNoModification,
- *FieldTrials::CreateNoGlobal("")));
+ CreateTestFieldTrials()));
// Empty string (default) means everything is allowed from the perspective of
// the trial.
EXPECT_TRUE(IsSdpMungingAllowed(SdpMungingType::kUnknownModification,
- *FieldTrials::CreateNoGlobal("")));
+ CreateTestFieldTrials()));
// Deny list is set, modification on deny list is rejected.
EXPECT_FALSE(IsSdpMungingAllowed(
SdpMungingType::kUnknownModification /*=1*/,
- *FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleReject/Enabled,1/")));
+ CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1/")));
// Deny list is set, modification not on deny list is allowed.
EXPECT_TRUE(IsSdpMungingAllowed(
SdpMungingType::kWithoutCreateAnswer /*=2*/,
- *FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleReject/Enabled,1/")));
+ CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1/")));
// Split by comma.
EXPECT_FALSE(IsSdpMungingAllowed(
SdpMungingType::kUnknownModification /*=1*/,
- *FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleReject/Enabled,1,2/")));
+ CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1,2/")));
EXPECT_FALSE(IsSdpMungingAllowed(
SdpMungingType::kWithoutCreateAnswer /*=2*/,
- *FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleReject/Enabled,1,2/")));
+ CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1,2/")));
EXPECT_TRUE(IsSdpMungingAllowed(
SdpMungingType::kWithoutCreateOffer /*=3*/,
- *FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleReject/Enabled,1,2,4/")));
+ CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1,2,4/")));
}
TEST_F(SdpMungingTest, DenyWithAllowListForTesting) {
// Don't munge and you are good.
EXPECT_TRUE(IsSdpMungingAllowed(SdpMungingType::kNoModification,
- *FieldTrials::CreateNoGlobal("")));
+ CreateTestFieldTrials()));
// Empty string (default) means everything is allowed from the perspective of
// the trial.
EXPECT_TRUE(IsSdpMungingAllowed(SdpMungingType::kUnknownModification,
- *FieldTrials::CreateNoGlobal("")));
+ CreateTestFieldTrials()));
// Allow-list is set, modification is on allow list.
- EXPECT_TRUE(
- IsSdpMungingAllowed(SdpMungingType::kUnknownModification /*=1*/,
- *FieldTrials::CreateNoGlobal(
- "WebRTC-NoSdpMangleAllowForTesting/Enabled,1/")));
+ EXPECT_TRUE(IsSdpMungingAllowed(
+ SdpMungingType::kUnknownModification /*=1*/,
+ CreateTestFieldTrials("WebRTC-NoSdpMangleAllowForTesting/Enabled,1/")));
// Allow-list is set, modification is not on allow list.
- EXPECT_FALSE(
- IsSdpMungingAllowed(SdpMungingType::kWithoutCreateAnswer /*=2*/,
- *FieldTrials::CreateNoGlobal(
- "WebRTC-NoSdpMangleAllowForTesting/Enabled,1/")));
+ EXPECT_FALSE(IsSdpMungingAllowed(
+ SdpMungingType::kWithoutCreateAnswer /*=2*/,
+ CreateTestFieldTrials("WebRTC-NoSdpMangleAllowForTesting/Enabled,1/")));
// Split by comma.
EXPECT_TRUE(IsSdpMungingAllowed(
SdpMungingType::kUnknownModification /*=1*/,
- *FieldTrials::CreateNoGlobal(
- "WebRTC-NoSdpMangleAllowForTesting/Enabled,1,2/")));
+ CreateTestFieldTrials("WebRTC-NoSdpMangleAllowForTesting/Enabled,1,2/")));
EXPECT_TRUE(IsSdpMungingAllowed(
SdpMungingType::kWithoutCreateAnswer /*=2*/,
- *FieldTrials::CreateNoGlobal(
- "WebRTC-NoSdpMangleAllowForTesting/Enabled,1,2/")));
+ CreateTestFieldTrials("WebRTC-NoSdpMangleAllowForTesting/Enabled,1,2/")));
EXPECT_FALSE(IsSdpMungingAllowed(
SdpMungingType::kWithoutCreateOffer /*=3*/,
- *FieldTrials::CreateNoGlobal(
+ CreateTestFieldTrials(
"WebRTC-NoSdpMangleAllowForTesting/Enabled,1,2,4/")));
}