Skip to content

Isolate ListViewItem hover tests from the physical cursor - #15078

Open
Eales wants to merge 1 commit into
dotnet:mainfrom
Eales:test/isolate-listview-item-hover
Open

Eales wants to merge 1 commit into
dotnet:mainfrom
Eales:test/isolate-listview-item-hover

Conversation

@Eales

@Eales Eales commented Sep 10, 2026

Copy link
Copy Markdown

Fixes #12319

Proposed changes

  • Replace physical cursor movement in the ListViewItem hover test with controlled
    accessibility bounds: an empty rectangle for outside and a rectangle covering the
    documented signed-16-bit virtual-screen coordinate range for inside. Neither value
    depends on the current monitor arrangement or DPI.
  • Keep the real ListViewItem.IKeyboardToolTip.IsHoveredWithMouse implementation.
    Use the existing Moq protected-factory pattern to substitute only the accessibility
    bounds, with normal ListView behavior retained via CallBase.
  • Restore the disabled virtual-mode/hovered case and remove its ActiveIssue marker.
    Keep the existing attached/detached and inside/outside cases. Verify that attached
    items consult the bounds and that the test does not create a native control handle.

Customer Impact

  • Running this test no longer moves the user's cursor or races with mouse movement
    from another test or process.
  • The previously disabled virtual-mode case runs again without requiring an
    interactive cursor-positioning step.

Regression?

  • No product regression is being changed; this fixes existing test isolation.

Risk

  • Low: one test file only, no product or public API changes, no new dependency,
    retries, skip conditions, or shared mutable state.
  • The test still verifies the real hover decision, not a mocked hover result.
    Real native accessibility geometry remains outside this test's scope.

Test methodology

  • Base: current main, 8efd9a920dba90722f8db1f7e943f74837d26579.
  • Targeted hover theory: 5 passed, 0 failed, 0 skipped, with both pl-PL and
    en-US, including the restored virtual-mode case.
  • Controlled mutation: temporarily force virtual-mode hover to return false. The
    restored positive case fails, and the bounds-read check also detects the bypass
    in the virtual-mode/outside case. Mutation removed before the final build/test.
  • The original cursor-moving test was not executed on the active desktop. A local
    structural guard found its two Cursor.Position writes and passes after the fix;
    this is not a claim to reproduce the original intermittent CI failure.
  • Broader class comparison: baseline 70 passed / 9 failed (hover excluded to
    avoid moving the cursor); patched 75 passed / 9 failed, with no exclusions or
    skips. The same nine unchanged ViewLargeIcon neighboring-rectangle cases fail
    before and after. Their layout assumptions are deliberately outside this PR.
  • Release build: zero warnings/errors; git diff --check passes. The full repository
    suite was not run for this change.

Run the target from the built System.Windows.Forms.Tests executable with:

--filter-method System.Windows.Forms.Tests.ListViewItem_IKeyboardToolTipTests.ListViewItemKeyboardToolTip_InvokeIsHoveredWithMouse_ReturnsExpected

Test environment(s)

Microsoft Reviewers: Open in CodeFlow

@Eales
Eales requested a review from a team as a code owner September 10, 2026 16:42
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.24166%. Comparing base (8efd9a9) to head (4938908).

Additional details and impacted files
@@              Coverage Diff              @@
##                main      #15078   +/-   ##
=============================================
  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.

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.

Unstable unit test: System.Windows.Forms.Tests.ListViewItem_IKeyboardToolTipTests.ListViewItemKeyboardToolTip_InvokeIsHoveredWithMouse_ReturnsExpected

1 participant