user32/tests: Add ALT+letter hotkey tests.
Signed-off-by: Ziqing Hui <zhui@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
56dde41b6d
commit
556490d35b
|
@ -17359,6 +17359,29 @@ static const struct message WmHotkeyNew[] = {
|
|||
{ WM_KEYUP, sent, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
|
||||
{ 0 }
|
||||
};
|
||||
static const struct message WmHotkeyPressALT[] = {
|
||||
{ WM_SYSKEYDOWN, kbd_hook|wparam|lparam, VK_LMENU, LLKHF_INJECTED|LLKHF_ALTDOWN },
|
||||
{ HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
|
||||
{ WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
|
||||
{ 0 }
|
||||
};
|
||||
static const struct message WmHotkeyPressWithALT[] = {
|
||||
{ WM_SYSKEYDOWN, kbd_hook, 0, LLKHF_INJECTED|LLKHF_ALTDOWN }, /* lparam not checked */
|
||||
{ WM_HOTKEY, sent|wparam, 6 },
|
||||
{ 0 }
|
||||
};
|
||||
static const struct message WmHotkeyReleaseWithALT[] = {
|
||||
{ WM_SYSKEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP|LLKHF_ALTDOWN },
|
||||
{ HCBT_KEYSKIPPED, hook|lparam|optional, 0, 0xa0000001 },
|
||||
{ WM_SYSKEYUP, sent|lparam, 0, 0xa0000001 },
|
||||
{ 0 }
|
||||
};
|
||||
static const struct message WmHotkeyReleaseALT[] = {
|
||||
{ WM_KEYUP, kbd_hook|wparam|lparam, VK_LMENU, LLKHF_INJECTED|LLKHF_UP },
|
||||
{ HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 },
|
||||
{ WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static int hotkey_letter;
|
||||
|
||||
|
@ -17378,9 +17401,12 @@ static LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam
|
|||
msg.descr = "KeyboardHookProc";
|
||||
add_message(&msg);
|
||||
|
||||
if (wParam == WM_KEYUP || wParam == WM_KEYDOWN)
|
||||
if (wParam == WM_KEYUP || wParam == WM_KEYDOWN ||
|
||||
wParam == WM_SYSKEYUP || wParam == WM_SYSKEYDOWN)
|
||||
{
|
||||
ok(kdbhookstruct->vkCode == VK_LWIN || kdbhookstruct->vkCode == hotkey_letter,
|
||||
ok(kdbhookstruct->vkCode == VK_LWIN ||
|
||||
kdbhookstruct->vkCode == VK_LMENU ||
|
||||
kdbhookstruct->vkCode == hotkey_letter,
|
||||
"unexpected keycode %x\n", kdbhookstruct->vkCode);
|
||||
}
|
||||
}
|
||||
|
@ -17635,6 +17661,56 @@ static void test_hotkey(void)
|
|||
}
|
||||
ok_sequence(WmHotkeyReleaseLWIN, "thread hotkey release LWIN", FALSE);
|
||||
|
||||
/* Search for an ALT + letter combination that hasn't been registered */
|
||||
for (hotkey_letter = 0x41; hotkey_letter <= 0x51; hotkey_letter ++)
|
||||
{
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = RegisterHotKey(test_window, 6, MOD_ALT, hotkey_letter);
|
||||
|
||||
if (ret == TRUE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef),
|
||||
"unexpected error %d\n", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
if (hotkey_letter == 0x52)
|
||||
{
|
||||
ok(0, "Couldn't find any free ALT + letter combination\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
keybd_event(VK_LMENU, 0, 0, 0);
|
||||
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
DispatchMessageA(&msg);
|
||||
ok_sequence(WmHotkeyPressALT, "window hotkey press ALT", TRUE);
|
||||
|
||||
keybd_event(hotkey_letter, 0, 0, 0);
|
||||
while (PeekMessageA(&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(MOD_ALT, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
|
||||
}
|
||||
DispatchMessageA(&msg);
|
||||
}
|
||||
ok_sequence(WmHotkeyPressWithALT, "window hotkey press with ALT", TRUE);
|
||||
|
||||
keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
|
||||
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
DispatchMessageA(&msg);
|
||||
ok_sequence(WmHotkeyReleaseWithALT, "window hotkey release with ALT", TRUE);
|
||||
|
||||
keybd_event(VK_LMENU, 0, KEYEVENTF_KEYUP, 0);
|
||||
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
DispatchMessageA(&msg);
|
||||
ok_sequence(WmHotkeyReleaseALT, "window hotkey release ALT", FALSE);
|
||||
|
||||
/* Unregister thread hotkey */
|
||||
ret = UnregisterHotKey(NULL, 5);
|
||||
ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());
|
||||
|
@ -17645,6 +17721,7 @@ static void test_hotkey(void)
|
|||
end:
|
||||
UnregisterHotKey(NULL, 5);
|
||||
UnregisterHotKey(test_window, 5);
|
||||
UnregisterHotKey(test_window, 6);
|
||||
DestroyWindow(test_window);
|
||||
flush_sequence();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue