Skip to content

Commit

Permalink
TestSuite: added "window_append_status"
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Apr 19, 2024
1 parent fac000b commit fc5105f
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion imgui_test_suite/imgui_tests_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ void RegisterTests_Window(ImGuiTestEngine* e)
};

// ## Test appending multiple times to a child window (bug #2282)
t = IM_REGISTER_TEST(e, "window", "window_append");
t = IM_REGISTER_TEST(e, "window", "window_append_child");
t->GuiFunc = [](ImGuiTestContext* ctx)
{
ImGui::SetNextWindowSize(ImVec2(200, 200));
Expand Down Expand Up @@ -411,6 +411,39 @@ void RegisterTests_Window(ImGuiTestEngine* e)
ImGui::End();
};

// ## Test IsItemXXX calls after an append-Begin() call (#7506)
t = IM_REGISTER_TEST(e, "window", "window_append_status");
t->GuiFunc = [](ImGuiTestContext* ctx)
{
auto& vars = ctx->GenericVars;
ImGui::Begin("Test Window", NULL, ImGuiWindowFlags_NoSavedSettings);
vars.Bool1 = ImGui::IsItemHovered();
ImGui::Text("IsItemHovered = %d (first)", vars.Bool1);
ImRect window_rect = ImGui::GetCurrentWindowRead()->Rect();
ImGui::End();

// Make sure we have an item in-between so that old last item isn't used
ImGui::SetNextWindowPos(ImVec2(window_rect.Max.x, window_rect.Min.y));
ImGui::Begin("Another window");
ImGui::Button("Foobar");
{
ImGui::Begin("Test Window", NULL, ImGuiWindowFlags_NoSavedSettings);
vars.Bool2 = ImGui::IsItemHovered();
ImGui::Text("IsItemHovered = %d (append)", vars.Bool2);
ImGui::End();
}
ImGui::End();
};
t->TestFunc = [](ImGuiTestContext* ctx)
{
auto& vars = ctx->GenericVars;
ctx->MouseMoveToPos(ctx->GetWindowTitlebarPoint("Test Window"));
IM_CHECK(vars.Bool1 == true);
#if IMGUI_VERSION_NUM >= 19052
IM_CHECK(vars.Bool2 == true);
#endif
};

// ## Test basic focus behavior
// FIXME-TESTS: This in particular when combined with Docking should be tested with and without ConfigDockingTabBarOnSingleWindows
t = IM_REGISTER_TEST(e, "window", "window_focus_1");
Expand Down

0 comments on commit fc5105f

Please sign in to comment.