/* * Copyright 2018 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/ #ifndef TEST_SCENARIO_SCENARIO_H_ #define TEST_SCENARIO_SCENARIO_H_ #include <memory> #include <string> #include <utility> #include <vector>
namespace webrtc { namespace test { // Scenario is a class owning everything for a test scenario. It creates and // holds network nodes, call clients and media streams. It also provides methods // for changing behavior at runtime. Since it always keeps ownership of the // created components, it generally returns non-owning pointers. It maintains // the life of its objects until it is destroyed. // For methods accepting configuration structs, a modifier function interface is // generally provided. This allows simple partial overriding of the default // configuration. class Scenario { public:
Scenario(); explicit Scenario(const testing::TestInfo* test_info); explicit Scenario(absl::string_view file_name);
Scenario(absl::string_view file_name, bool real_time);
Scenario(std::unique_ptr<LogWriterFactoryInterface> log_writer_manager, bool real_time);
// Runs the provided function with a fixed interval. For real time tests, // `function` starts being called after `interval` from the call to Every(). void Every(TimeDelta interval, absl::AnyInvocable<void(TimeDelta)> function); void Every(TimeDelta interval, absl::AnyInvocable<void()> function);
// Runs the provided function on the internal task queue. This ensure that // it's run on the main thread for simulated time tests. void Post(absl::AnyInvocable<void() &&> function);
// Runs the provided function after given duration has passed. For real time // tests, `function` is called after `target_time_since_start` from the call // to Every(). void At(TimeDelta offset, absl::AnyInvocable<void() &&> function);
// Sends a packet over the nodes and runs `action` when it has been delivered. void NetworkDelayedAction(std::vector<EmulatedNetworkNode*> over_nodes,
size_t packet_size,
std::function<void()> action);
// Runs the scenario for the given time. void RunFor(TimeDelta duration); // Runs the scenario until `target_time_since_start`. void RunUntil(TimeDelta target_time_since_start); // Runs the scenario until `target_time_since_start` or `exit_function` // returns true. `exit_function` is polled after each `check_interval` has // passed. void RunUntil(TimeDelta target_time_since_start,
TimeDelta check_interval,
std::function<bool()> exit_function); void Start(); void Stop();
// Triggers sending of dummy packets over the given nodes. void TriggerPacketBurst(std::vector<EmulatedNetworkNode*> over_nodes,
size_t num_packets,
size_t packet_size);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.