From ba9231993dc452122bb66f2e0427de681ea405f7 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 17 Jun 2011 11:18:47 -0500 Subject: [PATCH] user32/tests: Test that hotkeys are really replaced when using the same id/hwnd. --- dlls/user32/tests/msg.c | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 3d9452d9a02..1beed35b875 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -13094,6 +13094,29 @@ static const struct message WmHotkeyCombined[] = { { WM_KEYUP, sent|wparam|lparam, VK_LWIN, 0xc0000001 }, { 0 } }; +static const struct message WmHotkeyPrevious[] = { + { WM_KEYDOWN, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED }, + { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED }, + { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP }, + { WM_KEYUP, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED|LLKHF_UP }, + { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 1 }, + { WM_KEYDOWN, sent|wparam|lparam, VK_LWIN, 1 }, + { HCBT_KEYSKIPPED, hook|lparam|optional, 0, 1 }, + { WM_KEYDOWN, sent|lparam, 0, 1 }, + { HCBT_KEYSKIPPED, hook|optional|lparam, 0, 0xc0000001 }, + { WM_KEYUP, sent|lparam, 0, 0xc0000001 }, + { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 0xc0000001 }, + { WM_KEYUP, sent|wparam|lparam, VK_LWIN, 0xc0000001 }, + { 0 } +}; +static const struct message WmHotkeyNew[] = { + { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED }, + { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP }, + { WM_HOTKEY, sent|wparam, 5 }, + { HCBT_KEYSKIPPED, hook|optional, 0, 0x80000001 }, + { WM_KEYUP, sent, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */ + { 0 } +}; static int hotkey_letter; @@ -13261,6 +13284,31 @@ static void test_hotkey(void) ret = RegisterHotKey(test_window, 5, 0, hotkey_letter); ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError()); + /* Previous key combination does not work */ + keybd_event(VK_LWIN, 0, 0, 0); + keybd_event(hotkey_letter, 0, 0, 0); + keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0); + keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0); + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + DispatchMessage(&msg); + ok_sequence(WmHotkeyPrevious, "window hotkey previous", FALSE); + + /* New key combination works */ + keybd_event(hotkey_letter, 0, 0, 0); + keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0); + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + if (msg.message == WM_HOTKEY) + { + ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd); + ok(msg.lParam == MAKELPARAM(0, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam); + } + DispatchMessage(&msg); + } + ok_sequence(WmHotkeyNew, "window hotkey new", FALSE); + /* Unregister hotkey properly */ ret = UnregisterHotKey(test_window, 5); ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());