class TestLoop

Defined at line 32 of file ../../sdk/lib/async-testing/include/lib/async-testing/test_loop.h

A message loop with a fake clock, to be controlled within a test setting.

Public Methods

void TestLoop (const TestLoop & )

Defined at line 42 of file ../../sdk/lib/async-testing/include/lib/async-testing/test_loop.h

TestLoop & operator= (const TestLoop & )

Defined at line 43 of file ../../sdk/lib/async-testing/include/lib/async-testing/test_loop.h

void TestLoop (TestLoop && )

Defined at line 45 of file ../../sdk/lib/async-testing/include/lib/async-testing/test_loop.h

TestLoop & operator= (TestLoop && )

Defined at line 46 of file ../../sdk/lib/async-testing/include/lib/async-testing/test_loop.h

uint32_t initial_state ()

The initial value of the state of the TestLoop.

Defined at line 102 of file ../../sdk/lib/async-testing/include/lib/async-testing/test_loop.h

void TestLoop ()

Constructs a TestLoop with a seed from the environment, or a random

seed if absent.

Defined at line 113 of file ../../sdk/lib/async-testing/test_loop.cc

void TestLoop (uint32_t state)

If state is nonzero, constructs a TestLoop with the given seed.

Otherwise, uses a seed from the environment or a random seed.

Defined at line 115 of file ../../sdk/lib/async-testing/test_loop.cc

void ~TestLoop ()

Defined at line 124 of file ../../sdk/lib/async-testing/test_loop.cc

async_dispatcher_t * dispatcher ()

Returns the test loop's asynchronous dispatcher.

Defined at line 126 of file ../../sdk/lib/async-testing/test_loop.cc

std::unique_ptr<LoopInterface> StartNewLoop ()

Returns a loop interface simulating the starting up of a new message

loop. Each successive call to this method corresponds to a new

subloop. The subloop is unregistered and destructed when the returned

interface is destructed. The returned interface must not outlive the test

loop.

Defined at line 164 of file ../../sdk/lib/async-testing/test_loop.cc

std::unique_ptr<SubloopToken> RegisterLoop (async_test_subloop_t * loop)

Registers a new loop. The test loop takes ownership of the subloop. The

subloop is unregistered and finalized when the returned registration

token is destructed. The token must not outlive the test loop.

Defined at line 171 of file ../../sdk/lib/async-testing/test_loop.cc

zx::time Now ()

Returns the current fake clock time.

Defined at line 178 of file ../../sdk/lib/async-testing/test_loop.cc

void Quit ()

Quits the message loop. If called while running, it will immediately

exit and dispatch no further tasks or waits; if called before running,

then next call to run will immediately exit. Further calls to run will

dispatch as usual.

Defined at line 180 of file ../../sdk/lib/async-testing/test_loop.cc

bool BlockCurrentSubLoopAndRunOthersUntil (fit::function<bool ()> condition)

This method must be called while running. It will block the current subloop

until |condition| is realized. Other subloops will continue to run. Returns

|true| when |condition| is realized, and |false| if |condition| is not

realized and no further progress is possible.

Defined at line 128 of file ../../sdk/lib/async-testing/test_loop.cc

void AdvanceTimeByEpsilon ()

Advances the fake clock time by the smallest possible amount.

This doesn't run the loop.

Defined at line 182 of file ../../sdk/lib/async-testing/test_loop.cc

bool RunUntil (zx::time deadline)

Dispatches all waits and all tasks with deadlines up until |deadline|,

progressively advancing the fake clock.

Returns true iff any tasks or waits were invoked during the run.

Defined at line 184 of file ../../sdk/lib/async-testing/test_loop.cc

bool RunFor (zx::duration duration)

Dispatches all waits and all tasks with deadlines up until |duration|

from the the current time, progressively advancing the fake clock.

Returns true iff any tasks or waits were invoked during the run.

Defined at line 194 of file ../../sdk/lib/async-testing/test_loop.cc

void RunRepeatedlyFor (zx::duration increment)

Repeatedly runs the loop by |increment| until nothing further is left to

dispatch.

Defined at line 196 of file ../../sdk/lib/async-testing/test_loop.cc

bool RunUntilIdle ()

Dispatches all waits and all tasks with deadlines up until the current

time, progressively advancing the fake clock.

Returns true iff any tasks or waits were invoked during the run.

Defined at line 201 of file ../../sdk/lib/async-testing/test_loop.cc