Fixed fragile toplevel drag unit tests

This commit is contained in:
Tig
2024-04-04 19:34:39 -04:00
parent c5b7b084a9
commit e1a2793c5c
3 changed files with 11 additions and 336 deletions

View File

@@ -812,77 +812,16 @@ public class ApplicationTests
((FakeDriver)Application.Driver).SetBufferSize (10, 10);
RunState rs = Application.Begin (w);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌───┐
│ │
│ │
│ │
└───┘",
_output
);
// Don't use visuals to test as style of border can change over time.
Assert.Equal (new Point (0, 0), w.Frame.Location);
Attribute [] attributes =
{
// 0
new (ColorName.White, ColorName.Black),
// 1
Colors.ColorSchemes ["Base"].Normal
};
TestHelpers.AssertDriverAttributesAre (
@"
1111100000
1111100000
1111100000
1111100000
1111100000
",
null,
attributes
);
// TODO: In PR #2920 this breaks because the mouse is not grabbed anymore.
// TODO: Move the mouse grap/drag mode from Toplevel to Border.
Application.OnMouseEvent (new () { X = 0, Y = 0, Flags = MouseFlags.Button1Pressed });
Assert.Equal (w.Border, Application.MouseGrabView);
Assert.Equal (new Point (0,0), w.Frame.Location);
// Move down and to the right.
Application.OnMouseEvent (new () { X = 1, Y = 1, Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition });
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌───┐
│ │
│ │
│ │
└───┘",
_output
);
attributes = new []
{
// 0
new (ColorName.White, ColorName.Black),
// 1
Colors.ColorSchemes ["Base"].Normal
};
TestHelpers.AssertDriverAttributesAre (
@"
0000000000
0111110000
0111110000
0111110000
0111110000
0111110000
",
null,
attributes
);
Assert.Equal (new Point (1, 1), w.Frame.Location);
Application.End (rs);
w.Dispose ();