Added unit tests for Link label - #15138
Rabina4363sf wants to merge 5 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15138 +/- ##
=============================================
Coverage 37.24166% 37.24166%
=============================================
Files 246 246
Lines 9774 9774
Branches 1029 1029
=============================================
Hits 3640 3640
Misses 5970 5970
Partials 164 164
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
One test incorrectly requires the first repaint to invalidate, over-constraining valid implementations.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds regression coverage for LinkLabel paint-loop issue #10679/#10515.
Changes:
- Tests repeated painting with empty and non-empty text.
- Tests layout invalidation and painting without a handle.
File summaries
| File | Description |
|---|---|
src/test/unit/System.Windows.Forms/LinkLabelTests.cs |
Adds LinkLabel paint and invalidation tests. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The handle-free test cannot detect repeated invalidation because Invalidated is not raised without a handle.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Resolved since last review (1)
| // The first paint calculates the text layout and is allowed to invalidate the control. | ||
| linkLabel.OnPaint(e); | ||
|
|
||
| int invalidatedCount = 0; | ||
| linkLabel.Invalidated += (sender, args) => invalidatedCount++; | ||
|
|
||
| linkLabel.OnPaint(e); | ||
| linkLabel.OnPaint(e); | ||
|
|
||
| invalidatedCount.Should().Be(0); | ||
| linkLabel.IsHandleCreated.Should().BeFalse(); |

Fixes #10679
Proposed changes
Customer Impact
Regression?
Risk
Test methodology
• Added tests covering null, empty, and non-empty LinkLabel.Text values.
• Verified repeated OnPaint calls do not continue raising invalidation events.
• Verified layout invalidation after a text change and painting before handle creation.
Accessibility testing
Test environment(s)
Microsoft Reviewers: Open in CodeFlow