Skip to content

Commit 32993a1

Browse files
committed
TestSuite: added "window_size_collapsed_4"
1 parent 99d4ed8 commit 32993a1

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

imgui_test_suite/imgui_tests_core.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,44 @@ void RegisterTests_Window(ImGuiTestEngine* e)
216216
IM_CHECK(vars.Bool1 == true); // Begin() return true
217217
};
218218

219+
// ## Test preserving content sizes while collapsed, and effect of SetWindowCollapsed(),SetNextWindowCollapsed() API (#7691)
220+
#if IMGUI_VERSION_NUM >= 19192
221+
t = IM_REGISTER_TEST(e, "window", "window_size_collapsed_4");
222+
t->GuiFunc = [](ImGuiTestContext* ctx)
223+
{
224+
auto& vars = ctx->GenericVars;
225+
if (vars.Step == 1)
226+
ImGui::SetNextWindowCollapsed(true);
227+
if (vars.Step == 2)
228+
ImGui::SetNextWindowCollapsed(false);
229+
if (ImGui::Begin("Test Window", NULL, ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize))
230+
ImGui::Button("Button", ImVec2(100, 100));
231+
if (vars.Step == 1)
232+
ImGui::SetWindowCollapsed(true);
233+
if (vars.Step == 2)
234+
ImGui::SetWindowCollapsed(false);
235+
if (!ctx->IsFirstGuiFrame())
236+
IM_CHECK_EQ(ImGui::GetCurrentWindow()->ContentSize, ImVec2(100, 100));
237+
ImGui::End();
238+
};
239+
t->TestFunc = [](ImGuiTestContext* ctx)
240+
{
241+
auto& vars = ctx->GenericVars;
242+
ctx->OpFlags |= ImGuiTestOpFlags_NoAutoUncollapse;
243+
ctx->SetRef("Test Window");
244+
ctx->WindowCollapse("", false);
245+
ctx->Yield(3);
246+
vars.Step = 1;
247+
ctx->Yield(3);
248+
vars.Step = 2;
249+
ctx->Yield(3);
250+
vars.Step = 3;
251+
ctx->Yield(3);
252+
vars.Step = 4;
253+
ctx->Yield(3);
254+
};
255+
#endif
256+
219257
// ## Test content sizes and its effect on scrollbar visibility
220258
t = IM_REGISTER_TEST(e, "window", "window_size_contents");
221259
t->Flags |= ImGuiTestFlags_NoAutoFinish;

0 commit comments

Comments
 (0)