Cleanup VideoQualityTest api and usage

Allow to configure field trials before construction.
Pass InjectedComponents by value, thus avoiding need to worry about nullptr special case
Remove TestDependencyFactory as unused: custom components are provided through InjectedComponents
Update VideoQualityTest tests to propagate field trials without relying on the global field trial string

Bug: webrtc:419453427
Change-Id: I64f239c5406d3f9f552b09bf38c85dfeef93c951
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/396581
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#44954}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 346e1fe..706c48d 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -719,20 +719,6 @@
       ]
     }
 
-    rtc_library("test_dependency_factory") {
-      visibility = [ "*" ]
-      testonly = true
-      sources = [
-        "test/test_dependency_factory.cc",
-        "test/test_dependency_factory.h",
-      ]
-      deps = [
-        ":video_quality_test_fixture_api",
-        "../rtc_base:checks",
-        "../rtc_base:platform_thread_types",
-      ]
-    }
-
     rtc_library("create_video_quality_test_fixture_api") {
       visibility = [ "*" ]
       testonly = true
@@ -741,9 +727,6 @@
         "test/create_video_quality_test_fixture.h",
       ]
       deps = [
-        ":fec_controller_api",
-        ":network_state_predictor_api",
-        ":scoped_refptr",
         ":video_quality_test_fixture_api",
         "../video:video_quality_test",
       ]
diff --git a/api/DEPS b/api/DEPS
index 0e5b280..be22215 100644
--- a/api/DEPS
+++ b/api/DEPS
@@ -207,10 +207,6 @@
     "+rtc_base/thread_annotations.h",
   ],
 
-  "test_dependency_factory\.h": [
-    "+rtc_base/thread_checker.h",
-  ],
-
   "time_controller\.h": [
     "+rtc_base/thread.h",
   ],
diff --git a/api/test/compile_all_headers.cc b/api/test/compile_all_headers.cc
index ca586b3..2254a85 100644
--- a/api/test/compile_all_headers.cc
+++ b/api/test/compile_all_headers.cc
@@ -23,7 +23,6 @@
 // "api/test/neteq_simulator.h"
 // "api/test/simulated_network.h"
 // "api/test/simulcast_test_fixture.h"
-// "api/test/test_dependency_factory.h"
 // "api/test/videocodec_test_fixture.h"
 // "api/test/videocodec_test_stats.h"
 
diff --git a/api/test/create_video_quality_test_fixture.cc b/api/test/create_video_quality_test_fixture.cc
index 1cfe228..f393c11 100644
--- a/api/test/create_video_quality_test_fixture.cc
+++ b/api/test/create_video_quality_test_fixture.cc
@@ -13,30 +13,23 @@
 #include <memory>
 #include <utility>
 
-#include "api/fec_controller.h"
 #include "api/test/video_quality_test_fixture.h"
 #include "video/video_quality_test.h"
 
 namespace webrtc {
 
-std::unique_ptr<VideoQualityTestFixtureInterface>
-CreateVideoQualityTestFixture() {
-  // By default, we don't override the FEC module, so pass an empty factory.
-  return std::make_unique<VideoQualityTest>(nullptr);
-}
-
 std::unique_ptr<VideoQualityTestFixtureInterface> CreateVideoQualityTestFixture(
-    std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory) {
-  auto components =
-      std::make_unique<VideoQualityTestFixtureInterface::InjectionComponents>();
-  components->fec_controller_factory = std::move(fec_controller_factory);
+    VideoQualityTestFixtureInterface::InjectionComponents components) {
   return std::make_unique<VideoQualityTest>(std::move(components));
 }
 
 std::unique_ptr<VideoQualityTestFixtureInterface> CreateVideoQualityTestFixture(
     std::unique_ptr<VideoQualityTestFixtureInterface::InjectionComponents>
         components) {
-  return std::make_unique<VideoQualityTest>(std::move(components));
+  if (components == nullptr) {
+    return CreateVideoQualityTestFixture();
+  }
+  return CreateVideoQualityTestFixture(std::move(*components));
 }
 
 }  // namespace webrtc
diff --git a/api/test/create_video_quality_test_fixture.h b/api/test/create_video_quality_test_fixture.h
index ed618fe..ea6b3a5 100644
--- a/api/test/create_video_quality_test_fixture.h
+++ b/api/test/create_video_quality_test_fixture.h
@@ -12,17 +12,14 @@
 
 #include <memory>
 
-#include "api/fec_controller.h"
 #include "api/test/video_quality_test_fixture.h"
 
 namespace webrtc {
 
-std::unique_ptr<VideoQualityTestFixtureInterface>
-CreateVideoQualityTestFixture();
-
 std::unique_ptr<VideoQualityTestFixtureInterface> CreateVideoQualityTestFixture(
-    std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory);
+    VideoQualityTestFixtureInterface::InjectionComponents components = {});
 
+[[deprecated]]
 std::unique_ptr<VideoQualityTestFixtureInterface> CreateVideoQualityTestFixture(
     std::unique_ptr<VideoQualityTestFixtureInterface::InjectionComponents>
         components);
diff --git a/api/test/test_dependency_factory.cc b/api/test/test_dependency_factory.cc
deleted file mode 100644
index 4ed18d4..0000000
--- a/api/test/test_dependency_factory.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "api/test/test_dependency_factory.h"
-
-#include <memory>
-#include <utility>
-
-#include "api/test/video_quality_test_fixture.h"
-#include "rtc_base/checks.h"
-#include "rtc_base/platform_thread_types.h"
-
-namespace webrtc {
-
-namespace {
-// This checks everything in this file gets called on the same thread. It's
-// static because it needs to look at the static methods too.
-bool IsValidTestDependencyFactoryThread() {
-  const PlatformThreadRef main_thread = CurrentThreadRef();
-  return IsThreadRefEqual(main_thread, CurrentThreadRef());
-}
-}  // namespace
-
-std::unique_ptr<TestDependencyFactory> TestDependencyFactory::instance_ =
-    nullptr;
-
-const TestDependencyFactory& TestDependencyFactory::GetInstance() {
-  RTC_DCHECK(IsValidTestDependencyFactoryThread());
-  if (instance_ == nullptr) {
-    instance_ = std::make_unique<TestDependencyFactory>();
-  }
-  return *instance_;
-}
-
-void TestDependencyFactory::SetInstance(
-    std::unique_ptr<TestDependencyFactory> instance) {
-  RTC_DCHECK(IsValidTestDependencyFactoryThread());
-  RTC_CHECK(instance_ == nullptr);
-  instance_ = std::move(instance);
-}
-
-std::unique_ptr<VideoQualityTestFixtureInterface::InjectionComponents>
-TestDependencyFactory::CreateComponents() const {
-  RTC_DCHECK(IsValidTestDependencyFactoryThread());
-  return nullptr;
-}
-
-}  // namespace webrtc
diff --git a/api/test/test_dependency_factory.h b/api/test/test_dependency_factory.h
deleted file mode 100644
index 29f00b8..0000000
--- a/api/test/test_dependency_factory.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef API_TEST_TEST_DEPENDENCY_FACTORY_H_
-#define API_TEST_TEST_DEPENDENCY_FACTORY_H_
-
-#include <memory>
-
-#include "api/test/video_quality_test_fixture.h"
-
-namespace webrtc {
-
-// Override this class if to inject custom components into WebRTC tests.
-// Not all WebRTC tests get their components from here, so you need to make
-// sure the tests you want actually use this class.
-//
-// This class is not thread safe and you need to make call calls from the same
-// (test main) thread.
-class TestDependencyFactory {
- public:
-  virtual ~TestDependencyFactory() = default;
-
-  // The singleton MUST be stateless since tests execute in any order. It must
-  // be set before tests start executing.
-  static const TestDependencyFactory& GetInstance();
-  static void SetInstance(std::unique_ptr<TestDependencyFactory> instance);
-
-  // Returns the component a test should use. Returning nullptr means that the
-  // test is free to use whatever defaults it wants. The injection components
-  // themselves can be mutable, but we need to make new ones for every test that
-  // executes so state doesn't spread between tests.
-  virtual std::unique_ptr<VideoQualityTestFixtureInterface::InjectionComponents>
-  CreateComponents() const;
-
- private:
-  static std::unique_ptr<TestDependencyFactory> instance_;
-};
-
-}  // namespace webrtc
-
-#endif  // API_TEST_TEST_DEPENDENCY_FACTORY_H_
diff --git a/api/test/video_quality_test_fixture.h b/api/test/video_quality_test_fixture.h
index 8d84cbe..c0454a6 100644
--- a/api/test/video_quality_test_fixture.h
+++ b/api/test/video_quality_test_fixture.h
@@ -117,15 +117,13 @@
   // Contains objects, that will be injected on different layers of test
   // framework to override the behavior of system parts.
   struct InjectionComponents {
-    InjectionComponents();
-    ~InjectionComponents();
-
     // Simulations of sender and receiver networks. They must either both be
     // null (in which case `config` from Params is used), or both be non-null
     // (in which case `config` from Params must be nullopt).
     std::unique_ptr<NetworkBehaviorInterface> sender_network;
     std::unique_ptr<NetworkBehaviorInterface> receiver_network;
 
+    std::string field_trials;
     std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
     std::unique_ptr<VideoEncoderFactory> video_encoder_factory;
     std::unique_ptr<VideoDecoderFactory> video_decoder_factory;
diff --git a/test/BUILD.gn b/test/BUILD.gn
index dc2fcb7..61c5673 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -1374,9 +1374,9 @@
       "../rtc_base:threading",
       "../rtc_base:timeutils",
       "../system_wrappers",
-      "../system_wrappers:field_trial",
       "../video/config:encoder_config",
       "//third_party/abseil-cpp/absl/flags:flag",
+      "//third_party/abseil-cpp/absl/strings:string_view",
     ]
     if (!is_android && !build_with_chromium) {
       deps += [ "../modules/video_capture:video_capture_internal_impl" ]
diff --git a/test/call_test.cc b/test/call_test.cc
index 685ba45..9f6f5b9 100644
--- a/test/call_test.cc
+++ b/test/call_test.cc
@@ -20,6 +20,7 @@
 #include <utility>
 #include <vector>
 
+#include "absl/strings/string_view.h"
 #include "api/audio/audio_device.h"
 #include "api/audio/builtin_audio_processing_builder.h"
 #include "api/audio_codecs/audio_decoder_factory.h"
@@ -71,8 +72,9 @@
 namespace webrtc {
 namespace test {
 
-CallTest::CallTest()
-    : env_(CreateEnvironment(&field_trials_)),
+CallTest::CallTest(absl::string_view field_trials)
+    : field_trials_(field_trials),
+      env_(CreateEnvironment(&field_trials_)),
       send_env_(env_),
       recv_env_(env_),
       audio_send_config_(/*send_transport=*/nullptr),
diff --git a/test/call_test.h b/test/call_test.h
index 1a2fdbd..d8cae8c 100644
--- a/test/call_test.h
+++ b/test/call_test.h
@@ -18,6 +18,7 @@
 #include <string>
 #include <vector>
 
+#include "absl/strings/string_view.h"
 #include "api/array_view.h"
 #include "api/audio/audio_device.h"
 #include "api/audio/audio_processing.h"
@@ -68,7 +69,7 @@
 
 class CallTest : public ::testing::Test, public RtpPacketSinkInterface {
  public:
-  CallTest();
+  explicit CallTest(absl::string_view field_trials = "");
   virtual ~CallTest();
 
   static const std::map<uint8_t, MediaType> payload_type_map_;
diff --git a/video/BUILD.gn b/video/BUILD.gn
index a0a8dd2..af02a74 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -577,7 +577,6 @@
         "../api/audio:builtin_audio_processing_builder",
         "../api/audio:create_audio_device_module",
         "../api/environment",
-        "../api/environment:environment_factory",
         "../api/numerics",
         "../api/rtc_event_log",
         "../api/rtc_event_log:rtc_event_log_factory",
@@ -667,22 +666,14 @@
         ":video_quality_test",
         "../api:rtp_parameters",
         "../api:simulated_network_api",
-        "../api:test_dependency_factory",
         "../api:video_quality_test_fixture_api",
         "../api/units:data_rate",
         "../api/video_codecs:video_codecs_api",
-        "../modules/pacing",
         "../modules/video_coding:webrtc_vp9",
-        "../rtc_base/experiments:alr_experiment",
-        "../system_wrappers:field_trial",
-        "../test:field_trial",
         "../test:fileutils",
-        "../test:test_common",
         "../test:test_support",
-        "../video/config:encoder_config",
-        "//testing/gtest",
+        "config:encoder_config",
         "//third_party/abseil-cpp/absl/flags:flag",
-        "//third_party/abseil-cpp/absl/flags:parse",
       ]
     }
 
diff --git a/video/full_stack_tests.cc b/video/full_stack_tests.cc
index 6ae6e6e..d3bbf70 100644
--- a/video/full_stack_tests.cc
+++ b/video/full_stack_tests.cc
@@ -7,16 +7,13 @@
  *  in the file PATENTS.  All contributing project authors may
  *  be found in the AUTHORS file in the root of the source tree.
  */
-#include <memory>
 #include <optional>
 #include <string>
-#include <utility>
 #include <vector>
 
 #include "absl/flags/flag.h"
 #include "api/rtp_parameters.h"
 #include "api/test/simulated_network.h"
-#include "api/test/test_dependency_factory.h"
 #include "api/test/video_quality_test_fixture.h"
 #include "api/units/data_rate.h"
 #include "api/video_codecs/sdp_video_format.h"
@@ -24,8 +21,6 @@
 #include "api/video_codecs/video_codec.h"
 #include "api/video_codecs/vp9_profile.h"
 #include "modules/video_coding/codecs/vp9/include/vp9.h"
-#include "system_wrappers/include/field_trial.h"
-#include "test/field_trial.h"
 #include "test/gtest.h"
 #include "test/testsupport/file_utils.h"
 #include "video/config/video_encoder_config.h"
@@ -62,19 +57,6 @@
   }
 };
 
