diff --git a/Terminal.Gui/Application/Application.Run.cs b/Terminal.Gui/Application/Application.Run.cs index 5f6b5ddba..2a91ac8df 100644 --- a/Terminal.Gui/Application/Application.Run.cs +++ b/Terminal.Gui/Application/Application.Run.cs @@ -508,6 +508,7 @@ public static partial class Application // Run (Begin, Run, End, Stop) if (ClearScreenNextIteration) { forceDraw = true; + ClearScreenNextIteration = false; } if (forceDraw) { diff --git a/UnitTests/Application/ApplicationScreenTests.cs b/UnitTests/Application/ApplicationScreenTests.cs new file mode 100644 index 000000000..1ea896208 --- /dev/null +++ b/UnitTests/Application/ApplicationScreenTests.cs @@ -0,0 +1,67 @@ +using Xunit.Abstractions; + +namespace Terminal.Gui.ApplicationTests.NavigationTests; + +public class ApplicationScreenTests (ITestOutputHelper output) +{ + [Fact] + public void ClearScreenNextIteration_Resets_To_False_After_LayoutAndDraw () + { + // Arrange + Application.Init (); + + // Act + Application.ClearScreenNextIteration = true; + Application.LayoutAndDraw (); + + // Assert + Assert.False (Application.ClearScreenNextIteration); + + // Cleanup + Application.ResetState (true); + } + + [Fact] + [SetupFakeDriver] + public void ClearContents_Called_When_Top_Frame_Changes () + { + // Arrange + Application.Init (); + Application.Top = new Toplevel (); + Application.TopLevels.Push (Application.Top); + + int clearedContentsRaised = 0; + + Application.Driver!.ClearedContents += (e, a) => clearedContentsRaised++; + + // Act + Application.LayoutAndDraw (); + + // Assert + Assert.Equal (0, clearedContentsRaised); + + // Act + Application.Top.SetNeedsLayout (); + Application.LayoutAndDraw (); + + // Assert + Assert.Equal (0, clearedContentsRaised); + + // Act + Application.Top.X = 1; + Application.LayoutAndDraw (); + + // Assert + Assert.Equal (1, clearedContentsRaised); + + // Act + Application.Top.Width = 10; + Application.LayoutAndDraw (); + + // Assert + Assert.Equal (2, clearedContentsRaised); + + // Cleanup + Application.ResetState (true); + } +} diff --git a/bench.json b/bench.json deleted file mode 100644 index 52a38240e..000000000 --- a/bench.json +++ /dev/null @@ -1,52 +0,0 @@ -[ - { - "Scenario": "Adornments Demo", - "Duration": "00:00:00.1805368", - "IterationCount": 501, - "ClearedContentCount": 0, - "RefreshedCount": 503, - "UpdatedCount": 1, - "DrawCompleteCount": 82, - "LaidOutCount": 82 - }, - { - "Scenario": "All Views Tester", - "Duration": "00:00:00.1070009", - "IterationCount": 501, - "ClearedContentCount": 0, - "RefreshedCount": 503, - "UpdatedCount": 1, - "DrawCompleteCount": 103, - "LaidOutCount": 182 - }, - { - "Scenario": "Animation", - "Duration": "00:00:00.0675802", - "IterationCount": 501, - "ClearedContentCount": 0, - "RefreshedCount": 503, - "UpdatedCount": 1, - "DrawCompleteCount": 4, - "LaidOutCount": 4 - }, - { - "Scenario": "Arrangement", - "Duration": "00:00:00.1284709", - "IterationCount": 501, - "ClearedContentCount": 0, - "RefreshedCount": 503, - "UpdatedCount": 1, - "DrawCompleteCount": 123, - "LaidOutCount": 123 - }, - { - "Scenario": "ASCIICustomButtonTest", - "Duration": "00:00:01.0613372", - "IterationCount": 30, - "ClearedContentCount": 0, - "RefreshedCount": 32, - "UpdatedCount": 31, - "DrawCompleteCount": 4185, - "LaidOutCount": 2852 - } -] \ No newline at end of file