[windows] Make keyboard layout tests hermetic#189573
Draft
sero583 wants to merge 1 commit into
Draft
Conversation
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.
This was referenced Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Windows keyboard tests in
keyboard_unittests.ccare authored against the US and US-International layouts, but the test harness resolves a virtual key to a character throughMapVirtualKey(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.DeadKeyTwiceThenLetterpressesVK_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
LayoutUsStandardreturns the valueMapVirtualKey(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 theirMAPVK_VK_TO_CHARlookups through it. Non-character virtual keys keep returning0, 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.DeadKeyTwiceThenLetterfails; after it, all 36KeyboardTestcases 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-assistbot 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.