3#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE
6#if __has_include("imgui_test_engine/imgui_te_context.h")
7#include "imgui_test_engine/imgui_te_context.h"
8#elif __has_include("imgui_te_context.h")
9#include "imgui_te_context.h"
11#error "ImGui Test Engine context header not found"
14#if __has_include("imgui_test_engine/imgui_te_engine.h")
15#include "imgui_test_engine/imgui_te_engine.h"
16#elif __has_include("imgui_te_engine.h")
17#include "imgui_te_engine.h"
19#error "ImGui Test Engine engine header not found"
31static void RegisterPanelVisibilityTests(ImGuiTestEngine* engine) {
35 IM_REGISTER_TEST(engine,
"dungeon_panels",
"object_editor_opens");
36 test->TestFunc = [](ImGuiTestContext* ctx) {
37 ctx->SetRef(
"Dungeon Workbench");
38 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
40 ctx->ItemClick(
"**/BG1");
41 ctx->ItemClick(
"**/BG1");
48 IM_REGISTER_TEST(engine,
"dungeon_panels",
"room_selector_exists");
49 test->TestFunc = [](ImGuiTestContext* ctx) {
50 ctx->SetRef(
"Room Selector");
51 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
53 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
66static void RegisterLayerToggleTests(ImGuiTestEngine* engine) {
70 IM_REGISTER_TEST(engine,
"dungeon_layers",
"bg1_toggle_clickable");
71 test->TestFunc = [](ImGuiTestContext* ctx) {
73 ctx->SetRef(
"Dungeon Workbench");
74 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
76 ctx->ItemClick(
"**/BG1");
79 ctx->ItemClick(
"**/BG1");
86 IM_REGISTER_TEST(engine,
"dungeon_layers",
"bg2_toggle_clickable");
87 test->TestFunc = [](ImGuiTestContext* ctx) {
88 ctx->SetRef(
"Dungeon Workbench");
89 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
91 ctx->ItemClick(
"**/BG2");
92 ctx->ItemClick(
"**/BG2");
103static void RegisterToolbarTests(ImGuiTestEngine* engine) {
107 IM_REGISTER_TEST(engine,
"dungeon_toolbar",
"workbench_focus");
108 test->TestFunc = [](ImGuiTestContext* ctx) {
109 ctx->SetRef(
"Dungeon Workbench");
110 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
111 ctx->WindowFocus(
"");
112 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
125static void RegisterKeyboardShortcutTests(ImGuiTestEngine* engine) {
129 IM_REGISTER_TEST(engine,
"dungeon_keys",
"escape_no_crash");
130 test->TestFunc = [](ImGuiTestContext* ctx) {
131 ctx->SetRef(
"Dungeon Workbench");
132 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
133 ctx->WindowFocus(
"");
134 ctx->KeyPress(ImGuiKey_Escape);
136 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
143 IM_REGISTER_TEST(engine,
"dungeon_keys",
"delete_no_crash");
144 test->TestFunc = [](ImGuiTestContext* ctx) {
145 ctx->SetRef(
"Dungeon Workbench");
146 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
147 ctx->WindowFocus(
"");
148 ctx->KeyPress(ImGuiKey_Delete);
150 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
156 ImGuiTest* test = IM_REGISTER_TEST(engine,
"dungeon_keys",
"undo_no_crash");
157 test->TestFunc = [](ImGuiTestContext* ctx) {
158 ctx->SetRef(
"Dungeon Workbench");
159 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
160 ctx->WindowFocus(
"");
161 ctx->KeyPress(ImGuiMod_Ctrl | ImGuiKey_Z);
163 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
177static void RegisterToastTests(ImGuiTestEngine* engine) {
181 IM_REGISTER_TEST(engine,
"dungeon_toast",
"rapid_actions_stable");
182 test->TestFunc = [](ImGuiTestContext* ctx) {
183 ctx->SetRef(
"Dungeon Workbench");
184 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
185 ctx->WindowFocus(
"");
190 for (
int i = 0; i < 5; ++i) {
191 ctx->KeyPress(ImGuiKey_Escape);
195 IM_CHECK(ctx->GetWindowByRef(
"") !=
nullptr);
205 RegisterPanelVisibilityTests(engine);
206 RegisterLayerToggleTests(engine);
207 RegisterToolbarTests(engine);
208 RegisterKeyboardShortcutTests(engine);
209 RegisterToastTests(engine);
void RegisterDungeonUITests(ImGuiTestEngine *)