Skip to content

Added unit tests for Link label - #15138

Open
Rabina4363sf wants to merge 5 commits into
dotnet:mainfrom
Rabina4363sf:Fix_Issue_10679
Open

Rabina4363sf wants to merge 5 commits into
dotnet:mainfrom
Rabina4363sf:Fix_Issue_10679

Conversation

@Rabina4363sf

@Rabina4363sf Rabina4363sf commented Sep 17, 2026

Copy link
Copy Markdown

Fixes #10679

Proposed changes

  • Add regression coverage for LinkLabel paint behavior with empty and non-empty text.
  • Verify repeated paints do not continuously invalidate the control.
  • Verify text changes invalidate the layout once and that painting without a handle remains stable.

Customer Impact

  • No direct customer impact; this change adds test coverage only.
  • Prevents future regressions involving repeated invalidation or paint loops in LinkLabel .

Regression?

  • No

Risk

  • Low. No production code or runtime behavior is changed.

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

  • NA

Test environment(s)

  • Windows
  • .NET SDK 11.0.100-preview.6.26359.118
  • x64
Microsoft Reviewers: Open in CodeFlow

@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.24166%. Comparing base (75072a6) to head (70887c3).

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           
Flag Coverage Δ
Debug 37.24166% <ø> (ø)
production 39.36526% <ø> (ø)
test 20.64923% <ø> (ø)
unit 39.36526% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread src/test/unit/System.Windows.Forms/LinkLabelTests.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity

Open (1)
Resolved since last review (1)

Comment on lines +337 to +347
// 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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit test for Link label

2 participants