Skip to content

Add CheckedListBox check-state and ItemCheck tests - #15401

Merged
Shyam-Gupta merged 2 commits into
mainfrom
dev/shgu/checked-list-box-check-state
Nov 12, 2026
Merged

Shyam-Gupta merged 2 commits into
mainfrom
dev/shgu/checked-list-box-check-state

Conversation

@Shyam-Gupta

@Shyam-Gupta Shyam-Gupta commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Proposed changes

  • Cover ItemCheck for SetItemCheckState/SetItemChecked (old/new state, no event when unchanged) and for real user clicks, with and without CheckOnClick, including clicking an indeterminate item.
  • Cover handlers that change or cancel NewValue, for both programmatic and user checking.
  • Check that CheckedItems/CheckedIndices follow checking rather than selection, and that indeterminate/checked states survive handle recreation.
  • Add a small RecreateHandle wrapper to the existing test subclass.

Customer Impact

  • Protects check-state behavior from regressions. No runtime behavior changes.

Regression?

  • No; test-only coverage.

Risk

  • Low. No product code or public API changes.

Validation

From the repository root in a normal, non-elevated Windows session:

  • .\build.cmd -verbosity minimal — passed, 0 warnings and 0 errors.
  • With DOTNET_ROOT set to the repo-local .dotnet directory, the command below passed five consecutive times: 109 passed, 0 failed, 0 skipped on each run.
& .\artifacts\bin\System.Windows.Forms.Tests\Debug\net12.0-windows7.0\System.Windows.Forms.Tests.exe --filter-method 'System.Windows.Forms.Tests.CheckedListBoxTests.*'
Microsoft Reviewers: Open in CodeFlow

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.79260%. Comparing base (8d62c3c) to head (379c1dd).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@              Coverage Diff              @@
##                main      #15401   +/-   ##
=============================================
  Coverage   39.79260%   39.79260%           
=============================================
  Files            246         246           
  Lines           9836        9836           
  Branches        1036        1036           
=============================================
  Hits            3914        3914           
  Misses          5741        5741           
  Partials         181         181           
Flag Coverage Δ
Debug 39.79260% <ø> (ø)
production 42.31695% <ø> (ø)
test 19.92786% <ø> (ø)
unit 42.31695% <ø> (ø)

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.

@dotnet-policy-service dotnet-policy-service Bot added the draft draft PR label Nov 11, 2026
@Shyam-Gupta
Shyam-Gupta marked this pull request as ready for review November 12, 2026 18:25
@Shyam-Gupta
Shyam-Gupta requested a review from a team as a code owner November 12, 2026 18:25
@Shyam-Gupta Shyam-Gupta added test-enhancement Improvements of test source code and removed draft draft PR labels Nov 12, 2026
@Shyam-Gupta
Shyam-Gupta requested a balanced review from Copilot November 12, 2026 18:29

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

The hidden-form mouse tests bypass the click path that clears keyboard-induced check suppression, leaving a gap that needs visible-host coverage verifying Click delivery after keyboard navigation.

1 open issue
What changed in this PR

Adds regression coverage for CheckedListBox check-state behavior and ItemCheck events without changing runtime code or public APIs.

Changes:

  • Tests programmatic state changes, event values, unchanged-state behavior, and handler overrides or cancellation.
  • Adds mouse-message tests for CheckOnClick, repeated clicks, and indeterminate items.
  • Verifies checked collections remain independent of selection and check states survive handle recreation.
File Description
src/​test/​unit/​System.Windows.Forms/​CheckedListBoxTests.cs Adds check-state and event tests, mouse-message helpers, and a test-only RecreateHandle wrapper.

Review effort: Balanced

@Shyam-Gupta
Shyam-Gupta merged commit 796ed8d into main Nov 12, 2026
8 checks passed
@Shyam-Gupta
Shyam-Gupta deleted the dev/shgu/checked-list-box-check-state branch November 12, 2026 19:22
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test-enhancement Improvements of test source code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants