Allows creating a test network node builder without manager.
This is used to allow using a pre-configured builders as arguments to fixture code. Bug: webrtc:9510 Change-Id: I7837d284580fdbc926535ce5b2d8f582056534ce Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161948 Reviewed-by: Per Kjellander <perkj@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30070}
This commit is contained in:
parent
bcc1a765fb
commit
ce911263a4
@ -50,10 +50,19 @@ NetworkEmulationManager::SimulatedNetworkNode::Builder::loss(double loss_rate) {
|
||||
|
||||
NetworkEmulationManager::SimulatedNetworkNode
|
||||
NetworkEmulationManager::SimulatedNetworkNode::Builder::Build() const {
|
||||
RTC_CHECK(net_);
|
||||
return Build(net_);
|
||||
}
|
||||
|
||||
NetworkEmulationManager::SimulatedNetworkNode
|
||||
NetworkEmulationManager::SimulatedNetworkNode::Builder::Build(
|
||||
NetworkEmulationManager* net) const {
|
||||
RTC_CHECK(net);
|
||||
RTC_CHECK(net_ == nullptr || net_ == net);
|
||||
SimulatedNetworkNode res;
|
||||
auto behavior = std::make_unique<SimulatedNetwork>(config_);
|
||||
res.simulation = behavior.get();
|
||||
res.node = net_->CreateEmulatedNode(std::move(behavior));
|
||||
res.node = net->CreateEmulatedNode(std::move(behavior));
|
||||
return res;
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
@ -83,6 +83,7 @@ class NetworkEmulationManager {
|
||||
class Builder {
|
||||
public:
|
||||
explicit Builder(NetworkEmulationManager* net) : net_(net) {}
|
||||
Builder() : net_(nullptr) {}
|
||||
Builder(const Builder&) = default;
|
||||
// Sets the config state, note that this will replace any previously set
|
||||
// values.
|
||||
@ -92,6 +93,7 @@ class NetworkEmulationManager {
|
||||
Builder& capacity_Mbps(int link_capacity_Mbps);
|
||||
Builder& loss(double loss_rate);
|
||||
SimulatedNetworkNode Build() const;
|
||||
SimulatedNetworkNode Build(NetworkEmulationManager* net) const;
|
||||
|
||||
private:
|
||||
NetworkEmulationManager* const net_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user