Skip to content

Commit e7cf491

Browse files
committed
TestSuite: added "table_synced_3_autofit"
ocornut/imgui#7218
1 parent a3b0296 commit e7cf491

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

imgui_test_suite/imgui_tests_tables.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,48 @@ void RegisterTests_Table(ImGuiTestEngine* e)
16251625
};
16261626
#endif
16271627

1628+
#if IMGUI_VERSION_NUM >= 19047
1629+
// ## Test auto-fit with synced instance (#7218)
1630+
t = IM_REGISTER_TEST(e, "table", "table_synced_3_autofit");
1631+
t->GuiFunc = [](ImGuiTestContext* ctx)
1632+
{
1633+
bool do_checks = !ctx->IsFirstGuiFrame();
1634+
ImGui::Begin("Test Window", NULL, ImGuiWindowFlags_NoSavedSettings);
1635+
if (ImGui::BeginTable("test_table", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit))
1636+
{
1637+
ImGui::TableNextColumn();
1638+
if (do_checks)
1639+
IM_CHECK_EQ_NO_RET(ImGui::GetContentRegionAvail().x, ImGui::CalcTextSize("Very very long text 1").x);
1640+
ImGui::Text("Very very long text 1");
1641+
ImGui::TableNextColumn();
1642+
if (do_checks)
1643+
IM_CHECK_EQ_NO_RET(ImGui::GetContentRegionAvail().x, ImGui::CalcTextSize("Text 1").x);
1644+
ImGui::Text("Text 1");
1645+
ImGui::EndTable();
1646+
}
1647+
for (int n = 0; n < 2; n++)
1648+
{
1649+
// Third table is indented. Because our table width computation logic stores absolute coordinates
1650+
// for efficiency, it makes sense to double-check this case as well.
1651+
if (n == 1)
1652+
ImGui::Indent();
1653+
if (ImGui::BeginTable("test_table", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit))
1654+
{
1655+
ImGui::TableNextColumn();
1656+
if (do_checks)
1657+
IM_CHECK_EQ_NO_RET(ImGui::GetContentRegionAvail().x, ImGui::CalcTextSize("Very very long text 1").x);
1658+
ImGui::Text("Text 1");
1659+
ImGui::TableNextColumn();
1660+
if (do_checks)
1661+
IM_CHECK_EQ_NO_RET(ImGui::GetContentRegionAvail().x, ImGui::CalcTextSize("Text 2").x);
1662+
ImGui::Text("Text 2");
1663+
ImGui::EndTable();
1664+
}
1665+
}
1666+
ImGui::End();
1667+
};
1668+
#endif
1669+
16281670
// ## Test two tables in a tooltip continuously expanding tooltip size (#3162)
16291671
t = IM_REGISTER_TEST(e, "table", "table_two_tables_in_tooltip");
16301672
t->GuiFunc = [](ImGuiTestContext* ctx)

0 commit comments

Comments
 (0)