Do not use FakeNetworkPipe::SetConfig.
Switch from using FakeNetworkPipe::SetConfig on holding direct reference
on instances of NetworkSimulationInterface if you are required to
reconfigure it in the runtime.
Also add fake_network_unittests to built test targets.
Bug: webrtc:9630
Change-Id: I5fd6b33904367aa6dc00ca2e2f5f780f433acf35
Reviewed-on: https://webrtc-review.googlesource.com/94510
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24314}
diff --git a/call/test/fake_network_pipe_unittest.cc b/call/test/fake_network_pipe_unittest.cc
index fe7d8a9..284d18c 100644
--- a/call/test/fake_network_pipe_unittest.cc
+++ b/call/test/fake_network_pipe_unittest.cc
@@ -13,6 +13,7 @@
#include <memory>
#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 @@
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
MockReceiver receiver;
+ std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
+ SimulatedNetwork* simulated_network = network.get();
std::unique_ptr<FakeNetworkPipe> 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 @@
// 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 @@
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
MockReceiver receiver;
+ std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
+ SimulatedNetwork* simulated_network = network.get();
std::unique_ptr<FakeNetworkPipe> 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 @@
// 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 @@
config.queue_delay_ms = 100;
config.delay_standard_deviation_ms = 10;
ReorderTestReceiver receiver;
+ std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
+ SimulatedNetwork* simulated_network = network.get();
std::unique_ptr<FakeNetworkPipe> 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 @@
}
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();