MCPcopy Create free account
hub / github.com/OpenImageDebugger/OpenImageDebugger / FakeHostBackend

Class FakeHostBackend

tests/host/frame_loop_test.cpp:39–70  ·  view source on GitHub ↗

Backend that reports should_close() true after `close_after` polls, and records the order of calls so the loop's contract can be asserted.

Source from the content-addressed store, hash-verified

37// Backend that reports should_close() true after `close_after` polls, and
38// records the order of calls so the loop's contract can be asserted.
39class FakeHostBackend final : public HostBackend {
40 public:
41 explicit FakeHostBackend(int close_after) : close_after_(close_after) {}
42
43 bool initialize(const char*, int, int) override {
44 return true;
45 }
46 void poll_events() override {
47 ++polls_;
48 }
49 [[nodiscard]] bool should_close() const override {
50 return polls_ >= close_after_;
51 }
52 [[nodiscard]] FramebufferSize framebuffer_size() const override {
53 return {640, 480};
54 }
55 void begin_frame() override {
56 ++begins_;
57 }
58 void end_frame() override {
59 ++ends_;
60 }
61 void shutdown() override {
62 ++shutdowns_;
63 }
64
65 int polls_{0};
66 int begins_{0};
67 int ends_{0};
68 int shutdowns_{0};
69 int close_after_;
70};
71
72TEST(FrameLoop, TickRendersUntilBackendRequestsClose) {
73 FakeHostBackend backend{/*close_after=*/3};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected