From a268b690378c0abf71d07ccfcd2f127edb5e946a Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Tue, 12 Mar 2019 13:37:28 +0100 Subject: [PATCH] Rename EndpointConfig into EmulatedEndpointConfig Also fix minor issues in this class. Bug: webrtc:10138 Change-Id: Icb3ec7f6296c34da260e701ec51d7b87ce62a4d7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127281 Reviewed-by: Sebastian Jansson Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/master@{#27073} --- test/pc/e2e/peer_connection_e2e_smoke_test.cc | 4 ++-- .../network/network_emulation_manager.cc | 24 +++++++++++-------- .../network/network_emulation_manager.h | 20 ++++++++-------- .../network/network_emulation_pc_unittest.cc | 4 ++-- .../network/network_emulation_unittest.cc | 12 +++++----- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/test/pc/e2e/peer_connection_e2e_smoke_test.cc b/test/pc/e2e/peer_connection_e2e_smoke_test.cc index b8259f63e2..93e659c2e8 100644 --- a/test/pc/e2e/peer_connection_e2e_smoke_test.cc +++ b/test/pc/e2e/peer_connection_e2e_smoke_test.cc @@ -81,9 +81,9 @@ TEST(PeerConnectionE2EQualityTestSmokeTest, RunWithEmulatedNetwork) { EmulatedNetworkNode* bob_node = network_emulation_manager.CreateEmulatedNode( absl::make_unique(BuiltInNetworkBehaviorConfig())); EmulatedEndpoint* alice_endpoint = - network_emulation_manager.CreateEndpoint(EndpointConfig()); + network_emulation_manager.CreateEndpoint(EmulatedEndpointConfig()); EmulatedEndpoint* bob_endpoint = - network_emulation_manager.CreateEndpoint(EndpointConfig()); + network_emulation_manager.CreateEndpoint(EmulatedEndpointConfig()); network_emulation_manager.CreateRoute(alice_endpoint, {alice_node}, bob_endpoint); network_emulation_manager.CreateRoute(bob_endpoint, {bob_node}, diff --git a/test/scenario/network/network_emulation_manager.cc b/test/scenario/network/network_emulation_manager.cc index 141ad0c572..16f4187237 100644 --- a/test/scenario/network/network_emulation_manager.cc +++ b/test/scenario/network/network_emulation_manager.cc @@ -29,12 +29,16 @@ constexpr uint32_t kMaxIPv4Address = 0xC0A8FFFF; } // namespace -EndpointConfig::EndpointConfig() = default; -EndpointConfig::~EndpointConfig() = default; -EndpointConfig::EndpointConfig(EndpointConfig&) = default; -EndpointConfig& EndpointConfig::operator=(EndpointConfig&) = default; -EndpointConfig::EndpointConfig(EndpointConfig&&) = default; -EndpointConfig& EndpointConfig::operator=(EndpointConfig&&) = default; +EmulatedEndpointConfig::EmulatedEndpointConfig() = default; +EmulatedEndpointConfig::~EmulatedEndpointConfig() = default; +EmulatedEndpointConfig::EmulatedEndpointConfig(EmulatedEndpointConfig&) = + default; +EmulatedEndpointConfig& EmulatedEndpointConfig::operator=( + EmulatedEndpointConfig&) = default; +EmulatedEndpointConfig::EmulatedEndpointConfig(EmulatedEndpointConfig&&) = + default; +EmulatedEndpointConfig& EmulatedEndpointConfig::operator=( + EmulatedEndpointConfig&&) = default; NetworkEmulationManager::NetworkEmulationManager() : clock_(Clock::GetRealTimeClock()), @@ -68,15 +72,15 @@ EmulatedNetworkNode* NetworkEmulationManager::CreateEmulatedNode( } EmulatedEndpoint* NetworkEmulationManager::CreateEndpoint( - EndpointConfig config) { + EmulatedEndpointConfig config) { absl::optional ip = config.ip; if (!ip) { switch (config.generated_ip_family) { - case EndpointConfig::IpAddressFamily::kIpv4: + case EmulatedEndpointConfig::IpAddressFamily::kIpv4: ip = GetNextIPv4Address(); RTC_CHECK(ip) << "All auto generated IPv4 addresses exhausted"; break; - case EndpointConfig::IpAddressFamily::kIpv6: + case EmulatedEndpointConfig::IpAddressFamily::kIpv6: ip = GetNextIPv4Address(); RTC_CHECK(ip) << "All auto generated IPv6 addresses exhausted"; ip = ip->AsIPv6Address(); @@ -128,7 +132,7 @@ void NetworkEmulationManager::ClearRoute( TrafficRoute* NetworkEmulationManager::CreateTrafficRoute( std::vector via_nodes) { RTC_CHECK(!via_nodes.empty()); - EmulatedEndpoint* endpoint = CreateEndpoint(EndpointConfig()); + EmulatedEndpoint* endpoint = CreateEndpoint(EmulatedEndpointConfig()); // Setup a route via specified nodes. EmulatedNetworkNode* cur_node = via_nodes[0]; diff --git a/test/scenario/network/network_emulation_manager.h b/test/scenario/network/network_emulation_manager.h index 7fb8a6e0e9..8c408f5fb7 100644 --- a/test/scenario/network/network_emulation_manager.h +++ b/test/scenario/network/network_emulation_manager.h @@ -31,18 +31,18 @@ namespace webrtc { namespace test { -struct EndpointConfig { - enum IpAddressFamily { kIpv4, kIpv6 }; +struct EmulatedEndpointConfig { + enum class IpAddressFamily { kIpv4, kIpv6 }; - EndpointConfig(); - ~EndpointConfig(); - EndpointConfig(EndpointConfig&); - EndpointConfig& operator=(EndpointConfig&); - EndpointConfig(EndpointConfig&&); - EndpointConfig& operator=(EndpointConfig&&); + EmulatedEndpointConfig(); + ~EmulatedEndpointConfig(); + EmulatedEndpointConfig(EmulatedEndpointConfig&); + EmulatedEndpointConfig& operator=(EmulatedEndpointConfig&); + EmulatedEndpointConfig(EmulatedEndpointConfig&&); + EmulatedEndpointConfig& operator=(EmulatedEndpointConfig&&); IpAddressFamily generated_ip_family = IpAddressFamily::kIpv4; - // If specified will be used as IP address for endpoint node. Should be unique + // If specified will be used as IP address for endpoint node. Must be unique // among all created nodes. absl::optional ip; }; @@ -55,7 +55,7 @@ class NetworkEmulationManager { EmulatedNetworkNode* CreateEmulatedNode( std::unique_ptr network_behavior); - EmulatedEndpoint* CreateEndpoint(EndpointConfig config); + EmulatedEndpoint* CreateEndpoint(EmulatedEndpointConfig config); void CreateRoute(EmulatedEndpoint* from, std::vector via_nodes, diff --git a/test/scenario/network/network_emulation_pc_unittest.cc b/test/scenario/network/network_emulation_pc_unittest.cc index 36e1e2b19a..26b900c048 100644 --- a/test/scenario/network/network_emulation_pc_unittest.cc +++ b/test/scenario/network/network_emulation_pc_unittest.cc @@ -109,9 +109,9 @@ TEST(NetworkEmulationManagerPCTest, Run) { EmulatedNetworkNode* bob_node = network_manager.CreateEmulatedNode( absl::make_unique(BuiltInNetworkBehaviorConfig())); EmulatedEndpoint* alice_endpoint = - network_manager.CreateEndpoint(EndpointConfig()); + network_manager.CreateEndpoint(EmulatedEndpointConfig()); EmulatedEndpoint* bob_endpoint = - network_manager.CreateEndpoint(EndpointConfig()); + network_manager.CreateEndpoint(EmulatedEndpointConfig()); network_manager.CreateRoute(alice_endpoint, {alice_node}, bob_endpoint); network_manager.CreateRoute(bob_endpoint, {bob_node}, alice_endpoint); diff --git a/test/scenario/network/network_emulation_unittest.cc b/test/scenario/network/network_emulation_unittest.cc index 351d6026fb..24fe089ab9 100644 --- a/test/scenario/network/network_emulation_unittest.cc +++ b/test/scenario/network/network_emulation_unittest.cc @@ -60,8 +60,8 @@ class SocketReader : public sigslot::has_slots<> { TEST(NetworkEmulationManagerTest, GeneratedIpv4AddressDoesNotCollide) { NetworkEmulationManager network_manager; std::set ips; - EndpointConfig config; - config.generated_ip_family = EndpointConfig::IpAddressFamily::kIpv4; + EmulatedEndpointConfig config; + config.generated_ip_family = EmulatedEndpointConfig::IpAddressFamily::kIpv4; for (int i = 0; i < 1000; i++) { EmulatedEndpoint* endpoint = network_manager.CreateEndpoint(config); ASSERT_EQ(endpoint->GetPeerLocalAddress().family(), AF_INET); @@ -73,8 +73,8 @@ TEST(NetworkEmulationManagerTest, GeneratedIpv4AddressDoesNotCollide) { TEST(NetworkEmulationManagerTest, GeneratedIpv6AddressDoesNotCollide) { NetworkEmulationManager network_manager; std::set ips; - EndpointConfig config; - config.generated_ip_family = EndpointConfig::IpAddressFamily::kIpv6; + EmulatedEndpointConfig config; + config.generated_ip_family = EmulatedEndpointConfig::IpAddressFamily::kIpv6; for (int i = 0; i < 1000; i++) { EmulatedEndpoint* endpoint = network_manager.CreateEndpoint(config); ASSERT_EQ(endpoint->GetPeerLocalAddress().family(), AF_INET6); @@ -91,9 +91,9 @@ TEST(NetworkEmulationManagerTest, Run) { EmulatedNetworkNode* bob_node = network_manager.CreateEmulatedNode( absl::make_unique(BuiltInNetworkBehaviorConfig())); EmulatedEndpoint* alice_endpoint = - network_manager.CreateEndpoint(EndpointConfig()); + network_manager.CreateEndpoint(EmulatedEndpointConfig()); EmulatedEndpoint* bob_endpoint = - network_manager.CreateEndpoint(EndpointConfig()); + network_manager.CreateEndpoint(EmulatedEndpointConfig()); network_manager.CreateRoute(alice_endpoint, {alice_node}, bob_endpoint); network_manager.CreateRoute(bob_endpoint, {bob_node}, alice_endpoint);