chore: include imgui_test_engine
This commit is contained in:
@@ -27,6 +27,7 @@ target_include_directories(
|
||||
yaze_test PUBLIC
|
||||
app/
|
||||
lib/
|
||||
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
|
||||
${ASAR_INCLUDE_DIR}
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${PNG_INCLUDE_DIRS}
|
||||
@@ -38,7 +39,6 @@ target_link_libraries(
|
||||
asar-static
|
||||
${ABSL_TARGETS}
|
||||
${PNG_LIBRARIES}
|
||||
${GLEW_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
${CMAKE_DL_LIBS}
|
||||
yaze_c
|
||||
|
||||
39
src/test/integration/test_editor.cc
Normal file
39
src/test/integration/test_editor.cc
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "test/integration/test_editor.h"
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui_test_engine/imgui_te_context.h"
|
||||
#include "imgui_test_engine/imgui_te_engine.h"
|
||||
#include "imgui_test_engine/imgui_te_ui.h"
|
||||
|
||||
namespace yaze_test {
|
||||
namespace integration {
|
||||
|
||||
absl::Status TestEditor::Update() {
|
||||
if (ImGui::Begin("My Window")) {
|
||||
ImGui::Text("Hello, world!");
|
||||
ImGui::Button("My Button");
|
||||
}
|
||||
|
||||
static bool show_demo_window = true;
|
||||
|
||||
ImGuiTestEngine_ShowTestEngineWindows(engine_, &show_demo_window);
|
||||
|
||||
ImGui::End();
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
void TestEditor::RegisterTests(ImGuiTestEngine* engine) {
|
||||
ImGuiTest* test = IM_REGISTER_TEST(engine, "demo_test", "test1");
|
||||
test->TestFunc = [](ImGuiTestContext* ctx) {
|
||||
ctx->SetRef("My Window");
|
||||
ctx->ItemClick("My Button");
|
||||
ctx->ItemCheck("Node/Checkbox");
|
||||
ctx->ItemInputValue("Slider", 123);
|
||||
|
||||
ctx->MenuCheck("//Dear ImGui Demo/Tools/About Dear ImGui");
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace integration
|
||||
} // namespace yaze_test
|
||||
@@ -2,6 +2,9 @@
|
||||
#define YAZE_TEST_INTEGRATION_TEST_EDITOR_H
|
||||
|
||||
#include "app/editor/utils/editor.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui_test_engine/imgui_te_context.h"
|
||||
#include "imgui_test_engine/imgui_te_engine.h"
|
||||
|
||||
namespace yaze_test {
|
||||
namespace integration {
|
||||
@@ -32,9 +35,13 @@ class TestEditor : public yaze::app::editor::Editor {
|
||||
return absl::UnimplementedError("Not implemented");
|
||||
}
|
||||
|
||||
absl::Status Update() override {
|
||||
return absl::UnimplementedError("Not implemented");
|
||||
}
|
||||
absl::Status Update() override;
|
||||
|
||||
void RegisterTests(ImGuiTestEngine* engine);
|
||||
|
||||
private:
|
||||
|
||||
ImGuiTestEngine* engine_;
|
||||
};
|
||||
|
||||
} // namespace integration
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
#include "absl/debugging/failure_signal_handler.h"
|
||||
#include "absl/debugging/symbolize.h"
|
||||
#include "app/core/controller.h"
|
||||
#include "app/core/platform/renderer.h"
|
||||
#include "imgui/backends/imgui_impl_sdl2.h"
|
||||
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui_test_engine/imgui_te_context.h"
|
||||
#include "imgui_test_engine/imgui_te_engine.h"
|
||||
#include "imgui_test_engine/imgui_te_imconfig.h"
|
||||
#include "test/integration/test_editor.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
@@ -26,10 +30,33 @@ int main(int argc, char* argv[]) {
|
||||
yaze::app::core::Controller controller;
|
||||
controller.init_test_editor(&test_editor);
|
||||
|
||||
auto entry = controller.OnEntry();
|
||||
if (!entry.ok()) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
controller.CreateSDL_Window();
|
||||
controller.CreateRenderer();
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
|
||||
// Initialize Test Engine
|
||||
ImGuiTestEngine* engine = ImGuiTestEngine_CreateContext();
|
||||
ImGuiTestEngineIO& test_io = ImGuiTestEngine_GetIO(engine);
|
||||
test_io.ConfigVerboseLevel = ImGuiTestVerboseLevel_Info;
|
||||
test_io.ConfigVerboseLevelOnError = ImGuiTestVerboseLevel_Debug;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
|
||||
// Initialize ImGui for SDL
|
||||
ImGui_ImplSDL2_InitForSDLRenderer(
|
||||
controller.window(),
|
||||
yaze::app::core::Renderer::GetInstance().renderer());
|
||||
ImGui_ImplSDLRenderer2_Init(
|
||||
yaze::app::core::Renderer::GetInstance().renderer());
|
||||
|
||||
test_editor.RegisterTests(engine);
|
||||
ImGuiTestEngine_Start(engine, ImGui::GetCurrentContext());
|
||||
|
||||
// Build a new ImGui frame
|
||||
ImGui_ImplSDLRenderer2_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
|
||||
while (controller.IsActive()) {
|
||||
controller.OnInput();
|
||||
@@ -39,6 +66,7 @@ int main(int argc, char* argv[]) {
|
||||
controller.DoRender();
|
||||
}
|
||||
|
||||
ImGuiTestEngine_Stop(engine);
|
||||
controller.OnExit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user