-std::unique_ptr<VideoQualityTestFixtureInterface>
-CreateVideoQualityTestFixture() {
-  // The components will normally be nullptr (= use defaults), but it's possible
-  // for external test runners to override the list of injected components.
-  auto components = TestDependencyFactory::GetInstance().CreateComponents();
-  return std::make_unique<VideoQualityTest>(std::move(components));
-}
-
-// Takes the current active field trials set, and appends some new trials.
-std::string AppendFieldTrials(std::string new_trial_string) {
-  return std::string(field_trial::GetFieldTrialString()) + new_trial_string;
-}
-
 std::string ClipNameToClipPath(const char* clip_name) {
   return test::ResourcePath(clip_name, "yuv");
 }
@@ -92,7 +74,7 @@
 
 #if defined(RTC_ENABLE_VP9)
 TEST(FullStackTest, Foreman_Cif_Net_Delay_0_0_Plr_0_VP9) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -102,12 +84,12 @@
       false,  false,  true,   ClipNameToClipPath("foreman_cif")};
   foreman_cif.analyzer = {"foreman_cif_net_delay_0_0_plr_0_VP9", 0.0, 0.0,
                           kFullStackTestDurationSecs};
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(GenericDescriptorTest,
      Foreman_Cif_Delay_50_0_Plr_5_VP9_Generic_Descriptor) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -120,7 +102,7 @@
   foreman_cif.config->loss_percent = 5;
   foreman_cif.config->queue_delay_ms = 50;
   foreman_cif.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Generator_Net_Delay_0_0_Plr_0_VP9Profile2) {
@@ -135,7 +117,7 @@
   }
   if (!profile_2_is_supported)
     return;
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
 
   CodecParameterMap vp92 = {
       {kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile2)}};
@@ -146,7 +128,7 @@
       1,    0,   0,   false, false,  true,   "GeneratorI010", 0,     vp92};
   generator.analyzer = {"generator_net_delay_0_0_plr_0_VP9Profile2", 0.0, 0.0,
                         kFullStackTestDurationSecs};
-  fixture->RunWithAnalyzer(generator);
+  fixture.RunWithAnalyzer(generator);
 }
 
 #endif  // defined(RTC_ENABLE_VP9)
@@ -158,7 +140,7 @@
 #define MAYBE_Net_Delay_0_0_Plr_0 Net_Delay_0_0_Plr_0
 #endif
 TEST(FullStackTest, MAYBE_Net_Delay_0_0_Plr_0) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging paris_qcif;
   paris_qcif.call.send_side_bwe = true;
   paris_qcif.video[0] = {
@@ -168,12 +150,12 @@
       false,  false,  true,   ClipNameToClipPath("paris_qcif")};
   paris_qcif.analyzer = {"net_delay_0_0_plr_0", 36.0, 0.96,
                          kFullStackTestDurationSecs};
-  fixture->RunWithAnalyzer(paris_qcif);
+  fixture.RunWithAnalyzer(paris_qcif);
 }
 
 TEST(GenericDescriptorTest,
      Foreman_Cif_Net_Delay_0_0_Plr_0_Generic_Descriptor) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   // TODO(pbos): Decide on psnr/ssim thresholds for foreman_cif.
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
@@ -185,12 +167,12 @@
   foreman_cif.analyzer = {"foreman_cif_net_delay_0_0_plr_0_generic_descriptor",
                           0.0, 0.0, kFullStackTestDurationSecs};
   foreman_cif.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(GenericDescriptorTest,
      Foreman_Cif_30kbps_Net_Delay_0_0_Plr_0_Generic_Descriptor) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -202,12 +184,12 @@
       "foreman_cif_30kbps_net_delay_0_0_plr_0_generic_descriptor", 0.0, 0.0,
       kFullStackTestDurationSecs};
   foreman_cif.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 // Link capacity below default start rate.
 TEST(FullStackTest, Foreman_Cif_Link_150kbps_Net_Delay_0_0_Plr_0) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -218,13 +200,13 @@
   foreman_cif.analyzer = {"foreman_cif_link_150kbps_net_delay_0_0_plr_0", 0.0,
                           0.0, kFullStackTestDurationSecs};
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(150);
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 // Restricted network and encoder overproducing by 30%.
 TEST(FullStackTest,
      Foreman_Cif_Link_150kbps_Delay100ms_30pkts_Queue_Overshoot30) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -239,7 +221,7 @@
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(150);
   foreman_cif.config->queue_length_packets = 30;
   foreman_cif.config->queue_delay_ms = 100;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 // Weak 3G-style link: 250kbps, 1% loss, 100ms delay, 15 packets queue.
@@ -247,7 +229,7 @@
 // This triggers protection overhead to toggle between zero and non-zero.
 // Link queue is restrictive enough to trigger loss on probes.
 TEST(FullStackTest, Foreman_Cif_Link_250kbps_Delay100ms_10pkts_Loss1) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -262,11 +244,11 @@
   foreman_cif.config->queue_length_packets = 10;
   foreman_cif.config->queue_delay_ms = 100;
   foreman_cif.config->loss_percent = 1;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(GenericDescriptorTest, Foreman_Cif_Delay_50_0_Plr_5_Generic_Descriptor) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -279,12 +261,12 @@
   foreman_cif.config->loss_percent = 5;
   foreman_cif.config->queue_delay_ms = 50;
   foreman_cif.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(GenericDescriptorTest,
      Foreman_Cif_Delay_50_0_Plr_5_Ulpfec_Generic_Descriptor) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -298,11 +280,11 @@
   foreman_cif.config->loss_percent = 5;
   foreman_cif.config->queue_delay_ms = 50;
   foreman_cif.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Foreman_Cif_Delay_50_0_Plr_5_Flexfec) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -314,11 +296,11 @@
                           kFullStackTestDurationSecs};
   foreman_cif.config->loss_percent = 5;
   foreman_cif.config->queue_delay_ms = 50;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Foreman_Cif_500kbps_Delay_50_0_Plr_3_Flexfec) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -331,11 +313,11 @@
   foreman_cif.config->loss_percent = 3;
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(500);
   foreman_cif.config->queue_delay_ms = 50;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Foreman_Cif_500kbps_Delay_50_0_Plr_3_Ulpfec) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -348,12 +330,12 @@
   foreman_cif.config->loss_percent = 3;
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(500);
   foreman_cif.config->queue_delay_ms = 50;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 #if defined(WEBRTC_USE_H264)
 TEST(FullStackTest, Foreman_Cif_Net_Delay_0_0_Plr_0_H264) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   // TODO(pbos): Decide on psnr/ssim thresholds for foreman_cif.
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
@@ -364,11 +346,11 @@
       false,  false,  true,   ClipNameToClipPath("foreman_cif")};
   foreman_cif.analyzer = {"foreman_cif_net_delay_0_0_plr_0_H264", 0.0, 0.0,
                           kFullStackTestDurationSecs};
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Foreman_Cif_30kbps_Net_Delay_0_0_Plr_0_H264) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -378,12 +360,12 @@
       false,  false, true,  ClipNameToClipPath("foreman_cif")};
   foreman_cif.analyzer = {"foreman_cif_30kbps_net_delay_0_0_plr_0_H264", 0.0,
                           0.0, kFullStackTestDurationSecs};
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(GenericDescriptorTest,
      Foreman_Cif_Delay_50_0_Plr_5_H264_Generic_Descriptor) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -397,13 +379,12 @@
   foreman_cif.config->loss_percent = 5;
   foreman_cif.config->queue_delay_ms = 50;
   foreman_cif.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Foreman_Cif_Delay_50_0_Plr_5_H264_Sps_Pps_Idr) {
-  test::ScopedFieldTrials override_field_trials(
-      AppendFieldTrials("WebRTC-SpsPpsIdrIsH264Keyframe/Enabled/"));
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture(
+      {.field_trials = "WebRTC-SpsPpsIdrIsH264Keyframe/Enabled/"});
 
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
@@ -416,12 +397,12 @@
                           0.0, kFullStackTestDurationSecs};
   foreman_cif.config->loss_percent = 5;
   foreman_cif.config->queue_delay_ms = 50;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 // Verify that this is worth the bot time, before enabling.
 TEST(FullStackTest, Foreman_Cif_Delay_50_0_Plr_5_H264_Flexfec) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -433,13 +414,13 @@
                           kFullStackTestDurationSecs};
   foreman_cif.config->loss_percent = 5;
   foreman_cif.config->queue_delay_ms = 50;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 // Ulpfec with H264 is an unsupported combination, so this test is only useful
 // for debugging. It is therefore disabled by default.
 TEST(FullStackTest, DISABLED_Foreman_Cif_Delay_50_0_Plr_5_H264_Ulpfec) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -451,12 +432,12 @@
                           kFullStackTestDurationSecs};
   foreman_cif.config->loss_percent = 5;
   foreman_cif.config->queue_delay_ms = 50;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 #endif  // defined(WEBRTC_USE_H264)
 
 TEST(FullStackTest, Foreman_Cif_500kbps) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -469,11 +450,11 @@
   foreman_cif.config->queue_length_packets = 0;
   foreman_cif.config->queue_delay_ms = 0;
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(500);
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Foreman_Cif_500kbps_32pkts_Queue) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -486,11 +467,11 @@
   foreman_cif.config->queue_length_packets = 32;
   foreman_cif.config->queue_delay_ms = 0;
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(500);
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Foreman_Cif_500kbps_100ms) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -503,12 +484,12 @@
   foreman_cif.config->queue_length_packets = 0;
   foreman_cif.config->queue_delay_ms = 100;
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(500);
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(GenericDescriptorTest,
      Foreman_Cif_500kbps_100ms_32pkts_Queue_Generic_Descriptor) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -523,11 +504,11 @@
   foreman_cif.config->queue_delay_ms = 100;
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(500);
   foreman_cif.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Foreman_Cif_500kbps_100ms_32pkts_Queue_Recv_Bwe) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = false;
   foreman_cif.video[0] = {
@@ -540,11 +521,11 @@
   foreman_cif.config->queue_length_packets = 32;
   foreman_cif.config->queue_delay_ms = 100;
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(500);
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Foreman_Cif_1000kbps_100ms_32pkts_Queue) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {
@@ -557,12 +538,12 @@
   foreman_cif.config->queue_length_packets = 32;
   foreman_cif.config->queue_delay_ms = 100;
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(1000);
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 // TODO(sprang): Remove this if we have the similar ModerateLimits below?
 TEST(FullStackTest, Conference_Motion_Hd_2000kbps_100ms_32pkts_Queue) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging conf_motion_hd;
   conf_motion_hd.call.send_side_bwe = true;
   conf_motion_hd.video[0] = {
@@ -579,12 +560,12 @@
   conf_motion_hd.config->queue_length_packets = 32;
   conf_motion_hd.config->queue_delay_ms = 100;
   conf_motion_hd.config->link_capacity = DataRate::KilobitsPerSec(2000);
-  fixture->RunWithAnalyzer(conf_motion_hd);
+  fixture.RunWithAnalyzer(conf_motion_hd);
 }
 
 TEST(GenericDescriptorTest,
      Conference_Motion_Hd_2tl_Moderate_Limits_Generic_Descriptor) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging conf_motion_hd;
   conf_motion_hd.call.send_side_bwe = true;
   conf_motion_hd.video[0] = {
@@ -604,11 +585,11 @@
   conf_motion_hd.config->queue_delay_ms = 100;
   conf_motion_hd.config->link_capacity = DataRate::KilobitsPerSec(2000);
   conf_motion_hd.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(conf_motion_hd);
+  fixture.RunWithAnalyzer(conf_motion_hd);
 }
 
 TEST(FullStackTest, Conference_Motion_Hd_3tl_Moderate_Limits) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging conf_motion_hd;
   conf_motion_hd.call.send_side_bwe = true;
   conf_motion_hd.video[0] = {
@@ -626,11 +607,11 @@
   conf_motion_hd.config->loss_percent = 3;
   conf_motion_hd.config->queue_delay_ms = 100;
   conf_motion_hd.config->link_capacity = DataRate::KilobitsPerSec(2000);
-  fixture->RunWithAnalyzer(conf_motion_hd);
+  fixture.RunWithAnalyzer(conf_motion_hd);
 }
 
 TEST(FullStackTest, Conference_Motion_Hd_4tl_Moderate_Limits) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging conf_motion_hd;
   conf_motion_hd.call.send_side_bwe = true;
   conf_motion_hd.video[0] = {
@@ -648,11 +629,11 @@
   conf_motion_hd.config->loss_percent = 3;
   conf_motion_hd.config->queue_delay_ms = 100;
   conf_motion_hd.config->link_capacity = DataRate::KilobitsPerSec(2000);
-  fixture->RunWithAnalyzer(conf_motion_hd);
+  fixture.RunWithAnalyzer(conf_motion_hd);
 }
 
 TEST(FullStackTest, Foreman_Cif_30kbps_AV1) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging foreman_cif;
   foreman_cif.call.send_side_bwe = true;
   foreman_cif.video[0] = {.enabled = true,
@@ -670,11 +651,11 @@
                           .test_durations_secs = kFullStackTestDurationSecs};
   foreman_cif.config->link_capacity = DataRate::KilobitsPerSec(30);
   foreman_cif.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(foreman_cif);
+  fixture.RunWithAnalyzer(foreman_cif);
 }
 
 TEST(FullStackTest, Conference_Motion_Hd_3tl_AV1) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging conf_motion_hd;
   conf_motion_hd.call.send_side_bwe = true;
   conf_motion_hd.video[0] = {
@@ -696,7 +677,7 @@
   conf_motion_hd.config->queue_delay_ms = 100;
   conf_motion_hd.config->link_capacity = DataRate::KilobitsPerSec(1000);
   conf_motion_hd.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(conf_motion_hd);
+  fixture.RunWithAnalyzer(conf_motion_hd);
 }
 
 #if defined(WEBRTC_MAC)
