diff --git a/api/test/DEPS b/api/test/DEPS index b5bbed6ca6..1a02bf16e9 100644 --- a/api/test/DEPS +++ b/api/test/DEPS @@ -23,6 +23,7 @@ specific_include_rules = { "network_emulation_manager\.h": [ "+rtc_base/thread.h", "+rtc_base/network.h", + "+rtc_base/network_constants.h", ], "peerconnection_quality_test_fixture\.h": [ "+logging/rtc_event_log/rtc_event_log_factory_interface.h", diff --git a/api/test/network_emulation_manager.h b/api/test/network_emulation_manager.h index a04767019b..3e9cf113d2 100644 --- a/api/test/network_emulation_manager.h +++ b/api/test/network_emulation_manager.h @@ -17,9 +17,9 @@ #include "api/test/network_emulation/network_emulation_interfaces.h" #include "api/test/simulated_network.h" #include "api/test/time_controller.h" - #include "api/units/timestamp.h" #include "rtc_base/network.h" +#include "rtc_base/network_constants.h" #include "rtc_base/thread.h" namespace webrtc { @@ -52,6 +52,8 @@ struct EmulatedEndpointConfig { // Should endpoint be enabled or not, when it will be created. // Enabled endpoints will be available for webrtc to send packets. bool start_as_enabled = true; + // Network type which will be used to represent endpoint to WebRTC. + rtc::AdapterType type = rtc::AdapterType::ADAPTER_TYPE_UNKNOWN; }; diff --git a/test/network/BUILD.gn b/test/network/BUILD.gn index 8b05eec2d3..4b01479c9b 100644 --- a/test/network/BUILD.gn +++ b/test/network/BUILD.gn @@ -110,6 +110,7 @@ rtc_library("cross_traffic_unittest") { "../:test_support", "../../api:simulated_network_api", "../../call:simulated_network", + "../../rtc_base", "../../rtc_base:logging", "../../rtc_base:rtc_event", "//test/time_controller:time_controller", diff --git a/test/network/cross_traffic_unittest.cc b/test/network/cross_traffic_unittest.cc index 4bf19845c0..43967e693c 100644 --- a/test/network/cross_traffic_unittest.cc +++ b/test/network/cross_traffic_unittest.cc @@ -20,6 +20,7 @@ #include "call/simulated_network.h" #include "rtc_base/event.h" #include "rtc_base/logging.h" +#include "rtc_base/network_constants.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/network/network_emulation_manager.h" @@ -45,8 +46,12 @@ struct TrafficCounterFixture { SimulatedClock clock{0}; CountingReceiver counter; TaskQueueForTest task_queue_; - EmulatedEndpointImpl endpoint{/*id=*/1, rtc::IPAddress(kTestIpAddress), - /*is_enabled=*/true, &task_queue_, &clock}; + EmulatedEndpointImpl endpoint{/*id=*/1, + rtc::IPAddress(kTestIpAddress), + /*is_enabled=*/true, + /*type=*/rtc::AdapterType::ADAPTER_TYPE_UNKNOWN, + &task_queue_, + &clock}; }; } // namespace diff --git a/test/network/network_emulation.cc b/test/network/network_emulation.cc index a0ac5aee40..57dcf51242 100644 --- a/test/network/network_emulation.cc +++ b/test/network/network_emulation.cc @@ -169,11 +169,13 @@ EmulatedNetworkNode::~EmulatedNetworkNode() = default; EmulatedEndpointImpl::EmulatedEndpointImpl(uint64_t id, const rtc::IPAddress& ip, bool is_enabled, + rtc::AdapterType type, rtc::TaskQueue* task_queue, Clock* clock) : id_(id), peer_local_addr_(ip), is_enabled_(is_enabled), + type_(type), clock_(clock), task_queue_(task_queue), router_(task_queue_), @@ -190,7 +192,7 @@ EmulatedEndpointImpl::EmulatedEndpointImpl(uint64_t id, rtc::IPAddress prefix = TruncateIP(ip, prefix_length); network_ = std::make_unique( ip.ToString(), "Endpoint id=" + std::to_string(id_), prefix, - prefix_length, rtc::AdapterType::ADAPTER_TYPE_UNKNOWN); + prefix_length, type_); network_->AddIP(ip); enabled_state_checker_.Detach(); diff --git a/test/network/network_emulation.h b/test/network/network_emulation.h index bb5319f1a4..75e9c2c78a 100644 --- a/test/network/network_emulation.h +++ b/test/network/network_emulation.h @@ -25,6 +25,7 @@ #include "api/units/timestamp.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/network.h" +#include "rtc_base/network_constants.h" #include "rtc_base/socket_address.h" #include "rtc_base/task_queue_for_test.h" #include "rtc_base/task_utils/repeating_task.h" @@ -130,6 +131,7 @@ class EmulatedEndpointImpl : public EmulatedEndpoint { EmulatedEndpointImpl(uint64_t id, const rtc::IPAddress& ip, bool is_enabled, + rtc::AdapterType type, rtc::TaskQueue* task_queue, Clock* clock); ~EmulatedEndpointImpl() override; @@ -173,6 +175,7 @@ class EmulatedEndpointImpl : public EmulatedEndpoint { // Peer's local IP address for this endpoint network interface. const rtc::IPAddress peer_local_addr_; bool is_enabled_ RTC_GUARDED_BY(enabled_state_checker_); + const rtc::AdapterType type_; Clock* const clock_; rtc::TaskQueue* const task_queue_; std::unique_ptr network_; diff --git a/test/network/network_emulation_manager.cc b/test/network/network_emulation_manager.cc index caa950e0bd..3be1185710 100644 --- a/test/network/network_emulation_manager.cc +++ b/test/network/network_emulation_manager.cc @@ -98,7 +98,8 @@ EmulatedEndpoint* NetworkEmulationManagerImpl::CreateEndpoint( bool res = used_ip_addresses_.insert(*ip).second; RTC_CHECK(res) << "IP=" << ip->ToString() << " already in use"; auto node = std::make_unique( - next_node_id_++, *ip, config.start_as_enabled, &task_queue_, clock_); + next_node_id_++, *ip, config.start_as_enabled, config.type, &task_queue_, + clock_); EmulatedEndpoint* out = node.get(); endpoints_.push_back(std::move(node)); return out;