class FakeClock
Defined at line 30 of file ../../src/connectivity/network/mdns/service/test/fake_clock.h
Fakes |zx_clock_get_monotonic| (and therefore |zx::clock::get_monotonic()|).
Creating an instance of this class fakes the clock during the lifetime of the instance:
{
// Real clock in use here.
...
FakeClock kayfabe;
// Fake clock in use here.
...
FakeClock::Advance(zx::sec(10));
...
}
// Real clock in use here.
Alternatively, the static methods |Start| and |Stop| may be used.
Public Methods
void Start (zx::time at)
Begins faking |zx_clock_get_monotonic|, initially setting the fake clock time to |at|.
To resume faking the clock at its current value, do this:
FakeClock::Start(FakeClock::Get());
Starting the fake clock at zero is generally not recommended, because some code may reasonably
assume that |zx_clock_get_monotonic| will never return zero.
Defined at line 20 of file ../../src/connectivity/network/mdns/service/test/fake_clock.cc
void Stop ()
Makes |zx_clock_get_monotonic| function normally.
Defined at line 26 of file ../../src/connectivity/network/mdns/service/test/fake_clock.cc
void Advance (zx::duration by)
Advances the fake clock value by the specified duration.
Defined at line 29 of file ../../src/connectivity/network/mdns/service/test/fake_clock.cc
void Set (zx::time to)
Sets the current fake clock value.
Defined at line 32 of file ../../src/connectivity/network/mdns/service/test/fake_clock.cc
zx::time Get ()
Gets the current fake clock value.
Defined at line 35 of file ../../src/connectivity/network/mdns/service/test/fake_clock.cc
void FakeClock (zx::time at)
Constructs a |FakeClock|, starting the fake clock at |at| and stopping it when the destructor
runs.
Defined at line 55 of file ../../src/connectivity/network/mdns/service/test/fake_clock.h
void ~FakeClock ()
Destructs the current |FakeClock|, returning |zx_clock_get_monotonic| to normal function.
Defined at line 58 of file ../../src/connectivity/network/mdns/service/test/fake_clock.h