From ed1365297ad53cfebfc3712e19f4377ef09e04d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincas=20Mili=C5=ABnas?= Date: Tue, 5 Jul 2011 23:01:49 +0300 Subject: [PATCH 04/20] user32/tests: Added GetRawInputDeviceInfoA 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 c9f1dff..2bc45f0 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 *pGetRawInputDeviceInfoA) (HANDLE, UINT, LPVOID, PUINT); static UINT (WINAPI *pGetRawInputDeviceInfoW) (HANDLE, UINT, LPVOID, PUINT); static UINT (WINAPI *pGetRawInputDeviceList) (PRAWINPUTDEVICELIST, PUINT, UINT); @@ -164,6 +165,7 @@ static void init_function_pointers(void) GET_PROC(SendInput) GET_PROC(DefRawInputProc) GET_PROC(GetMouseMovePointsEx) + GET_PROC(GetRawInputDeviceInfoA) GET_PROC(GetRawInputDeviceInfoW) GET_PROC(GetRawInputDeviceList) @@ -1778,6 +1780,104 @@ static void test_get_raw_input_device_info_w(void) HeapFree(GetProcessHeap(), 0, devices); } +static void test_get_raw_input_device_info_a(void) +{ + UINT ret, size = 0, count; + RAWINPUTDEVICELIST *devices; + char buffer[512]; + RID_DEVICE_INFO info; + DWORD error; + + if (!pGetRawInputDeviceInfoA || !pGetRawInputDeviceList) + { + win_skip("GetRawInputDeviceInfoA and GetRawInputDeviceList are not available\n"); + return; + } + + SetLastError(0xdeadbeef); + ret = pGetRawInputDeviceInfoA(NULL, 0, NULL, NULL); + error = GetLastError(); + todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: " + "expected (UINT)-1, got %u\n", ret); + todo_wine ok(error == ERROR_NOACCESS, "GetRawInputDeviceInfoA returned " + "wrong error code: %u\n", error); + + SetLastError(0xdeadbeef); + size = 0; + ret = pGetRawInputDeviceInfoA(NULL, 0, NULL, &size); + error = GetLastError(); + todo_wine ok(ret == (UINT)-1, + "GetRawInputDeviceInfoA returned wrong value: expected (UINT)-1, got %u\n", ret); + todo_wine ok(error == ERROR_INVALID_HANDLE, + "GetRawInputDeviceInfoA 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 = pGetRawInputDeviceInfoA(devices[0].hDevice, 0, NULL, &size); + error = GetLastError(); + todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: " + "expected (UINT)-1, got %u\n", ret); + todo_wine ok(error == ERROR_INVALID_PARAMETER, "GetRawInputDeviceInfoA returned " + "wrong error code: %u\n", error); + + SetLastError(0xdeadbeef); + size = 0; + ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICENAME, buffer, &size); + error = GetLastError(); + todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceInfoA returned wrong value: " + "expected (UINT)-1, got %u\n", ret); + todo_wine ok(error == ERROR_INSUFFICIENT_BUFFER, "GetRawInputDeviceInfoA returned " + "wrong error code: %u\n", error); + + size = 0; + ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICENAME, NULL, &size); + ok(ret == 0, "GetRawInputDeviceInfoA returned wrong value: expected 0, got %u\n", ret); + todo_wine ok(size > 5, "GetRawInputDeviceInfoA returned wrong " + "device name size: expected x > 5, got %u\n", size); + + buffer[0] = 0; + ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICENAME, buffer, &size); + todo_wine ok(ret != (UINT)-1 && ret > 0, "GetRawInputDeviceInfoA returned wrong value: " + "expected 0 < x < (UINT)-1, got %u\n", ret); + size = strlen(buffer); + todo_wine ok(size > 5, "GetRawInputDeviceInfoA returned too short device name: " + "expected x > 5, got %u\n", size); + + size = 0; + ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICEINFO, NULL, &size); + ok(ret == 0, "GetRawInputDeviceInfoA returned wrong value: expected 0, got %u\n", ret); + todo_wine ok(size == sizeof(RID_DEVICE_INFO), "GetRawInputDeviceInfoA 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 = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_DEVICEINFO, &info, &size); + todo_wine ok(ret == sizeof(RID_DEVICE_INFO), "GetRawInputDeviceInfoA returned wrong value: " + "expected sizeof(RID_DEVICE_INFO), got %u\n", ret); + + size = 0xdeadbeef; + ret = pGetRawInputDeviceInfoA(devices[0].hDevice, RIDI_PREPARSEDDATA, NULL, &size); + ok(ret == 0, "GetRawInputDeviceInfoA returned wrong value: " + "expected 0, got %u\n", ret); + todo_wine ok(size == 0, "GetRawInputDeviceInfoA returned wrong preparsed data size: " + "expected 0, got %u\n", size); + + HeapFree(GetProcessHeap(), 0, devices); +} + START_TEST(input) { init_function_pointers(); @@ -1800,6 +1900,7 @@ START_TEST(input) test_def_raw_input_proc(); test_get_raw_input_device_list(); test_get_raw_input_device_info_w(); + test_get_raw_input_device_info_a(); if(pGetMouseMovePointsEx) test_GetMouseMovePointsEx(); -- 1.7.3.4