From b8a3fdf360eea3c7a39179af6c543adf379cde48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincas=20Mili=C5=ABnas?= Date: Tue, 5 Jul 2011 22:49:11 +0300 Subject: [PATCH 02/20] user32/tests: Added GetRawInputDeviceList tests (try 16) --- dlls/user32/tests/input.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index b70ce57..84590b5 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 *pGetRawInputDeviceList) (PRAWINPUTDEVICELIST, PUINT, UINT); #define MAXKEYEVENTS 12 #define MAXKEYMESSAGES MAXKEYEVENTS /* assuming a key event generates one @@ -162,6 +163,7 @@ static void init_function_pointers(void) GET_PROC(SendInput) GET_PROC(DefRawInputProc) GET_PROC(GetMouseMovePointsEx) + GET_PROC(GetRawInputDeviceList) #undef GET_PROC } @@ -1628,6 +1630,54 @@ static void test_def_raw_input_proc(void) ok(ret == S_OK, "DefRawInputProc returned wrong value: expected S_OK, got %lu\n", ret); } +static void test_get_raw_input_device_list(void) +{ + RAWINPUTDEVICELIST *device_list; + UINT ret, count, count2; + DWORD error; + + if (!pGetRawInputDeviceList) + { + win_skip("GetRawInputDeviceList is not available\n"); + return; + } + + count = 0; + ret = pGetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)); + ok(ret == 0, "GetRawInputDeviceList returned wrong value: " + "expected 0, got %u\n", ret); + todo_wine ok(count >= 1, "GetRawInputDeviceList returned incorrect number of " + "raw input device available: expected x >= 1, got %u\n", count); + + device_list = HeapAlloc(GetProcessHeap(), 0, count * sizeof(RAWINPUTDEVICELIST)); + memset(device_list, 0xFF, count * sizeof(RAWINPUTDEVICELIST)); + + SetLastError(0xdeadbeef); + count2 = 0; + ret = pGetRawInputDeviceList(device_list, &count2, sizeof(RAWINPUTDEVICELIST)); + error = GetLastError(); + todo_wine ok(ret == (UINT)-1, "GetRawInputDeviceList returned wrong value: " + "expected (UINT)-1, got %u\n", ret); + todo_wine ok(error == ERROR_INSUFFICIENT_BUFFER, "GetRawInputDeviceList returned " + "wrong error code: %u\n", error); + ok(count2 == count, "GetRawInputDeviceList returned incorrect number of devices: " + "expected %u, got %u\n", count, count2); + + count2 = count; + ret = pGetRawInputDeviceList(device_list, &count2, sizeof(RAWINPUTDEVICELIST)); + ok(ret == count, "GetRawInputDeviceList returned wrong value: " + "expected %u, got %u\n", count, ret); + ok(count2 == count, "GetRawInputDeviceList returned incorrect number of devices: " + "expected %u, got %u\n", count, count2); + + todo_wine ok(device_list[0].hDevice != NULL, "First raw input device doesn't have " + "a non-null handle\n"); + ok(device_list[0].dwType == RIM_TYPEMOUSE || device_list[0].dwType == RIM_TYPEKEYBOARD, + "First raw input device wasn't a mouse or a keyboard"); + + HeapFree(GetProcessHeap(), 0, device_list); +} + START_TEST(input) { init_function_pointers(); @@ -1648,6 +1698,7 @@ START_TEST(input) test_keyboard_layout_name(); test_def_raw_input_proc(); + test_get_raw_input_device_list(); if(pGetMouseMovePointsEx) test_GetMouseMovePointsEx(); -- 1.7.3.4