Fix SubViewNeedsDraw handling and improve test coverage

Refactored `View` class to ensure `SuperView.SubViewNeedsDraw`
is managed correctly. Added logic to prevent clearing the flag
prematurely when sibling subviews still require drawing.

Introduced a new `SubViewNeedsDraw` property with a private
setter and added `TODO` comments for potential future
improvements, such as making it a computed property.

Updated and added tests in `NeedsDrawTests` and `StaticDrawTests`
to validate the corrected behavior and prevent regressions.
Re-enabled a previously skipped test after fixing the related bug.
This commit is contained in:
Tig
2025-12-04 12:36:54 -07:00
parent 193a5873d1
commit 96151201f6
4 changed files with 30 additions and 9 deletions

View File

@@ -311,7 +311,7 @@ public class NeedsDrawTests : FakeDriverBase
Assert.Equal (new (1, 1, 5, 5), view.Viewport);
Assert.Equal (new (1, 1, 5, 5), view.NeedsDrawRect);
}
[Fact]
public void ClearNeedsDraw_ClearsOwnFlags ()
{
@@ -557,7 +557,7 @@ public class NeedsDrawTests : FakeDriverBase
}
[Fact (Skip = "This is a real bug discovered in PR #4431 that needs to be fixed")]
[Fact]
public void IndividualViewDraw_DoesNotClearSuperViewSubViewNeedsDraw ()
{
// This test validates that individual view Draw() calls should NOT clear the superview's

View File

@@ -95,9 +95,9 @@ public class StaticDrawTests : FakeDriverBase
// at the very end, cleaning up any SubViewNeedsDraw flags set
// by Margin.DrawMargins()
Assert.False (superview.SubViewNeedsDraw,
"SuperView's SubViewNeedsDraw should be false after all subviews are drawn and cleared");
"superview's SubViewNeedsDraw should be false after static Draw(). All subviews were drawn in the call to View.Draw");
Assert.False (subview1.SubViewNeedsDraw,
"SubView1's SubViewNeedsDraw should be false after its subviews are drawn and cleared");
"SubView1's SubViewNeedsDraw should be false after its subviews are drawn and cleared");
}
[Fact]
@@ -188,7 +188,7 @@ public class StaticDrawTests : FakeDriverBase
// All SubViewNeedsDraw flags should be cleared after the static Draw
Assert.False (topView.SubViewNeedsDraw,
"TopView's SubViewNeedsDraw should be false after static Draw()");
"TopView's SubViewNeedsDraw should be false after static Draw(). All subviews were drawn in the call to View.Draw");
Assert.False (middleView1.SubViewNeedsDraw,
"MiddleView1's SubViewNeedsDraw should be false after its subviews are drawn");
Assert.False (middleView2.SubViewNeedsDraw,