@@ -707,7 +688,7 @@
 #define MAYBE_Screenshare_Slides_Simulcast_AV1 Screenshare_Slides_Simulcast_AV1
 #endif
 TEST(FullStackTest, MAYBE_Screenshare_Slides_Simulcast_AV1) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging screenshare;
   screenshare.analyzer = {.test_label = "screenshare_slides_simulcast_AV1",
                           .test_durations_secs = kFullStackTestDurationSecs};
@@ -754,12 +735,12 @@
       .streams = streams,
       .selected_stream = 1,
   };
-  fixture->RunWithAnalyzer(screenshare);
+  fixture.RunWithAnalyzer(screenshare);
 }
 
 #if defined(RTC_ENABLE_VP9)
 TEST(FullStackTest, Conference_Motion_Hd_2000kbps_100ms_32pkts_Queue_Vp9) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging conf_motion_hd;
   conf_motion_hd.call.send_side_bwe = true;
   conf_motion_hd.video[0] = {
@@ -777,12 +758,12 @@
   conf_motion_hd.config->queue_length_packets = 32;
   conf_motion_hd.config->queue_delay_ms = 100;
   conf_motion_hd.config->link_capacity = DataRate::KilobitsPerSec(2000);
-  fixture->RunWithAnalyzer(conf_motion_hd);
+  fixture.RunWithAnalyzer(conf_motion_hd);
 }
 #endif
 
 TEST(FullStackTest, Screenshare_Slides) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging screenshare;
   screenshare.call.send_side_bwe = true;
   screenshare.video[0] = {true,    1850,  1110,  5, 50000, 200000,
@@ -791,13 +772,13 @@
   screenshare.screenshare[0] = {true, false, 10};
   screenshare.analyzer = {"screenshare_slides", 0.0, 0.0,
                           kFullStackTestDurationSecs};
-  fixture->RunWithAnalyzer(screenshare);
+  fixture.RunWithAnalyzer(screenshare);
 }
 
 #if !defined(WEBRTC_MAC) && !defined(WEBRTC_WIN)
 // TODO(bugs.webrtc.org/9840): Investigate why is this test flaky on Win/Mac.
 TEST(FullStackTest, Screenshare_Slides_Simulcast) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging screenshare;
   screenshare.call.send_side_bwe = true;
   screenshare.screenshare[0] = {true, false, 10};
@@ -821,13 +802,13 @@
   screenshare.ss[0] = {
       streams, 1, 1, 0, InterLayerPredMode::kOn, std::vector<SpatialLayer>(),
       false};
