C/C++ API Reference
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
22
42 public:
44 FakeDispatcher& dispatcher() { return dispatcher_; }
45
47 chrono::SystemClock::time_point now() { return dispatcher_.now(); }
48
51 bool RunUntilIdle() { return dispatcher_.RunUntilIdle(); }
52
56 bool RunUntil(chrono::SystemClock::time_point end_time) {
57 return dispatcher_.RunUntil(end_time);
58 }
59
64 return dispatcher_.RunFor(duration);
65 }
66
67 private:
68 FakeDispatcher dispatcher_;
69};
70
71} // namespace pw::async::test
Definition: fake_dispatcher_fixture.h:41
Definition: framework_backend.h:698
FakeDispatcher & dispatcher()
Returns the FakeDispatcher that should be used for dependency injection.
Definition: fake_dispatcher_fixture.h:44
bool RunUntil(chrono::SystemClock::time_point end_time)
Definition: fake_dispatcher_fixture.h:56
chrono::SystemClock::time_point now()
Returns the current fake time.
Definition: fake_dispatcher_fixture.h:47
bool RunFor(chrono::SystemClock::duration duration)
Definition: fake_dispatcher_fixture.h:63
bool RunUntilIdle()
Definition: fake_dispatcher_fixture.h:51
std::chrono::duration< rep, period > duration
Alias for durations representable with this clock.
Definition: system_clock.h:90