mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-22 16:44:10 +00:00
user32/tests: Use the standard INPUT type definition.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7c6f6d2775
commit
b67d66f583
|
@ -108,18 +108,6 @@ static const int GETFLAGS[]={0, 0, KEYEVENTF_KEYUP, 0, KEYEVENTF_KEYUP, 0, KEYEV
|
|||
/* matching descriptions */
|
||||
static const char *getdesc[]={"", "+alt","-alt","+X","-X","+shift","-shift","+ctrl","-ctrl"};
|
||||
|
||||
/* The MSVC headers ignore our NONAMELESSUNION requests so we have to define our own type */
|
||||
typedef struct
|
||||
{
|
||||
DWORD type;
|
||||
union
|
||||
{
|
||||
MOUSEINPUT mi;
|
||||
KEYBDINPUT ki;
|
||||
HARDWAREINPUT hi;
|
||||
} u;
|
||||
} TEST_INPUT;
|
||||
|
||||
typedef struct {
|
||||
UINT message;
|
||||
WPARAM wParam;
|
||||
|
@ -230,7 +218,7 @@ static int KbdMessage( KEV kev, WPARAM *pwParam, LPARAM *plParam )
|
|||
*/
|
||||
static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] )
|
||||
{
|
||||
TEST_INPUT inputs[MAXKEYEVENTS];
|
||||
INPUT inputs[MAXKEYEVENTS];
|
||||
KMSG expmsg[MAXKEYEVENTS];
|
||||
MSG msg;
|
||||
char buf[100];
|
||||
|
@ -242,11 +230,11 @@ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] )
|
|||
for (i = 0; i < MAXKEYEVENTS; i++)
|
||||
{
|
||||
inputs[evtctr].type = INPUT_KEYBOARD;
|
||||
inputs[evtctr].u.ki.wVk = GETVKEY[td[i]];
|
||||
inputs[evtctr].u.ki.wScan = GETSCAN[td[i]];
|
||||
inputs[evtctr].u.ki.dwFlags = GETFLAGS[td[i]];
|
||||
inputs[evtctr].u.ki.dwExtraInfo = 0;
|
||||
inputs[evtctr].u.ki.time = ++timetag;
|
||||
inputs[evtctr].ki.wVk = GETVKEY[td[i]];
|
||||
inputs[evtctr].ki.wScan = GETSCAN[td[i]];
|
||||
inputs[evtctr].ki.dwFlags = GETFLAGS[td[i]];
|
||||
inputs[evtctr].ki.dwExtraInfo = 0;
|
||||
inputs[evtctr].ki.time = ++timetag;
|
||||
if (td[i]) evtctr++;
|
||||
|
||||
strcat(buf, getdesc[td[i]]);
|
||||
|
@ -258,7 +246,7 @@ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] )
|
|||
for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++)
|
||||
;
|
||||
ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" );
|
||||
ret = SendInput(evtctr, (INPUT *)inputs, sizeof(INPUT));
|
||||
ret = SendInput(evtctr, inputs, sizeof(INPUT));
|
||||
ok(ret == evtctr, "SendInput failed to send some events\n");
|
||||
i = 0;
|
||||
if (winetest_debug > 1)
|
||||
|
@ -925,7 +913,7 @@ if(0) /* For some reason not stable on Wine */
|
|||
}
|
||||
static void test_Input_blackbox(void)
|
||||
{
|
||||
TEST_INPUT i;
|
||||
INPUT i;
|
||||
int ii;
|
||||
BYTE ks1[256], ks2[256];
|
||||
LONG_PTR prevWndProc;
|
||||
|
@ -962,15 +950,15 @@ static void test_Input_blackbox(void)
|
|||
ok(prevWndProc != 0 || GetLastError() == 0, "error: %d\n", (int) GetLastError());
|
||||
|
||||
i.type = INPUT_KEYBOARD;
|
||||
i.u.ki.time = 0;
|
||||
i.u.ki.dwExtraInfo = 0;
|
||||
i.ki.time = 0;
|
||||
i.ki.dwExtraInfo = 0;
|
||||
|
||||
for (ii = 0; ii < ARRAY_SIZE(sendinput_test)-1; ii++) {
|
||||
GetKeyboardState(ks1);
|
||||
i.u.ki.wScan = ii+1 /* useful for debugging */;
|
||||
i.u.ki.dwFlags = sendinput_test[ii].dwFlags;
|
||||
i.u.ki.wVk = sendinput_test[ii].wVk;
|
||||
SendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
|
||||
i.ki.wScan = ii+1 /* useful for debugging */;
|
||||
i.ki.dwFlags = sendinput_test[ii].dwFlags;
|
||||
i.ki.wVk = sendinput_test[ii].wVk;
|
||||
SendInput(1, &i, sizeof(INPUT));
|
||||
empty_message_queue();
|
||||
GetKeyboardState(ks2);
|
||||
compare_and_check(ii, ks1, ks2, &sendinput_test[ii], foreground);
|
||||
|
@ -1000,21 +988,21 @@ static void reset_key_status(WORD vk)
|
|||
|
||||
static void test_unicode_keys(HWND hwnd, HHOOK hook)
|
||||
{
|
||||
TEST_INPUT inputs[2];
|
||||
INPUT inputs[2];
|
||||
MSG msg;
|
||||
|
||||
/* init input data that never changes */
|
||||
inputs[1].type = inputs[0].type = INPUT_KEYBOARD;
|
||||
inputs[1].u.ki.dwExtraInfo = inputs[0].u.ki.dwExtraInfo = 0;
|
||||
inputs[1].u.ki.time = inputs[0].u.ki.time = 0;
|
||||
inputs[1].ki.dwExtraInfo = inputs[0].ki.dwExtraInfo = 0;
|
||||
inputs[1].ki.time = inputs[0].ki.time = 0;
|
||||
|
||||
/* pressing & releasing a single unicode character */
|
||||
inputs[0].u.ki.wVk = 0;
|
||||
inputs[0].u.ki.wScan = 0x3c0;
|
||||
inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
|
||||
inputs[0].ki.wVk = 0;
|
||||
inputs[0].ki.wScan = 0x3c0;
|
||||
inputs[0].ki.dwFlags = KEYEVENTF_UNICODE;
|
||||
|
||||
reset_key_status(VK_PACKET);
|
||||
SendInput(1, (INPUT*)inputs, sizeof(INPUT));
|
||||
SendInput(1, inputs, sizeof(INPUT));
|
||||
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
|
||||
if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){
|
||||
TranslateMessage(&msg);
|
||||
|
@ -1031,12 +1019,12 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
|
|||
"Last hookdown msg should have been 0x3c0, was: 0x%lx\n", key_status.last_hook_down);
|
||||
}
|
||||
|
||||
inputs[1].u.ki.wVk = 0;
|
||||
inputs[1].u.ki.wScan = 0x3c0;
|
||||
inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
|
||||
inputs[1].ki.wVk = 0;
|
||||
inputs[1].ki.wScan = 0x3c0;
|
||||
inputs[1].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
|
||||
|
||||
reset_key_status(VK_PACKET);
|
||||
SendInput(1, (INPUT*)(inputs+1), sizeof(INPUT));
|
||||
SendInput(1, inputs + 1, sizeof(INPUT));
|
||||
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
|
||||
if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){
|
||||
TranslateMessage(&msg);
|
||||
|
@ -1052,17 +1040,17 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
|
|||
}
|
||||
|
||||
/* holding alt, pressing & releasing a unicode character, releasing alt */
|
||||
inputs[0].u.ki.wVk = VK_LMENU;
|
||||
inputs[0].u.ki.wScan = 0;
|
||||
inputs[0].u.ki.dwFlags = 0;
|
||||
inputs[0].ki.wVk = VK_LMENU;
|
||||
inputs[0].ki.wScan = 0;
|
||||
inputs[0].ki.dwFlags = 0;
|
||||
|
||||
inputs[1].u.ki.wVk = 0;
|
||||
inputs[1].u.ki.wScan = 0x3041;
|
||||
inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE;
|
||||
inputs[1].ki.wVk = 0;
|
||||
inputs[1].ki.wScan = 0x3041;
|
||||
inputs[1].ki.dwFlags = KEYEVENTF_UNICODE;
|
||||
|
||||
reset_key_status(VK_PACKET);
|
||||
key_status.expect_alt = TRUE;
|
||||
SendInput(2, (INPUT*)inputs, sizeof(INPUT));
|
||||
SendInput(2, inputs, sizeof(INPUT));
|
||||
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
|
||||
if(msg.message == WM_SYSKEYDOWN && msg.wParam == VK_PACKET){
|
||||
TranslateMessage(&msg);
|
||||
|
@ -1079,17 +1067,17 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
|
|||
"Last hooksysdown msg should have been 0x3041, was: 0x%lx\n", key_status.last_hook_syskey_down);
|
||||
}
|
||||
|
||||
inputs[1].u.ki.wVk = 0;
|
||||
inputs[1].u.ki.wScan = 0x3041;
|
||||
inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
|
||||
inputs[1].ki.wVk = 0;
|
||||
inputs[1].ki.wScan = 0x3041;
|
||||
inputs[1].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
|
||||
|
||||
inputs[0].u.ki.wVk = VK_LMENU;
|
||||
inputs[0].u.ki.wScan = 0;
|
||||
inputs[0].u.ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
inputs[0].ki.wVk = VK_LMENU;
|
||||
inputs[0].ki.wScan = 0;
|
||||
inputs[0].ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
|
||||
reset_key_status(VK_PACKET);
|
||||
key_status.expect_alt = TRUE;
|
||||
SendInput(2, (INPUT*)inputs, sizeof(INPUT));
|
||||
SendInput(2, inputs, sizeof(INPUT));
|
||||
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
|
||||
if(msg.message == WM_SYSKEYDOWN && msg.wParam == VK_PACKET){
|
||||
TranslateMessage(&msg);
|
||||
|
@ -1105,16 +1093,16 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
|
|||
}
|
||||
|
||||
/* Press and release, non-zero key code. */
|
||||
inputs[0].u.ki.wVk = 0x51;
|
||||
inputs[0].u.ki.wScan = 0x123;
|
||||
inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
|
||||
inputs[0].ki.wVk = 0x51;
|
||||
inputs[0].ki.wScan = 0x123;
|
||||
inputs[0].ki.dwFlags = KEYEVENTF_UNICODE;
|
||||
|
||||
inputs[1].u.ki.wVk = 0x51;
|
||||
inputs[1].u.ki.wScan = 0x123;
|
||||
inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
|
||||
inputs[1].ki.wVk = 0x51;
|
||||
inputs[1].ki.wScan = 0x123;
|
||||
inputs[1].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
|
||||
|
||||
reset_key_status(inputs[0].u.ki.wVk);
|
||||
SendInput(2, (INPUT*)inputs, sizeof(INPUT));
|
||||
reset_key_status(inputs[0].ki.wVk);
|
||||
SendInput(2, inputs, sizeof(INPUT));
|
||||
while (PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
|
@ -1485,7 +1473,7 @@ static void test_GetMouseMovePointsEx(const char *argv0)
|
|||
MOUSEMOVEPOINT in;
|
||||
MOUSEMOVEPOINT out[200];
|
||||
POINT point;
|
||||
TEST_INPUT input;
|
||||
INPUT input;
|
||||
|
||||
/* Get a valid content for the input struct */
|
||||
if(!GetCursorPos(&point)) {
|
||||
|
@ -1681,10 +1669,10 @@ static void test_GetMouseMovePointsEx(const char *argv0)
|
|||
|
||||
input.type = INPUT_MOUSE;
|
||||
memset( &input, 0, sizeof(input) );
|
||||
input.u.mi.dwFlags = MOUSEEVENTF_MOVE;
|
||||
input.u.mi.dwExtraInfo = 0xdeadbeef;
|
||||
input.u.mi.dx = -17;
|
||||
input.u.mi.dy = 13;
|
||||
input.mi.dwFlags = MOUSEEVENTF_MOVE;
|
||||
input.mi.dwExtraInfo = 0xdeadbeef;
|
||||
input.mi.dx = -17;
|
||||
input.mi.dy = 13;
|
||||
SendInput( 1, (INPUT *)&input, sizeof(INPUT) );
|
||||
ok( GetCursorPos( &point ), "failed to get cursor position\n" );
|
||||
ok( in.x != point.x && in.y != point.y, "cursor didn't change position after mouse_event()\n" );
|
||||
|
@ -4259,7 +4247,7 @@ static LRESULT WINAPI msg_source_proc( HWND hwnd, UINT message, WPARAM wp, LPARA
|
|||
static void test_input_message_source(void)
|
||||
{
|
||||
WNDCLASSA cls;
|
||||
TEST_INPUT inputs[2];
|
||||
INPUT inputs[2];
|
||||
HWND hwnd;
|
||||
RECT rc;
|
||||
MSG msg;
|
||||
|
@ -4283,20 +4271,20 @@ static void test_input_message_source(void)
|
|||
SetFocus( hwnd );
|
||||
|
||||
inputs[0].type = INPUT_KEYBOARD;
|
||||
inputs[0].u.ki.dwExtraInfo = 0;
|
||||
inputs[0].u.ki.time = 0;
|
||||
inputs[0].u.ki.wVk = 0;
|
||||
inputs[0].u.ki.wScan = 0x3c0;
|
||||
inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
|
||||
inputs[0].ki.dwExtraInfo = 0;
|
||||
inputs[0].ki.time = 0;
|
||||
inputs[0].ki.wVk = 0;
|
||||
inputs[0].ki.wScan = 0x3c0;
|
||||
inputs[0].ki.dwFlags = KEYEVENTF_UNICODE;
|
||||
inputs[1] = inputs[0];
|
||||
inputs[1].u.ki.dwFlags |= KEYEVENTF_KEYUP;
|
||||
inputs[1].ki.dwFlags |= KEYEVENTF_KEYUP;
|
||||
|
||||
expect_src.deviceType = IMDT_UNAVAILABLE;
|
||||
expect_src.originId = IMO_UNAVAILABLE;
|
||||
SendMessageA( hwnd, WM_KEYDOWN, 0, 0 );
|
||||
SendMessageA( hwnd, WM_MOUSEMOVE, 0, 0 );
|
||||
|
||||
SendInput( 2, (INPUT *)inputs, sizeof(INPUT) );
|
||||
SendInput( 2, inputs, sizeof(INPUT) );
|
||||
while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ))
|
||||
{
|
||||
expect_src.deviceType = IMDT_KEYBOARD;
|
||||
|
|
|
@ -49,19 +49,6 @@ static LRESULT WINAPI menu_check_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LP
|
|||
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
/* The MSVC headers ignore our NONAMELESSUNION requests so we have to define
|
||||
* our own type */
|
||||
typedef struct
|
||||
{
|
||||
DWORD type;
|
||||
union
|
||||
{
|
||||
MOUSEINPUT mi;
|
||||
KEYBDINPUT ki;
|
||||
HARDWAREINPUT hi;
|
||||
} u;
|
||||
} TEST_INPUT;
|
||||
|
||||
/* globals to communicate between test and wndproc */
|
||||
|
||||
static BOOL bMenuVisible;
|
||||
|
@ -2243,18 +2230,18 @@ static struct menu_mouse_tests_s {
|
|||
|
||||
static void send_key(WORD wVk)
|
||||
{
|
||||
TEST_INPUT i[2];
|
||||
INPUT i[2];
|
||||
memset(i, 0, sizeof(i));
|
||||
i[0].type = i[1].type = INPUT_KEYBOARD;
|
||||
i[0].u.ki.wVk = i[1].u.ki.wVk = wVk;
|
||||
i[1].u.ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
SendInput(2, (INPUT *) i, sizeof(INPUT));
|
||||
i[0].ki.wVk = i[1].ki.wVk = wVk;
|
||||
i[1].ki.dwFlags = KEYEVENTF_KEYUP;
|
||||
SendInput(2, i, sizeof(INPUT));
|
||||
}
|
||||
|
||||
static BOOL click_menu(HANDLE hWnd, struct menu_item_pair_s *mi)
|
||||
{
|
||||
HMENU hMenu = hMenus[mi->uMenu];
|
||||
TEST_INPUT i[3];
|
||||
INPUT i[3];
|
||||
MSG msg;
|
||||
RECT r;
|
||||
int screen_w = GetSystemMetrics(SM_CXSCREEN);
|
||||
|
@ -2264,16 +2251,16 @@ static BOOL click_menu(HANDLE hWnd, struct menu_item_pair_s *mi)
|
|||
|
||||
memset(i, 0, sizeof(i));
|
||||
i[0].type = i[1].type = i[2].type = INPUT_MOUSE;
|
||||
i[0].u.mi.dx = i[1].u.mi.dx = i[2].u.mi.dx
|
||||
i[0].mi.dx = i[1].mi.dx = i[2].mi.dx
|
||||
= ((r.left + 5) * 65535) / screen_w;
|
||||
i[0].u.mi.dy = i[1].u.mi.dy = i[2].u.mi.dy
|
||||
i[0].mi.dy = i[1].mi.dy = i[2].mi.dy
|
||||
= ((r.top + 5) * 65535) / screen_h;
|
||||
i[0].u.mi.dwFlags = i[1].u.mi.dwFlags = i[2].u.mi.dwFlags
|
||||
i[0].mi.dwFlags = i[1].mi.dwFlags = i[2].mi.dwFlags
|
||||
= MOUSEEVENTF_ABSOLUTE;
|
||||
i[0].u.mi.dwFlags |= MOUSEEVENTF_MOVE;
|
||||
i[1].u.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
|
||||
i[2].u.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
|
||||
ret = SendInput(3, (INPUT *) i, sizeof(INPUT));
|
||||
i[0].mi.dwFlags |= MOUSEEVENTF_MOVE;
|
||||
i[1].mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
|
||||
i[2].mi.dwFlags |= MOUSEEVENTF_LEFTUP;
|
||||
ret = SendInput(3, i, sizeof(INPUT));
|
||||
|
||||
/* hack to prevent mouse message buildup in Wine */
|
||||
while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
|
||||
|
|
Loading…
Reference in a new issue