-  fixture->RunWithAnalyzer(screenshare);
+  fixture.RunWithAnalyzer(screenshare);
 }
 
 #endif  // !defined(WEBRTC_MAC) && !defined(WEBRTC_WIN)
 
 TEST(FullStackTest, Screenshare_Slides_Scrolling) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging config;
   config.call.send_side_bwe = true;
   config.video[0] = {true,    1850,  1110 / 2, 5, 50000, 200000,
@@ -836,11 +817,11 @@
   config.screenshare[0] = {true, false, 10, 2};
   config.analyzer = {"screenshare_slides_scrolling", 0.0, 0.0,
                      kFullStackTestDurationSecs};
-  fixture->RunWithAnalyzer(config);
+  fixture.RunWithAnalyzer(config);
 }
 
 TEST(GenericDescriptorTest, Screenshare_Slides_Lossy_Net_Generic_Descriptor) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging screenshare;
   screenshare.call.send_side_bwe = true;
   screenshare.video[0] = {true,    1850,  1110,  5, 50000, 200000,
@@ -853,11 +834,11 @@
   screenshare.config->queue_delay_ms = 200;
   screenshare.config->link_capacity = DataRate::KilobitsPerSec(500);
   screenshare.call.generic_descriptor = true;
-  fixture->RunWithAnalyzer(screenshare);
+  fixture.RunWithAnalyzer(screenshare);
 }
 
 TEST(FullStackTest, Screenshare_Slides_Very_Lossy) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging screenshare;
   screenshare.call.send_side_bwe = true;
   screenshare.video[0] = {true,    1850,  1110,  5, 50000, 200000,
@@ -869,11 +850,11 @@
   screenshare.config->loss_percent = 10;
   screenshare.config->queue_delay_ms = 200;
   screenshare.config->link_capacity = DataRate::KilobitsPerSec(500);
-  fixture->RunWithAnalyzer(screenshare);
+  fixture.RunWithAnalyzer(screenshare);
 }
 
 TEST(FullStackTest, Screenshare_Slides_Lossy_Limited) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging screenshare;
   screenshare.call.send_side_bwe = true;
   screenshare.video[0] = {true,    1850,  1110,  5, 50000, 200000,
@@ -886,11 +867,11 @@
   screenshare.config->link_capacity = DataRate::KilobitsPerSec(200);
   screenshare.config->queue_length_packets = 30;
 
-  fixture->RunWithAnalyzer(screenshare);
+  fixture.RunWithAnalyzer(screenshare);
 }
 
 TEST(FullStackTest, Screenshare_Slides_Moderately_Restricted) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging screenshare;
   screenshare.call.send_side_bwe = true;
   screenshare.video[0] = {true,    1850,  1110,  5, 50000, 200000,
@@ -903,7 +884,7 @@
   screenshare.config->link_capacity = DataRate::KilobitsPerSec(1200);
   screenshare.config->queue_length_packets = 30;
 
-  fixture->RunWithAnalyzer(screenshare);
+  fixture.RunWithAnalyzer(screenshare);
 }
 
 // Since ParamsWithLogging::Video is not trivially destructible, we can't
@@ -959,7 +940,7 @@
 #if defined(RTC_ENABLE_VP9)
 
 TEST(FullStackTest, Screenshare_Slides_Vp9_3sl_High_Fps) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging screenshare;
   screenshare.call.send_side_bwe = true;
   screenshare.video[0] = {true,    1850,  1110,  30, 50000, 200000,
@@ -971,16 +952,15 @@
   screenshare.ss[0] = {
       std::vector<VideoStream>(),  0,   3, 2, InterLayerPredMode::kOn,
       std::vector<SpatialLayer>(), true};
-  fixture->RunWithAnalyzer(screenshare);
+  fixture.RunWithAnalyzer(screenshare);
 }
 
 // TODO(http://bugs.webrtc.org/9506): investigate.
 #if !defined(WEBRTC_MAC)
 
 TEST(FullStackTest, Vp9ksvc_3sl_High) {
-  test::ScopedFieldTrials override_trials(
-      AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"));
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture(
+      {.field_trials = "WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"});
   ParamsWithLogging simulcast;
   simulcast.call.send_side_bwe = true;
   simulcast.video[0] = SvcVp9Video();
@@ -989,13 +969,12 @@
   simulcast.ss[0] = {
       std::vector<VideoStream>(),  0,    3, 2, InterLayerPredMode::kOnKeyPic,
       std::vector<SpatialLayer>(), false};
-  fixture->RunWithAnalyzer(simulcast);
+  fixture.RunWithAnalyzer(simulcast);
 }
 
 TEST(FullStackTest, Vp9ksvc_3sl_Low) {
-  test::ScopedFieldTrials override_trials(
-      AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"));
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture(
+      {.field_trials = "WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"});
   ParamsWithLogging simulcast;
   simulcast.call.send_side_bwe = true;
   simulcast.video[0] = SvcVp9Video();
@@ -1004,13 +983,12 @@
   simulcast.ss[0] = {
       std::vector<VideoStream>(),  0,    3, 0, InterLayerPredMode::kOnKeyPic,
       std::vector<SpatialLayer>(), false};
-  fixture->RunWithAnalyzer(simulcast);
+  fixture.RunWithAnalyzer(simulcast);
 }
 
 TEST(FullStackTest, Vp9ksvc_3sl_Low_Bw_Limited) {
-  test::ScopedFieldTrials override_trials(
-      AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"));
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture(
+      {.field_trials = "WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"});
   ParamsWithLogging simulcast;
   simulcast.config->link_capacity = DataRate::KilobitsPerSec(500);
   simulcast.call.send_side_bwe = true;
@@ -1020,13 +998,12 @@
   simulcast.ss[0] = {
       std::vector<VideoStream>(),  0,    3, 0, InterLayerPredMode::kOnKeyPic,
       std::vector<SpatialLayer>(), false};
-  fixture->RunWithAnalyzer(simulcast);
+  fixture.RunWithAnalyzer(simulcast);
 }
 
 TEST(FullStackTest, Vp9ksvc_3sl_Medium_Network_Restricted) {
-  test::ScopedFieldTrials override_trials(
-      AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"));
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture(
+      {.field_trials = "WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"});
   ParamsWithLogging simulcast;
   simulcast.call.send_side_bwe = true;
   simulcast.video[0] = SvcVp9Video();
@@ -1037,14 +1014,13 @@
       std::vector<SpatialLayer>(), false};
   simulcast.config->link_capacity = DataRate::KilobitsPerSec(1000);
   simulcast.config->queue_delay_ms = 100;
-  fixture->RunWithAnalyzer(simulcast);
+  fixture.RunWithAnalyzer(simulcast);
 }
 
 // TODO(webrtc:9722): Remove when experiment is cleaned up.
 TEST(FullStackTest, Vp9ksvc_3sl_Medium_Network_Restricted_Trusted_Rate) {
-  test::ScopedFieldTrials override_trials(
-      AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"));
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture(
+      {.field_trials = "WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/"});
   ParamsWithLogging simulcast;
   simulcast.call.send_side_bwe = true;
   simulcast.video[0] = SvcVp9Video();
@@ -1055,7 +1031,7 @@
       std::vector<SpatialLayer>(), false};
   simulcast.config->link_capacity = DataRate::KilobitsPerSec(1000);
   simulcast.config->queue_delay_ms = 100;
-  fixture->RunWithAnalyzer(simulcast);
+  fixture.RunWithAnalyzer(simulcast);
 }
 #endif  // !defined(WEBRTC_MAC)
 
@@ -1070,7 +1046,9 @@
 #endif
 
 TEST(FullStackTest, MAYBE_Simulcast_HD_High) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture(
+      {.field_trials =
+           "WebRTC-ForceSimulatedOveruseIntervalMs/1000-50000-300/"});
   ParamsWithLogging simulcast;
   simulcast.call.send_side_bwe = true;
   simulcast.video[0] = {true,    1920,  1080,  30,         800000, 2500000,
@@ -1087,13 +1065,11 @@
   simulcast.ss[0] = {
       streams, 2, 1, 0, InterLayerPredMode::kOn, std::vector<SpatialLayer>(),
       true};
-  test::ScopedFieldTrials override_trials(AppendFieldTrials(
-      "WebRTC-ForceSimulatedOveruseIntervalMs/1000-50000-300/"));
-  fixture->RunWithAnalyzer(simulcast);
+  fixture.RunWithAnalyzer(simulcast);
 }
 
 TEST(FullStackTest, Simulcast_Vp8_3sl_High) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging simulcast;
   simulcast.call.send_side_bwe = true;
   simulcast.video[0] = SimulcastVp8VideoHigh();
@@ -1115,11 +1091,11 @@
   simulcast.ss[0] = {
       streams, 2, 1, 0, InterLayerPredMode::kOn, std::vector<SpatialLayer>(),
       false};
-  fixture->RunWithAnalyzer(simulcast);
+  fixture.RunWithAnalyzer(simulcast);
 }
 
 TEST(FullStackTest, Simulcast_Vp8_3sl_Low) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging simulcast;
   simulcast.call.send_side_bwe = true;
   simulcast.video[0] = SimulcastVp8VideoHigh();
@@ -1141,7 +1117,7 @@
   simulcast.ss[0] = {
       streams, 0, 1, 0, InterLayerPredMode::kOn, std::vector<SpatialLayer>(),
       false};
-  fixture->RunWithAnalyzer(simulcast);
+  fixture.RunWithAnalyzer(simulcast);
 }
 
 // This test assumes ideal network conditions with target bandwidth being
@@ -1153,7 +1129,7 @@
 #define MAYBE_High_Bitrate_With_Fake_Codec High_Bitrate_With_Fake_Codec
 #endif  // defined(WEBRTC_ANDROID)
 TEST(FullStackTest, MAYBE_High_Bitrate_With_Fake_Codec) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   const int target_bitrate = 100000000;
   ParamsWithLogging generator;
   generator.call.send_side_bwe = true;
@@ -1178,7 +1154,7 @@
                         "Generator"};
   generator.analyzer = {"high_bitrate_with_fake_codec", 0.0, 0.0,
                         kFullStackTestDurationSecs};
