From 149abe8d980e17a7525554df4575964cae6e7125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincas=20Mili=C5=ABnas?= Date: Mon, 11 Jul 2011 15:08:43 +0300 Subject: [PATCH 05/20] user32/tests: Added basic GetRegisteredRawInputDevices tests (try 16) --- dlls/user32/tests/input.c | 98 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 0 deletions(-) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 2bc45f0..7b5a397 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -81,6 +81,12 @@ 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); +static UINT (WINAPI *pGetRegisteredRawInputDevices) (PRAWINPUTDEVICE, PUINT, UINT); +static BOOL (WINAPI *pRegisterRawInputDevices) (PRAWINPUTDEVICE, UINT, UINT); + +#define HID_USAGE_PAGE_GENERIC ((unsigned short)0x01) +#define HID_USAGE_GENERIC_MOUSE ((unsigned short)0x02) +#define HID_USAGE_GENERIC_KEYBOARD ((unsigned short)0x06) #define MAXKEYEVENTS 12 #define MAXKEYMESSAGES MAXKEYEVENTS /* assuming a key event generates one @@ -168,6 +174,8 @@ static void init_function_pointers(void) GET_PROC(GetRawInputDeviceInfoA) GET_PROC(GetRawInputDeviceInfoW) GET_PROC(GetRawInputDeviceList) + GET_PROC(GetRegisteredRawInputDevices) + GET_PROC(RegisterRawInputDevices) #undef GET_PROC } @@ -1878,6 +1886,95 @@ static void test_get_raw_input_device_info_a(void) HeapFree(GetProcessHeap(), 0, devices); } +static void test_basic_get_registered_raw_input_devices(void) +{ + RAWINPUTDEVICE device, devices[2]; + BOOL ret; + UINT ret2, count; + DWORD error; + + if (!pGetRegisteredRawInputDevices || !pRegisterRawInputDevices) + { + win_skip("GetRegisteredRawInputDevices and RegisterRawInputDevices are not available\n"); + return; + } + + /* Basic tests for GetRegisteredRawInputDevices */ + SetLastError(0xdeadbeef); + ret2 = pGetRegisteredRawInputDevices(NULL, NULL, 0); + error = GetLastError(); + todo_wine ok(ret2 == (UINT)-1, "GetRegisteredRawInputDevices returned wrong value: " + "expected (UINT)-1, got %u\n", ret2); + todo_wine ok(error == ERROR_INVALID_PARAMETER, "GetRegisteredRawInputDevices returned " + "wrong error code: %u\n", error); + + SetLastError(0xdeadbeef); + ret2 = pGetRegisteredRawInputDevices(NULL, NULL, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(ret2 == (UINT)-1, "GetRegisteredRawInputDevices returned wrong value: " + "expected (UINT)-1, got %u\n", ret2); + todo_wine ok(error == ERROR_NOACCESS, "GetRegisteredRawInputDevices returned " + "wrong error code: %u\n", error); + + SetLastError(0xdeadbeef); + ret2 = pGetRegisteredRawInputDevices(NULL, &count, 1); + error = GetLastError(); + todo_wine ok(ret2 == (UINT)-1, "GetRegisteredRawInputDevices returned wrong value: " + "expected (UINT)-1, got %u\n", ret2); + todo_wine ok(error == ERROR_INVALID_PARAMETER, "GetRegisteredRawInputDevices returned " + "wrong error code: %u\n", error); + + count = 0xdeadbeef; + ret2 = pGetRegisteredRawInputDevices(NULL, &count, sizeof(RAWINPUTDEVICE)); + ok(ret2 == 0, "GetRegisteredRawInputDevices returned wrong value: " + "expected 0, got %u\n", ret2); + todo_wine ok(count == 0, "GetRegisteredRawInputDevices returned incorrect registration count: " + "expected 0, got %u\n", count); + + device.usUsagePage = HID_USAGE_PAGE_GENERIC; + device.usUsage = HID_USAGE_GENERIC_MOUSE; + device.dwFlags = 0; + device.hwndTarget = NULL; + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + ok(ret, "RegisterRawInputDevices failed to subscribe to mouse raw input\n"); + + ret2 = pGetRegisteredRawInputDevices(NULL, &count, sizeof(RAWINPUTDEVICE)); + ok(ret2 == 0, "GetRegisteredRawInputDevices returned wrong value: " + "expected 0, got %u\n", ret2); + todo_wine ok(count == 1, "GetRegisteredRawInputDevices returned incorrect registration count: " + "expected 1, got %u\n", count); + + memset(&devices[0], 0xFF, sizeof(RAWINPUTDEVICE)); + ret2 = pGetRegisteredRawInputDevices(&devices[0], &count, sizeof(RAWINPUTDEVICE)); + todo_wine ok(ret2 == 1, "GetRegisteredRawInputDevices returned wrong value: " + "expected 1, got %u\n", ret2); + todo_wine ok(memcmp(&device, &devices[0], sizeof(RAWINPUTDEVICE)) == 0, + "GetRegisteredRawInputDevices returned incorrect raw input device registration\n"); + + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + ok(ret, "RegisterRawInputDevices failed to resubscribe to mouse raw input\n"); + + /* Verify that there is still the only one registration */ + memset(&devices[0], 0xFF, sizeof(RAWINPUTDEVICE)); + ret2 = pGetRegisteredRawInputDevices(&devices[0], &count, sizeof(RAWINPUTDEVICE)); + todo_wine ok(ret2 == 1, "GetRegisteredRawInputDevices returned wrong value: " + "expected 1, got %u\n", ret2); + todo_wine ok(memcmp(&device, &devices[0], sizeof(RAWINPUTDEVICE)) == 0, + "GetRegisteredRawInputDevices returned incorrect raw input device registration\n"); + + device.dwFlags = RIDEV_REMOVE; + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + ok(ret, "RegisterRawInputDevices failed to unsubscribe from mouse raw input\n"); + + /* Verify that no registrations are present */ + count = 0xdeadbeef; + ret2 = pGetRegisteredRawInputDevices(NULL, &count, sizeof(RAWINPUTDEVICE)); + ok(ret2 == 0, "GetRegisteredRawInputDevices returned wrong value: " + "expected 0, got %u\n", ret2); + todo_wine ok(count == 0, "GetRegisteredRawInputDevices returned incorrect registration count: " + "expected 0, got %u\n", count); +} + START_TEST(input) { init_function_pointers(); @@ -1901,6 +1998,7 @@ START_TEST(input) test_get_raw_input_device_list(); test_get_raw_input_device_info_w(); test_get_raw_input_device_info_a(); + test_basic_get_registered_raw_input_devices(); if(pGetMouseMovePointsEx) test_GetMouseMovePointsEx(); -- 1.7.3.4