Propagate field trials in test::PeerScenario based tests
Bug: webrtc:419453427
Change-Id: Iafc51142eff84f867946f7dc924d13a82105af5b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/395720
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#44864}
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 93a5cf1..167b95b 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -2592,6 +2592,7 @@
"../test:test_support",
"../test:wait_until",
"../test/pc/sctp:fake_sctp_transport",
+ "scenario_tests:pc_scenario_tests",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
diff --git a/pc/scenario_tests/BUILD.gn b/pc/scenario_tests/BUILD.gn
index fa3a67c..61136ff 100644
--- a/pc/scenario_tests/BUILD.gn
+++ b/pc/scenario_tests/BUILD.gn
@@ -13,12 +13,16 @@
testonly = true
sources = [ "goog_cc_test.cc" ]
deps = [
+ "..:pc_test_utils",
+ "../../api:audio_options_api",
+ "../../api:make_ref_counted",
+ "../../api:rtc_error",
"../../api:rtc_stats_api",
- "../../modules/rtp_rtcp:rtp_rtcp",
- "../../pc:pc_test_utils",
- "../../test:field_trial",
+ "../../api:simulated_network_api",
+ "../../api/units:data_rate",
+ "../../api/units:time_delta",
"../../test:test_support",
- "../../test/peer_scenario:peer_scenario",
+ "../../test/peer_scenario",
]
}
}
diff --git a/pc/scenario_tests/goog_cc_test.cc b/pc/scenario_tests/goog_cc_test.cc
index 057267c..bfe2764 100644
--- a/pc/scenario_tests/goog_cc_test.cc
+++ b/pc/scenario_tests/goog_cc_test.cc
@@ -8,11 +8,14 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "api/stats/rtc_stats_collector_callback.h"
+#include "api/audio_options.h"
+#include "api/make_ref_counted.h"
+#include "api/rtc_error.h"
#include "api/stats/rtcstats_objects.h"
+#include "api/test/simulated_network.h"
#include "api/units/data_rate.h"
+#include "api/units/time_delta.h"
#include "pc/test/mock_peer_connection_observers.h"
-#include "test/field_trial.h"
#include "test/gtest.h"
#include "test/peer_scenario/peer_scenario.h"
#include "test/peer_scenario/peer_scenario_client.h"
@@ -28,19 +31,20 @@
#define MAYBE_NoBweChangeFromVideoUnmute NoBweChangeFromVideoUnmute
#endif
TEST(GoogCcPeerScenarioTest, MAYBE_NoBweChangeFromVideoUnmute) {
+ PeerScenarioClient::Config config;
// If transport wide sequence numbers are used for audio, and the call
// switches from audio only to video only, there will be a sharp change in
// packets sizes. This will create a change in propagation time which might be
// detected as an overuse. Using separate overuse detectors for audio and
// video avoids the issue.
- std::string audio_twcc_trials("WebRTC-Audio-AlrProbing/Disabled/");
- std::string separate_audio_video(
- "WebRTC-Bwe-SeparateAudioPackets/"
- "enabled:true,packet_threshold:15,time_threshold:1000ms/");
- ScopedFieldTrials field_trial(audio_twcc_trials + separate_audio_video);
+ config.field_trials.Set("WebRTC-Audio-AlrProbing", "Disabled");
+ config.field_trials.Set(
+ "WebRTC-Bwe-SeparateAudioPackets",
+ "enabled:true,packet_threshold:15,time_threshold:1000ms");
+
PeerScenario s(*test_info_);
- auto* caller = s.CreateClient(PeerScenarioClient::Config());
- auto* callee = s.CreateClient(PeerScenarioClient::Config());
+ auto* caller = s.CreateClient(config);
+ auto* callee = s.CreateClient(config);
BuiltInNetworkBehaviorConfig net_conf;
net_conf.link_capacity = DataRate::KilobitsPerSec(350);
diff --git a/test/peer_scenario/BUILD.gn b/test/peer_scenario/BUILD.gn
index b623fc0..8edf94a 100644
--- a/test/peer_scenario/BUILD.gn
+++ b/test/peer_scenario/BUILD.gn
@@ -23,6 +23,7 @@
]
deps = [
"..:create_frame_generator_capturer",
+ "..:create_test_field_trials",
"..:fake_video_codecs",
"..:fileutils",
"..:frame_generator_capturer",
@@ -32,6 +33,7 @@
"../../api:audio_options_api",
"../../api:candidate",
"../../api:enable_media_with_defaults",
+ "../../api:field_trials",
"../../api:libjingle_peerconnection_api",
"../../api:make_ref_counted",
"../../api:media_stream_interface",
diff --git a/test/peer_scenario/peer_scenario_client.cc b/test/peer_scenario/peer_scenario_client.cc
index f5a207c..d6ca145 100644
--- a/test/peer_scenario/peer_scenario_client.cc
+++ b/test/peer_scenario/peer_scenario_client.cc
@@ -26,6 +26,7 @@
#include "api/enable_media_with_defaults.h"
#include "api/environment/environment.h"
#include "api/environment/environment_factory.h"
+#include "api/field_trials.h"
#include "api/jsep.h"
#include "api/make_ref_counted.h"
#include "api/media_stream_interface.h"
@@ -240,8 +241,10 @@
Thread* signaling_thread,
std::unique_ptr<LogWriterFactoryInterface> log_writer_factory,
PeerScenarioClient::Config config)
- : env_(CreateEnvironment(net->time_controller()->GetClock(),
- net->time_controller()->GetTaskQueueFactory())),
+ : env_(CreateEnvironment(
+ std::make_unique<FieldTrials>(std::move(config.field_trials)),
+ net->time_controller()->GetClock(),
+ net->time_controller()->GetTaskQueueFactory())),
endpoints_(CreateEndpoints(net, config.endpoints)),
signaling_thread_(signaling_thread),
log_writer_factory_(std::move(log_writer_factory)),
diff --git a/test/peer_scenario/peer_scenario_client.h b/test/peer_scenario/peer_scenario_client.h
index 6e2510f..cc14d25 100644
--- a/test/peer_scenario/peer_scenario_client.h
+++ b/test/peer_scenario/peer_scenario_client.h
@@ -22,6 +22,7 @@
#include "api/candidate.h"
#include "api/data_channel_interface.h"
#include "api/environment/environment.h"
+#include "api/field_trials.h"
#include "api/jsep.h"
#include "api/media_stream_interface.h"
#include "api/peer_connection_interface.h"
@@ -39,6 +40,7 @@
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/clock.h"
#include "test/create_frame_generator_capturer.h"
+#include "test/create_test_field_trials.h"
#include "test/frame_generator_capturer.h"
#include "test/logging/log_writer.h"
@@ -88,6 +90,7 @@
on_remove_track;
};
struct Config {
+ FieldTrials field_trials = CreateTestFieldTrials();
// WebRTC only support one audio device that is setup up on construction, so
// we provide the audio generator configuration here rather than on creation
// of the tracks. This is unlike video, where multiple capture sources can
diff --git a/test/peer_scenario/scenario_connection.h b/test/peer_scenario/scenario_connection.h
index bd9161b..4f24ce4 100644
--- a/test/peer_scenario/scenario_connection.h
+++ b/test/peer_scenario/scenario_connection.h
@@ -23,7 +23,6 @@
#include "p2p/base/transport_description.h"
#include "rtc_base/copy_on_write_buffer.h"
#include "test/network/network_emulation_manager.h"
-#include "test/scoped_key_value_config.h"
namespace webrtc {
@@ -60,8 +59,6 @@
virtual EmulatedEndpoint* endpoint() = 0;
virtual const TransportDescription& transport_description() const = 0;
-
- webrtc::test::ScopedKeyValueConfig field_trials;
};
} // namespace webrtc
diff --git a/test/peer_scenario/tests/BUILD.gn b/test/peer_scenario/tests/BUILD.gn
index b6252b7..85a30de 100644
--- a/test/peer_scenario/tests/BUILD.gn
+++ b/test/peer_scenario/tests/BUILD.gn
@@ -20,15 +20,13 @@
]
deps = [
"..:peer_scenario",
- "../../:create_frame_generator_capturer",
- "../../:field_trial",
- "../../:test_support",
+ "../..:create_frame_generator_capturer",
+ "../..:test_support",
"../../../api:audio_options_api",
"../../../api:libjingle_peerconnection_api",
"../../../api:make_ref_counted",
"../../../api:rtc_stats_api",
"../../../api:rtp_parameters",
- "../../../api:rtp_sender_interface",
"../../../api:rtp_transceiver_direction",
"../../../api:scoped_refptr",
"../../../api/test/network_emulation",
@@ -46,7 +44,7 @@
"../../../rtc_base:logging",
"../../../rtc_base:network_constants",
"../../scenario",
- "//third_party/abseil-cpp/absl/strings:strings",
+ "//third_party/abseil-cpp/absl/strings",
]
if (rtc_enable_protobuf) {
deps += [
diff --git a/test/peer_scenario/tests/l4s_test.cc b/test/peer_scenario/tests/l4s_test.cc
index c8153f2..ce110f9 100644
--- a/test/peer_scenario/tests/l4s_test.cc
+++ b/test/peer_scenario/tests/l4s_test.cc
@@ -31,7 +31,6 @@
#include "rtc_base/logging.h"
#include "rtc_base/network_constants.h"
#include "test/create_frame_generator_capturer.h"
-#include "test/field_trial.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/peer_scenario/peer_scenario.h"
@@ -122,11 +121,10 @@
}
TEST(L4STest, NegotiateAndUseCcfbIfEnabled) {
- test::ScopedFieldTrials trials(
- "WebRTC-RFC8888CongestionControlFeedback/Enabled/");
PeerScenario s(*test_info_);
- PeerScenarioClient::Config config = PeerScenarioClient::Config();
+ PeerScenarioClient::Config config;
+ config.field_trials.Set("WebRTC-RFC8888CongestionControlFeedback", "Enabled");
config.disable_encryption = true;
PeerScenarioClient* caller = s.CreateClient(config);
PeerScenarioClient* callee = s.CreateClient(config);
@@ -198,11 +196,10 @@
}
TEST(L4STest, CallerAdaptToLinkCapacityWithoutEcn) {
- test::ScopedFieldTrials trials(
- "WebRTC-RFC8888CongestionControlFeedback/Enabled/");
PeerScenario s(*test_info_);
- PeerScenarioClient::Config config = PeerScenarioClient::Config();
+ PeerScenarioClient::Config config;
+ config.field_trials.Set("WebRTC-RFC8888CongestionControlFeedback", "Enabled");
PeerScenarioClient* caller = s.CreateClient(config);
PeerScenarioClient* callee = s.CreateClient(config);
@@ -237,11 +234,10 @@
}
TEST(L4STest, SendsEct1UntilFirstFeedback) {
- test::ScopedFieldTrials trials(
- "WebRTC-RFC8888CongestionControlFeedback/Enabled/");
PeerScenario s(*test_info_);
- PeerScenarioClient::Config config = PeerScenarioClient::Config();
+ PeerScenarioClient::Config config;
+ config.field_trials.Set("WebRTC-RFC8888CongestionControlFeedback", "Enabled");
config.disable_encryption = true;
PeerScenarioClient* caller = s.CreateClient(config);
PeerScenarioClient* callee = s.CreateClient(config);
@@ -292,11 +288,10 @@
}
TEST(L4STest, SendsEct1AfterRouteChange) {
- test::ScopedFieldTrials trials(
- "WebRTC-RFC8888CongestionControlFeedback/Enabled/");
PeerScenario s(*test_info_);
PeerScenarioClient::Config config;
+ config.field_trials.Set("WebRTC-RFC8888CongestionControlFeedback", "Enabled");
config.disable_encryption = true;
config.endpoints = {{0, {.type = AdapterType::ADAPTER_TYPE_WIFI}}};
PeerScenarioClient* caller = s.CreateClient(config);