diff --git a/BUILD.gn b/BUILD.gn index b3afa76fc2..3ae4500f39 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -43,6 +43,7 @@ if (!build_with_chromium) { ":video_engine_tests", ":webrtc_nonparallel_tests", ":webrtc_perf_tests", + "call:fake_network_unittests", "common_audio:common_audio_unittests", "common_video:common_video_unittests", "media:rtc_media_unittests", diff --git a/call/BUILD.gn b/call/BUILD.gn index 2f797729f7..838728ad78 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -435,6 +435,7 @@ if (rtc_include_tests) { deps = [ ":call_interfaces", ":fake_network", + ":simulated_network", "../modules/rtp_rtcp", "../rtc_base:rtc_base_approved", "../system_wrappers", diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index 6a2ff3548d..ea8da42640 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -126,6 +126,8 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module { void SetClockOffset(int64_t offset_ms); + // DO NOT USE. Hold direct reference on NetworkSimulationInterface instead + // and call SetConfig on that object directly. Will be removed soon. // Sets a new configuration. This won't affect packets already in the pipe. void SetConfig(const FakeNetworkPipe::Config& config); diff --git a/call/test/fake_network_pipe_unittest.cc b/call/test/fake_network_pipe_unittest.cc index fe7d8a9420..284d18c9cd 100644 --- a/call/test/fake_network_pipe_unittest.cc +++ b/call/test/fake_network_pipe_unittest.cc @@ -13,6 +13,7 @@ #include #include "call/call.h" +#include "call/simulated_network.h" #include "modules/rtp_rtcp/include/rtp_header_parser.h" #include "system_wrappers/include/clock.h" #include "test/gmock.h" @@ -204,8 +205,11 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) { config.queue_length_packets = 20; config.link_capacity_kbps = 80; MockReceiver receiver; + std::unique_ptr network(new SimulatedNetwork(config)); + SimulatedNetwork* simulated_network = network.get(); std::unique_ptr pipe( - new FakeNetworkPipe(&fake_clock_, config, &receiver)); + new FakeNetworkPipe(&fake_clock_, std::move(network))); + pipe->SetReceiver(&receiver); // Add 10 packets of 1000 bytes, = 80 kb, and verify it takes one second to // get through the pipe. @@ -229,7 +233,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) { // Change the capacity. config.link_capacity_kbps /= 2; // Reduce to 50%. - pipe->SetConfig(config); + simulated_network->SetConfig(config); // Add another 10 packets of 1000 bytes, = 80 kb, and verify it takes two // seconds to get them through the pipe. @@ -263,8 +267,11 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) { config.queue_length_packets = 20; config.link_capacity_kbps = 80; MockReceiver receiver; + std::unique_ptr network(new SimulatedNetwork(config)); + SimulatedNetwork* simulated_network = network.get(); std::unique_ptr pipe( - new FakeNetworkPipe(&fake_clock_, config, &receiver)); + new FakeNetworkPipe(&fake_clock_, std::move(network))); + pipe->SetReceiver(&receiver); // Add 10 packets of 1000 bytes, = 80 kb. const int kNumPackets = 10; @@ -276,7 +283,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) { // Change the capacity. config.link_capacity_kbps *= 2; // Double the capacity. - pipe->SetConfig(config); + simulated_network->SetConfig(config); // Add another 10 packets of 1000 bytes, = 80 kb, and verify it takes two // seconds to get them through the pipe. @@ -318,8 +325,11 @@ TEST_F(FakeNetworkPipeTest, DisallowReorderingThenAllowReordering) { config.queue_delay_ms = 100; config.delay_standard_deviation_ms = 10; ReorderTestReceiver receiver; + std::unique_ptr network(new SimulatedNetwork(config)); + SimulatedNetwork* simulated_network = network.get(); std::unique_ptr pipe( - new FakeNetworkPipe(&fake_clock_, config, &receiver)); + new FakeNetworkPipe(&fake_clock_, std::move(network))); + pipe->SetReceiver(&receiver); const uint32_t kNumPackets = 100; const int kPacketSize = 10; @@ -336,7 +346,7 @@ TEST_F(FakeNetworkPipeTest, DisallowReorderingThenAllowReordering) { } config.allow_reordering = true; - pipe->SetConfig(config); + simulated_network->SetConfig(config); SendPackets(pipe.get(), kNumPackets, kPacketSize); fake_clock_.AdvanceTimeMilliseconds(1000); receiver.delivered_sequence_numbers_.clear();