Loading...
Searching...
No Matches
UITestHarness.cpp
Go to the documentation of this file.
1//
2// Created by denzel on 10/12/2025.
3//
4
6
7#include <imgui_te_ui.h>
8#include <imgui_te_context.h>
9
10#include "tests/ProjectCreatorTests.h"
11
12namespace hellfire::tests {
14
15 void UITestHarness::on_initialize(Application &app) {
16 instance = this;
17
18 EditorApplication::on_initialize(app);
19
20 test_engine_ = ImGuiTestEngine_CreateContext();
21 ImGuiTestEngineIO &io = ImGuiTestEngine_GetIO(test_engine_);
22
23 io.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
24 io.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
25 io.ConfigRunSpeed = ImGuiTestRunSpeed_Fast;
26 io.ConfigNoThrottle = true; // Run as fast as possible
27
28 ImGuiTestEngine_Start(test_engine_, ImGui::GetCurrentContext());
29
30 // Register all test suites
31 RegisterProjectHubTests(test_engine_);
32 RegisterProjectCreatorTests(test_engine_);
33 RegisterEditorStateTests(test_engine_);
34
35 // Queue all tests
36 ImGuiTestEngine_QueueTests(test_engine_, ImGuiTestGroup_Tests);
37 }
38
40 EditorApplication::on_render();
41
42#ifndef HELLFIRE_CI_BUILD
43 ImGuiTestEngine_ShowTestEngineWindows(test_engine_, nullptr);
44#endif
45
46 // Check if tests are done
47 if (!tests_complete_ && test_engine_) {
48 ImGuiTestEngineIO &io = ImGuiTestEngine_GetIO(test_engine_);
49 if (!io.IsRunningTests) {
50 // Tests were queued and have finished running
51 tests_complete_ = true;
52 }
53 }
54 }
55
57 if (test_engine_) {
58 ImGuiTestEngine_PostSwap(test_engine_);
59 }
60 EditorApplication::on_end_frame();
61 }
62
64 if (!test_engine_) return 1;
65
66 int tested = 0, success = 0;
67 ImGuiTestEngine_GetResult(test_engine_, tested, success);
68
69 return (tested > 0 && tested == success) ? 0 : 1;
70 }
71
73 instance = nullptr;
74
75 if (test_engine_) {
76 ImGuiTestEngine_Stop(test_engine_);
77 cleanup_imgui();
78 ImGuiTestEngine_DestroyContext(test_engine_);
79 }
80 }
81
82
83
84 void RegisterEditorStateTests(ImGuiTestEngine *engine) {
85 }
86}
void on_initialize(Application &app) override
static UITestHarness * instance
void RegisterEditorStateTests(ImGuiTestEngine *engine)