tests: Integrated ImGui Test Engine

This commit is contained in:
WerWolv
2025-05-29 23:44:49 +02:00
parent fe1309fb3d
commit 1ca40481bb
41 changed files with 17612 additions and 14 deletions

View File

@@ -13,6 +13,7 @@
#include <jthread.hpp>
#include <hex/helpers/opengl.hpp>
struct ImGuiTestEngine;
struct GLFWwindow;
struct ImGuiSettingsHandler;
@@ -60,6 +61,7 @@ namespace hex {
void forceNewFrame();
GLFWwindow *m_window = nullptr;
ImGuiTestEngine *m_testEngine = nullptr;
std::string m_windowTitle, m_windowTitleFull;

View File

@@ -23,6 +23,10 @@
#include <exception>
#include <typeinfo>
#if defined(IMGUI_TEST_ENGINE)
#include <imgui_te_engine.h>
#endif
#if defined (OS_WINDOWS)
#include <windows.h>
#elif defined (OS_MACOS)
@@ -123,6 +127,10 @@ namespace hex::crash {
// Flush all streams
fflush(stdout);
fflush(stderr);
#if defined(IMGUI_TEST_ENGINE)
ImGuiTestEngine_CrashHandler();
#endif
}
// Custom signal handler to print various information and a stacktrace when the application crashes

View File

@@ -1,3 +1,5 @@
#include <hex/api/event_manager.hpp>
#include "messaging.hpp"
#include <hex/subcommands/subcommands.hpp>
@@ -73,6 +75,7 @@ namespace hex::init {
hex::subcommands::processArguments(args);
// Unload plugins again
EventManager::clear();
PluginManager::unload();
}

View File

@@ -39,6 +39,10 @@
#include <implot3d_internal.h>
#include <imnodes.h>
#include <imnodes_internal.h>
#if defined(IMGUI_TEST_ENGINE)
#include <imgui_te_engine.h>
#include <imgui_te_ui.h>
#endif
#include <wolv/utils/string.hpp>
@@ -359,7 +363,14 @@ namespace hex {
currentFont = font->ContainerAtlas;
ImGui_ImplOpenGL3_CreateFontsTexture();
currentFont->ClearInputData();
for (ImFontConfig& fontCfg : font->ContainerAtlas->Sources) {
if (fontCfg.FontData && fontCfg.FontDataOwnedByAtlas) {
IM_FREE(fontCfg.FontData);
fontCfg.FontData = NULL;
}
}
currentFont->ClearTexData();
}
@@ -375,7 +386,14 @@ namespace hex {
cfg.SizePixels = ImHexApi::Fonts::DefaultFontSize;
font = io.Fonts->AddFontDefault(&cfg);
ImGui_ImplOpenGL3_CreateFontsTexture();
io.Fonts->ClearInputData();
for (ImFontConfig& fontCfg : font->ContainerAtlas->Sources) {
if (fontCfg.FontData && fontCfg.FontDataOwnedByAtlas) {
IM_FREE(fontCfg.FontData);
fontCfg.FontData = NULL;
}
}
io.Fonts->ClearTexData();
} else {
currentFont = font->ContainerAtlas;
@@ -389,6 +407,10 @@ namespace hex {
ImGui::NewFrame();
#if defined(IMGUI_TEST_ENGINE)
ImGuiTestEngine_ShowTestEngineWindows(m_testEngine, nullptr);
#endif
TutorialManager::drawTutorial();
EventFrameBegin::post();
@@ -843,6 +865,10 @@ namespace hex {
glfwSwapBuffers(m_window);
}
#if defined(IMGUI_TEST_ENGINE)
ImGuiTestEngine_PostSwap(m_testEngine);
#endif
// Process layout load requests
// NOTE: This needs to be done before a new frame is started, otherwise ImGui won't handle docking correctly
LayoutManager::process();
@@ -1268,6 +1294,17 @@ namespace hex {
ImPlot3D::GImPlot3D = ImPlot3D::CreateContext();
GImNodes = ImNodes::CreateContext();
#if defined(IMGUI_TEST_ENGINE)
m_testEngine = ImGuiTestEngine_CreateContext();
auto testEngineIo = ImGuiTestEngine_GetIO(m_testEngine);
testEngineIo.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
testEngineIo.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
EventRegisterImGuiTests::post(m_testEngine);
ImGuiTestEngine_Start(m_testEngine, ImGui::GetCurrentContext());
#endif
ImGuiIO &io = ImGui::GetIO();
ImGuiStyle &style = ImGui::GetStyle();