Pigweed
 
Loading...
Searching...
No Matches
pw::async::test::FakeDispatcherFixture Class Reference

#include <fake_dispatcher_fixture.h>

Inheritance diagram for pw::async::test::FakeDispatcherFixture:
pw::unit_test::internal::Test

Public Member Functions

FakeDispatcher & dispatcher ()
 Returns the FakeDispatcher that should be used for dependency injection.
 
chrono::SystemClock::time_point now ()
 Returns the current fake time.
 
bool RunUntilIdle ()
 
bool RunUntil (chrono::SystemClock::time_point end_time)
 
bool RunFor (chrono::SystemClock::duration duration)
 
- Public Member Functions inherited from pw::unit_test::internal::Test
 Test (const Test &)=delete
 
Testoperator= (const Test &)=delete
 
void PigweedTestRun ()
 

Additional Inherited Members

- Static Public Member Functions inherited from pw::unit_test::internal::Test
static void SetUpTestSuite ()
 
static void TearDownTestSuite ()
 
static bool HasFailure ()
 
- Protected Member Functions inherited from pw::unit_test::internal::Test
virtual void SetUp ()
 
virtual void TearDown ()
 

Detailed Description

Test fixture that is a simple wrapper around a FakeDispatcher.

Example:

TEST_F(ExampleTest, Example) {
MyClass obj(dispatcher());
obj.ScheduleSomeTasks();
EXPECT_TRUE(RunUntilIdle());
EXPECT_TRUE(some condition);
obj.ScheduleTaskToRunIn30Seconds();
EXPECT_TRUE(RunFor(30s));
EXPECT_TRUE(task ran);
}
Definition: fake_dispatcher_fixture.h:39
FakeDispatcher & dispatcher()
Returns the FakeDispatcher that should be used for dependency injection.
Definition: fake_dispatcher_fixture.h:42
bool RunFor(chrono::SystemClock::duration duration)
Definition: fake_dispatcher_fixture.h:61
bool RunUntilIdle()
Definition: fake_dispatcher_fixture.h:49

Member Function Documentation

◆ RunFor()

bool pw::async::test::FakeDispatcherFixture::RunFor ( chrono::SystemClock::duration  duration)
inline

Dispatches all tasks with due times up to now() + duration, progressively advancing the fake clock. Returns true iff any tasks were invoked during the run.

◆ RunUntil()

bool pw::async::test::FakeDispatcherFixture::RunUntil ( chrono::SystemClock::time_point  end_time)
inline

Dispatches all tasks with due times up to end_time, progressively advancing the fake clock. Returns true iff any tasks were invoked during the run.

◆ RunUntilIdle()

bool pw::async::test::FakeDispatcherFixture::RunUntilIdle ( )
inline

Dispatches all tasks with due times up until now(). Returns true iff any tasks were invoked during the run.


The documentation for this class was generated from the following file: