From 48b1b18065c5aff930a5354f691e22df014e4be9 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Fri, 5 Jul 2019 13:09:48 +0200 Subject: [PATCH] Add ability to create EmulatedNetworkNode from BuiltInNetworkBehaviorConfig There is no public API to create NetworkBehaviorInterface from BuiltInNetworkBehaviorConfig, so this CL will add direct method, that will allow downstream projects to use BuiltInNetworkBehaviorConfig for network emulation. Bug: webrtc:10138 Change-Id: Iaec3ea17c12bd06b1c0ff3e5bc2b32cc1c4f62f8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144628 Reviewed-by: Sebastian Jansson Reviewed-by: Karl Wiberg Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/master@{#28494} --- api/test/network_emulation_manager.h | 2 ++ test/network/BUILD.gn | 1 + test/network/network_emulation_manager.cc | 6 ++++++ test/network/network_emulation_manager.h | 2 ++ 4 files changed, 11 insertions(+) diff --git a/api/test/network_emulation_manager.h b/api/test/network_emulation_manager.h index 404a8c07cb..c241cdb1c7 100644 --- a/api/test/network_emulation_manager.h +++ b/api/test/network_emulation_manager.h @@ -110,6 +110,8 @@ class NetworkEmulationManager { // Creates an emulated network node, which represents single network in // the emulated network layer. + virtual EmulatedNetworkNode* CreateEmulatedNode( + BuiltInNetworkBehaviorConfig config) = 0; virtual EmulatedNetworkNode* CreateEmulatedNode( std::unique_ptr network_behavior) = 0; diff --git a/test/network/BUILD.gn b/test/network/BUILD.gn index c8f14ddb73..92a53c7ac5 100644 --- a/test/network/BUILD.gn +++ b/test/network/BUILD.gn @@ -40,6 +40,7 @@ rtc_source_set("emulated_network") { "../../api/units:data_size", "../../api/units:time_delta", "../../api/units:timestamp", + "../../call:simulated_network", "../../rtc_base", "../../rtc_base:rtc_base_tests_utils", "../../rtc_base:rtc_task_queue", diff --git a/test/network/network_emulation_manager.cc b/test/network/network_emulation_manager.cc index 4ae7299ebd..d2f6947c81 100644 --- a/test/network/network_emulation_manager.cc +++ b/test/network/network_emulation_manager.cc @@ -16,6 +16,7 @@ #include "absl/memory/memory.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "call/simulated_network.h" #include "rtc_base/fake_network.h" #include "test/time_controller/real_time_controller.h" @@ -69,6 +70,11 @@ NetworkEmulationManagerImpl::NetworkEmulationManagerImpl( // destroyed. NetworkEmulationManagerImpl::~NetworkEmulationManagerImpl() = default; +EmulatedNetworkNode* NetworkEmulationManagerImpl::CreateEmulatedNode( + BuiltInNetworkBehaviorConfig config) { + return CreateEmulatedNode(absl::make_unique(config)); +} + EmulatedNetworkNode* NetworkEmulationManagerImpl::CreateEmulatedNode( std::unique_ptr network_behavior) { auto node = absl::make_unique( diff --git a/test/network/network_emulation_manager.h b/test/network/network_emulation_manager.h index c860362b92..118c701ac8 100644 --- a/test/network/network_emulation_manager.h +++ b/test/network/network_emulation_manager.h @@ -43,6 +43,8 @@ class NetworkEmulationManagerImpl : public NetworkEmulationManager { explicit NetworkEmulationManagerImpl(TimeController* time_controller); ~NetworkEmulationManagerImpl(); + EmulatedNetworkNode* CreateEmulatedNode( + BuiltInNetworkBehaviorConfig config) override; EmulatedNetworkNode* CreateEmulatedNode( std::unique_ptr network_behavior) override;