- update user32 winetest

svn path=/trunk/; revision=37702
This commit is contained in:
Kamil Hornicek 2008-11-28 12:02:57 +00:00
parent 017c4d5476
commit acffd663c1
20 changed files with 4031 additions and 784 deletions

View file

@ -357,17 +357,31 @@ static void test_Input_whitebox(void)
DestroyWindow(hWndTest);
}
static void empty_message_queue(void) {
/* try to make sure pending X events have been processed before continuing */
static void empty_message_queue(void)
{
MSG msg;
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
int diff = 200;
int min_timeout = 50;
DWORD time = GetTickCount() + diff;
while (diff > 0)
{
if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) break;
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
diff = time - GetTickCount();
min_timeout = 20;
}
}
struct transition_s {
WORD wVk;
BYTE before_state;
BYTE optional;
};
typedef enum {
@ -398,6 +412,7 @@ struct sendinput_test_s {
struct message expected_messages[MAXKEYMESSAGES+1];
} sendinput_test[] = {
/* test ALT+F */
/* 0 */
{VK_LMENU, 0, 0, {{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {0}},
{{WM_SYSKEYDOWN, hook|wparam, VK_LMENU}, {WM_SYSKEYDOWN}, {0}}},
{'F', 0, 0, {{'F', 0x00}, {0}},
@ -410,6 +425,7 @@ struct sendinput_test_s {
{{WM_KEYUP, hook}, {WM_KEYUP}, {0}}},
/* test CTRL+O */
/* 4 */
{VK_LCONTROL, 0, 0, {{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}},
{{WM_KEYDOWN, hook}, {WM_KEYDOWN}, {0}}},
{'O', 0, 0, {{'O', 0x00}, {0}},
@ -420,6 +436,7 @@ struct sendinput_test_s {
{{WM_KEYUP, hook}, {WM_KEYUP}, {0}}},
/* test ALT+CTRL+X */
/* 8 */
{VK_LMENU, 0, 0, {{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {0}},
{{WM_SYSKEYDOWN, hook}, {WM_SYSKEYDOWN}, {0}}},
{VK_LCONTROL, 0, 0, {{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}},
@ -434,6 +451,7 @@ struct sendinput_test_s {
{{WM_KEYUP, hook}, {WM_KEYUP}, {0}}},
/* test SHIFT+A */
/* 14 */
{VK_LSHIFT, 0, 0, {{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00}, {0}},
{{WM_KEYDOWN, hook}, {WM_KEYDOWN}, {0}}},
{'A', 0, 0, {{'A', 0x00}, {0}},
@ -444,16 +462,19 @@ struct sendinput_test_s {
{{WM_KEYUP, hook}, {WM_KEYUP}, {0}}},
/* test L-SHIFT & R-SHIFT: */
/* RSHIFT == LSHIFT */
/* 18 */
{VK_RSHIFT, 0, 0,
{{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00}, {0}},
/* recent windows versions (>= w2k3) correctly report an RSHIFT transition */
{{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00, TRUE}, {VK_RSHIFT, 0x00, TRUE}, {0}},
{{WM_KEYDOWN, hook|wparam, VK_RSHIFT},
{WM_KEYDOWN}, {0}}},
{VK_RSHIFT, KEYEVENTF_KEYUP, 0,
{{VK_SHIFT, 0x80}, {VK_LSHIFT, 0x80}, {0}},
{{VK_SHIFT, 0x80}, {VK_LSHIFT, 0x80, TRUE}, {VK_RSHIFT, 0x80, TRUE}, {0}},
{{WM_KEYUP, hook, hook|wparam, VK_RSHIFT},
{WM_KEYUP}, {0}}},
/* LSHIFT | KEYEVENTF_EXTENDEDKEY == RSHIFT */
/* 20 */
{VK_LSHIFT, KEYEVENTF_EXTENDEDKEY, 0,
{{VK_SHIFT, 0x00}, {VK_RSHIFT, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam|lparam, VK_LSHIFT, LLKHF_EXTENDED},
@ -463,6 +484,7 @@ struct sendinput_test_s {
{{WM_KEYUP, hook|wparam|lparam, VK_LSHIFT, LLKHF_UP|LLKHF_EXTENDED},
{WM_KEYUP, wparam|lparam, VK_SHIFT, KF_UP}, {0}}},
/* RSHIFT | KEYEVENTF_EXTENDEDKEY == RSHIFT */
/* 22 */
{VK_RSHIFT, KEYEVENTF_EXTENDEDKEY, 0,
{{VK_SHIFT, 0x00}, {VK_RSHIFT, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam|lparam, VK_RSHIFT, LLKHF_EXTENDED},
@ -471,27 +493,35 @@ struct sendinput_test_s {
{{VK_SHIFT, 0x80}, {VK_RSHIFT, 0x80}, {0}},
{{WM_KEYUP, hook|wparam|lparam, VK_RSHIFT, LLKHF_UP|LLKHF_EXTENDED},
{WM_KEYUP, wparam|lparam, VK_SHIFT, KF_UP}, {0}}},
/* Note about wparam for hook with generic key (VK_SHIFT, VK_CONTROL, VK_MENU):
win2k - sends to hook whatever we generated here
winXP+ - Attempts to convert key to L/R key but not always correct
*/
/* SHIFT == LSHIFT */
/* 24 */
{VK_SHIFT, 0, 0,
{{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam|lparam, VK_SHIFT, 0},
{{WM_KEYDOWN, hook/* |wparam */|lparam, VK_SHIFT, 0},
{WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0}, {0}}},
{VK_SHIFT, KEYEVENTF_KEYUP, 0,
{{VK_SHIFT, 0x80}, {VK_LSHIFT, 0x80}, {0}},
{{WM_KEYUP, hook|wparam|lparam, VK_SHIFT, LLKHF_UP},
{{WM_KEYUP, hook/*|wparam*/|lparam, VK_SHIFT, LLKHF_UP},
{WM_KEYUP, wparam|lparam, VK_SHIFT, KF_UP}, {0}}},
/* SHIFT | KEYEVENTF_EXTENDEDKEY == RSHIFT */
/* 26 */
{VK_SHIFT, KEYEVENTF_EXTENDEDKEY, 0,
{{VK_SHIFT, 0x00}, {VK_RSHIFT, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam|lparam, VK_SHIFT, LLKHF_EXTENDED},
{{WM_KEYDOWN, hook/*|wparam*/|lparam, VK_SHIFT, LLKHF_EXTENDED},
{WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0}, {0}}},
{VK_SHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0,
{{VK_SHIFT, 0x80}, {VK_RSHIFT, 0x80}, {0}},
{{WM_KEYUP, hook|wparam|lparam, VK_SHIFT, LLKHF_UP|LLKHF_EXTENDED},
{{WM_KEYUP, hook/*|wparam*/|lparam, VK_SHIFT, LLKHF_UP|LLKHF_EXTENDED},
{WM_KEYUP, wparam|lparam, VK_SHIFT, KF_UP}, {0}}},
/* test L-CONTROL & R-CONTROL: */
/* RCONTROL == LCONTROL */
/* 28 */
{VK_RCONTROL, 0, 0,
{{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam, VK_RCONTROL},
@ -501,6 +531,7 @@ struct sendinput_test_s {
{{WM_KEYUP, hook|wparam, VK_RCONTROL},
{WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP}, {0}}},
/* LCONTROL | KEYEVENTF_EXTENDEDKEY == RCONTROL */
/* 30 */
{VK_LCONTROL, KEYEVENTF_EXTENDEDKEY, 0,
{{VK_CONTROL, 0x00}, {VK_RCONTROL, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam|lparam, VK_LCONTROL, LLKHF_EXTENDED},
@ -510,6 +541,7 @@ struct sendinput_test_s {
{{WM_KEYUP, hook|wparam|lparam, VK_LCONTROL, LLKHF_UP|LLKHF_EXTENDED},
{WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP|KF_EXTENDED}, {0}}},
/* RCONTROL | KEYEVENTF_EXTENDEDKEY == RCONTROL */
/* 32 */
{VK_RCONTROL, KEYEVENTF_EXTENDEDKEY, 0,
{{VK_CONTROL, 0x00}, {VK_RCONTROL, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam|lparam, VK_RCONTROL, LLKHF_EXTENDED},
@ -519,26 +551,29 @@ struct sendinput_test_s {
{{WM_KEYUP, hook|wparam|lparam, VK_RCONTROL, LLKHF_UP|LLKHF_EXTENDED},
{WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP|KF_EXTENDED}, {0}}},
/* CONTROL == LCONTROL */
/* 34 */
{VK_CONTROL, 0, 0,
{{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam, VK_CONTROL},
{{WM_KEYDOWN, hook/*|wparam, VK_CONTROL*/},
{WM_KEYDOWN, wparam|lparam, VK_CONTROL, 0}, {0}}},
{VK_CONTROL, KEYEVENTF_KEYUP, 0,
{{VK_CONTROL, 0x80}, {VK_LCONTROL, 0x80}, {0}},
{{WM_KEYUP, hook|wparam, VK_CONTROL},
{{WM_KEYUP, hook/*|wparam, VK_CONTROL*/},
{WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP}, {0}}},
/* CONTROL | KEYEVENTF_EXTENDEDKEY == RCONTROL */
/* 36 */
{VK_CONTROL, KEYEVENTF_EXTENDEDKEY, 0,
{{VK_CONTROL, 0x00}, {VK_RCONTROL, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam|lparam, VK_CONTROL, LLKHF_EXTENDED},
{{WM_KEYDOWN, hook/*|wparam*/|lparam, VK_CONTROL, LLKHF_EXTENDED},
{WM_KEYDOWN, wparam|lparam, VK_CONTROL, KF_EXTENDED}, {0}}},
{VK_CONTROL, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0,
{{VK_CONTROL, 0x80}, {VK_RCONTROL, 0x80}, {0}},
{{WM_KEYUP, hook|wparam|lparam, VK_CONTROL, LLKHF_UP|LLKHF_EXTENDED},
{{WM_KEYUP, hook/*|wparam*/|lparam, VK_CONTROL, LLKHF_UP|LLKHF_EXTENDED},
{WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP|KF_EXTENDED}, {0}}},
/* test L-MENU & R-MENU: */
/* RMENU == LMENU */
/* 38 */
{VK_RMENU, 0, 0,
{{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {0}},
{{WM_SYSKEYDOWN, hook|wparam, VK_RMENU},
@ -549,6 +584,7 @@ struct sendinput_test_s {
{WM_SYSKEYUP, wparam|lparam, VK_MENU, KF_UP},
{WM_SYSCOMMAND}, {0}}},
/* LMENU | KEYEVENTF_EXTENDEDKEY == RMENU */
/* 40 */
{VK_LMENU, KEYEVENTF_EXTENDEDKEY, 0,
{{VK_MENU, 0x00}, {VK_RMENU, 0x00}, {0}},
{{WM_SYSKEYDOWN, hook|wparam|lparam, VK_LMENU, LLKHF_EXTENDED},
@ -559,6 +595,7 @@ struct sendinput_test_s {
{WM_SYSKEYUP, wparam|lparam, VK_MENU, KF_UP|KF_EXTENDED},
{WM_SYSCOMMAND}, {0}}},
/* RMENU | KEYEVENTF_EXTENDEDKEY == RMENU */
/* 42 */
{VK_RMENU, KEYEVENTF_EXTENDEDKEY, 0,
{{VK_MENU, 0x00}, {VK_RMENU, 0x00}, {0}},
{{WM_SYSKEYDOWN, hook|wparam|lparam, VK_RMENU, LLKHF_EXTENDED},
@ -569,27 +606,30 @@ struct sendinput_test_s {
{WM_SYSKEYUP, wparam|lparam, VK_MENU, KF_UP|KF_EXTENDED},
{WM_SYSCOMMAND}, {0}}},
/* MENU == LMENU */
/* 44 */
{VK_MENU, 0, 0,
{{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {0}},
{{WM_SYSKEYDOWN, hook|wparam, VK_MENU},
{{WM_SYSKEYDOWN, hook/*|wparam, VK_MENU*/},
{WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0}, {0}}},
{VK_MENU, KEYEVENTF_KEYUP, 1,
{{VK_MENU, 0x80}, {VK_LMENU, 0x80}, {0}},
{{WM_KEYUP, hook|wparam, VK_MENU},
{{WM_KEYUP, hook/*|wparam, VK_MENU*/},
{WM_SYSKEYUP, wparam|lparam, VK_MENU, KF_UP},
{WM_SYSCOMMAND}, {0}}},
/* MENU | KEYEVENTF_EXTENDEDKEY == RMENU */
/* 46 */
{VK_MENU, KEYEVENTF_EXTENDEDKEY, 0,
{{VK_MENU, 0x00}, {VK_RMENU, 0x00}, {0}},
{{WM_SYSKEYDOWN, hook|wparam|lparam, VK_MENU, LLKHF_EXTENDED},
{{WM_SYSKEYDOWN, hook/*|wparam*/|lparam, VK_MENU, LLKHF_EXTENDED},
{WM_SYSKEYDOWN, wparam|lparam, VK_MENU, KF_EXTENDED}, {0}}},
{VK_MENU, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 1,
{{VK_MENU, 0x80}, {VK_RMENU, 0x80}, {0}},
{{WM_KEYUP, hook|wparam|lparam, VK_MENU, LLKHF_UP|LLKHF_EXTENDED},
{{WM_KEYUP, hook/*|wparam*/|lparam, VK_MENU, LLKHF_UP|LLKHF_EXTENDED},
{WM_SYSKEYUP, wparam|lparam, VK_MENU, KF_UP|KF_EXTENDED},
{WM_SYSCOMMAND}, {0}}},
/* test LSHIFT & RSHIFT */
/* 48 */
{VK_LSHIFT, 0, 0,
{{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00}, {0}},
{{WM_KEYDOWN, hook|wparam|lparam, VK_LSHIFT, 0},
@ -629,15 +669,15 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, struct sendinput_tes
{
failcount++;
todo_wine {
ok(matched, "%02d: %02x from %02x -> %02x "
"instead of %02x -> %02x\n", id, t->wVk,
ks1[t->wVk]&0x80, ks2[t->wVk]&0x80, t->before_state,
ok(matched, "%2d (%x/%x): %02x from %02x -> %02x "
"instead of %02x -> %02x\n", id, test->wVk, test->dwFlags,
t->wVk, ks1[t->wVk]&0x80, ks2[t->wVk]&0x80, t->before_state,
~t->before_state&0x80);
}
} else {
ok(matched, "%02d: %02x from %02x -> %02x "
"instead of %02x -> %02x\n", id, t->wVk,
ks1[t->wVk]&0x80, ks2[t->wVk]&0x80, t->before_state,
ok(matched || t->optional, "%2d (%x/%x): %02x from %02x -> %02x "
"instead of %02x -> %02x\n", id, test->wVk, test->dwFlags,
t->wVk, ks1[t->wVk]&0x80, ks2[t->wVk]&0x80, t->before_state,
~t->before_state&0x80);
}
ks2[t->wVk] = ks1[t->wVk]; /* clear the match */
@ -648,11 +688,12 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, struct sendinput_tes
{
failcount++;
todo_wine
ok(FALSE, "%02d: %02x from %02x -> %02x unexpected\n", id, i, ks1[i], ks2[i]);
ok(FALSE, "%2d (%x/%x): %02x from %02x -> %02x unexpected\n",
id, test->wVk, test->dwFlags, i, ks1[i], ks2[i]);
}
else
ok(ks2[i] == ks1[i], "%02d: %02x from %02x -> %02x unexpected\n",
id, i, ks1[i], ks2[i]);
ok(ks2[i] == ks1[i], "%2d (%x/%x): %02x from %02x -> %02x unexpected\n",
id, test->wVk, test->dwFlags, i, ks1[i], ks2[i]);
while (expected->message && actual_cnt < sent_messages_cnt)
{
@ -661,8 +702,8 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, struct sendinput_tes
if (expected->message == actual->message)
{
ok((expected->flags & hook) == (actual->flags & hook),
"%x/%x: the msg 0x%04x should have been sent by a hook\n",
test->wVk, test->dwFlags, expected->message);
"%2d (%x/%x): the msg 0x%04x should have been sent by a hook\n",
id, test->wVk, test->dwFlags, expected->message);
if (expected->flags & wparam)
{
@ -670,13 +711,13 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, struct sendinput_tes
{
failcount++;
todo_wine
ok(FALSE, "%x/%x: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
test->wVk, test->dwFlags, expected->message, expected->wParam, actual->wParam);
ok(FALSE, "%2d (%x/%x): in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
id, test->wVk, test->dwFlags, expected->message, expected->wParam, actual->wParam);
}
else
ok(expected->wParam == actual->wParam,
"%x/%x: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
test->wVk, test->dwFlags, expected->message, expected->wParam, actual->wParam);
"%2d (%x/%x): in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
id, test->wVk, test->dwFlags, expected->message, expected->wParam, actual->wParam);
}
if (expected->flags & lparam)
{
@ -684,13 +725,13 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, struct sendinput_tes
{
failcount++;
todo_wine
ok(FALSE, "%x/%x: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
test->wVk, test->dwFlags, expected->message, expected->lParam, actual->lParam);
ok(FALSE, "%2d (%x/%x): in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
id, test->wVk, test->dwFlags, expected->message, expected->lParam, actual->lParam);
}
else
ok(expected->lParam == actual->lParam,
"%x/%x: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
test->wVk, test->dwFlags, expected->message, expected->lParam, actual->lParam);
"%2d (%x/%x): in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
id, test->wVk, test->dwFlags, expected->message, expected->lParam, actual->lParam);
}
}
else if (expected->flags & optional)
@ -703,13 +744,13 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, struct sendinput_tes
failcount++;
todo_wine
ok(FALSE,
"%x/%x: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
test->wVk, test->dwFlags, expected->message, actual->message);
"%2d (%x/%x): the msg 0x%04x was expected, but got msg 0x%04x instead\n",
id, test->wVk, test->dwFlags, expected->message, actual->message);
}
else
ok(FALSE,
"%x/%x: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
test->wVk, test->dwFlags, expected->message, actual->message);
"%2d (%x/%x): the msg 0x%04x was expected, but got msg 0x%04x instead\n",
id, test->wVk, test->dwFlags, expected->message, actual->message);
actual_cnt++;
expected++;
@ -725,17 +766,17 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, struct sendinput_tes
{
failcount++;
todo_wine
ok(FALSE, "%x/%x: the msg sequence is not complete: expected %04x - actual %04x\n",
test->wVk, test->dwFlags, expected->message, sent_messages[actual_cnt].message);
ok(FALSE, "%2d (%x/%x): the msg sequence is not complete: expected %04x - actual %04x\n",
id, test->wVk, test->dwFlags, expected->message, sent_messages[actual_cnt].message);
}
else
ok(FALSE, "%x/%x: the msg sequence is not complete: expected %04x - actual %04x\n",
test->wVk, test->dwFlags, expected->message, sent_messages[actual_cnt].message);
ok(FALSE, "%2d (%x/%x): the msg sequence is not complete: expected %04x - actual %04x\n",
id, test->wVk, test->dwFlags, expected->message, sent_messages[actual_cnt].message);
}
if( test->_todo_wine && !failcount) /* succeeded yet marked todo */
todo_wine
ok(TRUE, "%x/%x: marked \"todo_wine\" but succeeds\n", test->wVk, test->dwFlags);
ok(TRUE, "%2d (%x/%x): marked \"todo_wine\" but succeeds\n", id, test->wVk, test->dwFlags);
sent_messages_cnt = 0;
}
@ -1000,19 +1041,19 @@ static void test_GetMouseMovePointsEx(void)
SetLastError(MYERROR);
retval = pGetMouseMovePointsEx(0, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_INVALID_PARAMETER == GetLastError(),
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
"expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
SetLastError(MYERROR);
retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_INVALID_PARAMETER == GetLastError(),
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
"expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
SetLastError(MYERROR);
retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)+1, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_INVALID_PARAMETER == GetLastError(),
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
"expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
/* test second and third parameter
@ -1020,7 +1061,7 @@ static void test_GetMouseMovePointsEx(void)
SetLastError(MYERROR);
retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_NOACCESS == GetLastError(),
ok(GetLastError() == ERROR_NOACCESS || GetLastError() == MYERROR,
"expected error ERROR_NOACCESS, got %u\n", GetLastError());
SetLastError(MYERROR);
@ -1051,7 +1092,7 @@ static void test_GetMouseMovePointsEx(void)
count = -1;
retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
ok(retval == count, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_INVALID_PARAMETER == GetLastError(),
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
"expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
SetLastError(MYERROR);
@ -1075,7 +1116,7 @@ static void test_GetMouseMovePointsEx(void)
SetLastError(MYERROR);
retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_INVALID_PARAMETER == GetLastError(),
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
"expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
/* it was not possible to force an error with the fifth parameter on win2k */
@ -1084,25 +1125,25 @@ static void test_GetMouseMovePointsEx(void)
SetLastError(MYERROR);
retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, NULL, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_INVALID_PARAMETER == GetLastError(),
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
"expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
SetLastError(MYERROR);
retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, &in, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_INVALID_PARAMETER == GetLastError(),
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
"expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
SetLastError(MYERROR);
retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, out, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_INVALID_PARAMETER == GetLastError(),
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
"expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
SetLastError(MYERROR);
retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
ok(ERROR_INVALID_PARAMETER == GetLastError(),
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == MYERROR,
"expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
#undef BUFLIM
@ -1113,6 +1154,18 @@ static void test_key_map(void)
{
HKL kl = GetKeyboardLayout(0);
UINT kL, kR, s, sL;
int i;
static const UINT numpad_collisions[][2] = {
{ VK_NUMPAD0, VK_INSERT },
{ VK_NUMPAD1, VK_END },
{ VK_NUMPAD2, VK_DOWN },
{ VK_NUMPAD3, VK_NEXT },
{ VK_NUMPAD4, VK_LEFT },
{ VK_NUMPAD6, VK_RIGHT },
{ VK_NUMPAD7, VK_HOME },
{ VK_NUMPAD8, VK_UP },
{ VK_NUMPAD9, VK_PRIOR },
};
s = MapVirtualKeyEx(VK_SHIFT, MAPVK_VK_TO_VSC, kl);
ok(s != 0, "MapVirtualKeyEx(VK_SHIFT) should return non-zero\n");
@ -1128,6 +1181,60 @@ static void test_key_map(void)
ok(kL == VK_LSHIFT, "Scan code -> vKey = %x (not VK_LSHIFT)\n", kL);
kR = MapVirtualKeyEx(0x36, MAPVK_VSC_TO_VK_EX, kl);
ok(kR == VK_RSHIFT, "Scan code -> vKey = %x (not VK_RSHIFT)\n", kR);
/* test that MAPVK_VSC_TO_VK prefers the non-numpad vkey if there's ambiguity */
for (i = 0; i < sizeof(numpad_collisions)/sizeof(numpad_collisions[0]); i++)
{
UINT numpad_scan = MapVirtualKeyEx(numpad_collisions[i][0], MAPVK_VK_TO_VSC, kl);
UINT other_scan = MapVirtualKeyEx(numpad_collisions[i][1], MAPVK_VK_TO_VSC, kl);
/* do they really collide for this layout? */
if (numpad_scan && other_scan == numpad_scan)
{
UINT vkey = MapVirtualKeyEx(numpad_scan, MAPVK_VSC_TO_VK, kl);
ok(vkey != numpad_collisions[i][0],
"Got numpad vKey %x for scan code %x when there was another choice\n",
vkey, numpad_scan);
}
}
}
static void test_ToUnicode(void)
{
WCHAR wStr[2];
BYTE state[256];
const BYTE SC_RETURN = 0x1c, SC_TAB = 0x0f;
const BYTE HIGHEST_BIT = 0x80;
int i, ret;
for(i=0; i<256; i++)
state[i]=0;
SetLastError(0xdeadbeef);
ret = ToUnicode(VK_RETURN, SC_RETURN, state, wStr, 2, 0);
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
skip("ToUnicode is not implemented\n");
return;
}
ok(ret == 1, "ToUnicode for Return key didn't return 1 (was %i)\n", ret);
if(ret == 1)
ok(wStr[0]=='\r', "ToUnicode for CTRL + Return was %i (expected 13)\n", wStr[0]);
state[VK_CONTROL] |= HIGHEST_BIT;
state[VK_LCONTROL] |= HIGHEST_BIT;
ret = ToUnicode(VK_TAB, SC_TAB, state, wStr, 2, 0);
todo_wine ok(ret == 0, "ToUnicode for CTRL + Tab didn't return 0 (was %i)\n", ret);
ret = ToUnicode(VK_RETURN, SC_RETURN, state, wStr, 2, 0);
ok(ret == 1, "ToUnicode for CTRL + Return didn't return 1 (was %i)\n", ret);
if(ret == 1)
ok(wStr[0]=='\n', "ToUnicode for CTRL + Return was %i (expected 10)\n", wStr[0]);
state[VK_SHIFT] |= HIGHEST_BIT;
state[VK_LSHIFT] |= HIGHEST_BIT;
ret = ToUnicode(VK_RETURN, SC_RETURN, state, wStr, 2, 0);
todo_wine ok(ret == 0, "ToUnicode for CTRL + SHIFT + Return didn't return 0 (was %i)\n", ret);
}
START_TEST(input)
@ -1143,6 +1250,7 @@ START_TEST(input)
test_keynames();
test_mouse_ll_hook();
test_key_map();
test_ToUnicode();
if(pGetMouseMovePointsEx)
test_GetMouseMovePointsEx();