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}
diff --git a/api/test/network_emulation_manager.cc b/api/test/network_emulation_manager.cc
index e23c09b..5b7cd15 100644
--- a/api/test/network_emulation_manager.cc
+++ b/api/test/network_emulation_manager.cc
@@ -50,10 +50,19 @@
 
 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
diff --git a/api/test/network_emulation_manager.h b/api/test/network_emulation_manager.h
index b368aef..8a67993 100644
--- a/api/test/network_emulation_manager.h
+++ b/api/test/network_emulation_manager.h
@@ -83,6 +83,7 @@
     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 @@
       Builder& capacity_Mbps(int link_capacity_Mbps);
       Builder& loss(double loss_rate);
       SimulatedNetworkNode Build() const;
+      SimulatedNetworkNode Build(NetworkEmulationManager* net) const;
 
      private:
       NetworkEmulationManager* const net_;