diff --git a/OpenNest.WinForms.Tests/Controls/GridStyleTests.cs b/OpenNest.WinForms.Tests/Controls/GridStyleTests.cs index b60f94b2..ca9858cd 100644 --- a/OpenNest.WinForms.Tests/Controls/GridStyleTests.cs +++ b/OpenNest.WinForms.Tests/Controls/GridStyleTests.cs @@ -94,10 +94,17 @@ public class GridStyleTests form.Show(); Pump(grid); - // As when the keyboard moves to a cell in the embedded version history. + // As when the keyboard moves to a cell in the embedded version history. On Windows 11 + // and later a keyboard tooltip is persistent and starts no timer, so make it behave as + // it does on earlier Windows, where the timer exists. var toolTip = (ToolTip)typeof(DataGridView).GetProperty("KeyboardToolTip", members).GetValue(grid); + typeof(ToolTip).GetProperty("IsPersistent", members).SetValue(toolTip, false); typeof(ToolTip).GetMethod("ShowKeyboardToolTip", members) .Invoke(toolTip, new object[] { "2", grid.Rows[0].Cells[0], 3000 }); + // Showing hooks the form's Deactivate, which hides the tip and stops its timer; losing + // activation to another window (a parallel test's form) is not the case under test, so + // make sure the auto-pop timer is running before the grid goes. + typeof(ToolTip).GetMethod("StartTimer", members).Invoke(toolTip, new object[] { grid, 3000 }); var timer = typeof(ToolTip).GetField("_timer", members); Assert.NotNull(timer.GetValue(toolTip));