From f4cb1ba29a86a75bec274145f624634568b21041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincas=20Mili=C5=ABnas?= Date: Tue, 5 Jul 2011 22:57:57 +0300 Subject: [PATCH 03/20] user32/tests: Added GetRawInputDeviceInfoW tests (try 16) --- dlls/user32/tests/input.c | 101 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 101 insertions(+), 0 deletions(-) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 84590b5..c9f1dff 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -78,6 +78,7 @@ static struct { static UINT (WINAPI *pSendInput) (UINT, INPUT*, size_t); static int (WINAPI *pGetMouseMovePointsEx) (UINT, LPMOUSEMOVEPOINT, LPMOUSEMOVEPOINT, int, DWORD); static UINT (WINAPI *pDefRawInputProc) (PRAWINPUT*, INT, UINT); +static UINT (WINAPI *pGetRawInputDeviceInfoW) (HANDLE, UINT, LPVOID, PUINT); static UINT (WINAPI *pGetRawInputDeviceList) (PRAWINPUTDEVICELIST, PUINT, UINT); #define MAXKEYEVENTS 12 @@ -163,6 +164,7 @@ static void init_function_pointers(void) GET_PROC(SendInput) GET_PROC(DefRawInputProc) GET_PROC(GetMouseMovePointsEx) + GET_PROC(GetRawInputDeviceInfoW) GET_PROC(GetRawInputDeviceList) #undef GET_PROC @@ -1678,6 +1680,104 @@ static void test_get_raw_input_device_list(void) HeapFree(GetProcessHeap(), 0, device_list); } +static void test_get_raw_input_device_info_w(void) +{ + UINT ret, size = 0, count; + RAWINPUTDEVICELIST *devices; + WCHAR buffer[512]; + RID_DEVICE_INFO info; + DWORD error; + + if (!pGetRawInputDeviceInfoW || !pGetRawInputDeviceList) + { + win_skip("GetRawInputDeviceInfoW and GetRawInputDeviceList are not available\n"); + return; + } + + SetLastError(0xdeadbeef); + ret = pGetRawInputDeviceInfoW(NULL, 0, NULL, NULL); + error = GetLastError(); + todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceInfoW returned wrong value: " + "expected (UINT)-1, got %u\n", ret); + todo_wine ok(error == ERROR_NOACCESS, "GetRawInputDeviceInfoW returned " + "wrong error code: %u\n", error); + + SetLastError(0xdeadbeef); + size = 0; + ret = pGetRawInputDeviceInfoW(NULL, 0, NULL, &size); + error = GetLastError(); + todo_wine ok(ret == (UINT)-1, + "GetRawInputDeviceInfoW returned wrong value: expected (UINT)-1, got %u\n", ret); + todo_wine ok(error == ERROR_INVALID_HANDLE, + "GetRawInputDeviceInfoW returned wrong error code: %u\n", error); + + ret = pGetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)); + ok(ret == 0, "GetRawInputDeviceList failed to return raw input device count\n"); + todo_wine ok(count > 0, "Should have at least one raw input device available\n"); + + devices = HeapAlloc(GetProcessHeap(), 0, count * sizeof(RAWINPUTDEVICELIST)); + ok(devices != NULL, "Failed to allocate memory for raw input devices\n"); + if (!devices) + return; + + ret = pGetRawInputDeviceList(devices, &count, sizeof(RAWINPUTDEVICELIST)); + ok(ret == count, "GetRawInputDeviceList returned incorrect " + "number of devices: expected %u, got %u", count, ret); + + SetLastError(0xdeadbeef); + size = 0; + ret = pGetRawInputDeviceInfoW(devices[0].hDevice, 0, NULL, &size); + error = GetLastError(); + todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceInfoW returned wrong value: " + "expected (UINT)-1, got %u\n", ret); + todo_wine ok(error == ERROR_INVALID_PARAMETER, "GetRawInputDeviceInfoW returned " + "wrong error code: %u\n", error); + + SetLastError(0xdeadbeef); + size = 0; + ret = pGetRawInputDeviceInfoW(devices[0].hDevice, RIDI_DEVICENAME, buffer, &size); + error = GetLastError(); + todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceInfoW returned wrong value: " + "expected (UINT)-1, got %u\n", ret); + todo_wine ok(error == ERROR_INSUFFICIENT_BUFFER, "GetRawInputDeviceInfoW returned " + "wrong error code: %u\n", error); + + size = 0; + ret = pGetRawInputDeviceInfoW(devices[0].hDevice, RIDI_DEVICENAME, NULL, &size); + ok(ret == 0, "GetRawInputDeviceInfoW returned wrong value: expected 0, got %u\n", ret); + todo_wine ok(size > 5, "GetRawInputDeviceInfoW returned wrong " + "device name size: expected x > 5, got %u\n", size); + + buffer[0] = 0; + ret = pGetRawInputDeviceInfoW(devices[0].hDevice, RIDI_DEVICENAME, buffer, &size); + todo_wine ok(ret != (UINT)-1 && ret > 0, "GetRawInputDeviceInfoW returned wrong value: " + "expected 0 < x < (UINT)-1, got %u\n", ret); + size = lstrlenW(buffer); + todo_wine ok(size > 5, "GetRawInputDeviceInfoW returned too short device name: " + "expected x > 5, got %u\n", size); + + size = 0; + ret = pGetRawInputDeviceInfoW(devices[0].hDevice, RIDI_DEVICEINFO, NULL, &size); + ok(ret == 0, "GetRawInputDeviceInfoW returned wrong value: expected 0, got %u\n", ret); + todo_wine ok(size == sizeof(RID_DEVICE_INFO), "GetRawInputDeviceInfoW returned " + "wrong device info size: expected sizeof(RID_DEVICE_INFO), got %u\n", size); + + size = sizeof(RID_DEVICE_INFO); + info.cbSize = sizeof(RID_DEVICE_INFO); + ret = pGetRawInputDeviceInfoW(devices[0].hDevice, RIDI_DEVICEINFO, &info, &size); + todo_wine ok(ret == sizeof(RID_DEVICE_INFO), "GetRawInputDeviceInfoW returned wrong value: " + "expected sizeof(RID_DEVICE_INFO), got %u\n", ret); + + size = 0xdeadbeef; + ret = pGetRawInputDeviceInfoW(devices[0].hDevice, RIDI_PREPARSEDDATA, NULL, &size); + ok(ret == 0, "GetRawInputDeviceInfoW returned wrong value: " + "expected 0, got %u\n", ret); + todo_wine ok(size == 0, "GetRawInputDeviceInfoW returned wrong preparsed data size: " + "expected 0, got %u\n", size); + + HeapFree(GetProcessHeap(), 0, devices); +} + START_TEST(input) { init_function_pointers(); @@ -1699,6 +1799,7 @@ START_TEST(input) test_def_raw_input_proc(); test_get_raw_input_device_list(); + test_get_raw_input_device_info_w(); if(pGetMouseMovePointsEx) test_GetMouseMovePointsEx(); -- 1.7.3.4