From: Rémi Bernon rbernon@codeweavers.com
And rename keyboard tests to avoid conflicts with mouse tests. --- dlls/user32/tests/input.c | 212 +++++++++++++++++++------------------- 1 file changed, 108 insertions(+), 104 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 2e66b084d6a..9d5b0e36c64 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -119,6 +119,7 @@ struct user_call { struct { + HWND hwnd; UINT msg; WPARAM wparam; LPARAM lparam; @@ -187,6 +188,7 @@ static int ok_call_( const char *file, int line, const struct user_call *expecte switch (expected->func) { case MSG_TEST_WIN: + if ((ret = expected->message.hwnd - received->message.hwnd)) goto done; if ((ret = expected->message.msg - received->message.msg)) goto done; if ((ret = (expected->message.wparam - received->message.wparam))) goto done; if ((ret = (expected->message.lparam - received->message.lparam))) goto done; @@ -207,12 +209,12 @@ done: { case MSG_TEST_WIN: todo_wine_if( expected->todo || expected->todo_value ) - ok_(file, line)( !ret, "got msg %s, wparam %#Ix, lparam %#Ix\n", debugstr_wm(received->message.msg), - received->message.wparam, received->message.lparam ); + ok_(file, line)( !ret, "got MSG_TEST_WIN hwnd %p, msg %s, wparam %#Ix, lparam %#Ix\n", received->message.hwnd, + debugstr_wm(received->message.msg), received->message.wparam, received->message.lparam ); return ret; case LL_HOOK_KEYBD: todo_wine_if( expected->todo || expected->todo_value ) - ok_(file, line)( !ret, "got hook msg %s scan %#x, vkey %s, flags %#x, extra %#Ix\n", debugstr_wm(received->ll_hook_kbd.msg), + ok_(file, line)( !ret, "got LL_HOOK_KEYBD msg %s scan %#x, vkey %s, flags %#x, extra %#Ix\n", debugstr_wm(received->ll_hook_kbd.msg), received->ll_hook_kbd.scan, debugstr_vk(received->ll_hook_kbd.vkey), received->ll_hook_kbd.flags, received->ll_hook_kbd.extra ); return ret; @@ -222,12 +224,12 @@ done: { case MSG_TEST_WIN: todo_wine_if( expected->todo || expected->todo_value ) - ok_(file, line)( !ret, "msg %s, wparam %#Ix, lparam %#Ix\n", debugstr_wm(expected->message.msg), - expected->message.wparam, expected->message.lparam ); + ok_(file, line)( !ret, "MSG_TEST_WIN hwnd %p, %s, wparam %#Ix, lparam %#Ix\n", expected->message.hwnd, + debugstr_wm(expected->message.msg), expected->message.wparam, expected->message.lparam ); break; case LL_HOOK_KEYBD: todo_wine_if( expected->todo || expected->todo_value ) - ok_(file, line)( !ret, "hook msg %s scan %#x, vkey %s, flags %#x, extra %#Ix\n", debugstr_wm(expected->ll_hook_kbd.msg), + ok_(file, line)( !ret, "LL_HOOK_KBD msg %s scan %#x, vkey %s, flags %#x, extra %#Ix\n", debugstr_wm(expected->ll_hook_kbd.msg), expected->ll_hook_kbd.scan, debugstr_vk(expected->ll_hook_kbd.vkey), expected->ll_hook_kbd.flags, expected->ll_hook_kbd.extra ); break; @@ -244,7 +246,7 @@ static void ok_seq_( const char *file, int line, const struct user_call *expecte
while (expected->func || received->func) { - winetest_push_context( "%u%s%s", i++, !expected->func ? " (spurious)" : "", + winetest_push_context( "%s %u%s%s", context, i++, !expected->func ? " (spurious)" : "", !received->func ? " (missing)" : "" ); ret = ok_call_( file, line, expected, received ); if (ret && expected->todo && expected->func && @@ -279,21 +281,23 @@ static void append_ll_hook_kbd( UINT msg, const KBDLLHOOKSTRUCT *info ) current_sequence[index] = call; }
+static BOOL append_message_hwnd; static BOOL (*p_accept_message)( UINT msg ); -static void append_message( UINT msg, WPARAM wparam, LPARAM lparam ) +static void append_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { if (!p_accept_message || p_accept_message( msg )) { - struct user_call call = {.func = MSG_TEST_WIN, .message = {.msg = msg, .wparam = wparam, .lparam = lparam}}; + struct user_call call = {.func = MSG_TEST_WIN, .message = {.hwnd = hwnd, .msg = msg, .wparam = wparam, .lparam = lparam}}; ULONG index = InterlockedIncrement( ¤t_sequence_len ) - 1; ok( index < ARRAY_SIZE(current_sequence), "got %lu calls\n", index ); + if (!append_message_hwnd) call.message.hwnd = 0; current_sequence[index] = call; } }
static LRESULT CALLBACK append_message_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - append_message( msg, wparam, lparam ); + append_message( hwnd, msg, wparam, lparam ); return DefWindowProcW( hwnd, msg, wparam, lparam ); }
@@ -418,7 +422,7 @@ static DWORD msg_wait_for_events_( const char *file, int line, DWORD count, HAND { while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) { - if (append_peeked) append_message( msg.message, msg.wParam, msg.lParam ); + if (append_peeked) append_message( msg.hwnd, msg.message, msg.wParam, msg.lParam ); TranslateMessage( &msg ); DispatchMessageW( &msg ); } @@ -466,7 +470,7 @@ static void empty_message_queue(void) } }
-struct send_input_test +struct send_input_keyboard_test { WORD scan; WORD vkey; @@ -514,8 +518,8 @@ static void check_keyboard_state_( int line, const BYTE expect_state[256], const } }
-#define check_send_input_test( a, b ) check_send_input_test_( a, #a, b ) -static void check_send_input_test_( const struct send_input_test *test, const char *context, BOOL peeked ) +#define check_send_input_keyboard_test( a, b ) check_send_input_keyboard_test_( a, #a, b ) +static void check_send_input_keyboard_test_( const struct send_input_keyboard_test *test, const char *context, BOOL peeked ) { static BYTE empty_state[256] = {0}; INPUT input = {.type = INPUT_KEYBOARD}; @@ -544,7 +548,7 @@ static void check_send_input_test_( const struct send_input_test *test, const ch winetest_pop_context(); }
-static BOOL test_send_input_accept_message( UINT msg ) +static BOOL accept_keyboard_messages_syscommand( UINT msg ) { return is_keyboard_message( msg ) || msg == WM_SYSCOMMAND; } @@ -624,7 +628,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W #define KEY_MSG_(m, s, v, f, ...) WIN_MSG( m, v, MAKELONG(1, (s) | (m == WM_KEYUP || m == WM_SYSKEYUP ? (KF_UP | KF_REPEAT) : 0) | (f)), ## __VA_ARGS__ ) #define KEY_MSG(m, s, v, ...) KEY_MSG_( m, s, v, 0, ## __VA_ARGS__ )
- struct send_input_test lmenu_vkey[] = + struct send_input_keyboard_test lmenu_vkey[] = { {.vkey = VK_LMENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_LMENU, LLKHF_ALTDOWN, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN), {0}}}, @@ -646,7 +650,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- struct send_input_test lmenu_vkey_peeked[] = + struct send_input_keyboard_test lmenu_vkey_peeked[] = { {.vkey = VK_LMENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_LMENU, LLKHF_ALTDOWN, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN), {0}}}, @@ -667,7 +671,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- struct send_input_test lcontrol_vkey[] = + struct send_input_keyboard_test lcontrol_vkey[] = { {.vkey = VK_LCONTROL, .expect_state = {[VK_CONTROL] = 0x80, [VK_LCONTROL] = 0x80}, .expect = {KEY_HOOK(WM_KEYDOWN, 1, VK_LCONTROL), KEY_MSG(WM_KEYDOWN, 1, VK_CONTROL), {0}}}, @@ -680,7 +684,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- struct send_input_test lmenu_lcontrol_vkey[] = + struct send_input_keyboard_test lmenu_lcontrol_vkey[] = { {.vkey = VK_LMENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_LMENU, LLKHF_ALTDOWN, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN), {0}}}, @@ -697,7 +701,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- struct send_input_test shift_vkey[] = + struct send_input_keyboard_test shift_vkey[] = { {.vkey = VK_LSHIFT, .expect_state = {[VK_SHIFT] = 0x80, [VK_LSHIFT] = 0x80}, .expect = {KEY_HOOK(WM_KEYDOWN, 1, VK_LSHIFT), KEY_MSG(WM_KEYDOWN, 1, VK_SHIFT), {0}}}, @@ -710,7 +714,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- static const struct send_input_test rshift[] = + static const struct send_input_keyboard_test rshift[] = { {.vkey = VK_RSHIFT, .expect_state = {[VK_SHIFT] = 0x80, [VK_RSHIFT] = 0x80}, .todo_state = {[VK_RSHIFT] = TRUE, [VK_LSHIFT] = TRUE}, .expect = {KEY_HOOK_(WM_KEYDOWN, 1, VK_RSHIFT, LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG(WM_KEYDOWN, 1, VK_SHIFT), {0}}}, @@ -718,7 +722,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK_(WM_KEYUP, 2, VK_RSHIFT, LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG(WM_KEYUP, 2, VK_SHIFT), {0}}}, {0}, }; - static const struct send_input_test lshift_ext[] = + static const struct send_input_keyboard_test lshift_ext[] = { {.vkey = VK_LSHIFT, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_SHIFT] = 0x80, [VK_RSHIFT] = 0x80}, .expect = {KEY_HOOK_(WM_KEYDOWN, 1, VK_LSHIFT, LLKHF_EXTENDED), KEY_MSG(WM_KEYDOWN, 1, VK_SHIFT), {0}}}, @@ -726,7 +730,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK_(WM_KEYUP, 2, VK_LSHIFT, LLKHF_EXTENDED), KEY_MSG(WM_KEYUP, 2, VK_SHIFT), {0}}}, {0}, }; - static const struct send_input_test rshift_ext[] = + static const struct send_input_keyboard_test rshift_ext[] = { {.vkey = VK_RSHIFT, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_SHIFT] = 0x80, [VK_RSHIFT] = 0x80}, .expect = {KEY_HOOK_(WM_KEYDOWN, 1, VK_RSHIFT, LLKHF_EXTENDED), KEY_MSG(WM_KEYDOWN, 1, VK_SHIFT), {0}}}, @@ -734,7 +738,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK_(WM_KEYUP, 2, VK_RSHIFT, LLKHF_EXTENDED), KEY_MSG(WM_KEYUP, 2, VK_SHIFT), {0}}}, {0}, }; - static const struct send_input_test shift[] = + static const struct send_input_keyboard_test shift[] = { {.vkey = VK_SHIFT, .expect_state = {[VK_SHIFT] = 0x80, [VK_LSHIFT] = 0x80}, .expect = {KEY_HOOK(WM_KEYDOWN, 1, VK_LSHIFT, .todo_value = TRUE), KEY_MSG(WM_KEYDOWN, 1, VK_SHIFT), {0}}}, @@ -742,7 +746,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK(WM_KEYUP, 2, VK_LSHIFT, .todo_value = TRUE), KEY_MSG(WM_KEYUP, 2, VK_SHIFT), {0}}}, {0}, }; - static const struct send_input_test shift_ext[] = + static const struct send_input_keyboard_test shift_ext[] = { {.vkey = VK_SHIFT, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_SHIFT] = 0x80, [VK_RSHIFT] = 0x80}, .expect = {KEY_HOOK_(WM_KEYDOWN, 1, VK_LSHIFT, LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG(WM_KEYDOWN, 1, VK_SHIFT), {0}}}, @@ -751,7 +755,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- static const struct send_input_test rcontrol[] = + static const struct send_input_keyboard_test rcontrol[] = { {.vkey = VK_RCONTROL, .expect_state = {[VK_CONTROL] = 0x80, [VK_LCONTROL] = 0x80}, .expect = {KEY_HOOK(WM_KEYDOWN, 1, VK_RCONTROL), KEY_MSG(WM_KEYDOWN, 1, VK_CONTROL), {0}}}, @@ -759,7 +763,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK(WM_KEYUP, 2, VK_RCONTROL), KEY_MSG(WM_KEYUP, 2, VK_CONTROL), {0}}}, {0}, }; - static const struct send_input_test lcontrol_ext[] = + static const struct send_input_keyboard_test lcontrol_ext[] = { {.vkey = VK_LCONTROL, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_CONTROL] = 0x80, [VK_RCONTROL] = 0x80}, .expect = {KEY_HOOK_(WM_KEYDOWN, 1, VK_LCONTROL, LLKHF_EXTENDED), KEY_MSG_(WM_KEYDOWN, 1, VK_CONTROL, KF_EXTENDED), {0}}}, @@ -767,7 +771,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK_(WM_KEYUP, 2, VK_LCONTROL, LLKHF_EXTENDED), KEY_MSG_(WM_KEYUP, 2, VK_CONTROL, KF_EXTENDED), {0}}}, {0}, }; - static const struct send_input_test rcontrol_ext[] = + static const struct send_input_keyboard_test rcontrol_ext[] = { {.vkey = VK_RCONTROL, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_CONTROL] = 0x80, [VK_RCONTROL] = 0x80}, .expect = {KEY_HOOK_(WM_KEYDOWN, 1, VK_RCONTROL, LLKHF_EXTENDED), KEY_MSG_(WM_KEYDOWN, 1, VK_CONTROL, KF_EXTENDED), {0}}}, @@ -775,7 +779,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK_(WM_KEYUP, 2, VK_RCONTROL, LLKHF_EXTENDED), KEY_MSG_(WM_KEYUP, 2, VK_CONTROL, KF_EXTENDED), {0}}}, {0}, }; - static const struct send_input_test control[] = + static const struct send_input_keyboard_test control[] = { {.vkey = VK_CONTROL, .expect_state = {[VK_CONTROL] = 0x80, [VK_LCONTROL] = 0x80}, .expect = {KEY_HOOK(WM_KEYDOWN, 1, VK_LCONTROL, .todo_value = TRUE), KEY_MSG(WM_KEYDOWN, 1, VK_CONTROL), {0}}}, @@ -783,7 +787,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK(WM_KEYUP, 2, VK_LCONTROL, .todo_value = TRUE), KEY_MSG(WM_KEYUP, 2, VK_CONTROL), {0}}}, {0}, }; - static const struct send_input_test control_ext[] = + static const struct send_input_keyboard_test control_ext[] = { {.vkey = VK_CONTROL, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_CONTROL] = 0x80, [VK_RCONTROL] = 0x80}, .expect = {KEY_HOOK_(WM_KEYDOWN, 1, VK_RCONTROL, LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_KEYDOWN, 1, VK_CONTROL, KF_EXTENDED), {0}}}, @@ -792,7 +796,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- static const struct send_input_test rmenu[] = + static const struct send_input_keyboard_test rmenu[] = { {.vkey = VK_RMENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_RMENU, LLKHF_ALTDOWN, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN), {0}}}, @@ -800,7 +804,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK(WM_KEYUP, 2, VK_RMENU, .todo_value = TRUE), KEY_MSG(WM_SYSKEYUP, 2, VK_MENU), WIN_MSG(WM_SYSCOMMAND, SC_KEYMENU, 0), {0}}}, {0}, }; - static const struct send_input_test lmenu_ext[] = + static const struct send_input_keyboard_test lmenu_ext[] = { {.vkey = VK_LMENU, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_MENU] = 0x80, [VK_RMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_LMENU, LLKHF_ALTDOWN|LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN|KF_EXTENDED), {0}}}, @@ -808,7 +812,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK_(WM_KEYUP, 2, VK_LMENU, LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYUP, 2, VK_MENU, KF_EXTENDED), WIN_MSG(WM_SYSCOMMAND, SC_KEYMENU, 0), {0}}}, {0}, }; - static const struct send_input_test rmenu_ext[] = + static const struct send_input_keyboard_test rmenu_ext[] = { {.vkey = VK_RMENU, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_MENU] = 0x80, [VK_RMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_RMENU, LLKHF_ALTDOWN|LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN|KF_EXTENDED), {0}}}, @@ -816,7 +820,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK_(WM_KEYUP, 2, VK_RMENU, LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYUP, 2, VK_MENU, KF_EXTENDED), WIN_MSG(WM_SYSCOMMAND, SC_KEYMENU, 0), {0}}}, {0}, }; - static const struct send_input_test menu[] = + static const struct send_input_keyboard_test menu[] = { {.vkey = VK_MENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_LMENU, LLKHF_ALTDOWN, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN), {0}}}, @@ -824,7 +828,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK(WM_KEYUP, 2, VK_LMENU, .todo_value = TRUE), KEY_MSG(WM_SYSKEYUP, 2, VK_MENU), WIN_MSG(WM_SYSCOMMAND, SC_KEYMENU, 0), {0}}}, {0}, }; - static const struct send_input_test menu_ext[] = + static const struct send_input_keyboard_test menu_ext[] = { {.vkey = VK_MENU, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_MENU] = 0x80, [VK_RMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_RMENU, LLKHF_ALTDOWN|LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN|KF_EXTENDED), {0}}}, @@ -833,7 +837,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- static const struct send_input_test rmenu_peeked[] = + static const struct send_input_keyboard_test rmenu_peeked[] = { {.vkey = VK_RMENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_RMENU, LLKHF_ALTDOWN, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN), {0}}}, @@ -841,7 +845,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK(WM_KEYUP, 2, VK_RMENU, .todo_value = TRUE), KEY_MSG(WM_SYSKEYUP, 2, VK_MENU), {0}}}, {0}, }; - static const struct send_input_test lmenu_ext_peeked[] = + static const struct send_input_keyboard_test lmenu_ext_peeked[] = { {.vkey = VK_LMENU, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_MENU] = 0x80, [VK_RMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_LMENU, LLKHF_ALTDOWN|LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN|KF_EXTENDED), {0}}}, @@ -849,7 +853,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK_(WM_KEYUP, 2, VK_LMENU, LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYUP, 2, VK_MENU, KF_EXTENDED), {0}}}, {0}, }; - static const struct send_input_test rmenu_ext_peeked[] = + static const struct send_input_keyboard_test rmenu_ext_peeked[] = { {.vkey = VK_RMENU, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_MENU] = 0x80, [VK_RMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_RMENU, LLKHF_ALTDOWN|LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN|KF_EXTENDED), {0}}}, @@ -857,7 +861,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK_(WM_KEYUP, 2, VK_RMENU, LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYUP, 2, VK_MENU, KF_EXTENDED), {0}}}, {0}, }; - static const struct send_input_test menu_peeked[] = + static const struct send_input_keyboard_test menu_peeked[] = { {.vkey = VK_MENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_LMENU, LLKHF_ALTDOWN, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN), {0}}}, @@ -865,7 +869,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK(WM_KEYUP, 2, VK_LMENU, .todo_value = TRUE), KEY_MSG(WM_SYSKEYUP, 2, VK_MENU), {0}}}, {0}, }; - static const struct send_input_test menu_ext_peeked[] = + static const struct send_input_keyboard_test menu_ext_peeked[] = { {.vkey = VK_MENU, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_MENU] = 0x80, [VK_RMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_RMENU, LLKHF_ALTDOWN|LLKHF_EXTENDED, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN|KF_EXTENDED), {0}}}, @@ -874,7 +878,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- struct send_input_test rmenu_altgr[] = + struct send_input_keyboard_test rmenu_altgr[] = { { .vkey = VK_RMENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80, [VK_CONTROL] = 0x80, [VK_LCONTROL] = 0x80}, @@ -900,7 +904,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W }, {0}, }; - struct send_input_test rmenu_ext_altgr[] = + struct send_input_keyboard_test rmenu_ext_altgr[] = { { .vkey = VK_RMENU, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_MENU] = 0x80, [VK_RMENU] = 0x80, [VK_CONTROL] = 0x80, [VK_LCONTROL] = 0x80}, @@ -926,7 +930,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W }, {0}, }; - struct send_input_test menu_ext_altgr[] = + struct send_input_keyboard_test menu_ext_altgr[] = { { .vkey = VK_MENU, .flags = KEYEVENTF_EXTENDEDKEY, .expect_state = {[VK_MENU] = 0x80, [VK_RMENU] = 0x80, [VK_CONTROL] = 0x80, [VK_LCONTROL] = 0x80}, @@ -953,7 +957,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- static const struct send_input_test lrshift_ext[] = + static const struct send_input_keyboard_test lrshift_ext[] = { {.vkey = VK_LSHIFT, .expect_state = {[VK_SHIFT] = 0x80, [VK_LSHIFT] = 0x80}, .expect = {KEY_HOOK(WM_KEYDOWN, 1, VK_LSHIFT), KEY_MSG(WM_KEYDOWN, 1, VK_SHIFT), {0}}}, @@ -966,7 +970,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- struct send_input_test rshift_scan[] = + struct send_input_keyboard_test rshift_scan[] = { {.scan = 0x36, .flags = KEYEVENTF_SCANCODE, .expect_state = {[VK_SHIFT] = 0x80, [VK_LSHIFT] = 0x80}, .todo_state = {[0] = TRUE, [VK_SHIFT] = TRUE, [VK_LSHIFT] = TRUE}, @@ -982,7 +986,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- struct send_input_test unicode[] = + struct send_input_keyboard_test unicode[] = { {.scan = 0x3c0, .flags = KEYEVENTF_UNICODE, .expect_state = {[VK_PACKET] = 0x80}, .expect = {KEY_HOOK(WM_KEYDOWN, 0x3c0, VK_PACKET), KEY_MSG(WM_KEYDOWN, 0, VK_PACKET, .todo_value = TRUE), WIN_MSG(WM_CHAR, 0x3c0, 1), {0}}}, @@ -991,7 +995,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- struct send_input_test lmenu_unicode[] = + struct send_input_keyboard_test lmenu_unicode[] = { {.vkey = VK_LMENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_LMENU, LLKHF_ALTDOWN, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN), {0}}}, @@ -1012,7 +1016,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W .expect = {KEY_HOOK(WM_KEYUP, 4, VK_LMENU), KEY_MSG(WM_KEYUP, 4, VK_MENU), {0}}}, {0}, }; - struct send_input_test lmenu_unicode_peeked[] = + struct send_input_keyboard_test lmenu_unicode_peeked[] = { {.vkey = VK_LMENU, .expect_state = {[VK_MENU] = 0x80, [VK_LMENU] = 0x80}, .expect = {KEY_HOOK_(WM_SYSKEYDOWN, 1, VK_LMENU, LLKHF_ALTDOWN, .todo_value = TRUE), KEY_MSG_(WM_SYSKEYDOWN, 1, VK_MENU, KF_ALTDOWN), {0}}}, @@ -1033,7 +1037,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W {0}, };
- struct send_input_test unicode_vkey[] = + struct send_input_keyboard_test unicode_vkey[] = { {.scan = 0x3c0, .vkey = vkey, .flags = KEYEVENTF_UNICODE, .expect_state = {/*[vkey] = 0x80*/}, .expect = {KEY_HOOK(WM_KEYDOWN, 0xc0, vkey, .todo_value = TRUE), KEY_MSG(WM_KEYDOWN, 0xc0, vkey, .todo_value = TRUE), WIN_MSG(WM_CHAR, wch, MAKELONG(1, 0xc0), .todo_value = TRUE), {0}}}, @@ -1065,7 +1069,7 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W hook = SetWindowsHookExW( WH_KEYBOARD_LL, ll_hook_kbd_proc, GetModuleHandleW( NULL ), 0 ); ok_ne( NULL, hook, HHOOK, "%p" );
- p_accept_message = test_send_input_accept_message; + p_accept_message = accept_keyboard_messages_syscommand; ok_seq( empty_sequence );
lmenu_vkey_peeked[1].expect_state[vkey] = 0x80; @@ -1079,36 +1083,36 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W
/* test peeked messages */ winetest_push_context( "peek" ); - check_send_input_test( lmenu_vkey_peeked, TRUE ); - check_send_input_test( lcontrol_vkey, TRUE ); - check_send_input_test( lmenu_lcontrol_vkey, TRUE ); - check_send_input_test( shift_vkey, TRUE ); - check_send_input_test( rshift, TRUE ); - check_send_input_test( lshift_ext, TRUE ); - check_send_input_test( rshift_ext, TRUE ); - check_send_input_test( shift, TRUE ); - check_send_input_test( shift_ext, TRUE ); - check_send_input_test( rcontrol, TRUE ); - check_send_input_test( lcontrol_ext, TRUE ); - check_send_input_test( rcontrol_ext, TRUE ); - check_send_input_test( control, TRUE ); - check_send_input_test( control_ext, TRUE ); + check_send_input_keyboard_test( lmenu_vkey_peeked, TRUE ); + check_send_input_keyboard_test( lcontrol_vkey, TRUE ); + check_send_input_keyboard_test( lmenu_lcontrol_vkey, TRUE ); + check_send_input_keyboard_test( shift_vkey, TRUE ); + check_send_input_keyboard_test( rshift, TRUE ); + check_send_input_keyboard_test( lshift_ext, TRUE ); + check_send_input_keyboard_test( rshift_ext, TRUE ); + check_send_input_keyboard_test( shift, TRUE ); + check_send_input_keyboard_test( shift_ext, TRUE ); + check_send_input_keyboard_test( rcontrol, TRUE ); + check_send_input_keyboard_test( lcontrol_ext, TRUE ); + check_send_input_keyboard_test( rcontrol_ext, TRUE ); + check_send_input_keyboard_test( control, TRUE ); + check_send_input_keyboard_test( control_ext, TRUE ); if (skip_altgr) skip( "skipping rmenu_altgr test\n" ); - else if (altgr) check_send_input_test( rmenu_altgr, TRUE ); - else check_send_input_test( rmenu_peeked, TRUE ); - check_send_input_test( lmenu_ext_peeked, TRUE ); + else if (altgr) check_send_input_keyboard_test( rmenu_altgr, TRUE ); + else check_send_input_keyboard_test( rmenu_peeked, TRUE ); + check_send_input_keyboard_test( lmenu_ext_peeked, TRUE ); if (skip_altgr) skip( "skipping rmenu_ext_altgr test\n" ); - else if (altgr) check_send_input_test( rmenu_ext_altgr, TRUE ); - else check_send_input_test( rmenu_ext_peeked, TRUE ); - check_send_input_test( menu_peeked, TRUE ); + else if (altgr) check_send_input_keyboard_test( rmenu_ext_altgr, TRUE ); + else check_send_input_keyboard_test( rmenu_ext_peeked, TRUE ); + check_send_input_keyboard_test( menu_peeked, TRUE ); if (skip_altgr) skip( "skipping menu_ext_altgr test\n" ); - else if (altgr) check_send_input_test( menu_ext_altgr, TRUE ); - else check_send_input_test( menu_ext_peeked, TRUE ); - check_send_input_test( lrshift_ext, TRUE ); - check_send_input_test( rshift_scan, TRUE ); - check_send_input_test( unicode, TRUE ); - check_send_input_test( lmenu_unicode_peeked, TRUE ); - check_send_input_test( unicode_vkey, TRUE ); + else if (altgr) check_send_input_keyboard_test( menu_ext_altgr, TRUE ); + else check_send_input_keyboard_test( menu_ext_peeked, TRUE ); + check_send_input_keyboard_test( lrshift_ext, TRUE ); + check_send_input_keyboard_test( rshift_scan, TRUE ); + check_send_input_keyboard_test( unicode, TRUE ); + check_send_input_keyboard_test( lmenu_unicode_peeked, TRUE ); + check_send_input_keyboard_test( unicode_vkey, TRUE ); winetest_pop_context();
wait_messages( 100, FALSE ); @@ -1119,36 +1123,36 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W ok_ne( 0, old_proc, LONG_PTR, "%#Ix" );
winetest_push_context( "receive" ); - check_send_input_test( lmenu_vkey, FALSE ); - check_send_input_test( lcontrol_vkey, FALSE ); - check_send_input_test( lmenu_lcontrol_vkey, FALSE ); - check_send_input_test( shift_vkey, FALSE ); - check_send_input_test( rshift, FALSE ); - check_send_input_test( lshift_ext, FALSE ); - check_send_input_test( rshift_ext, FALSE ); - check_send_input_test( shift, FALSE ); - check_send_input_test( shift_ext, FALSE ); - check_send_input_test( rcontrol, FALSE ); - check_send_input_test( lcontrol_ext, FALSE ); - check_send_input_test( rcontrol_ext, FALSE ); - check_send_input_test( control, FALSE ); - check_send_input_test( control_ext, FALSE ); + check_send_input_keyboard_test( lmenu_vkey, FALSE ); + check_send_input_keyboard_test( lcontrol_vkey, FALSE ); + check_send_input_keyboard_test( lmenu_lcontrol_vkey, FALSE ); + check_send_input_keyboard_test( shift_vkey, FALSE ); + check_send_input_keyboard_test( rshift, FALSE ); + check_send_input_keyboard_test( lshift_ext, FALSE ); + check_send_input_keyboard_test( rshift_ext, FALSE ); + check_send_input_keyboard_test( shift, FALSE ); + check_send_input_keyboard_test( shift_ext, FALSE ); + check_send_input_keyboard_test( rcontrol, FALSE ); + check_send_input_keyboard_test( lcontrol_ext, FALSE ); + check_send_input_keyboard_test( rcontrol_ext, FALSE ); + check_send_input_keyboard_test( control, FALSE ); + check_send_input_keyboard_test( control_ext, FALSE ); if (skip_altgr) skip( "skipping rmenu_altgr test\n" ); - else if (altgr) check_send_input_test( rmenu_altgr, FALSE ); - else check_send_input_test( rmenu, FALSE ); - check_send_input_test( lmenu_ext, FALSE ); + else if (altgr) check_send_input_keyboard_test( rmenu_altgr, FALSE ); + else check_send_input_keyboard_test( rmenu, FALSE ); + check_send_input_keyboard_test( lmenu_ext, FALSE ); if (skip_altgr) skip( "skipping rmenu_ext_altgr test\n" ); - else if (altgr) check_send_input_test( rmenu_ext_altgr, FALSE ); - else check_send_input_test( rmenu_ext, FALSE ); - check_send_input_test( menu, FALSE ); + else if (altgr) check_send_input_keyboard_test( rmenu_ext_altgr, FALSE ); + else check_send_input_keyboard_test( rmenu_ext, FALSE ); + check_send_input_keyboard_test( menu, FALSE ); if (skip_altgr) skip( "skipping menu_ext_altgr test\n" ); - else if (altgr) check_send_input_test( menu_ext_altgr, FALSE ); - else check_send_input_test( menu_ext, FALSE ); - check_send_input_test( lrshift_ext, FALSE ); - check_send_input_test( rshift_scan, FALSE ); - check_send_input_test( unicode, FALSE ); - check_send_input_test( lmenu_unicode, FALSE ); - check_send_input_test( unicode_vkey, FALSE ); + else if (altgr) check_send_input_keyboard_test( menu_ext_altgr, FALSE ); + else check_send_input_keyboard_test( menu_ext, FALSE ); + check_send_input_keyboard_test( lrshift_ext, FALSE ); + check_send_input_keyboard_test( rshift_scan, FALSE ); + check_send_input_keyboard_test( unicode, FALSE ); + check_send_input_keyboard_test( lmenu_unicode, FALSE ); + check_send_input_keyboard_test( unicode_vkey, FALSE ); winetest_pop_context();
ok_ret( 1, DestroyWindow( hwnd ) );
From: Rémi Bernon rbernon@codeweavers.com
And run them in the dedicated desktop. --- dlls/user32/tests/input.c | 695 ++++++++++++++++++++++---------------- 1 file changed, 409 insertions(+), 286 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 9d5b0e36c64..ea11c709a50 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -109,6 +109,7 @@ enum user_function { MSG_TEST_WIN = 1, LL_HOOK_KEYBD, + LL_HOOK_MOUSE, };
struct user_call @@ -132,6 +133,15 @@ struct user_call UINT flags; UINT_PTR extra; } ll_hook_kbd; + struct + { + UINT msg; + POINT point; + UINT data; + UINT flags; + UINT time; + UINT_PTR extra; + } ll_hook_ms; };
BOOL todo; @@ -154,6 +164,11 @@ static const char *debugstr_wm( UINT msg ) case WM_SYSCOMMAND: return "WM_SYSCOMMAND"; case WM_SYSKEYDOWN: return "WM_SYSKEYDOWN"; case WM_SYSKEYUP: return "WM_SYSKEYUP"; + case WM_MOUSEMOVE: return "WM_MOUSEMOVE"; + case WM_LBUTTONDOWN: return "WM_LBUTTONDOWN"; + case WM_LBUTTONUP: return "WM_LBUTTONUP"; + case WM_LBUTTONDBLCLK: return "WM_LBUTTONDBLCLK"; + case WM_NCHITTEST: return "WM_NCHITTEST"; } return wine_dbg_sprintf( "%#x", msg ); } @@ -200,6 +215,15 @@ static int ok_call_( const char *file, int line, const struct user_call *expecte if ((ret = (expected->ll_hook_kbd.flags - received->ll_hook_kbd.flags))) goto done; if ((ret = (expected->ll_hook_kbd.extra - received->ll_hook_kbd.extra))) goto done; break; + case LL_HOOK_MOUSE: + if ((ret = expected->ll_hook_ms.msg - received->ll_hook_ms.msg)) goto done; + if ((ret = expected->ll_hook_ms.point.x - received->ll_hook_ms.point.x)) goto done; + if ((ret = expected->ll_hook_ms.point.y - received->ll_hook_ms.point.y)) goto done; + if ((ret = (expected->ll_hook_ms.data - received->ll_hook_ms.data))) goto done; + if ((ret = (expected->ll_hook_ms.flags - received->ll_hook_ms.flags))) goto done; + if (0 && (ret = expected->ll_hook_ms.time - received->ll_hook_ms.time)) goto done; + if ((ret = (expected->ll_hook_ms.extra - received->ll_hook_ms.extra))) goto done; + break; }
done: @@ -218,6 +242,12 @@ done: received->ll_hook_kbd.scan, debugstr_vk(received->ll_hook_kbd.vkey), received->ll_hook_kbd.flags, received->ll_hook_kbd.extra ); return ret; + case LL_HOOK_MOUSE: + todo_wine_if( expected->todo || expected->todo_value ) + ok_(file, line)( !ret, "got LL_HOOK_MOUSE msg %s, point %s, data %#x, flags %#x, time %u, extra %#Ix\n", debugstr_wm(received->ll_hook_ms.msg), + wine_dbgstr_point(&received->ll_hook_ms.point), received->ll_hook_ms.data, received->ll_hook_ms.flags, received->ll_hook_ms.time, + received->ll_hook_ms.extra ); + return ret; }
switch (expected->func) @@ -233,6 +263,12 @@ done: expected->ll_hook_kbd.scan, debugstr_vk(expected->ll_hook_kbd.vkey), expected->ll_hook_kbd.flags, expected->ll_hook_kbd.extra ); break; + case LL_HOOK_MOUSE: + todo_wine_if( expected->todo || expected->todo_value ) + ok_(file, line)( !ret, "LL_HOOK_MOUSE msg %s, point %s, data %#x, flags %#x, time %u, extra %#Ix\n", debugstr_wm(received->ll_hook_ms.msg), + wine_dbgstr_point(&received->ll_hook_ms.point), received->ll_hook_ms.data, received->ll_hook_ms.flags, received->ll_hook_ms.time, + received->ll_hook_ms.extra ); + return ret; }
return 0; @@ -281,6 +317,21 @@ static void append_ll_hook_kbd( UINT msg, const KBDLLHOOKSTRUCT *info ) current_sequence[index] = call; }
+static void append_ll_hook_ms( UINT msg, const MSLLHOOKSTRUCT *info ) +{ + struct user_call call = + { + .func = LL_HOOK_MOUSE, .ll_hook_ms = + { + .msg = msg, .point = info->pt, .data = info->mouseData, .flags = info->flags, + .time = info->time, .extra = info->dwExtraInfo + } + }; + ULONG index = InterlockedIncrement( ¤t_sequence_len ) - 1; + ok( index < ARRAY_SIZE(current_sequence), "got %lu calls\n", index ); + current_sequence[index] = call; +} + static BOOL append_message_hwnd; static BOOL (*p_accept_message)( UINT msg ); static void append_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) @@ -3535,24 +3586,6 @@ static void simulate_click(BOOL left, int x, int y) ok(events_no == 2, "SendInput returned %d\n", events_no); }
-static BOOL wait_for_message( MSG *msg ) -{ - BOOL ret; - - for (;;) - { - ret = PeekMessageA(msg, 0, 0, 0, PM_REMOVE); - if (ret) - { - if (msg->message == WM_PAINT) DispatchMessageA(msg); - else break; - } - else if (MsgWaitForMultipleObjects(0, NULL, FALSE, 100, QS_ALLINPUT) == WAIT_TIMEOUT) break; - } - if (!ret) msg->message = 0; - return ret; -} - static BOOL wait_for_event(HANDLE event, int timeout) { DWORD end_time = GetTickCount() + timeout; @@ -3569,49 +3602,42 @@ static BOOL wait_for_event(HANDLE event, int timeout) return FALSE; }
-static WNDPROC def_static_proc; -static DWORD hittest_no; -static LRESULT WINAPI static_hook_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +static LRESULT CALLBACK httransparent_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - if (msg == WM_NCHITTEST) - { - /* break infinite hittest loop */ - if(hittest_no > 50) return HTCLIENT; - hittest_no++; - } - - return def_static_proc(hwnd, msg, wp, lp); + append_message( hwnd, msg, wparam, lparam ); + if (msg == WM_NCHITTEST) return HTTRANSPARENT; + return DefWindowProcW( hwnd, msg, wparam, lparam ); }
-struct thread_data +struct create_transparent_window_params { HANDLE start_event; HANDLE end_event; - HWND win; + HWND hwnd; };
-static DWORD WINAPI create_static_win(void *arg) +static DWORD WINAPI create_transparent_window_thread(void *arg) { - struct thread_data *thread_data = arg; - HWND win; - MSG msg; + struct create_transparent_window_params *params = arg; + ULONG_PTR old_proc; + + params->hwnd = CreateWindowW( L"static", NULL, WS_VISIBLE | WS_POPUP, 0, 0, 100, 100, NULL, NULL, NULL, NULL ); + ok_ne( NULL, params->hwnd, HWND, "%p" ); + wait_messages( 100, FALSE ); + old_proc = SetWindowLongPtrW( params->hwnd, GWLP_WNDPROC, (LONG_PTR)httransparent_wndproc ); + ok_ne( 0, old_proc, LONG_PTR, "%#Ix" );
- win = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP, - 100, 100, 100, 100, 0, NULL, NULL, NULL); - ok(win != 0, "CreateWindow failed\n"); - def_static_proc = (void*)SetWindowLongPtrA(win, - GWLP_WNDPROC, (LONG_PTR)static_hook_proc); - thread_data->win = win; + ok_ret( 1, SetEvent( params->start_event ) ); + wait_for_event( params->end_event, 5000 );
- while (wait_for_message(&msg)) DispatchMessageA(&msg); - SetEvent(thread_data->start_event); - wait_for_event(thread_data->end_event, 5000); + ok_ret( 1, DestroyWindow( params->hwnd ) ); + wait_messages( 100, FALSE ); return 0; }
static LRESULT CALLBACK mouse_move_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - static DWORD last_x = 200, expect_x = 210; + static DWORD last_x = 50, expect_x = 60;
if (msg == WM_MOUSEMOVE) { @@ -3621,281 +3647,378 @@ static LRESULT CALLBACK mouse_move_wndproc(HWND hwnd, UINT msg, WPARAM wparam, L flaky if (pt.x != last_x) ok( pt.x == expect_x, "got unexpected WM_MOUSEMOVE x %ld, expected %ld\n", pt.x, expect_x );
- expect_x = pt.x == 200 ? 210 : 200; + expect_x = pt.x == 50 ? 60 : 50; last_x = pt.x; }
return DefWindowProcW(hwnd, msg, wparam, lparam); }
-static void test_Input_mouse(void) +struct send_input_mouse_test { - BOOL got_button_down, got_button_up; - HWND hwnd, button_win, static_win; - struct thread_data thread_data; - HANDLE thread; - DWORD thread_id; - POINT pt, pt_org; - MSG msg; - BOOL ret; + BOOL set_cursor_pos; + POINT cursor_pos; + UINT data; + UINT flags; + ULONG_PTR extra; + struct user_call expect[8]; + BYTE expect_state[256]; + BOOL todo_state[256]; +};
- SetLastError(0xdeadbeef); - ret = GetCursorPos(NULL); - ok(!ret, "GetCursorPos succeed\n"); - ok(GetLastError() == 0xdeadbeef || GetLastError() == ERROR_NOACCESS, "error %lu\n", GetLastError()); +static LRESULT CALLBACK ll_hook_ms_proc( int code, WPARAM wparam, LPARAM lparam ) +{ + MSLLHOOKSTRUCT *hook_info = (MSLLHOOKSTRUCT *)lparam; + if (code == HC_ACTION) append_ll_hook_ms( wparam, hook_info ); + return CallNextHookEx( 0, code, wparam, lparam ); +}
- SetLastError(0xdeadbeef); - ret = GetCursorPos(&pt_org); - ok(ret, "GetCursorPos failed\n"); - ok(GetLastError() == 0xdeadbeef, "error %lu\n", GetLastError()); - - button_win = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP, - 100, 100, 100, 100, 0, NULL, NULL, NULL); - ok(button_win != 0, "CreateWindow failed\n"); - - pt.x = pt.y = 50; - ClientToScreen(button_win, &pt); - hwnd = WindowFromPoint(pt); - if (hwnd != button_win) - { - skip("there's another window covering test window\n"); - DestroyWindow(button_win); - return; - } +static BOOL accept_mouse_messages_nomove( UINT msg ) +{ + return is_mouse_message( msg ) && msg != WM_MOUSEMOVE; +}
- /* simple button click test */ - simulate_click(TRUE, pt.x, pt.y); - got_button_down = got_button_up = FALSE; - while (wait_for_message(&msg)) +static void test_SendInput_mouse_messages(void) +{ +#define WIN_MSG(m, h, w, l, ...) {.func = MSG_TEST_WIN, .message = {.msg = m, .hwnd = h, .wparam = w, .lparam = l}, ## __VA_ARGS__} +#define MS_HOOK(m, x, y, ...) {.func = LL_HOOK_MOUSE, .ll_hook_ms = {.msg = m, .point = {x, y}, .flags = 1}, ## __VA_ARGS__} + struct user_call button_down_hwnd[] = { - DispatchMessageA(&msg); + MS_HOOK(WM_LBUTTONDOWN, 50, 50), + WIN_MSG(WM_LBUTTONDOWN, (HWND)-1/*hwnd*/, 0x1, MAKELONG(50, 50)), + {0}, + }; + struct user_call button_down_hwnd_todo[] = + { + MS_HOOK(WM_LBUTTONDOWN, 50, 50), + WIN_MSG(WM_LBUTTONDOWN, (HWND)-1/*hwnd*/, 0x1, MAKELONG(50, 50), .todo = TRUE), + {0}, + }; + struct user_call button_down_hwnd_todo_attached[] = + { + MS_HOOK(WM_LBUTTONDOWN, 50, 50), + WIN_MSG(WM_LBUTTONDOWN, (HWND)-1/*hwnd*/, 0x1, MAKELONG(50, 50), .todo = TRUE), + {.todo = TRUE /* spurious message on Wine */}, + {0}, + }; + struct user_call button_up_hwnd[] = + { + MS_HOOK(WM_LBUTTONUP, 50, 50), + WIN_MSG(WM_LBUTTONUP, (HWND)-1/*hwnd*/, 0, MAKELONG(50, 50)), + {0}, + }; + struct user_call button_up_hwnd_todo[] = + { + MS_HOOK(WM_LBUTTONUP, 50, 50), + WIN_MSG(WM_LBUTTONUP, (HWND)-1/*hwnd*/, 0, MAKELONG(50, 50), .todo = TRUE), + {0}, + }; + struct user_call button_down_no_message[] = + { + MS_HOOK(WM_LBUTTONDOWN, 50, 50), + {.todo = TRUE /* spurious message on Wine */}, + {0}, + }; + struct user_call button_up_no_message[] = + { + MS_HOOK(WM_LBUTTONUP, 50, 50), + {.todo = TRUE /* spurious message on Wine */}, + {0}, + }; +#undef WIN_MSG +#undef MS_HOOK + static const POINT expect_60x50 = {60, 50}, expect_50x50 = {50, 50};
- if (msg.message == WM_LBUTTONDOWN) - { - got_button_down = TRUE; - } - else if (msg.message == WM_LBUTTONUP) - { - got_button_up = TRUE; - break; - } - } - ok(got_button_down, "expected WM_LBUTTONDOWN message\n"); - ok(got_button_up, "expected WM_LBUTTONUP message\n"); + struct create_transparent_window_params params = {0}; + ULONG_PTR old_proc, old_other_proc; + UINT dblclk_time; + HWND hwnd, other; + DWORD thread_id; + HANDLE thread; + HHOOK hook; + POINT pt;
- /* click through HTTRANSPARENT child window */ - static_win = CreateWindowA("static", "static", WS_VISIBLE | WS_CHILD, - 0, 0, 100, 100, button_win, NULL, NULL, NULL); - ok(static_win != 0, "CreateWindow failed\n"); - def_static_proc = (void*)SetWindowLongPtrA(static_win, - GWLP_WNDPROC, (LONG_PTR)static_hook_proc); - simulate_click(FALSE, pt.x, pt.y); - hittest_no = 0; - got_button_down = got_button_up = FALSE; - while (wait_for_message(&msg)) - { - DispatchMessageA(&msg); + params.start_event = CreateEventA( NULL, FALSE, FALSE, NULL ); + ok( !!params.start_event, "CreateEvent failed\n" ); + params.end_event = CreateEventA( NULL, FALSE, FALSE, NULL ); + ok( !!params.end_event, "CreateEvent failed\n" ); + + + dblclk_time = GetDoubleClickTime(); + ok_eq( 500, dblclk_time, UINT, "%u" ); + + ok_ret( 1, SetCursorPos( 50, 50 ) ); + ok_ret( 1, SetDoubleClickTime( 1 ) ); + + hwnd = CreateWindowW( L"static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, NULL, NULL ); + ok_ne( NULL, hwnd, HWND, "%p" ); + wait_messages( 100, FALSE ); + trace( "hwnd %p\n", hwnd ); + + hook = SetWindowsHookExW( WH_MOUSE_LL, ll_hook_ms_proc, GetModuleHandleW( NULL ), 0 ); + ok_ne( NULL, hook, HHOOK, "%p" ); + + append_message_hwnd = TRUE; + p_accept_message = accept_mouse_messages_nomove; + ok_seq( empty_sequence ); + + + /* basic button messages */ + + old_proc = SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)append_message_wndproc ); + ok_ne( 0, old_proc, LONG_PTR, "%#Ix" ); + + ok_ret( 1, SetCursorPos( 50, 50 ) ); + wait_messages( 100, FALSE ); + ok_seq( empty_sequence ); + + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_down_hwnd[1].message.hwnd = hwnd; + ok_seq( button_down_hwnd ); + + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_up_hwnd[1].message.hwnd = hwnd; + ok_seq( button_up_hwnd ); + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_up_hwnd[1].message.hwnd = hwnd; + ok_seq( button_up_hwnd ); + + + /* click through top-level window */ + + other = CreateWindowW( L"static", NULL, WS_VISIBLE | WS_POPUP, 0, 0, 100, 100, NULL, NULL, NULL, NULL ); + ok_ne( NULL, hwnd, HWND, "%p" ); + wait_messages( 100, FALSE ); + current_sequence_len = 0; + + old_other_proc = SetWindowLongPtrW( other, GWLP_WNDPROC, (LONG_PTR)append_message_wndproc ); + ok_ne( 0, old_other_proc, LONG_PTR, "%#Ix" ); + + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_down_hwnd[1].message.hwnd = other; + ok_seq( button_down_hwnd ); + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_up_hwnd[1].message.hwnd = other; + ok_seq( button_up_hwnd ); + + ok_ret( 1, DestroyWindow( other ) ); + wait_messages( 0, FALSE ); + + + /* click through child window */ + + other = CreateWindowW( L"static", NULL, WS_VISIBLE | WS_CHILD, 0, 0, 100, 100, hwnd, NULL, NULL, NULL ); + ok_ne( NULL, hwnd, HWND, "%p" ); + wait_messages( 100, FALSE ); + current_sequence_len = 0; + + old_other_proc = SetWindowLongPtrW( other, GWLP_WNDPROC, (LONG_PTR)append_message_wndproc ); + ok_ne( 0, old_other_proc, LONG_PTR, "%#Ix" ); + + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_down_hwnd[1].message.hwnd = other; + ok_seq( button_down_hwnd ); + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_up_hwnd[1].message.hwnd = other; + ok_seq( button_up_hwnd ); + + ok_ret( 1, DestroyWindow( other ) ); + wait_messages( 0, FALSE );
- if (msg.message == WM_RBUTTONDOWN) - { - ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); - got_button_down = TRUE; - } - else if (msg.message == WM_RBUTTONUP) - { - ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); - got_button_up = TRUE; - break; - } - } - ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n"); - ok(got_button_down, "expected WM_RBUTTONDOWN message\n"); - ok(got_button_up, "expected WM_RBUTTONUP message\n"); - DestroyWindow(static_win);
/* click through HTTRANSPARENT top-level window */ - static_win = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP, - 100, 100, 100, 100, 0, NULL, NULL, NULL); - ok(static_win != 0, "CreateWindow failed\n"); - def_static_proc = (void*)SetWindowLongPtrA(static_win, - GWLP_WNDPROC, (LONG_PTR)static_hook_proc); - pt.x = pt.y = 50; - ClientToScreen(static_win, &pt); - simulate_click(TRUE, pt.x, pt.y); - hittest_no = 0; - got_button_down = got_button_up = FALSE; - while (wait_for_message(&msg)) - { - DispatchMessageA(&msg);
- if (msg.message == WM_LBUTTONDOWN) - { - ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); - got_button_down = TRUE; - } - else if (msg.message == WM_LBUTTONUP) - { - ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); - got_button_up = TRUE; - break; - } - } - ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n"); - todo_wine ok(got_button_down, "expected WM_LBUTTONDOWN message\n"); - todo_wine ok(got_button_up, "expected WM_LBUTTONUP message\n"); - DestroyWindow(static_win); + other = CreateWindowW( L"static", NULL, WS_VISIBLE | WS_POPUP, 0, 0, 100, 100, NULL, NULL, NULL, NULL ); + ok_ne( NULL, hwnd, HWND, "%p" ); + wait_messages( 100, FALSE ); + current_sequence_len = 0; + + old_other_proc = SetWindowLongPtrW( other, GWLP_WNDPROC, (LONG_PTR)httransparent_wndproc ); + ok_ne( 0, old_other_proc, LONG_PTR, "%#Ix" ); + + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_down_hwnd_todo[1].message.hwnd = hwnd; + ok_seq( button_down_hwnd_todo ); + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_up_hwnd_todo[1].message.hwnd = hwnd; + ok_seq( button_up_hwnd_todo ); + + ok_ret( 1, DestroyWindow( other ) ); + wait_messages( 0, FALSE ); + + + /* click through HTTRANSPARENT child window */ + + other = CreateWindowW( L"static", NULL, WS_VISIBLE | WS_CHILD, 0, 0, 100, 100, hwnd, NULL, NULL, NULL ); + ok_ne( NULL, hwnd, HWND, "%p" ); + wait_messages( 100, FALSE ); + current_sequence_len = 0; + + old_other_proc = SetWindowLongPtrW( other, GWLP_WNDPROC, (LONG_PTR)httransparent_wndproc ); + ok_ne( 0, old_other_proc, LONG_PTR, "%#Ix" ); + + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_down_hwnd[1].message.hwnd = hwnd; + ok_seq( button_down_hwnd ); + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_up_hwnd[1].message.hwnd = hwnd; + ok_seq( button_up_hwnd ); + + ok_ret( 1, DestroyWindow( other ) ); + wait_messages( 0, FALSE ); +
/* click on HTTRANSPARENT top-level window that belongs to other thread */ - thread_data.start_event = CreateEventA(NULL, FALSE, FALSE, NULL); - ok(thread_data.start_event != NULL, "CreateEvent failed\n"); - thread_data.end_event = CreateEventA(NULL, FALSE, FALSE, NULL); - ok(thread_data.end_event != NULL, "CreateEvent failed\n"); - thread = CreateThread(NULL, 0, create_static_win, &thread_data, 0, NULL); - ok(thread != NULL, "CreateThread failed\n"); - hittest_no = 0; - got_button_down = got_button_up = FALSE; - WaitForSingleObject(thread_data.start_event, INFINITE); - pt.x = pt.y = 50; - ClientToScreen(thread_data.win, &pt); - simulate_click(FALSE, pt.x, pt.y); - while (wait_for_message(&msg)) - { - DispatchMessageA(&msg);
- if (msg.message == WM_RBUTTONDOWN) - got_button_down = TRUE; - else if (msg.message == WM_RBUTTONUP) - got_button_up = TRUE; - } - SetEvent(thread_data.end_event); - WaitForSingleObject(thread, INFINITE); - CloseHandle(thread); - flaky_wine - ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n"); - ok(!got_button_down, "unexpected WM_RBUTTONDOWN message\n"); - ok(!got_button_up, "unexpected WM_RBUTTONUP message\n"); + thread = CreateThread( NULL, 0, create_transparent_window_thread, ¶ms, 0, NULL ); + ok_ne( NULL, thread, HANDLE, "%p" ); + + ok_ret( 0, WaitForSingleObject( params.start_event, 5000 ) ); + ok_ret( 0, SendMessageW( params.hwnd, WM_USER, 0, 0 ) ); + + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + ok_seq( button_down_no_message ); + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + ok_seq( button_up_no_message ); + + ok_ret( 1, SetEvent( params.end_event ) ); + ok_ret( 0, WaitForSingleObject( thread, 5000 ) ); + ok_ret( 1, CloseHandle( thread ) ); + ResetEvent( params.start_event ); + ResetEvent( params.end_event ); +
/* click on HTTRANSPARENT top-level window that belongs to other thread, * thread input queues are attached */ - thread = CreateThread(NULL, 0, create_static_win, &thread_data, 0, &thread_id); - ok(thread != NULL, "CreateThread failed\n"); - hittest_no = 0; - got_button_down = got_button_up = FALSE; - WaitForSingleObject(thread_data.start_event, INFINITE); - ok(AttachThreadInput(thread_id, GetCurrentThreadId(), TRUE), - "AttachThreadInput failed\n"); - while (wait_for_message(&msg)) DispatchMessageA(&msg); - SetWindowPos(thread_data.win, button_win, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE); - pt.x = pt.y = 50; - ClientToScreen(thread_data.win, &pt); - simulate_click(TRUE, pt.x, pt.y); - while (wait_for_message(&msg)) - { - DispatchMessageA(&msg);
- if (msg.message == WM_LBUTTONDOWN) - got_button_down = TRUE; - else if (msg.message == WM_LBUTTONUP) - got_button_up = TRUE; - } - SetEvent(thread_data.end_event); - WaitForSingleObject(thread, INFINITE); - todo_wine ok(hittest_no > 50, "expected loop with WM_NCHITTEST messages\n"); - ok(!got_button_down, "unexpected WM_LBUTTONDOWN message\n"); - ok(!got_button_up, "unexpected WM_LBUTTONUP message\n"); + thread = CreateThread( NULL, 0, create_transparent_window_thread, ¶ms, 0, &thread_id ); + ok_ne( NULL, thread, HANDLE, "%p" );
- /* click after SetCapture call */ - hwnd = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP, - 0, 0, 100, 100, 0, NULL, NULL, NULL); - ok(hwnd != 0, "CreateWindow failed\n"); - SetCapture(button_win); - got_button_down = got_button_up = FALSE; - pt.x = pt.y = 50; - ClientToScreen(hwnd, &pt); - simulate_click(FALSE, pt.x, pt.y); - while (wait_for_message(&msg)) - { - DispatchMessageA(&msg); + ok_ret( 0, WaitForSingleObject( params.start_event, 5000 ) ); + todo_wine ok_ret( 1, AttachThreadInput( thread_id, GetCurrentThreadId(), TRUE ) ); + ok_ret( 0, SendMessageW( params.hwnd, WM_USER, 0, 0 ) );
- if (msg.message == WM_RBUTTONDOWN) - { - ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); - got_button_down = TRUE; - } - else if (msg.message == WM_RBUTTONUP) - { - ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); - got_button_up = TRUE; - break; - } - } - ok(got_button_down, "expected WM_RBUTTONDOWN message\n"); - ok(got_button_up, "expected WM_RBUTTONUP message\n"); - DestroyWindow(hwnd); + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_down_hwnd_todo_attached[1].message.hwnd = hwnd; + ok_seq( button_down_hwnd_todo_attached ); + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_up_hwnd[1].message.hwnd = hwnd; + ok_seq( button_up_hwnd );
- /* click on child window after SetCapture call */ - hwnd = CreateWindowA("button", "button2", WS_VISIBLE | WS_CHILD, - 0, 0, 100, 100, button_win, NULL, NULL, NULL); - ok(hwnd != 0, "CreateWindow failed\n"); - got_button_down = got_button_up = FALSE; - pt.x = pt.y = 50; - ClientToScreen(hwnd, &pt); - simulate_click(TRUE, pt.x, pt.y); - while (wait_for_message(&msg)) - { - DispatchMessageA(&msg); + todo_wine ok_ret( 1, AttachThreadInput( thread_id, GetCurrentThreadId(), FALSE ) ); + ok_ret( 1, SetEvent( params.end_event ) ); + ok_ret( 0, WaitForSingleObject( thread, 5000 ) ); + ok_ret( 1, CloseHandle( thread ) ); + ResetEvent( params.start_event ); + ResetEvent( params.end_event );
- if (msg.message == WM_LBUTTONDOWN) - { - ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); - got_button_down = TRUE; - } - else if (msg.message == WM_LBUTTONUP) - { - ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd); - got_button_up = TRUE; - break; - } - } - ok(got_button_down, "expected WM_LBUTTONDOWN message\n"); - ok(got_button_up, "expected WM_LBUTTONUP message\n"); - DestroyWindow(hwnd); - ok(ReleaseCapture(), "ReleaseCapture failed\n"); - SetCursorPos(pt_org.x, pt_org.y);
- CloseHandle(thread_data.start_event); - CloseHandle(thread_data.end_event); - DestroyWindow(button_win); + /* click on top-level window with SetCapture called for the underlying window */ + + other = CreateWindowW( L"static", NULL, WS_VISIBLE | WS_POPUP, 0, 0, 100, 100, NULL, NULL, NULL, NULL ); + ok_ne( NULL, hwnd, HWND, "%p" ); + wait_messages( 100, FALSE ); + current_sequence_len = 0; + + old_other_proc = SetWindowLongPtrW( other, GWLP_WNDPROC, (LONG_PTR)append_message_wndproc ); + ok_ne( 0, old_other_proc, LONG_PTR, "%#Ix" ); + + SetCapture( hwnd ); + + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_down_hwnd[1].message.hwnd = hwnd; + ok_seq( button_down_hwnd ); + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_up_hwnd[1].message.hwnd = hwnd; + ok_seq( button_up_hwnd ); + + ok_ret( 1, DestroyWindow( other ) ); + wait_messages( 0, FALSE ); + + SetCapture( 0 ); + + + /* click through child window with SetCapture called for the underlying window */ + + other = CreateWindowW( L"static", NULL, WS_VISIBLE | WS_CHILD, 0, 0, 100, 100, hwnd, NULL, NULL, NULL ); + ok_ne( NULL, hwnd, HWND, "%p" ); + wait_messages( 100, FALSE ); + current_sequence_len = 0; + + old_other_proc = SetWindowLongPtrW( other, GWLP_WNDPROC, (LONG_PTR)append_message_wndproc ); + ok_ne( 0, old_other_proc, LONG_PTR, "%#Ix" ); + + SetCapture( hwnd ); + + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_down_hwnd[1].message.hwnd = hwnd; + ok_seq( button_down_hwnd ); + mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); + wait_messages( 5, FALSE ); + button_up_hwnd[1].message.hwnd = hwnd; + ok_seq( button_up_hwnd ); + + ok_ret( 1, DestroyWindow( other ) ); + wait_messages( 0, FALSE ); + + SetCapture( 0 );
- SetCursorPos(200, 200); - hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 200, 200, NULL, NULL, NULL, NULL); - ok(hwnd != NULL, "CreateWindowA failed %lu\n", GetLastError());
/* warm up test case by moving cursor and window a bit first */ - SetCursorPos(210, 200); - SetWindowPos(hwnd, NULL, 110, 100, 0, 0, SWP_NOSIZE); - empty_message_queue(); - SetCursorPos(200, 200); - SetWindowPos(hwnd, NULL, 100, 100, 0, 0, SWP_NOSIZE); - empty_message_queue(); - SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)mouse_move_wndproc); + ok_ret( 1, SetCursorPos( 60, 50 ) ); + ok_ret( 1, SetWindowPos( hwnd, NULL, 10, 0, 0, 0, SWP_NOSIZE ) ); + wait_messages( 5, FALSE ); + ok_ret( 1, SetCursorPos( 50, 50 ) ); + ok_ret( 1, SetWindowPos( hwnd, NULL, 0, 0, 0, 0, SWP_NOSIZE ) ); + wait_messages( 5, FALSE ); + SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)mouse_move_wndproc ); + + ok_ret( 1, SetCursorPos( 60, 50 ) ); + ok_ret( 1, SetWindowPos( hwnd, NULL, 10, 0, 0, 0, SWP_NOSIZE ) ); + wait_messages( 5, FALSE ); + ok_ret( 1, GetCursorPos( &pt ) ); + ok_point( expect_60x50, pt ); + + ok_ret( 1, SetCursorPos( 50, 50 ) ); + ok_ret( 1, SetWindowPos( hwnd, NULL, 0, 0, 0, 0, SWP_NOSIZE ) ); + wait_messages( 5, FALSE ); + ok_ret( 1, GetCursorPos( &pt ) ); + ok_point( expect_50x50, pt );
- SetCursorPos(210, 200); - SetWindowPos(hwnd, NULL, 110, 100, 0, 0, SWP_NOSIZE); - empty_message_queue(); - GetCursorPos(&pt); - ok(pt.x == 210 && pt.y == 200, "GetCursorPos returned %ldx%ld, expected 210x200\n", pt.x, pt.y);
- SetCursorPos(200, 200); - SetWindowPos(hwnd, NULL, 100, 100, 0, 0, SWP_NOSIZE); - empty_message_queue(); - GetCursorPos(&pt); - ok(pt.x == 200 && pt.y == 200, "GetCursorPos returned %ldx%ld, expected 200x200\n", pt.x, pt.y); + ok_ret( 1, UnhookWindowsHookEx( hook ) );
- SetCursorPos(pt_org.x, pt_org.y); - empty_message_queue(); - DestroyWindow(hwnd); + wait_messages( 100, FALSE ); + todo_wine ok_seq( empty_sequence ); + p_accept_message = NULL; + append_message_hwnd = FALSE; + + + ok_ret( 1, DestroyWindow( hwnd ) ); + + CloseHandle( params.start_event ); + CloseHandle( params.end_event ); + + + ok_ret( 1, SetDoubleClickTime( dblclk_time ) ); }
@@ -5234,6 +5357,7 @@ static void test_input_desktop( char **argv ) get_test_scan( 'F', &scan, &wch, &wch_shift ); test_SendInput( 'F', wch ); test_SendInput_keyboard_messages( 'F', scan, wch, wch_shift, '\x06' ); + test_SendInput_mouse_messages();
test_keyboard_ll_hook_blocking();
@@ -5291,7 +5415,6 @@ START_TEST(input) return test_input_desktop( argv );
run_in_desktop( argv, "test_input_desktop", 1 ); - test_Input_mouse(); test_keynames(); test_mouse_ll_hook(); test_key_map();
From: Rémi Bernon rbernon@codeweavers.com
And run SetCursorPos / ClipCursor tests in a separate function, they don't need hooks or windows. --- dlls/user32/tests/input.c | 425 ++++++++++++++++++++------------------ 1 file changed, 223 insertions(+), 202 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index ea11c709a50..b7dc5aac3b1 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1227,205 +1227,6 @@ static void test_keynames(void) } }
-static POINT pt_old, pt_new; -static BOOL clipped; -#define STEP 3 - -static LRESULT CALLBACK hook_proc1( int code, WPARAM wparam, LPARAM lparam ) -{ - MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam; - POINT pt, pt1; - - if (code == HC_ACTION) - { - /* This is our new cursor position */ - pt_new = hook->pt; - /* Should return previous position */ - GetCursorPos(&pt); - ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%ld,%ld)\n", pt.x, pt.y); - - /* Should set new position until hook chain is finished. */ - pt.x = pt_old.x + STEP; - pt.y = pt_old.y + STEP; - SetCursorPos(pt.x, pt.y); - GetCursorPos(&pt1); - if (clipped) - ok(pt1.x == pt_old.x && pt1.y == pt_old.y, "Wrong set pos: (%ld,%ld)\n", pt1.x, pt1.y); - else - ok(pt1.x == pt.x && pt1.y == pt.y, "Wrong set pos: (%ld,%ld)\n", pt1.x, pt1.y); - } - return CallNextHookEx( 0, code, wparam, lparam ); -} - -static LRESULT CALLBACK hook_proc2( int code, WPARAM wparam, LPARAM lparam ) -{ - MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam; - POINT pt; - - if (code == HC_ACTION) - { - ok(hook->pt.x == pt_new.x && hook->pt.y == pt_new.y, - "Wrong hook coords: (%ld %ld) != (%ld,%ld)\n", hook->pt.x, hook->pt.y, pt_new.x, pt_new.y); - - /* Should match position set above */ - GetCursorPos(&pt); - if (clipped) - ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%ld,%ld)\n", pt.x, pt.y); - else - ok(pt.x == pt_old.x +STEP && pt.y == pt_old.y +STEP, "GetCursorPos: (%ld,%ld)\n", pt.x, pt.y); - } - return CallNextHookEx( 0, code, wparam, lparam ); -} - -static LRESULT CALLBACK hook_proc3( int code, WPARAM wparam, LPARAM lparam ) -{ - POINT pt; - - if (code == HC_ACTION) - { - /* MSLLHOOKSTRUCT does not seem to be reliable and contains different data on each run. */ - GetCursorPos(&pt); - ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%ld,%ld)\n", pt.x, pt.y); - } - return CallNextHookEx( 0, code, wparam, lparam ); -} - -static void test_mouse_ll_hook(void) -{ - HWND hwnd; - HHOOK hook1, hook2; - POINT pt_org, pt; - RECT rc; - - GetCursorPos(&pt_org); - hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 10, 10, 200, 200, NULL, NULL, NULL, NULL); - SetCursorPos(100, 100); - - if (!(hook2 = SetWindowsHookExA(WH_MOUSE_LL, hook_proc2, GetModuleHandleA(0), 0))) - { - win_skip( "cannot set MOUSE_LL hook\n" ); - goto done; - } - hook1 = SetWindowsHookExA(WH_MOUSE_LL, hook_proc1, GetModuleHandleA(0), 0); - - GetCursorPos(&pt_old); - mouse_event(MOUSEEVENTF_MOVE, -STEP, 0, 0, 0); - GetCursorPos(&pt_old); - ok(pt_old.x == pt_new.x && pt_old.y == pt_new.y, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - mouse_event(MOUSEEVENTF_MOVE, +STEP, 0, 0, 0); - GetCursorPos(&pt_old); - ok(pt_old.x == pt_new.x && pt_old.y == pt_new.y, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - mouse_event(MOUSEEVENTF_MOVE, 0, -STEP, 0, 0); - GetCursorPos(&pt_old); - ok(pt_old.x == pt_new.x && pt_old.y == pt_new.y, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - mouse_event(MOUSEEVENTF_MOVE, 0, +STEP, 0, 0); - GetCursorPos(&pt_old); - ok(pt_old.x == pt_new.x && pt_old.y == pt_new.y, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - - SetRect(&rc, 50, 50, 151, 151); - ClipCursor(&rc); - clipped = TRUE; - - SetCursorPos(40, 40); - GetCursorPos(&pt_old); - ok(pt_old.x == 50 && pt_old.y == 50, "Wrong new pos: (%ld,%ld)\n", pt_new.x, pt_new.y); - SetCursorPos(160, 160); - GetCursorPos(&pt_old); - ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%ld,%ld)\n", pt_new.x, pt_new.y); - mouse_event(MOUSEEVENTF_MOVE, +STEP, +STEP, 0, 0); - GetCursorPos(&pt_old); - ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%ld,%ld)\n", pt_new.x, pt_new.y); - - clipped = FALSE; - pt_new.x = pt_new.y = 150; - ClipCursor(NULL); - UnhookWindowsHookEx(hook1); - - /* Now check that mouse buttons do not change mouse position - if we don't have MOUSEEVENTF_MOVE flag specified. */ - - /* We reusing the same hook callback, so make it happy */ - pt_old.x = pt_new.x - STEP; - pt_old.y = pt_new.y - STEP; - mouse_event(MOUSEEVENTF_LEFTUP, 123, 456, 0, 0); - GetCursorPos(&pt); - ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%ld,%ld)\n", pt.x, pt.y); - mouse_event(MOUSEEVENTF_RIGHTUP, 456, 123, 0, 0); - GetCursorPos(&pt); - ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%ld,%ld)\n", pt.x, pt.y); - - mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, 123, 456, 0, 0); - GetCursorPos(&pt); - ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%ld,%ld)\n", pt.x, pt.y); - mouse_event(MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, 456, 123, 0, 0); - GetCursorPos(&pt); - ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%ld,%ld)\n", pt.x, pt.y); - - UnhookWindowsHookEx(hook2); - hook1 = SetWindowsHookExA(WH_MOUSE_LL, hook_proc3, GetModuleHandleA(0), 0); - - SetRect(&rc, 150, 150, 150, 150); - ClipCursor(&rc); - clipped = TRUE; - - SetCursorPos(140, 140); - GetCursorPos(&pt_old); - ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - SetCursorPos(160, 160); - GetCursorPos(&pt_old); - todo_wine - ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0); - GetCursorPos(&pt_old); - ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - mouse_event(MOUSEEVENTF_MOVE, +STEP, +STEP, 0, 0); - GetCursorPos(&pt_old); - todo_wine - ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0); - GetCursorPos(&pt_old); - ok((pt_old.x == 150 && pt_old.y == 150) || - broken(pt_old.x == 149 && pt_old.y == 149) /* w1064v1809 */, - "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0); - GetCursorPos(&pt_old); - todo_wine - ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - - clipped = FALSE; - ClipCursor(NULL); - - SetCursorPos(140, 140); - SetRect(&rc, 150, 150, 150, 150); - ClipCursor(&rc); - GetCursorPos(&pt_old); - ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - ClipCursor(NULL); - - SetCursorPos(160, 160); - SetRect(&rc, 150, 150, 150, 150); - ClipCursor(&rc); - GetCursorPos(&pt_old); - todo_wine - ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - ClipCursor(NULL); - - SetCursorPos(150, 150); - SetRect(&rc, 150, 150, 150, 150); - ClipCursor(&rc); - GetCursorPos(&pt_old); - todo_wine - ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%ld,%ld)\n", pt_old.x, pt_old.y); - ClipCursor(NULL); - - UnhookWindowsHookEx(hook1); - -done: - DestroyWindow(hwnd); - SetCursorPos(pt_org.x, pt_org.y); -} - static void test_GetMouseMovePointsEx( char **argv ) { #define BUFLIM 64 @@ -3673,6 +3474,42 @@ static LRESULT CALLBACK ll_hook_ms_proc( int code, WPARAM wparam, LPARAM lparam return CallNextHookEx( 0, code, wparam, lparam ); }
+static LRESULT CALLBACK ll_hook_setpos_proc( int code, WPARAM wparam, LPARAM lparam ) +{ + if (code == HC_ACTION) + { + MSLLHOOKSTRUCT *hook_info = (MSLLHOOKSTRUCT *)lparam; + POINT pos, hook_pos = {40, 40}; + + ok( abs( hook_info->pt.x - 51 ) <= 1, "got x %ld\n", hook_info->pt.x ); + ok( abs( hook_info->pt.y - 49 ) <= 1, "got y %ld\n", hook_info->pt.y ); + + /* spuriously moves by 0 or 1 pixels on Windows */ + ok_ret( 1, GetCursorPos( &pos ) ); + ok( abs( pos.x - 51 ) <= 1, "got x %ld\n", pos.x ); + ok( abs( pos.y - 49 ) <= 1, "got y %ld\n", pos.y ); + + ok_ret( 1, SetCursorPos( 60, 60 ) ); + hook_info->pt = hook_pos; + } + + return CallNextHookEx( 0, code, wparam, lparam ); +} + +static LRESULT CALLBACK ll_hook_getpos_proc( int code, WPARAM wparam, LPARAM lparam ) +{ + if (code == HC_ACTION) + { + MSLLHOOKSTRUCT *hook_info = (MSLLHOOKSTRUCT *)lparam; + POINT pos, expect_pos = {60, 60}, hook_pos = {40, 40}; + ok_point( hook_pos, hook_info->pt ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + } + + return CallNextHookEx( 0, code, wparam, lparam ); +} + static BOOL accept_mouse_messages_nomove( UINT msg ) { return is_mouse_message( msg ) && msg != WM_MOUSEMOVE; @@ -3682,6 +3519,11 @@ static void test_SendInput_mouse_messages(void) { #define WIN_MSG(m, h, w, l, ...) {.func = MSG_TEST_WIN, .message = {.msg = m, .hwnd = h, .wparam = w, .lparam = l}, ## __VA_ARGS__} #define MS_HOOK(m, x, y, ...) {.func = LL_HOOK_MOUSE, .ll_hook_ms = {.msg = m, .point = {x, y}, .flags = 1}, ## __VA_ARGS__} + struct user_call mouse_move[] = + { + MS_HOOK(WM_MOUSEMOVE, 40, 40), + {0}, + }; struct user_call button_down_hwnd[] = { MS_HOOK(WM_LBUTTONDOWN, 50, 50), @@ -3731,11 +3573,12 @@ static void test_SendInput_mouse_messages(void)
struct create_transparent_window_params params = {0}; ULONG_PTR old_proc, old_other_proc; + RECT clip_rect = {55, 55, 55, 55}; UINT dblclk_time; HWND hwnd, other; DWORD thread_id; HANDLE thread; - HHOOK hook; + HHOOK hook, hook_setpos, hook_getpos; POINT pt;
params.start_event = CreateEventA( NULL, FALSE, FALSE, NULL ); @@ -3758,6 +3601,43 @@ static void test_SendInput_mouse_messages(void) hook = SetWindowsHookExW( WH_MOUSE_LL, ll_hook_ms_proc, GetModuleHandleW( NULL ), 0 ); ok_ne( NULL, hook, HHOOK, "%p" );
+ /* test hooks only, WM_MOUSEMOVE messages are very brittle */ + p_accept_message = is_mouse_message; + ok_seq( empty_sequence ); + + /* SetCursorPos or ClipCursor don't call mouse ll hooks */ + ok_ret( 1, SetCursorPos( 60, 60 ) ); + wait_messages( 5, FALSE ); + ok_ret( 1, ClipCursor( &clip_rect ) ); + wait_messages( 5, FALSE ); + ok_ret( 1, ClipCursor( NULL ) ); + wait_messages( 5, FALSE ); + ok_ret( 1, SetCursorPos( 50, 50 ) ); + wait_messages( 100, FALSE ); + todo_wine ok_seq( empty_sequence ); + + hook_getpos = SetWindowsHookExW( WH_MOUSE_LL, ll_hook_getpos_proc, GetModuleHandleW( NULL ), 0 ); + ok_ne( NULL, hook_getpos, HHOOK, "%p" ); + hook_setpos = SetWindowsHookExW( WH_MOUSE_LL, ll_hook_setpos_proc, GetModuleHandleW( NULL ), 0 ); + ok_ne( NULL, hook_setpos, HHOOK, "%p" ); + + mouse_event( MOUSEEVENTF_MOVE, 0, 0, 0, 0 ); + /* recent Windows versions don't call the hooks with no movement */ + if (current_sequence_len) + { + ok_seq( mouse_move ); + ok_ret( 1, SetCursorPos( 50, 50 ) ); + } + ok_seq( empty_sequence ); + + /* WH_MOUSE_LL hook is called even with 1 pixel moves */ + mouse_event( MOUSEEVENTF_MOVE, +1, -1, 0, 0 ); + ok_seq( mouse_move ); + + ok_ret( 1, UnhookWindowsHookEx( hook_getpos ) ); + ok_ret( 1, UnhookWindowsHookEx( hook_setpos ) ); + + append_message_hwnd = TRUE; p_accept_message = accept_mouse_messages_nomove; ok_seq( empty_sequence ); @@ -3770,7 +3650,7 @@ static void test_SendInput_mouse_messages(void)
ok_ret( 1, SetCursorPos( 50, 50 ) ); wait_messages( 100, FALSE ); - ok_seq( empty_sequence ); + todo_wine ok_seq( empty_sequence );
mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); wait_messages( 5, FALSE ); @@ -5305,6 +5185,147 @@ static void test_ClipCursor( char **argv ) if (!EqualRect( &rect, &virtual_rect )) ok_ret( 1, ClipCursor( NULL ) ); }
+static void test_SetCursorPos(void) +{ + RECT clip_rect = {50, 50, 51, 51}; + POINT pos, expect_pos = {50, 50}; + + ok_ret( 0, GetCursorPos( NULL ) ); + todo_wine ok_ret( ERROR_NOACCESS, GetLastError() ); + + /* immediate cursor position updates */ + ok_ret( 1, SetCursorPos( 50, 50 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + + /* without MOUSEEVENTF_MOVE cursor doesn't move */ + mouse_event( MOUSEEVENTF_LEFTUP, 123, 456, 0, 0 ); + mouse_event( MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, 123, 456, 0, 0 ); + mouse_event( MOUSEEVENTF_RIGHTUP, 456, 123, 0, 0 ); + mouse_event( MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, 456, 123, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + + /* need to move by at least 3 pixels to update, but not consistent */ + mouse_event( MOUSEEVENTF_MOVE, -1, 0, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + mouse_event( MOUSEEVENTF_MOVE, +1, 0, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + + /* spuriously moves by 1 or 2 pixels on Windows */ + expect_pos.x -= 2; + mouse_event( MOUSEEVENTF_MOVE, -4, 0, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok( abs( expect_pos.x - pos.x ) <= 1, "got pos %ld\n", pos.x ); + expect_pos.x += 2; + mouse_event( MOUSEEVENTF_MOVE, +4, 0, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok( abs( expect_pos.x - pos.x ) <= 1, "got pos %ld\n", pos.x ); + + /* test ClipCursor holding the cursor in place */ + expect_pos.x = expect_pos.y = 50; + ok_ret( 1, SetCursorPos( 49, 51 ) ); + ok_ret( 1, ClipCursor( &clip_rect ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + ok_ret( 1, SetCursorPos( 49, 49 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + ok_ret( 1, SetCursorPos( 50, 50 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + ok_ret( 1, SetCursorPos( 48, 48 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + ok_ret( 1, SetCursorPos( 51, 51 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + ok_ret( 1, SetCursorPos( 52, 52 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + ok_ret( 1, SetCursorPos( 49, 51 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + ok_ret( 1, SetCursorPos( 51, 49 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + + mouse_event( MOUSEEVENTF_MOVE, -1, 0, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + mouse_event( MOUSEEVENTF_MOVE, 0, +1, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + mouse_event( MOUSEEVENTF_MOVE, +1, 0, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + mouse_event( MOUSEEVENTF_MOVE, 0, -1, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + + /* weird behavior when ClipCursor rect is empty */ + clip_rect.right = clip_rect.bottom = 50; + ok_ret( 1, SetCursorPos( 50, 50 ) ); + expect_pos.x = expect_pos.y = 49; + ok_ret( 1, ClipCursor( &clip_rect ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + expect_pos.x = expect_pos.y = 50; + ok_ret( 1, SetCursorPos( 49, 49 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + expect_pos.x = expect_pos.y = 49; + ok_ret( 1, SetCursorPos( 50, 50 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + expect_pos.x = expect_pos.y = 50; + ok_ret( 1, SetCursorPos( 48, 48 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + expect_pos.x = expect_pos.y = 49; + ok_ret( 1, SetCursorPos( 51, 51 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + ok_ret( 1, SetCursorPos( 52, 52 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + expect_pos.x = 50; + expect_pos.y = 49; + ok_ret( 1, SetCursorPos( 49, 51 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + expect_pos.x = 49; + expect_pos.y = 50; + ok_ret( 1, SetCursorPos( 51, 49 ) ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + + expect_pos.x = 50; + expect_pos.y = 49; + mouse_event( MOUSEEVENTF_MOVE, -10, 0, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + expect_pos.x = 49; + expect_pos.y = 49; + mouse_event( MOUSEEVENTF_MOVE, 0, +10, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + expect_pos.x = 49; + expect_pos.y = 50; + mouse_event( MOUSEEVENTF_MOVE, +10, 0, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + todo_wine ok_point( expect_pos, pos ); + expect_pos.x = 50; + expect_pos.y = 50; + mouse_event( MOUSEEVENTF_MOVE, 0, -10, 0, 0 ); + ok_ret( 1, GetCursorPos( &pos ) ); + ok_point( expect_pos, pos ); + + ok_ret( 1, ClipCursor( NULL ) ); +} + static HANDLE ll_keyboard_event;
static LRESULT CALLBACK ll_keyboard_event_wait(int code, WPARAM wparam, LPARAM lparam) @@ -5353,6 +5374,7 @@ static void test_input_desktop( char **argv )
trace( "hkl %p\n", hkl ); ok_ret( 1, GetCursorPos( &pos ) ); + test_SetCursorPos();
get_test_scan( 'F', &scan, &wch, &wch_shift ); test_SendInput( 'F', wch ); @@ -5416,7 +5438,6 @@ START_TEST(input)
run_in_desktop( argv, "test_input_desktop", 1 ); test_keynames(); - test_mouse_ll_hook(); test_key_map(); test_ToUnicode(); test_ToAscii();
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=142356
Your paranoid android.
=== w10pro64_ja (64 bit report) ===
user32: input.c:3240: Test failed: 04110411 / 04110411: got change_hkl 0000000004110411
=== w10pro64_zh_CN (64 bit report) ===
user32: input.c:3240: Test failed: 08040804 / 08040804: got change_hkl 0000000008040804
=== debian11 (32 bit zh:CN report) ===
user32: input.c:592: Test failed: peek: lmenu_vkey_peeked: 1: test->expect 2: got MSG_TEST_WIN hwnd 00000000, msg WM_SYSCHAR, wparam 0x66, lparam 0x20020001 input.c:592: Test failed: peek: shift_vkey: 1: test->expect 2: got MSG_TEST_WIN hwnd 00000000, msg WM_CHAR, wparam 0x46, lparam 0x20001 input.c:592: Test failed: receive: lmenu_vkey: 1: test->expect 2: got MSG_TEST_WIN hwnd 00000000, msg WM_SYSCHAR, wparam 0x66, lparam 0x20020001 input.c:592: Test failed: receive: lmenu_vkey: 1: test->expect 3: got MSG_TEST_WIN hwnd 00000000, msg WM_SYSCOMMAND, wparam 0xf100, lparam 0x66 input.c:592: Test failed: receive: shift_vkey: 1: test->expect 2: got MSG_TEST_WIN hwnd 00000000, msg WM_CHAR, wparam 0x46, lparam 0x20001
Linux test failures are the current usual ones. Windows test failures are also unrelated, some usual `user32:sysparams` and some spurious `user32:win`.