mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[USER32_APITEST]
- Add a simple test for RegisterHotKey with regular vs modifier-only hotkeys CORE-9728 svn path=/trunk/; revision=68186
This commit is contained in:
parent
1a053ef99c
commit
171f891e93
3 changed files with 230 additions and 0 deletions
|
@ -20,6 +20,7 @@ list(APPEND SOURCE
|
|||
LoadImage.c
|
||||
LookupIconIdFromDirectoryEx.c
|
||||
RealGetWindowClass.c
|
||||
RegisterHotKey.c
|
||||
ScrollDC.c
|
||||
ScrollWindowEx.c
|
||||
SendMessageTimeout.c
|
||||
|
|
227
rostests/apitests/user32/RegisterHotKey.c
Normal file
227
rostests/apitests/user32/RegisterHotKey.c
Normal file
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* PROJECT: ReactOS API tests
|
||||
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
||||
* PURPOSE: Test for RegisterHotKey
|
||||
* PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
|
||||
*/
|
||||
|
||||
#include <apitest.h>
|
||||
|
||||
#include <winuser.h>
|
||||
#include <shlobj.h>
|
||||
#include <undocshell.h>
|
||||
#include <undocuser.h>
|
||||
|
||||
#define msg_hotkey(msg, id, mod, vk) do \
|
||||
{ \
|
||||
ok((msg)->message == WM_HOTKEY, "Unexpected message %u\n", (msg)->message); \
|
||||
ok((msg)->hwnd == NULL, "hwnd = %p\n", (msg)->hwnd); \
|
||||
ok((msg)->wParam == (id), "wParam = 0x%Ix\n", (msg)->wParam); \
|
||||
ok((msg)->lParam == MAKELONG(mod, vk), \
|
||||
"wParam = 0x%Ix, expected 0x%lx\n", (msg)->lParam, MAKELONG(mod, vk)); \
|
||||
} while (0)
|
||||
#define expect_hotkey(id, mod, vk) do \
|
||||
{ \
|
||||
MSG msg; \
|
||||
BOOL got_hotkey = FALSE; \
|
||||
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) \
|
||||
{ \
|
||||
msg_hotkey(&msg, id, mod, vk); \
|
||||
if (msg.message == WM_HOTKEY) got_hotkey = TRUE; \
|
||||
DispatchMessageW(&msg); \
|
||||
} \
|
||||
ok(got_hotkey, "Did not receive expected WM_HOTKEY message\n"); \
|
||||
} while (0)
|
||||
#define msg_no_hotkey(msg) do \
|
||||
{ \
|
||||
if ((msg)->message == WM_HOTKEY) \
|
||||
ok((msg)->message != WM_HOTKEY, \
|
||||
"Got WM_HOTKEY with hwnd=%p, wParam=0x%Ix, lParam=0x%Ix\n", \
|
||||
(msg)->hwnd, (msg)->wParam, (msg)->lParam); \
|
||||
else \
|
||||
ok(0, \
|
||||
"Unexpected message %u posted to thread with hwnd=%p, wParam=0x%Ix, lParam=0x%Ix\n", \
|
||||
(msg)->message, (msg)->hwnd, (msg)->wParam, (msg)->lParam); \
|
||||
} while (0)
|
||||
#define expect_no_hotkey() do \
|
||||
{ \
|
||||
MSG msg; \
|
||||
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) \
|
||||
{ \
|
||||
msg_no_hotkey(&msg); \
|
||||
DispatchMessageW(&msg); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
START_TEST(RegisterHotKey)
|
||||
{
|
||||
SetCursorPos(0, 0);
|
||||
|
||||
RegisterHotKey(NULL, 1, MOD_CONTROL, 0);
|
||||
RegisterHotKey(NULL, 2, MOD_CONTROL, 'U');
|
||||
RegisterHotKey(NULL, 3, MOD_CONTROL | MOD_ALT, 0);
|
||||
RegisterHotKey(NULL, 4, MOD_CONTROL | MOD_ALT, 'U');
|
||||
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Ctrl only\n");
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_hotkey(1, 0, VK_CONTROL);
|
||||
|
||||
trace("Ctrl+U\n");
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, 0, 0);
|
||||
expect_hotkey(2, MOD_CONTROL, 'U');
|
||||
keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Ctrl+U (with Ctrl up first)\n");
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, 0, 0);
|
||||
expect_hotkey(2, MOD_CONTROL, 'U');
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Ctrl+U (with U down first and Ctrl up first)\n");
|
||||
keybd_event('U', 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_hotkey(1, 0, VK_CONTROL);
|
||||
keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Ctrl+U (with U down first and U up first)\n");
|
||||
keybd_event('U', 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Ctrl+Alt\n");
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_hotkey(3, MOD_CONTROL, VK_MENU);
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Ctrl+Alt (with Ctrl up first)\n");
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_hotkey(3, MOD_ALT, VK_CONTROL);
|
||||
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Alt+Ctrl\n");
|
||||
keybd_event(VK_MENU, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_hotkey(3, MOD_ALT, VK_CONTROL);
|
||||
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Alt+Ctrl (with Alt up first)\n");
|
||||
keybd_event(VK_MENU, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_hotkey(3, MOD_CONTROL, VK_MENU);
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Alt+U\n");
|
||||
keybd_event(VK_MENU, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Ctrl+Alt+U\n");
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, 0, 0);
|
||||
expect_hotkey(4, MOD_CONTROL | MOD_ALT, 'U');
|
||||
keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Alt+Ctrl+U\n");
|
||||
keybd_event(VK_MENU, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, 0, 0);
|
||||
expect_hotkey(4, MOD_CONTROL | MOD_ALT, 'U');
|
||||
keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Ctrl+U+Alt\n");
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, 0, 0);
|
||||
expect_hotkey(2, MOD_CONTROL, 'U');
|
||||
keybd_event(VK_MENU, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_hotkey(3, MOD_CONTROL, VK_MENU);
|
||||
keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
trace("Alt+U+Ctrl\n");
|
||||
keybd_event(VK_MENU, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event('U', 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, 0, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_hotkey(3, MOD_ALT, VK_CONTROL);
|
||||
keybd_event('U', 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
expect_no_hotkey();
|
||||
|
||||
/* The remaining combinations are an exercise left to the reader */
|
||||
|
||||
UnregisterHotKey(NULL, 4);
|
||||
UnregisterHotKey(NULL, 3);
|
||||
UnregisterHotKey(NULL, 2);
|
||||
UnregisterHotKey(NULL, 1);
|
||||
|
||||
expect_no_hotkey();
|
||||
}
|
|
@ -22,6 +22,7 @@ extern void func_InitializeLpkHooks(void);
|
|||
extern void func_LoadImage(void);
|
||||
extern void func_LookupIconIdFromDirectoryEx(void);
|
||||
extern void func_RealGetWindowClass(void);
|
||||
extern void func_RegisterHotKey(void);
|
||||
extern void func_ScrollDC(void);
|
||||
extern void func_ScrollWindowEx(void);
|
||||
extern void func_SendMessageTimeout(void);
|
||||
|
@ -55,6 +56,7 @@ const struct test winetest_testlist[] =
|
|||
{ "LoadImage", func_LoadImage },
|
||||
{ "LookupIconIdFromDirectoryEx", func_LookupIconIdFromDirectoryEx },
|
||||
{ "RealGetWindowClass", func_RealGetWindowClass },
|
||||
{ "RegisterHotKey", func_RegisterHotKey },
|
||||
{ "ScrollDC", func_ScrollDC },
|
||||
{ "ScrollWindowEx", func_ScrollWindowEx },
|
||||
{ "SendMessageTimeout", func_SendMessageTimeout },
|
||||
|
|
Loading…
Reference in a new issue