Skip to content

[windows] Make keyboard layout tests hermetic#189573

Draft
sero583 wants to merge 1 commit into
flutter:masterfrom
sero583:fix-keyboard-test-layout-hermeticity
Draft

[windows] Make keyboard layout tests hermetic#189573
sero583 wants to merge 1 commit into
flutter:masterfrom
sero583:fix-keyboard-test-layout-hermeticity

Conversation

@sero583

@sero583 sero583 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

The Windows keyboard tests in keyboard_unittests.cc are authored against the US and US-International layouts, but the test harness resolves a virtual key to a character through MapVirtualKey(vk, MAPVK_VK_TO_CHAR), which consults the keyboard layout installed on the machine running the tests. On a host configured with a non-US layout the same virtual key produces a different character, so layout-sensitive tests fail. For example, KeyboardTest.DeadKeyTwiceThenLetter presses VK_OEM_3, which is the grave accent on a US layout but an umlaut on a German layout, so the test expects ` and receives ö.

This makes the character mapping hermetic. A new LayoutUsStandard returns the value MapVirtualKey(vk, MAPVK_VK_TO_CHAR) produces on a US layout for the keys the tests exercise (digits, letters, the OEM punctuation keys, and the control keys the tests use), and the default and French test layouts route their MAPVK_VK_TO_CHAR lookups through it. Non-character virtual keys keep returning 0, matching the platform. The tests no longer depend on the layout installed on the machine running them.

Verified on a machine configured with the German (de-DE) layout: before this change KeyboardTest.DeadKeyTwiceThenLetter fails; after it, all 36 KeyboardTest cases pass. The suite continues to pass on US layouts.

Fixes #189566

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

The keyboard tests are authored against the US and US-International
layouts, but the test harness resolved characters through
MapVirtualKey, which consults the keyboard layout installed on the
machine running the tests. On a non-US host the same virtual key
produces a different character, so layout-sensitive tests such as
DeadKeyTwiceThenLetter fail (VK_OEM_3 is the grave accent on US but an
umlaut on German).

Add a hermetic US layout table (LayoutUsStandard) and route the default
and French test layouts through it, so the character mapping no longer
depends on the host configuration.
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-windows Building on or for Windows specifically a: desktop Running on desktop team-windows Owned by the Windows platform team labels Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop engine flutter/engine related. See also e: labels. platform-windows Building on or for Windows specifically team-windows Owned by the Windows platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[windows] Keyboard unit tests fail when run on a machine with a non-US keyboard layout

1 participant