diff --git a/OpenNest.WinForms.Tests/Forms/CutSimulatorFormTests.cs b/OpenNest.WinForms.Tests/Forms/CutSimulatorFormTests.cs index 75734bab..4a9673c3 100644 --- a/OpenNest.WinForms.Tests/Forms/CutSimulatorFormTests.cs +++ b/OpenNest.WinForms.Tests/Forms/CutSimulatorFormTests.cs @@ -5,6 +5,13 @@ using OpenNest.Geometry; namespace OpenNest.WinForms.Tests.Forms; +// The layout checks failed once on CI (Settings tab columns ~84 px wider than measured when the +// window sized itself) and passed on the same commit and runner image before and after, never +// locally. Run apart from the parallel tests so other forms on other threads cannot interfere. +[CollectionDefinition("Cut simulator layout", DisableParallelization = true)] +public class CutSimulatorLayoutCollection; + +[Collection("Cut simulator layout")] public class CutSimulatorFormTests { [Fact] @@ -39,7 +46,8 @@ public class CutSimulatorFormTests { var bounds = page.RectangleToClient(control.RectangleToScreen(control.ClientRectangle)); Assert.True(page.ClientRectangle.Contains(bounds), - $"{control.GetType().Name} '{control.Text}' at {bounds} is clipped by the {page.Text} tab ({page.ClientRectangle})."); + $"{control.GetType().Name} '{control.Text}' at {bounds} is clipped by the {page.Text} tab ({page.ClientRectangle}).\n" + + DescribeLayout(tabs, page)); } } } @@ -94,6 +102,25 @@ public class CutSimulatorFormTests } }); + // Everything needed to tell which column grew, and whether the measurement or the layout moved. + private static string DescribeLayout(TabControl tabs, TabPage page) + { + var content = page.Controls[0]; + var lines = new List + { + $"DPI {page.DeviceDpi}; tabs {tabs.Size}, minimum {tabs.MinimumSize}; content {content.Bounds}, " + + $"preferred {content.GetPreferredSize(System.Drawing.Size.Empty)}", + }; + if (content is TableLayoutPanel table) + lines.Add($"Columns: {string.Join(", ", table.GetColumnWidths())}"); + foreach (Control control in content.Controls) + { + lines.Add($" {control.GetType().Name} '{control.Text}' {control.Bounds} preferred " + + $"{control.GetPreferredSize(System.Drawing.Size.Empty)} font {control.Font.Name} {control.Font.SizeInPoints}pt"); + } + return string.Join("\n", lines); + } + private static System.Drawing.Rectangle Screen(Control control) => control.RectangleToScreen(control.ClientRectangle);