Pigweed
 
Loading...
Searching...
No Matches
fake_dispatcher_fixture.h
1// Copyright 2023 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14#pragma once
15
16#include "pw_async/fake_dispatcher.h"
17#include "pw_unit_test/framework.h"
18
19namespace pw::async::test {
20
40 public:
42 FakeDispatcher& dispatcher() { return dispatcher_; }
43
45 chrono::SystemClock::time_point now() { return dispatcher_.now(); }
46
49 bool RunUntilIdle() { return dispatcher_.RunUntilIdle(); }
50
54 bool RunUntil(chrono::SystemClock::time_point end_time) {
55 return dispatcher_.RunUntil(end_time);
56 }
57
62 return dispatcher_.RunFor(duration);
63 }
64
65 private:
66 FakeDispatcher dispatcher_;
67};
68
69} // namespace pw::async::test
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 RunUntil(chrono::SystemClock::time_point end_time)
Definition: fake_dispatcher_fixture.h:54
chrono::SystemClock::time_point now()
Returns the current fake time.
Definition: fake_dispatcher_fixture.h:45
bool RunFor(chrono::SystemClock::duration duration)
Definition: fake_dispatcher_fixture.h:61
bool RunUntilIdle()
Definition: fake_dispatcher_fixture.h:49
Definition: framework_backend.h:693
std::chrono::duration< rep, period > duration
Alias for durations representable with this clock.
Definition: system_clock.h:86