In SimulcastTest pass field trials explicitly, bypassing global field trials

Bug: webrtc:10335
Change-Id: I0593002acb23cd8d9577eec640b3d64a116b067b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/347520
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42065}
diff --git a/video/config/BUILD.gn b/video/config/BUILD.gn
index b20e119..2ced656 100644
--- a/video/config/BUILD.gn
+++ b/video/config/BUILD.gn
@@ -77,10 +77,9 @@
     ]
     deps = [
       ":streams_config",
-      "../../api/transport:field_trial_based_config",
       "../../call/adaptation:resource_adaptation",
       "../../media:media_constants",
-      "../../test:field_trial",
+      "../../test:explicit_key_value_config",
       "../../test:test_support",
     ]
     absl_deps = [
diff --git a/video/config/simulcast_unittest.cc b/video/config/simulcast_unittest.cc
index e518d9b..e9d24e8 100644
--- a/video/config/simulcast_unittest.cc
+++ b/video/config/simulcast_unittest.cc
@@ -10,13 +10,15 @@
 
 #include "video/config/simulcast.h"
 
-#include "api/transport/field_trial_based_config.h"
 #include "media/base/media_constants.h"
-#include "test/field_trial.h"
+#include "test/explicit_key_value_config.h"
 #include "test/gtest.h"
 
 namespace webrtc {
 namespace {
+
+using test::ExplicitKeyValueConfig;
+
 constexpr int kQpMax = 55;
 constexpr double kBitratePriority = 2.0;
 constexpr bool kScreenshare = true;
@@ -79,8 +81,9 @@
 }
 
 TEST(SimulcastTest, GetConfig) {
+  const ExplicitKeyValueConfig trials("");
+
   const std::vector<VideoStream> kExpected = GetSimulcastBitrates720p();
-  const FieldTrialBasedConfig trials;
 
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 3;
@@ -112,9 +115,8 @@
 }
 
 TEST(SimulcastTest, GetConfigWithBaseHeavyVP8TL3RateAllocation) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-UseBaseHeavyVP8TL3RateAllocation/Enabled/");
-  FieldTrialBasedConfig trials;
 
   const std::vector<VideoStream> kExpected = GetSimulcastBitrates720p();
 
@@ -137,9 +139,10 @@
 }
 
 TEST(SimulcastTest, GetConfigWithLimitedMaxLayers) {
+  ExplicitKeyValueConfig trials("");
+
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 2;
-  FieldTrialBasedConfig trials;
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
       kMinLayers, kMaxLayers, 1280, 720, kBitratePriority, kQpMax,
       !kScreenshare, true, trials, webrtc::kVideoCodecVP8);
@@ -152,9 +155,9 @@
 }
 
 TEST(SimulcastTest, GetConfigWithLimitedMaxLayersForResolution) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-LegacySimulcastLayerLimit/Enabled/");
-  FieldTrialBasedConfig trials;
+
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 3;
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
@@ -169,9 +172,9 @@
 }
 
 TEST(SimulcastTest, GetConfigWithLowResolutionScreenshare) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-LegacySimulcastLayerLimit/Enabled/");
-  FieldTrialBasedConfig trials;
+
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 3;
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
@@ -184,9 +187,9 @@
 }
 
 TEST(SimulcastTest, GetConfigWithNotLimitedMaxLayersForResolution) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-LegacySimulcastLayerLimit/Disabled/");
-  FieldTrialBasedConfig trials;
+
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 3;
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
@@ -203,7 +206,8 @@
 }
 
 TEST(SimulcastTest, GetConfigWithNormalizedResolution) {
-  FieldTrialBasedConfig trials;
+  ExplicitKeyValueConfig trials("");
+
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 2;
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
@@ -219,9 +223,8 @@
 }
 
 TEST(SimulcastTest, GetConfigWithNormalizedResolutionDivisibleBy4) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-NormalizeSimulcastResolution/Enabled-2/");
-  FieldTrialBasedConfig trials;
 
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 2;
@@ -238,9 +241,8 @@
 }
 
 TEST(SimulcastTest, GetConfigWithNormalizedResolutionDivisibleBy8) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-NormalizeSimulcastResolution/Enabled-3/");
-  FieldTrialBasedConfig trials;
 
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 2;
@@ -257,9 +259,8 @@
 }
 
 TEST(SimulcastTest, GetConfigForLegacyLayerLimit) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-LegacySimulcastLayerLimit/Enabled/");
-  FieldTrialBasedConfig trials;
 
   const size_t kMinLayers = 1;
   const int kMaxLayers = 3;
@@ -280,9 +281,8 @@
 }
 
 TEST(SimulcastTest, GetConfigForLegacyLayerLimitWithRequiredHD) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-LegacySimulcastLayerLimit/Enabled/");
-  FieldTrialBasedConfig trials;
 
   const size_t kMinLayers = 3;  // "HD" layer must be present!
   const int kMaxLayers = 3;
@@ -303,7 +303,7 @@
 }
 
 TEST(SimulcastTest, GetConfigForScreenshareSimulcast) {
-  FieldTrialBasedConfig trials;
+  ExplicitKeyValueConfig trials("");
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 3;
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
@@ -325,7 +325,7 @@
 }
 
 TEST(SimulcastTest, GetConfigForScreenshareSimulcastWithLimitedMaxLayers) {
-  FieldTrialBasedConfig trials;
+  ExplicitKeyValueConfig trials("");
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 1;
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
@@ -336,7 +336,7 @@
 }
 
 TEST(SimulcastTest, AveragesBitratesForNonStandardResolution) {
-  FieldTrialBasedConfig trials;
+  ExplicitKeyValueConfig trials("");
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 3;
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
@@ -352,13 +352,14 @@
 }
 
 TEST(SimulcastTest, BitratesForCloseToStandardResolution) {
+  ExplicitKeyValueConfig trials("");
+
   const size_t kMinLayers = 1;
   const size_t kMaxLayers = 3;
   // Resolution very close to 720p in number of pixels
   const size_t kWidth = 1280;
   const size_t kHeight = 716;
   const std::vector<VideoStream> kExpectedNear = GetSimulcastBitrates720p();
-  FieldTrialBasedConfig trials;
 
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
       kMinLayers, kMaxLayers, kWidth, kHeight, kBitratePriority, kQpMax,
@@ -378,9 +379,9 @@
 }
 
 TEST(SimulcastTest, MaxLayersWithRoundUpDisabled) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.0/");
-  FieldTrialBasedConfig trials;
+
   const size_t kMinLayers = 1;
   const int kMaxLayers = 3;
 
@@ -407,7 +408,7 @@
 
 TEST(SimulcastTest, MaxLayersWithDefaultRoundUpRatio) {
   // Default: "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.1/"
-  FieldTrialBasedConfig trials;
+  ExplicitKeyValueConfig trials("");
   const size_t kMinLayers = 1;
   const int kMaxLayers = 3;
 
@@ -441,9 +442,9 @@
 }
 
 TEST(SimulcastTest, MaxLayersWithRoundUpRatio) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.13/");
-  FieldTrialBasedConfig trials;
+
   const size_t kMinLayers = 1;
   const int kMaxLayers = 3;
 
@@ -465,12 +466,10 @@
 
 TEST(SimulcastTest, BitratesInterpolatedForResBelow180p) {
   // TODO(webrtc:12415): Remove when feature launches.
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-LowresSimulcastBitrateInterpolation/Enabled/");
 
   const size_t kMaxLayers = 3;
-  FieldTrialBasedConfig trials;
-
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
       /* min_layers = */ 1, kMaxLayers, /* width = */ 960, /* height = */ 540,
       kBitratePriority, kQpMax, !kScreenshare, true, trials,
@@ -486,11 +485,9 @@
 
 TEST(SimulcastTest, BitratesConsistentForVerySmallRes) {
   // TODO(webrtc:12415): Remove when feature launches.
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-LowresSimulcastBitrateInterpolation/Enabled/");
 
-  FieldTrialBasedConfig trials;
-
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
       /* min_layers = */ 1, /* max_layers = */ 3, /* width = */ 1,
       /* height = */ 1, kBitratePriority, kQpMax, !kScreenshare, true, trials,
@@ -506,12 +503,10 @@
 
 TEST(SimulcastTest,
      BitratesNotInterpolatedForResBelow180pWhenDisabledTrialSet) {
-  test::ScopedFieldTrials field_trials(
+  ExplicitKeyValueConfig trials(
       "WebRTC-LowresSimulcastBitrateInterpolation/Disabled/");
 
   const size_t kMaxLayers = 3;
-  FieldTrialBasedConfig trials;
-
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
       /* min_layers = */ 1, kMaxLayers, /* width = */ 960, /* height = */ 540,
       kBitratePriority, kQpMax, !kScreenshare, true, trials,
@@ -526,9 +521,9 @@
 }
 
 TEST(SimulcastTest, BitratesBasedOnCodec) {
-  const size_t kMaxLayers = 3;
-  FieldTrialBasedConfig trials;
+  ExplicitKeyValueConfig trials("");
 
+  const size_t kMaxLayers = 3;
   std::vector<VideoStream> streams_vp8 = cricket::GetSimulcastConfig(
       /* min_layers = */ 1, /* max_layers = */ 3, /* width = */ 1280,
       /* height = */ 720, kBitratePriority, kQpMax, !kScreenshare, true, trials,
@@ -561,8 +556,9 @@
 }
 
 TEST(SimulcastTest, BitratesForVP9) {
+  ExplicitKeyValueConfig trials("");
+
   const size_t kMaxLayers = 3;
-  FieldTrialBasedConfig trials;
 
   std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
       /* min_layers = */ 1, kMaxLayers, /* width = */ 1280, /* height = */ 720,