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}
This commit is contained in:
1
BUILD.gn
1
BUILD.gn
@ -43,6 +43,7 @@ if (!build_with_chromium) {
|
|||||||
":video_engine_tests",
|
":video_engine_tests",
|
||||||
":webrtc_nonparallel_tests",
|
":webrtc_nonparallel_tests",
|
||||||
":webrtc_perf_tests",
|
":webrtc_perf_tests",
|
||||||
|
"call:fake_network_unittests",
|
||||||
"common_audio:common_audio_unittests",
|
"common_audio:common_audio_unittests",
|
||||||
"common_video:common_video_unittests",
|
"common_video:common_video_unittests",
|
||||||
"media:rtc_media_unittests",
|
"media:rtc_media_unittests",
|
||||||
|
@ -435,6 +435,7 @@ if (rtc_include_tests) {
|
|||||||
deps = [
|
deps = [
|
||||||
":call_interfaces",
|
":call_interfaces",
|
||||||
":fake_network",
|
":fake_network",
|
||||||
|
":simulated_network",
|
||||||
"../modules/rtp_rtcp",
|
"../modules/rtp_rtcp",
|
||||||
"../rtc_base:rtc_base_approved",
|
"../rtc_base:rtc_base_approved",
|
||||||
"../system_wrappers",
|
"../system_wrappers",
|
||||||
|
@ -126,6 +126,8 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module {
|
|||||||
|
|
||||||
void SetClockOffset(int64_t offset_ms);
|
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.
|
// Sets a new configuration. This won't affect packets already in the pipe.
|
||||||
void SetConfig(const FakeNetworkPipe::Config& config);
|
void SetConfig(const FakeNetworkPipe::Config& config);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "call/call.h"
|
#include "call/call.h"
|
||||||
|
#include "call/simulated_network.h"
|
||||||
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
|
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
|
||||||
#include "system_wrappers/include/clock.h"
|
#include "system_wrappers/include/clock.h"
|
||||||
#include "test/gmock.h"
|
#include "test/gmock.h"
|
||||||
@ -204,8 +205,11 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
|
|||||||
config.queue_length_packets = 20;
|
config.queue_length_packets = 20;
|
||||||
config.link_capacity_kbps = 80;
|
config.link_capacity_kbps = 80;
|
||||||
MockReceiver receiver;
|
MockReceiver receiver;
|
||||||
|
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
||||||
|
SimulatedNetwork* simulated_network = network.get();
|
||||||
std::unique_ptr<FakeNetworkPipe> pipe(
|
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
|
// Add 10 packets of 1000 bytes, = 80 kb, and verify it takes one second to
|
||||||
// get through the pipe.
|
// get through the pipe.
|
||||||
@ -229,7 +233,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
|
|||||||
|
|
||||||
// Change the capacity.
|
// Change the capacity.
|
||||||
config.link_capacity_kbps /= 2; // Reduce to 50%.
|
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
|
// Add another 10 packets of 1000 bytes, = 80 kb, and verify it takes two
|
||||||
// seconds to get them through the pipe.
|
// seconds to get them through the pipe.
|
||||||
@ -263,8 +267,11 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
|
|||||||
config.queue_length_packets = 20;
|
config.queue_length_packets = 20;
|
||||||
config.link_capacity_kbps = 80;
|
config.link_capacity_kbps = 80;
|
||||||
MockReceiver receiver;
|
MockReceiver receiver;
|
||||||
|
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
||||||
|
SimulatedNetwork* simulated_network = network.get();
|
||||||
std::unique_ptr<FakeNetworkPipe> pipe(
|
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.
|
// Add 10 packets of 1000 bytes, = 80 kb.
|
||||||
const int kNumPackets = 10;
|
const int kNumPackets = 10;
|
||||||
@ -276,7 +283,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
|
|||||||
|
|
||||||
// Change the capacity.
|
// Change the capacity.
|
||||||
config.link_capacity_kbps *= 2; // Double 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
|
// Add another 10 packets of 1000 bytes, = 80 kb, and verify it takes two
|
||||||
// seconds to get them through the pipe.
|
// seconds to get them through the pipe.
|
||||||
@ -318,8 +325,11 @@ TEST_F(FakeNetworkPipeTest, DisallowReorderingThenAllowReordering) {
|
|||||||
config.queue_delay_ms = 100;
|
config.queue_delay_ms = 100;
|
||||||
config.delay_standard_deviation_ms = 10;
|
config.delay_standard_deviation_ms = 10;
|
||||||
ReorderTestReceiver receiver;
|
ReorderTestReceiver receiver;
|
||||||
|
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
||||||
|
SimulatedNetwork* simulated_network = network.get();
|
||||||
std::unique_ptr<FakeNetworkPipe> pipe(
|
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 uint32_t kNumPackets = 100;
|
||||||
const int kPacketSize = 10;
|
const int kPacketSize = 10;
|
||||||
@ -336,7 +346,7 @@ TEST_F(FakeNetworkPipeTest, DisallowReorderingThenAllowReordering) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config.allow_reordering = true;
|
config.allow_reordering = true;
|
||||||
pipe->SetConfig(config);
|
simulated_network->SetConfig(config);
|
||||||
SendPackets(pipe.get(), kNumPackets, kPacketSize);
|
SendPackets(pipe.get(), kNumPackets, kPacketSize);
|
||||||
fake_clock_.AdvanceTimeMilliseconds(1000);
|
fake_clock_.AdvanceTimeMilliseconds(1000);
|
||||||
receiver.delivered_sequence_numbers_.clear();
|
receiver.delivered_sequence_numbers_.clear();
|
||||||
|
Reference in New Issue
Block a user