#define IMGUI_DEFINE_MATH_OPERATORS
#include "imgui.h"
#include "imgui_internal.h"
#include "imgui_te_engine.h"
#include "imgui_te_context.h"
#include "cimgui_test_engine.h"
extern "C" {
void imgui_test_engine_register_default_tests(ImGuiTestEngine* engine) {
if (engine == nullptr) {
return;
}
ImGuiTest* t = nullptr;
t = IM_REGISTER_TEST(engine, "demo_tests", "basic_interaction");
t->GuiFunc = [](ImGuiTestContext* ctx) {
IM_UNUSED(ctx);
ImGui::Begin("Test Window###DefaultTests", nullptr, ImGuiWindowFlags_NoSavedSettings);
ImGui::TextUnformatted("Hello, automation world");
ImGui::Button("Click Me");
if (ImGui::TreeNode("Node")) {
static bool b = false;
ImGui::Checkbox("Checkbox", &b);
ImGui::TreePop();
}
ImGui::End();
};
t->TestFunc = [](ImGuiTestContext* ctx) {
ctx->SetRef("Test Window###DefaultTests");
ctx->ItemClick("Click Me");
ctx->ItemCheck("Node/Checkbox");
ctx->ItemUncheck("Node/Checkbox");
};
t = IM_REGISTER_TEST(engine, "demo_tests", "input_value");
struct TestVars2 {
int MyInt = 42;
};
t->SetVarsDataType<TestVars2>();
t->GuiFunc = [](ImGuiTestContext* ctx) {
TestVars2& vars = ctx->GetVars<TestVars2>();
ImGui::Begin("Test Window###DefaultTests", nullptr, ImGuiWindowFlags_NoSavedSettings);
ImGui::SliderInt("Slider", &vars.MyInt, 0, 1000);
ImGui::End();
};
t->TestFunc = [](ImGuiTestContext* ctx) {
TestVars2& vars = ctx->GetVars<TestVars2>();
ctx->SetRef("Test Window###DefaultTests");
IM_CHECK_EQ(vars.MyInt, 42);
ctx->ItemInputValue("Slider", 123);
IM_CHECK_EQ(vars.MyInt, 123);
};
}
}