Enhance EditorIntegrationTest for ImGui Test Engine support
- Added conditional compilation for the ImGui Test Engine in `EditorIntegrationTest`, allowing for test registration and engine initialization when enabled. - Updated the constructor and destructor to manage the test engine context appropriately. - Improved the `Initialize` method to include test engine setup and registration, enhancing the integration testing capabilities. - Ensured compatibility with scenarios where the ImGui Test Engine is disabled by providing default implementations for related methods.
This commit is contained in:
@@ -9,22 +9,32 @@
|
|||||||
#include "imgui/backends/imgui_impl_sdl2.h"
|
#include "imgui/backends/imgui_impl_sdl2.h"
|
||||||
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
|
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
|
#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE
|
||||||
#include "imgui_test_engine/imgui_te_context.h"
|
#include "imgui_test_engine/imgui_te_context.h"
|
||||||
#include "imgui_test_engine/imgui_te_engine.h"
|
#include "imgui_test_engine/imgui_te_engine.h"
|
||||||
#include "imgui_test_engine/imgui_te_imconfig.h"
|
#include "imgui_test_engine/imgui_te_imconfig.h"
|
||||||
#include "imgui_test_engine/imgui_te_ui.h"
|
#include "imgui_test_engine/imgui_te_ui.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
EditorIntegrationTest::EditorIntegrationTest()
|
EditorIntegrationTest::EditorIntegrationTest()
|
||||||
: engine_(nullptr), show_demo_window_(true) {}
|
#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE
|
||||||
|
: engine_(nullptr), show_demo_window_(true)
|
||||||
|
#else
|
||||||
|
|
||||||
|
#endif
|
||||||
|
{}
|
||||||
|
|
||||||
EditorIntegrationTest::~EditorIntegrationTest() {
|
EditorIntegrationTest::~EditorIntegrationTest() {
|
||||||
|
#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE
|
||||||
if (engine_) {
|
if (engine_) {
|
||||||
ImGuiTestEngine_Stop(engine_);
|
ImGuiTestEngine_Stop(engine_);
|
||||||
ImGuiTestEngine_DestroyContext(engine_);
|
ImGuiTestEngine_DestroyContext(engine_);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status EditorIntegrationTest::Initialize() {
|
absl::Status EditorIntegrationTest::Initialize() {
|
||||||
@@ -33,11 +43,13 @@ absl::Status EditorIntegrationTest::Initialize() {
|
|||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
|
#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE
|
||||||
// Initialize Test Engine
|
// Initialize Test Engine
|
||||||
engine_ = ImGuiTestEngine_CreateContext();
|
engine_ = ImGuiTestEngine_CreateContext();
|
||||||
ImGuiTestEngineIO& test_io = ImGuiTestEngine_GetIO(engine_);
|
ImGuiTestEngineIO& test_io = ImGuiTestEngine_GetIO(engine_);
|
||||||
test_io.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
|
test_io.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
|
||||||
test_io.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
|
test_io.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
|
||||||
|
#endif
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
@@ -47,9 +59,11 @@ absl::Status EditorIntegrationTest::Initialize() {
|
|||||||
controller_.window(), yaze::core::Renderer::Get().renderer());
|
controller_.window(), yaze::core::Renderer::Get().renderer());
|
||||||
ImGui_ImplSDLRenderer2_Init(yaze::core::Renderer::Get().renderer());
|
ImGui_ImplSDLRenderer2_Init(yaze::core::Renderer::Get().renderer());
|
||||||
|
|
||||||
|
#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE
|
||||||
// Register tests
|
// Register tests
|
||||||
RegisterTests(engine_);
|
RegisterTests(engine_);
|
||||||
ImGuiTestEngine_Start(engine_, ImGui::GetCurrentContext());
|
ImGuiTestEngine_Start(engine_, ImGui::GetCurrentContext());
|
||||||
|
#endif
|
||||||
controller_.set_active(true);
|
controller_.set_active(true);
|
||||||
|
|
||||||
// Set the default style
|
// Set the default style
|
||||||
@@ -83,8 +97,10 @@ int EditorIntegrationTest::RunTest() {
|
|||||||
absl::Status EditorIntegrationTest::Update() {
|
absl::Status EditorIntegrationTest::Update() {
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE
|
||||||
// Show test engine windows
|
// Show test engine windows
|
||||||
ImGuiTestEngine_ShowTestEngineWindows(engine_, &show_demo_window_);
|
ImGuiTestEngine_ShowTestEngineWindows(engine_, &show_demo_window_);
|
||||||
|
#endif
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,11 @@
|
|||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/core/controller.h"
|
#include "app/core/controller.h"
|
||||||
#include "app/core/window.h"
|
#include "app/core/window.h"
|
||||||
|
|
||||||
|
#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE
|
||||||
#include "imgui_test_engine/imgui_te_context.h"
|
#include "imgui_test_engine/imgui_te_context.h"
|
||||||
#include "imgui_test_engine/imgui_te_engine.h"
|
#include "imgui_test_engine/imgui_te_engine.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace test {
|
namespace test {
|
||||||
@@ -39,8 +42,13 @@ class EditorIntegrationTest {
|
|||||||
// Run the test
|
// Run the test
|
||||||
int RunTest();
|
int RunTest();
|
||||||
|
|
||||||
|
#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE
|
||||||
// Register tests for a specific editor
|
// Register tests for a specific editor
|
||||||
virtual void RegisterTests(ImGuiTestEngine* engine) = 0;
|
virtual void RegisterTests(ImGuiTestEngine* engine) = 0;
|
||||||
|
#else
|
||||||
|
// Default implementation when ImGui Test Engine is disabled
|
||||||
|
virtual void RegisterTests(void* engine) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Update the test environment
|
// Update the test environment
|
||||||
virtual absl::Status Update();
|
virtual absl::Status Update();
|
||||||
@@ -66,9 +74,11 @@ class EditorIntegrationTest {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
core::Controller controller_;
|
core::Controller controller_;
|
||||||
|
#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE
|
||||||
ImGuiTestEngine* engine_;
|
ImGuiTestEngine* engine_;
|
||||||
std::unique_ptr<Rom> test_rom_;
|
|
||||||
bool show_demo_window_;
|
bool show_demo_window_;
|
||||||
|
#endif
|
||||||
|
std::unique_ptr<Rom> test_rom_;
|
||||||
core::Window window_;
|
core::Window window_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user