1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Shared helpers for the integration tests.
//!
//! The test suite is deliberately runtime-agnostic: the same sources run under
//! `runtime-tokio` and under `runtime-smol`, selected by Cargo feature. These helpers
//! resolve [`webrtc::runtime::default_runtime`] — the compiled-in built-in — so a test
//! body does not have to thread a handle through every call.
//!
//! This lives in the test tree on purpose. The library itself has **no** ambient runtime:
//! every internal call site takes an explicit `&dyn Runtime`, and a `PeerConnection`'s
//! runtime is injected per connection via `with_runtime`. Tests that exercise a specific
//! runtime (including `MockRuntime`) should build it themselves and call its methods
//! directly rather than using these helpers.
use Future;
use ;
use Duration;
use ;
/// The one runtime instance shared by every helper in this module.
///
/// `default_runtime()` *constructs* a runtime on each call, so resolving it per operation
/// would allocate a fresh `Arc<dyn Runtime>` for every `sleep` / `timeout` / `interval` /
/// `yield_now`. Beyond the waste, that is semantically wrong: it hands out a distinct
/// runtime each time, which is harmless for the stateless built-ins but would silently
/// break any runtime carrying state (a `MockRuntime` would get a different virtual clock
/// per call). Resolve once, then clone the handle.
static RUNTIME: = new;
/// The runtime under test, i.e. whichever built-in the enabled feature provides.
///
/// Cheap to call repeatedly: clones a shared `Arc` rather than building a new runtime.
/// **Every test and example should obtain its runtime from here** rather than calling
/// `default_runtime()` directly, so a single process-wide instance backs both the timer
/// helpers and each `PeerConnection`.
/// Drive `future` to completion on the runtime under test, returning its output.
///
/// [`Runtime::block_on`] is restricted to a `()` output so the trait stays object-safe;
/// this helper recovers the generic form for tests by moving the value out through a
/// local slot, as the trait documentation suggests.
/// Sleep on the runtime under test.
pub async
/// Cooperatively yield on the runtime under test.
pub async
/// Run `future` with a deadline on the runtime under test.
pub async
/// A repeating timer on the runtime under test.