From: Zebediah Figura zfigura@codeweavers.com
In order to test the wparam member I removed WS_VISIBLE from the window created by test_GetRawInputBuffer(). For some reason this caused events injected by that test not to be received if the test was executed after another test that created a window. My vague understanding is that we'd need XInput2 support to reliably receive those events, so as a stopgap solution I moved the tests earlier. --- dlls/user32/tests/input.c | 104 ++++++++++++++++++++++++++++++++++---- 1 file changed, 95 insertions(+), 9 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 6232a7456e8..59039164b6b 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -2101,13 +2101,29 @@ static void test_RegisterRawInputDevices(void)
static int rawinputbuffer_wndproc_count;
+typedef struct +{ + DWORD dwType; + DWORD dwSize; + ULONG hDevice; + ULONG wParam; +} RAWINPUTHEADER32; + #ifdef _WIN64 +typedef RAWINPUTHEADER RAWINPUTHEADER64; typedef RAWINPUT RAWINPUT64; #else typedef struct { - RAWINPUTHEADER header; - char pad[8]; + DWORD dwType; + DWORD dwSize; + ULONGLONG hDevice; + ULONGLONG wParam; +} RAWINPUTHEADER64; + +typedef struct +{ + RAWINPUTHEADER64 header; union { RAWMOUSE mouse; RAWKEYBOARD keyboard; @@ -2124,9 +2140,9 @@ static int rawinput_buffer_mouse_x(void *buffer, size_t index)
static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { + UINT i, size, count, rawinput_size, iteration = rawinputbuffer_wndproc_count++; RAWINPUT ri; char buffer[16 * sizeof(RAWINPUT64)]; - UINT size, count, rawinput_size, iteration = rawinputbuffer_wndproc_count++; MSG message;
if (is_wow64) rawinput_size = sizeof(RAWINPUT64); @@ -2134,8 +2150,12 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara
if (msg == WM_INPUT) { + ok(wparam == RIM_INPUTSINK, "Unexpected wparam: %#Ix\n", wparam); + + SetLastError(0xdeadbeef); count = GetRawInputBuffer(NULL, NULL, sizeof(RAWINPUTHEADER)); ok(count == ~0U, "GetRawInputBuffer succeeded\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError());
size = sizeof(buffer); count = GetRawInputBuffer(NULL, &size, sizeof(RAWINPUTHEADER)); @@ -2147,6 +2167,25 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara count = GetRawInputBuffer((RAWINPUT*)buffer, &size, sizeof(RAWINPUTHEADER)); ok(count == 3, "GetRawInputBuffer returned %u\n", count); ok(size == sizeof(buffer), "GetRawInputBuffer returned unexpected size: %u\n", size); + + for (i = 0; i < 3; ++i) + { + if (is_wow64) + { + const RAWINPUT64 *data = (RAWINPUT64 *)buffer; + ok(data->header.dwType == RIM_TYPEMOUSE, "Unexpected rawinput type: %lu\n", data->header.dwType); + ok(data->header.dwSize == sizeof(*data), "Unexpected rawinput size: %lu\n", data->header.dwSize); + todo_wine ok(data->header.wParam == wparam, "Unexpected wparam: %#I64x\n", data->header.wParam); + } + else + { + const RAWINPUT *data = (RAWINPUT *)buffer; + ok(data->header.dwType == RIM_TYPEMOUSE, "Unexpected rawinput type: %lu\n", data->header.dwType); + ok(data->header.dwSize == sizeof(*data), "Unexpected rawinput size: %lu\n", data->header.dwSize); + todo_wine ok(data->header.wParam == wparam, "Unexpected wparam: %#Ix\n", data->header.wParam); + } + } + ok(rawinput_buffer_mouse_x(buffer, 0) == 2, "Unexpected rawinput data: %d\n", rawinput_buffer_mouse_x(buffer, 0)); ok(rawinput_buffer_mouse_x(buffer, 1) == 3, "Unexpected rawinput data: %d\n", rawinput_buffer_mouse_x(buffer, 1)); ok(rawinput_buffer_mouse_x(buffer, 2) == 4, "Unexpected rawinput data: %d\n", rawinput_buffer_mouse_x(buffer, 2)); @@ -2183,7 +2222,12 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara { SetLastError(0xdeadbeef); count = GetRawInputData((HRAWINPUT)lparam, RID_INPUT, &ri, &size, 0); - ok(count == ~0U, "GetRawInputData succeeded\n"); + ok(count == ~0u, "GetRawInputData returned %d\n", count); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRawInputData returned %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + count = GetRawInputData((HRAWINPUT)lparam, RID_INPUT, &ri, &size, sizeof(RAWINPUTHEADER) + 1); + ok(count == ~0u, "GetRawInputData returned %d\n", count); ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRawInputData returned %08lx\n", GetLastError());
SetLastError(0xdeadbeef); @@ -2204,6 +2248,28 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara ok(count == sizeof(ri), "GetRawInputData failed\n"); ok(ri.data.mouse.lLastX == 6, "Unexpected rawinput data: %ld\n", ri.data.mouse.lLastX); ok(GetLastError() == 0xdeadbeef, "GetRawInputData returned %08lx\n", GetLastError()); + + SetLastError(0xdeadbeef); + size = sizeof(buffer); + if (sizeof(void *) == 8) + { + count = GetRawInputData((HRAWINPUT)lparam, RID_INPUT, &ri, &size, sizeof(RAWINPUTHEADER32)); + ok(count == ~0u, "GetRawInputData returned %d\n", count); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRawInputData returned %08lx\n", GetLastError()); + } + else if (is_wow64) + { + count = GetRawInputData((HRAWINPUT)lparam, RID_INPUT, &ri, &size, sizeof(RAWINPUTHEADER64)); + todo_wine ok(count == sizeof(ri), "GetRawInputData returned %d\n", count); + ok(ri.data.mouse.lLastX == 6, "Unexpected rawinput data: %ld\n", ri.data.mouse.lLastX); + todo_wine ok(GetLastError() == 0xdeadbeef, "GetRawInputData returned %08lx\n", GetLastError()); + } + else + { + count = GetRawInputData((HRAWINPUT)lparam, RID_INPUT, &ri, &size, sizeof(RAWINPUTHEADER64)); + ok(count == ~0u, "GetRawInputData returned %d\n", count); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRawInputData returned %08lx\n", GetLastError()); + } } else { @@ -2233,7 +2299,7 @@ static void test_GetRawInputBuffer(void) GetCursorPos(&pt); ok(pt.x == 300 && pt.y == 300, "Unexpected cursor position pos %ldx%ld\n", pt.x, pt.y);
- hwnd = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP, + hwnd = CreateWindowA("static", "static", WS_POPUP, 100, 100, 100, 100, 0, NULL, NULL, NULL); SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)rawinputbuffer_wndproc); ok(hwnd != 0, "CreateWindow failed\n"); @@ -2295,6 +2361,23 @@ static void test_GetRawInputBuffer(void) ok(count == ~0U, "GetRawInputBuffer succeeded\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRawInputBuffer returned %08lx\n", GetLastError());
+ SetLastError(0xdeadbeef); + size = sizeof(buffer); + count = GetRawInputBuffer((RAWINPUT*)buffer, &size, sizeof(RAWINPUTHEADER) + 1); + ok(count == ~0U, "GetRawInputBuffer succeeded\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRawInputBuffer returned %08lx\n", GetLastError()); + + /* the function returns 64-bit RAWINPUT structures on WoW64, but still + * forbids sizeof(RAWINPUTHEADER) from the wrong architecture */ + SetLastError(0xdeadbeef); + size = sizeof(buffer); + if (sizeof(void *) == 8) + count = GetRawInputBuffer((RAWINPUT*)buffer, &size, sizeof(RAWINPUTHEADER32)); + else + count = GetRawInputBuffer((RAWINPUT*)buffer, &size, sizeof(RAWINPUTHEADER64)); + ok(count == ~0U, "GetRawInputBuffer succeeded\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRawInputBuffer returned %08lx\n", GetLastError()); + size = sizeof(buffer); memset(buffer, 0, sizeof(buffer)); count = GetRawInputBuffer((RAWINPUT*)buffer, &size, sizeof(RAWINPUTHEADER)); @@ -2365,6 +2448,9 @@ static LRESULT CALLBACK rawinput_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPA ret = GetRawInputData((HRAWINPUT)lparam, RID_INPUT, &raw, &raw_size, sizeof(RAWINPUTHEADER)); ok(ret > 0 && ret != (UINT)-1, "GetRawInputData failed\n"); ok(raw.header.dwType == RIM_TYPEMOUSE, "Unexpected rawinput type: %lu\n", raw.header.dwType); + ok(raw.header.dwSize == raw_size, "Expected size %u, got %lu\n", raw_size, raw.header.dwSize); + todo_wine_if (wparam) + ok(raw.header.wParam == wparam, "Expected wparam %Iu, got %Iu\n", wparam, raw.header.wParam);
ok(!(raw.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE), "Unexpected absolute rawinput motion\n"); ok(!(raw.data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP), "Unexpected virtual desktop rawinput motion\n"); @@ -4491,6 +4577,10 @@ START_TEST(input) return; }
+ test_GetRawInputData(); + test_GetRawInputBuffer(); + test_RegisterRawInputDevices(); + test_rawinput(argv[0]); test_SendInput(); test_Input_blackbox(); test_Input_whitebox(); @@ -4507,10 +4597,6 @@ START_TEST(input) test_attach_input(); test_GetKeyState(); test_OemKeyScan(); - test_GetRawInputData(); - test_GetRawInputBuffer(); - test_RegisterRawInputDevices(); - test_rawinput(argv[0]);
if(pGetMouseMovePointsEx) test_GetMouseMovePointsEx(argv[0]);