From 2b2661bb1bea711a13454ad568d00aefeddc8e4a Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Mon, 2 Oct 2023 18:00:48 -0500 Subject: [PATCH] =?UTF-8?q?feat(developer):=20scancode=20and=20forms=20=20?= =?UTF-8?q?=F0=9F=99=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fixes to the special case test Fixes: #9403 --- .../types/src/consts/virtual-key-constants.ts | 1 + .../test-ldml-keyboard-xml-reader.ts | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/common/web/types/src/consts/virtual-key-constants.ts b/common/web/types/src/consts/virtual-key-constants.ts index 798dd95eade..3347660f015 100644 --- a/common/web/types/src/consts/virtual-key-constants.ts +++ b/common/web/types/src/consts/virtual-key-constants.ts @@ -202,6 +202,7 @@ export const CLDRScanToUSVirtualKeyCodes = { 0x56: k.K_oE2, // << Same as 0x7D; found on iso, abnt2 0x73: k.K_oC1, 0x7D: k.K_oE2, // << Same as 0x56; found on jis + }; export type KeyMap = number[][]; diff --git a/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts b/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts index 252f3e43190..43429676a0a 100644 --- a/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts +++ b/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts @@ -3,7 +3,7 @@ import 'mocha'; import {assert} from 'chai'; import { CommonTypesMessages } from '../../src/util/common-events.js'; import { testReaderCases } from '../helpers/reader-callback-test.js'; -import { CLDRScanToVkey, CLDRScanToKeyMap } from '../../src/consts/virtual-key-constants.js'; +import { CLDRScanToVkey, CLDRScanToKeyMap, USVirtualKeyCodes } from '../../src/consts/virtual-key-constants.js'; function pluckKeysFromKeybag(keys: LKKey[], ids: string[]) { return keys.filter(({id}) => ids.indexOf(id) !== -1); @@ -163,11 +163,20 @@ describe('check scan code routines', () => { // check all scancodes for (let scan = 0; scan <= 0xFF; scan++) { const vkey = CLDRScanToVkey(scan); - if (vkey !== undefined && vkey !== 226) { + if (vkey === undefined) { + // not mapped, which is OK + continue; + } + if (scan === 0x56 || scan === 0x7D) { + // These both can map to this scancode + assert.equal(vkey, USVirtualKeyCodes.K_oE2); + } else { + // don't check those exceptions assert.isFalse(vkeyToScan.has(vkey), - `vkey ${vkey} (other than 226) mapped from more than one scancode: ${Number(vkeyToScan.get(vkey)).toString(16)} and ${Number(scan).toString(16)}`); - vkeyToScan.set(vkey, scan); + `vkey ${vkey} mapped from more than one scancode: ${Number(vkeyToScan.get(vkey)).toString(16)} and ${Number(scan).toString(16)}`); } + // do make sure nothing else maps to that vkey + vkeyToScan.set(vkey, scan); } }); });