From 435860387459562c8902eecaa54bd375fdecb1c5 Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 11 Oct 2025 15:19:12 -0400 Subject: [PATCH] feat(tests): conditionally include ImGui test engine functionality - Added conditional compilation for ImGui test engine features in `test_utils.cc` and `test_utils.h`, enabling the loading of ROMs and opening of editors only when the YAZE_ENABLE_IMGUI_TEST_ENGINE flag is set. - Improved modularity by managing includes based on feature flags, enhancing the flexibility of the testing framework. Benefits: - Streamlined testing process for ImGui-related functionalities. - Enhanced code organization by isolating ImGui test engine dependencies. --- test/test_utils.cc | 4 ++++ test/test_utils.h | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/test_utils.cc b/test/test_utils.cc index 77222e08..3f61c523 100644 --- a/test/test_utils.cc +++ b/test/test_utils.cc @@ -6,12 +6,16 @@ namespace test { namespace gui { void LoadRomInTest(ImGuiTestContext* ctx, const std::string& rom_path) { +#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE yaze::core::Controller* controller = (yaze::core::Controller*)ctx->Test->UserData; controller->OnEntry(rom_path); +#endif } void OpenEditorInTest(ImGuiTestContext* ctx, const std::string& editor_name) { +#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE ctx->MenuClick(absl::StrFormat("Editors/%s", editor_name).c_str()); +#endif } } // namespace gui diff --git a/test/test_utils.h b/test/test_utils.h index 7552a149..a2b10d46 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -15,9 +15,12 @@ #include #include "absl/strings/str_format.h" -#include "imgui_test_engine/imgui_te_context.h" #include "app/rom.h" +#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE +#include "imgui_test_engine/imgui_te_context.h" +#endif + namespace yaze { namespace test { @@ -193,8 +196,10 @@ class RomDependentTest : public ::testing::Test { namespace gui { +#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE void LoadRomInTest(ImGuiTestContext* ctx, const std::string& rom_path); void OpenEditorInTest(ImGuiTestContext* ctx, const std::string& editor_name); +#endif } // namespace gui