Open S-A-Martin opened 1 year ago
Hello,
It's not really possible as the value is owned by you, so you need access to your data if you want to test against it.
We recently improved that section of the docs here: Automation-API -> Accessing your data
We have a WIP set of API (non-published yet) to "read" from emitted vertices or capture text logs, so you could technically capture the text output of the "sVal" widget (which would be e.g. "5.5" + "sVal") which may later be leveraged for this as an alternative solution.
I have pushed helpers to do this by using selection + clipboard + parse as a way to extract values. This is not the more general version I'm hoping to further develop but it does the job for simple cases, and is a good workaround.
t = IM_REGISTER_TEST(e, "testengine", "testengine_select_read_value");
t->GuiFunc = [](ImGuiTestContext* ctx)
{
ImGui::Begin("Test Window", NULL, ImGuiWindowFlags_NoSavedSettings);
int v_int = 123;
float v_float = 0.456f;
ImGui::SliderInt("int", &v_int, 0, 200);
ImGui::DragFloat("float", &v_float, 0.01f, 0.0f, 1.0f);
ImGui::End();
};
t->TestFunc = [](ImGuiTestContext* ctx)
{
ctx->SetRef("Test Window");
int v_int = 0;
float v_float = 0;
ctx->ItemSelectAndReadValue("int", &v_int);
ctx->ItemSelectAndReadValue("float", &v_float);
IM_CHECK_EQ(v_int, 123);
IM_CHECK_EQ(v_float, 0.456f);
};
How do I check the value of something by querying its ref? I'm hoping to do something like this:
I'm not using GuiFunc, so I don't 'think' using GetVars is what I need, and I don't have the variable tied to an app class or anything.
It's being used more like:
I just want to verify that the slider value is set correctly.