-  fixture->RunWithAnalyzer(generator);
+  fixture.RunWithAnalyzer(generator);
 }
 
 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
@@ -1190,7 +1166,7 @@
 #endif
 
 TEST(FullStackTest, MAYBE_Largeroom_50thumb) {
-  auto fixture = CreateVideoQualityTestFixture();
+  VideoQualityTest fixture;
   ParamsWithLogging large_room;
   large_room.call.send_side_bwe = true;
   large_room.video[0] = SimulcastVp8VideoHigh();
@@ -1213,7 +1189,7 @@
   large_room.ss[0] = {
       streams, 2, 1, 0, InterLayerPredMode::kOn, std::vector<SpatialLayer>(),
       false};
-  fixture->RunWithAnalyzer(large_room);
+  fixture.RunWithAnalyzer(large_room);
 }
 
 }  // namespace webrtc
diff --git a/video/screenshare_loopback.cc b/video/screenshare_loopback.cc
index a0bf6e9..cc78ee9 100644
--- a/video/screenshare_loopback.cc
+++ b/video/screenshare_loopback.cc
@@ -10,7 +10,6 @@
 
 #include <stdio.h>
 
-#include <memory>
 #include <optional>
 #include <string>
 #include <vector>
@@ -367,7 +366,7 @@
   SL_descriptors.push_back(SL0());
   SL_descriptors.push_back(SL1());
 
-  VideoQualityTest fixture(nullptr);
+  VideoQualityTest fixture;
   fixture.FillScalabilitySettings(
       &params, 0, stream_descriptors, NumStreams(), SelectedStream(),
       NumSpatialLayers(), SelectedSL(), InterLayerPred(), SL_descriptors);
diff --git a/video/sv_loopback.cc b/video/sv_loopback.cc
index 4e9e3c0..8f0f457 100644
--- a/video/sv_loopback.cc
+++ b/video/sv_loopback.cc
@@ -10,7 +10,6 @@
 
 #include <stdio.h>
 
-#include <memory>
 #include <optional>
 #include <string>
 #include <vector>
@@ -666,7 +665,7 @@
     params.ss[screenshare_idx].infer_streams = true;
   }
 
-  VideoQualityTest fixture(nullptr);
+  VideoQualityTest fixture;
 
   std::vector<std::string> stream_descriptors;
   stream_descriptors.push_back(ScreenshareStream0());
diff --git a/video/video_loopback.cc b/video/video_loopback.cc
index f2ab825..bee8b0c 100644
--- a/video/video_loopback.cc
+++ b/video/video_loopback.cc
@@ -11,7 +11,6 @@
 
 #include <stdio.h>
 
-#include <memory>
 #include <optional>
 #include <string>
 #include <vector>
@@ -421,7 +420,7 @@
   SL_descriptors.push_back(SL1());
   SL_descriptors.push_back(SL2());
 
-  VideoQualityTest fixture(nullptr);
+  VideoQualityTest fixture;
   fixture.FillScalabilitySettings(
       &params, 0, stream_descriptors, NumStreams(), SelectedStream(),
       NumSpatialLayers(), SelectedSL(), InterLayerPred(), SL_descriptors);
diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc
index f385adf..9386e73 100644
--- a/video/video_quality_test.cc
+++ b/video/video_quality_test.cc
@@ -20,7 +20,6 @@
 #include "api/audio/create_audio_device_module.h"
 #include "api/call/transport.h"
 #include "api/environment/environment.h"
-#include "api/environment/environment_factory.h"
 #include "api/field_trials_view.h"
 #include "api/make_ref_counted.h"
 #include "api/rtc_event_log/rtc_event_log.h"
@@ -52,6 +51,7 @@
 #include "rtc_base/logging.h"
 #include "rtc_base/numerics/safe_conversions.h"
 #include "rtc_base/system/file_wrapper.h"
+#include "test/call_test.h"
 #include "test/direct_transport.h"
 #include "test/frame_generator_capturer.h"
 #include "test/gtest.h"
@@ -407,9 +407,8 @@
   return encoder;
 }
 
-VideoQualityTest::VideoQualityTest(
-    std::unique_ptr<InjectionComponents> injection_components)
-    : env_(CreateEnvironment()),
+VideoQualityTest::VideoQualityTest(InjectionComponents injection_components)
+    : CallTest(injection_components.field_trials),
       video_decoder_factory_(
           [this](const Environment& env, const SdpVideoFormat& format) {
             return this->CreateVideoDecoder(env, format);
@@ -428,26 +427,23 @@
       send_logs_(0),
       injection_components_(std::move(injection_components)),
       num_video_streams_(0) {
-  if (injection_components_ == nullptr) {
-    injection_components_ = std::make_unique<InjectionComponents>();
-  }
-  if (injection_components_->video_decoder_factory != nullptr) {
-    decoder_factory_ = std::move(injection_components_->video_decoder_factory);
+  if (injection_components_.video_decoder_factory != nullptr) {
+    decoder_factory_ = std::move(injection_components_.video_decoder_factory);
   } else {
     decoder_factory_ = std::make_unique<InternalDecoderFactory>();
   }
-  if (injection_components_->video_encoder_factory != nullptr) {
-    encoder_factory_ = std::move(injection_components_->video_encoder_factory);
+  if (injection_components_.video_encoder_factory != nullptr) {
+    encoder_factory_ = std::move(injection_components_.video_encoder_factory);
   } else {
     encoder_factory_ = std::make_unique<InternalEncoderFactory>();
   }
 
   fec_controller_factory_ =
-      std::move(injection_components_->fec_controller_factory);
+      std::move(injection_components_.fec_controller_factory);
   network_state_predictor_factory_ =
-      std::move(injection_components_->network_state_predictor_factory);
+      std::move(injection_components_.network_state_predictor_factory);
   network_controller_factory_ =
-      std::move(injection_components_->network_controller_factory);
+      std::move(injection_components_.network_controller_factory);
 
   // Register header extensions that are used by transport to identify
   // extensions when parsing incomig packets.
@@ -465,10 +461,6 @@
       RtpExtension(RtpExtension::kVideoTimingUri, kVideoTimingExtensionId));
 }
 
-VideoQualityTest::InjectionComponents::InjectionComponents() = default;
-
-VideoQualityTest::InjectionComponents::~InjectionComponents() = default;
-
 void VideoQualityTest::TestBody() {}
 
 std::string VideoQualityTest::GenerateGraphTitle() const {
@@ -487,18 +479,15 @@
 }
 
 void VideoQualityTest::CheckParamsAndInjectionComponents() {
-  if (injection_components_ == nullptr) {
-    injection_components_ = std::make_unique<InjectionComponents>();
-  }
-  if (!params_.config && injection_components_->sender_network == nullptr &&
-      injection_components_->receiver_network == nullptr) {
+  if (!params_.config && injection_components_.sender_network == nullptr &&
+      injection_components_.receiver_network == nullptr) {
     params_.config = BuiltInNetworkBehaviorConfig();
   }
   RTC_CHECK(
-      (params_.config && injection_components_->sender_network == nullptr &&
-       injection_components_->receiver_network == nullptr) ||
-      (!params_.config && injection_components_->sender_network != nullptr &&
-       injection_components_->receiver_network != nullptr));
+      (params_.config && injection_components_.sender_network == nullptr &&
+       injection_components_.receiver_network == nullptr) ||
+      (!params_.config && injection_components_.sender_network != nullptr &&
+       injection_components_.receiver_network != nullptr));
   for (size_t video_idx = 0; video_idx < num_video_streams_; ++video_idx) {
     // Iterate over primary and secondary video streams.
     if (!params_.video[video_idx].enabled)
@@ -1200,10 +1189,10 @@
 std::unique_ptr<test::LayerFilteringTransport>
 VideoQualityTest::CreateSendTransport() {
   std::unique_ptr<NetworkBehaviorInterface> network_behavior = nullptr;
-  if (injection_components_->sender_network == nullptr) {
+  if (injection_components_.sender_network == nullptr) {
     network_behavior = std::make_unique<SimulatedNetwork>(*params_.config);
   } else {
-    network_behavior = std::move(injection_components_->sender_network);
+    network_behavior = std::move(injection_components_.sender_network);
   }
   return std::make_unique<test::LayerFilteringTransport>(
       task_queue(),
@@ -1221,10 +1210,10 @@
 std::unique_ptr<test::DirectTransport>
 VideoQualityTest::CreateReceiveTransport() {
   std::unique_ptr<NetworkBehaviorInterface> network_behavior = nullptr;
-  if (injection_components_->receiver_network == nullptr) {
+  if (injection_components_.receiver_network == nullptr) {
     network_behavior = std::make_unique<SimulatedNetwork>(*params_.config);
   } else {
-    network_behavior = std::move(injection_components_->receiver_network);
+    network_behavior = std::move(injection_components_.receiver_network);
   }
   return std::make_unique<test::DirectTransport>(
       task_queue(),
diff --git a/video/video_quality_test.h b/video/video_quality_test.h
index 391c2d3..e6cd625 100644
--- a/video/video_quality_test.h
+++ b/video/video_quality_test.h
@@ -55,8 +55,7 @@
 class VideoQualityTest : public test::CallTest,
                          public VideoQualityTestFixtureInterface {
  public:
-  explicit VideoQualityTest(
-      std::unique_ptr<InjectionComponents> injection_components);
+  explicit VideoQualityTest(InjectionComponents injection_components = {});
 
   void RunWithAnalyzer(const Params& params) override;
   void RunWithRenderers(const Params& params) override;
@@ -119,7 +118,6 @@
   virtual std::unique_ptr<test::LayerFilteringTransport> CreateSendTransport();
   virtual std::unique_ptr<test::DirectTransport> CreateReceiveTransport();
 
-  const Environment env_;
   std::vector<std::unique_ptr<VideoSourceInterface<VideoFrame>>>
       thumbnail_capturers_;
   RtcEventLogFactory rtc_event_log_factory_;
@@ -141,7 +139,7 @@
   int send_logs_;
 
   Params params_;
-  std::unique_ptr<InjectionComponents> injection_components_;
+  InjectionComponents injection_components_;
 
   // Set non-null when running with analyzer.
   std::unique_ptr<VideoAnalyzer> analyzer_;