FuncDoodle
Loading...
Searching...
No Matches
ImTest.h
Go to the documentation of this file.
1
12
13#pragma once
14
15#include "Core/App.h"
16#include "Test/Test.h"
17#include "imgui_te_context.h"
18
29struct ImTestCtx {
30 ImGuiTestContext* Ctx;
32};
33
43 auto* app =
44 static_cast<FuncDoodle::Application*>(ImGui::GetIO().UserData);
45 if (!app) {
47 }
48 return app;
49}
50
62
86template <typename F>
87inline ImGuiTest* ImTest(const char* name, F testFunc) {
88 auto* stored = new F(std::move(testFunc));
89 ImGuiTest* t = IM_REGISTER_TEST(s_TestEngine, "funcdoodle", name);
90 t->UserData = stored;
91 t->GuiFunc = [](ImGuiTestContext*) {};
92 t->TestFunc = [](ImGuiTestContext* ctx) {
93 auto& func = *static_cast<F*>(ctx->Test->UserData);
94 ImTestCtx tc{ctx, GetPopups()};
95 func(tc);
96 };
97 return t;
98}
99
Core FuncDoodle application class and runtime control interface.
ImGuiTest * ImTest(const char *name, F testFunc)
Registers a test under the "funcdoodle" group with automatic popup injection.
Definition ImTest.h:87
FuncDoodle::PopupRegistry & GetPopups()
Returns the application's popup registry.
Definition ImTest.h:59
FuncDoodle::Application * GetApp()
Returns the active FuncDoodle application instance.
Definition ImTest.h:42
Lightweight testing framework for FuncDoodle.
Class holding most of the data required to launch FuncDoodle.
Definition App.h:50
UIManager & GetUiManager()
Returns the top-level UI manager.
Definition App.h:297
static Application * Get()
Returns the active application singleton.
Definition App.h:60
Stores all popups used in FuncDoodle.
Definition PopupRegistry.h:76
PopupRegistry & GetPopups()
Returns the popup state registry owned by the UI manager.
Definition UIManager.h:49
Bundles the ImGui test context with a popup registry reference.
Definition ImTest.h:29
FuncDoodle::PopupRegistry & Popups
Definition ImTest.h:31
ImGuiTestContext * Ctx
Definition ImTest.h:30