user32/tests: Add another test for KEYEVENTF_UNICODE mode.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2019-07-01 14:09:29 +03:00 committed by Alexandre Julliard
parent 4b13f859f7
commit 0b2fbab179
1 changed files with 51 additions and 21 deletions

View File

@ -72,6 +72,7 @@ static struct {
LONG last_hook_up;
LONG last_hook_syskey_down;
LONG last_hook_syskey_up;
WORD vk;
BOOL expect_alt;
BOOL sendinput_broken;
} key_status;
@ -115,15 +116,6 @@ typedef struct
} u;
} TEST_INPUT;
#define ADDTOINPUTS(kev) \
inputs[evtctr].type = INPUT_KEYBOARD; \
((TEST_INPUT*)inputs)[evtctr].u.ki.wVk = GETVKEY[ kev]; \
((TEST_INPUT*)inputs)[evtctr].u.ki.wScan = GETSCAN[ kev]; \
((TEST_INPUT*)inputs)[evtctr].u.ki.dwFlags = GETFLAGS[ kev]; \
((TEST_INPUT*)inputs)[evtctr].u.ki.dwExtraInfo = 0; \
((TEST_INPUT*)inputs)[evtctr].u.ki.time = ++timetag; \
if( kev) evtctr++;
typedef struct {
UINT message;
WPARAM wParam;
@ -227,17 +219,25 @@ static int KbdMessage( KEV kev, WPARAM *pwParam, LPARAM *plParam )
*/
static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] )
{
INPUT inputs[MAXKEYEVENTS];
TEST_INPUT inputs[MAXKEYEVENTS];
KMSG expmsg[MAXKEYEVENTS];
MSG msg;
char buf[100];
UINT evtctr=0;
UINT evtctr=0, ret;
int kmctr, i;
buf[0]='\0';
TrackSysKey=0; /* see input.c */
for( i = 0; i < MAXKEYEVENTS; i++) {
ADDTOINPUTS(td[i])
for (i = 0; i < MAXKEYEVENTS; i++)
{
inputs[evtctr].type = INPUT_KEYBOARD;
inputs[evtctr].u.ki.wVk = GETVKEY[td[i]];
inputs[evtctr].u.ki.wScan = GETSCAN[td[i]];
inputs[evtctr].u.ki.dwFlags = GETFLAGS[td[i]];
inputs[evtctr].u.ki.dwExtraInfo = 0;
inputs[evtctr].u.ki.time = ++timetag;
if (td[i]) evtctr++;
strcat(buf, getdesc[td[i]]);
if(td[i])
expmsg[i].message = KbdMessage(td[i], &(expmsg[i].wParam), &(expmsg[i].lParam));
@ -247,8 +247,8 @@ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] )
for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++)
;
ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" );
if( evtctr != SendInput(evtctr, &inputs[0], sizeof(INPUT)))
ok (FALSE, "SendInput failed to send some events\n");
ret = SendInput(evtctr, (INPUT *)inputs, sizeof(INPUT));
ok(ret == evtctr, "SendInput failed to send some events\n");
i = 0;
if (winetest_debug > 1)
trace("======== key stroke sequence #%d: %s =============\n",
@ -963,7 +963,7 @@ static void test_Input_blackbox(void)
UnhookWindowsHookEx(hook);
}
static void reset_key_status(void)
static void reset_key_status(WORD vk)
{
key_status.last_key_down = -1;
key_status.last_key_up = -1;
@ -975,6 +975,7 @@ static void reset_key_status(void)
key_status.last_hook_up = -1;
key_status.last_hook_syskey_down = -1;
key_status.last_hook_syskey_up = -1;
key_status.vk = vk;
key_status.expect_alt = FALSE;
key_status.sendinput_broken = FALSE;
}
@ -994,7 +995,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
inputs[0].u.ki.wScan = 0x3c0;
inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
reset_key_status();
reset_key_status(VK_PACKET);
SendInput(1, (INPUT*)inputs, sizeof(INPUT));
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){
@ -1016,7 +1017,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
inputs[1].u.ki.wScan = 0x3c0;
inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
reset_key_status();
reset_key_status(VK_PACKET);
SendInput(1, (INPUT*)(inputs+1), sizeof(INPUT));
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){
@ -1041,7 +1042,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
inputs[1].u.ki.wScan = 0x3041;
inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE;
reset_key_status();
reset_key_status(VK_PACKET);
key_status.expect_alt = TRUE;
SendInput(2, (INPUT*)inputs, sizeof(INPUT));
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
@ -1068,7 +1069,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
inputs[0].u.ki.wScan = 0;
inputs[0].u.ki.dwFlags = KEYEVENTF_KEYUP;
reset_key_status();
reset_key_status(VK_PACKET);
key_status.expect_alt = TRUE;
SendInput(2, (INPUT*)inputs, sizeof(INPUT));
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
@ -1084,6 +1085,34 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
ok(key_status.last_hook_up == 0x3041,
"Last hook up msg should have been 0x3041, was: 0x%x\n", key_status.last_hook_up);
}
/* Press and release, non-zero key code. */
inputs[0].u.ki.wVk = 0x51;
inputs[0].u.ki.wScan = 0x123;
inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
inputs[1].u.ki.wVk = 0x51;
inputs[1].u.ki.wScan = 0x123;
inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
reset_key_status(inputs[0].u.ki.wVk);
SendInput(2, (INPUT*)inputs, sizeof(INPUT));
while (PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
if (!key_status.sendinput_broken)
{
todo_wine {
ok(key_status.last_key_down == 0x51, "Unexpected key down %#x.\n", key_status.last_key_down);
ok(key_status.last_key_up == 0x51, "Unexpected key up %#x.\n", key_status.last_key_up);
}
if (hook)
todo_wine
ok(key_status.last_hook_up == 0x23, "Unexpected hook message %#x.\n", key_status.last_hook_up);
}
}
static LRESULT CALLBACK unicode_wnd_proc( HWND hWnd, UINT msg, WPARAM wParam,
@ -1124,7 +1153,8 @@ static LRESULT CALLBACK llkbd_unicode_hook(int nCode, WPARAM wParam, LPARAM lPar
ok(info->vkCode == VK_LMENU, "vkCode should have been VK_LMENU[0x%04x], was: 0x%x\n", VK_LMENU, info->vkCode);
key_status.expect_alt = FALSE;
}else
ok(info->vkCode == VK_PACKET, "vkCode should have been VK_PACKET[0x%04x], was: 0x%x\n", VK_PACKET, info->vkCode);
todo_wine_if(key_status.vk != VK_PACKET)
ok(info->vkCode == key_status.vk, "Unexpected vkCode %#x, expected %#x.\n", info->vkCode, key_status.vk);
}
switch(wParam){
case WM_KEYDOWN: