Skip to content

Added unit tests for low-coverage System.Windows.Forms classes - #14911

Open
Sathish-087 wants to merge 2 commits into
dotnet:mainfrom
Sathish-087:Fix_Issue_13442
Open

Added unit tests for low-coverage System.Windows.Forms classes#14911
Sathish-087 wants to merge 2 commits into
dotnet:mainfrom
Sathish-087:Fix_Issue_13442

Conversation

@Sathish-087

@Sathish-087 Sathish-087 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #13442

Proposed changes

  • Added 9 unit tests for RadioButtonFlatAdapter.
  • Added 11 unit tests for RadioButtonPopupAdapter.
  • Added 8 unit tests for ToolStrip.RestoreFocusMessageFilter.
  • Added 8 unit tests for HtmlHistory.
  • Covered paint operations (PaintUp, PaintDown, PaintOver) for radio button adapter implementations.
  • Added coverage for adapter creation and layout behavior validation.
  • Added tests for DPI-aware check size calculations and shadowed text behavior.
  • Added coverage for checked-state rendering and text/image rendering scenarios.
  • Added tests validating focus restoration and message filtering behavior in ToolStrip.RestoreFocusMessageFilter.
  • Added tests covering HtmlHistory navigation APIs (Back, Forward, Go), property accessors, argument validation, and disposal behavior.
  • Improved unit test coverage for low-coverage classes in the System.Windows.Forms namespace.

Customer Impact

  • Improves unit test coverage for several previously low-coverage System.Windows.Forms classes.
  • Increases confidence in rendering, layout, focus restoration, and HTML history navigation functionality.
  • Helps prevent regressions in public and protected virtual APIs across the tested components.

Regression?

  • No

Risk

  • Low (tests only, no product code changes)

Test methodology

  • Executed existing WinForms unit test suite.
  • Added and executed new unit tests for RadioButtonFlatAdapter.
  • Added and executed new unit tests for RadioButtonPopupAdapter.
  • Added and executed new unit tests for ToolStrip.RestoreFocusMessageFilter.
  • Added and executed new unit tests for HtmlHistory.

Accessibility testing

NA

Test environment(s)

  • Visual Studio (Test Explorer)
  • Windows
  • .NET 11
Microsoft Reviewers: Open in CodeFlow

@KlausLoeffelmann

Copy link
Copy Markdown
Member

@SimonZhao888, could you do a manual review of this? Thx!

@KlausLoeffelmann
KlausLoeffelmann requested review from SimonZhao888 and a balanced review from Copilot August 31, 2026 16:04
@KlausLoeffelmann KlausLoeffelmann added this to the 11.0-rc2 milestone Aug 31, 2026

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

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds unit coverage for previously low-coverage WinForms rendering, focus-restoration, and browser-history components.

Changes:

  • Tests radio-button adapter painting and layout.
  • Tests ToolStrip focus restoration.
  • Tests HtmlHistory navigation, validation, and disposal.
File summaries
File Description
RadioButtonFlatAdapterTests.cs Tests flat adapter rendering and layout.
RadioButtonPopupAdapterTests.cs Tests popup adapter states and rendering.
ToolStrip.RestoreFocusMessageFilterTests.cs Tests message filtering and focus restoration.
HtmlHistoryTests.cs Tests history APIs and disposal behavior.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


Action action = () => adapter.PaintDown(e, control.Checked ? CheckState.Checked : CheckState.Unchecked);

action.Should().NotThrow();

Action action = () => adapter.PaintDown(e, control.Checked ? CheckState.Checked : CheckState.Unchecked);

action.Should().NotThrow();
Comment on lines +235 to +236
await Task.Run(() => control.Navigate(path));
Assert.True(await source.Task);
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.

Ensure that classes in the System.Windows.Forms namespace have adequate unit test coverage

3 participants