Skip to content

Test InputLanguage without modifying the Windows language list - #15076

Open
Eales wants to merge 1 commit into
dotnet:mainfrom
Eales:test/input-language-without-profile-mutation
Open

Test InputLanguage without modifying the Windows language list#15076
Eales wants to merge 1 commit into
dotnet:mainfrom
Eales:test/input-language-without-profile-mutation

Conversation

@Eales

@Eales Eales commented Sep 10, 2026

Copy link
Copy Markdown

Fixes #13274

cc @LeafShi1: this issue is still assigned to you. I did not find an open PR touching
these files; please let me know if there is ongoing work to coordinate with. Opening
as a draft for that coordination and review of the small internal testability extraction.

Proposed changes

  • Replace the supplemental-language tests' PowerShell install/uninstall steps with
    deterministic tests of the existing language-tag mapping. Tests no longer call
    Set-WinUserLanguageList or modify the user's installed language list.
  • Extract an internal mapping helper with a per-call language source. Cover all four
    transient keyboard IDs with got-Goth, jv-Java, zgh-Tfng, and nqo, plus
    non-transient bypass, first-match selection, and the existing CultureInfo fallback
    for empty/nonmatching sources. Production registry lookup remains lazy and ordered.
  • Use installed layouts for FromCulture, current-language, and associated event-args
    tests. Handle multiple layouts sharing a culture without assuming that FromCulture
    selects a particular handle other than the first matching installed layout.
  • Restore the original current input language in finally, on success and failure.
    The old setter test's catch swallowed assertion failures. Remove event-args tests'
    early returns that could pass without exercising the constructor.

Customer Impact

  • Contributors can run these tests without adding/removing Windows languages or
    having an en-US input layout installed.
  • Supplemental mapping coverage no longer depends on Windows applying a language-list
    update before the next assertion. Real installed-layout integration coverage remains.

Regression?

  • No new product behavior is intended; this addresses existing test issues.

Risk

  • Low: four InputLanguage-related files only; no public API changes or global test hook.
  • The internal extraction preserves the transient-ID gate, registry order, first-match
    behavior, fallback, and disposal. It does not change FromCulture or layout activation.

Test methodology

  • Based on main at 8efd9a920dba90722f8db1f7e943f74837d26579.
  • Baseline InputLanguage* selection: 34 passed, 4 failed. The four event-args cases
    required an unavailable en-US input language. The old supplemental installer test
    was deliberately not executed because it changes the real Windows language list;
    this is not a claim to have reproduced the installation timing race in Random failures in InputLanguage_FromCulture_SupplementalInputLanguages_Expected #13274.
  • Patched InputLanguage* selection: 64 passed, 0 failed, 0 skipped with each of
    --culture pl-PL and --culture en-US, without an exclusion filter.
  • Controlled mutation checks: removing the fourth transient ID caused six mapping
    failures; an injected setter assertion was reported with finally but incorrectly
    passed with the old catch policy. All temporary mutations were removed.
  • Release build: zero warnings and errors. No retries or skip conditions added.
    Validation is targeted; the full repository test suite was not run for this PR.

Targeted invocation after building the unit-test project:

.\.dotnet\dotnet.exe artifacts\bin\System.Windows.Forms.Tests\Release\net11.0-windows7.0\System.Windows.Forms.Tests.dll `
  --culture pl-PL --filter-class 'System.Windows.Forms.Tests.InputLanguage*'

Test environment(s)

  • Windows 11 25H2 x64, build 26200.9168; Polish input layout, no en-US input layout.
  • SDK 11.0.100-rc.1.26420.103; test runtime 12.0.0-alpha.1.26458.117 as required by main.
Microsoft Reviewers: Open in CodeFlow

@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 (3a2bf24).

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

@Eales
Eales marked this pull request as ready for review September 10, 2026 16:26
@Eales
Eales requested a review from a team as a code owner September 10, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

draft draft PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Random failures in InputLanguage_FromCulture_SupplementalInputLanguages_Expected

1 participant