move MasterEditor::RegisterTests to master_editor_test.cc

This commit is contained in:
scawful
2024-07-27 09:46:38 -04:00
parent 2962ae8e4e
commit dd3596607d
3 changed files with 45 additions and 55 deletions

View File

@@ -674,61 +674,6 @@ void MasterEditor::DrawViewMenu() {
}
}
void MasterEditor::RegisterTests(ImGuiTestEngine* e) {
test_engine = e;
ImGuiTest* t = nullptr;
t = IM_REGISTER_TEST(e, "master_editor", "open_rom");
t->GuiFunc = [](ImGuiTestContext* ctx) {
IM_UNUSED(ctx);
ImGui::Begin("Test Window", nullptr, ImGuiWindowFlags_NoSavedSettings);
ImGui::Text("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");
ctx->ItemClick("Click Me");
ctx->ItemOpen("Node"); // Optional as ItemCheck("Node/Checkbox") can do it
ctx->ItemCheck("Node/Checkbox");
ctx->ItemUncheck("Node/Checkbox");
};
t = IM_REGISTER_TEST(e, "master_editor", "use_variables");
struct TestVars2 {
int MyInt = 42;
};
t->SetVarsDataType<TestVars2>();
t->GuiFunc = [](ImGuiTestContext* ctx) {
TestVars2& vars = ctx->GetVars<TestVars2>();
ImGui::Begin("Test Window", 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");
IM_CHECK_EQ(vars.MyInt, 42);
ctx->ItemInputValue("Slider", 123);
IM_CHECK_EQ(vars.MyInt, 123);
};
t = IM_REGISTER_TEST(e, "master_editor", "open_metrics");
t->GuiFunc = [](ImGuiTestContext* ctx) {
IM_UNUSED(ctx);
ImGui::ShowMetricsWindow();
};
t->TestFunc = [](ImGuiTestContext* ctx) {
ctx->SetRef("Dear ImGui Metrics");
};
}
void MasterEditor::DrawTestMenu() {
static bool show_tests_ = false;