[PATCH] user32/tests: Recognize undefined characters in OemKeyScan tests

Alex Henrie alexhenrie24 at gmail.com
Fri Dec 29 00:46:57 CST 2017


This reverts commit 72ab2d5b078d0ebad70a0baed29a80ce6b6c86ad.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
My previous attempt did not resolve any of the test failures. It seems
that the problem is actually that OemToCharBuff always returns TRUE and
changes unmappable characters to question marks. However, because the
question mark character is character 3F in all OEM code pages, we can
safely assume that a question mark returned by OemToCharBuff for a
different OEM character indicates a character that cannot be mapped.

 dlls/user32/tests/Makefile.in |  2 +-
 dlls/user32/tests/input.c     | 13 ++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/dlls/user32/tests/Makefile.in b/dlls/user32/tests/Makefile.in
index c71cbe2547..7149dc824e 100644
--- a/dlls/user32/tests/Makefile.in
+++ b/dlls/user32/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL   = user32.dll
-IMPORTS   = user32 gdi32 advapi32 imm32
+IMPORTS   = user32 gdi32 advapi32
 
 C_SRCS = \
 	broadcast.c \
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index a15a64420d..030592b02f 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -54,7 +54,6 @@
 #include "winbase.h"
 #include "winuser.h"
 #include "winnls.h"
-#include "imm.h"
 
 #include "wine/test.h"
 
@@ -2516,23 +2515,23 @@ static void test_OemKeyScan(void)
     DWORD ret, expect, vkey, scan;
     WCHAR oem, wchr;
     char oem_char;
-    BOOL ime = ImmIsIME(GetKeyboardLayout(0));
 
     for (oem = 0; oem < 0x200; oem++)
     {
         ret = OemKeyScan( oem );
 
         oem_char = LOBYTE( oem );
-        if (!OemToCharBuffW( &oem_char, &wchr, 1 ))
+        /* OemKeyScan returns -1 for any character that cannot be mapped,
+         * whereas OemToCharBuff changes unmappable characters to question
+         * marks. The ASCII characters 0-127, including the real question mark
+         * character, are all mappable and are the same in all OEM codepages. */
+        if (!OemToCharBuffW( &oem_char, &wchr, 1 ) || (wchr == '?' && oem_char < 0))
             expect = -1;
         else
         {
             vkey = VkKeyScanW( wchr );
             scan = MapVirtualKeyW( LOBYTE( vkey ), MAPVK_VK_TO_VSC );
-            /* OemKeyScan returns -1 for any character that has to go through
-             * the IME, whereas VkKeyScan returns the virtual key code for the
-             * question mark key */
-            if (!scan || (ime && wchr != '?' && vkey == VkKeyScanW( '?' )))
+            if (!scan)
                 expect = -1;
             else
             {
-- 
2.15.1




More information about the wine-devel mailing list