diff --git a/UnitTests/TopLevels/ToplevelTests.cs b/UnitTests/TopLevels/ToplevelTests.cs index a6f803af0..3df27386b 100644 --- a/UnitTests/TopLevels/ToplevelTests.cs +++ b/UnitTests/TopLevels/ToplevelTests.cs @@ -1081,5 +1081,88 @@ namespace Terminal.Gui.TopLevelTests { Assert.Equal (new Rect (1, 3, 10, 5), view.Frame); Assert.Equal (new Rect (0, 0, 10, 5), view.NeedDisplay); } + + [Fact, AutoInitShutdown] + public void Single_Smaller_Top_Will_Have_Cleaning_Trails_Chunk_On_Move () + { + var dialog = new Dialog ("Single smaller Dialog") { Width = 30, Height = 10 }; + dialog.Add (new Label ( + "How should I've to react. Cleaning all chunk trails or setting the 'Cols' and 'Rows' to this dialog length?\n" + + "Cleaning is more easy to fix this.") { + X = Pos.Center (), + Y = Pos.Center (), + Width = Dim.Fill (), + Height = Dim.Fill (), + TextAlignment = TextAlignment.Centered, + VerticalTextAlignment = VerticalTextAlignment.Middle, + AutoSize = false + }); + + var rs = Application.Begin (dialog); + + Assert.Null (Application.MouseGrabView); + Assert.Equal (new Rect (25, 7, 30, 10), dialog.Frame); + TestHelpers.AssertDriverContentsWithFrameAre (@" + ┌ Single smaller Dialog ─────┐ + │ How should I've to react. │ + │Cleaning all chunk trails or│ + │ setting the 'Cols' and │ + │ 'Rows' to this dialog │ + │ length? │ + │Cleaning is more easy to fix│ + │ this. │ + │ │ + └────────────────────────────┘", output); + + ReflectionTools.InvokePrivate ( + typeof (Application), + "ProcessMouseEvent", + new MouseEvent () { + X = 25, + Y = 7, + Flags = MouseFlags.Button1Pressed + }); + + var firstIteration = false; + Application.RunMainLoopIteration (ref rs, true, ref firstIteration); Assert.Equal (dialog, Application.MouseGrabView); + + Assert.Equal (new Rect (25, 7, 30, 10), dialog.Frame); + TestHelpers.AssertDriverContentsWithFrameAre (@" + ┌ Single smaller Dialog ─────┐ + │ How should I've to react. │ + │Cleaning all chunk trails or│ + │ setting the 'Cols' and │ + │ 'Rows' to this dialog │ + │ length? │ + │Cleaning is more easy to fix│ + │ this. │ + │ │ + └────────────────────────────┘", output); + + ReflectionTools.InvokePrivate ( + typeof (Application), + "ProcessMouseEvent", + new MouseEvent () { + X = 20, + Y = 10, + Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition + }); + + firstIteration = false; + Application.RunMainLoopIteration (ref rs, true, ref firstIteration); + Assert.Equal (dialog, Application.MouseGrabView); + Assert.Equal (new Rect (20, 10, 30, 10), dialog.Frame); + TestHelpers.AssertDriverContentsWithFrameAre (@" + ┌ Single smaller Dialog ─────┐ + │ How should I've to react. │ + │Cleaning all chunk trails or│ + │ setting the 'Cols' and │ + │ 'Rows' to this dialog │ + │ length? │ + │Cleaning is more easy to fix│ + │ this. │ + │ │ + └────────────────────────────┘", output); + } } } \ No newline at end of file