From f9de2fe383905303a8e2e5fda684dc409d366ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincas=20Mili=C5=ABnas?= Date: Mon, 11 Jul 2011 15:09:44 +0300 Subject: [PATCH 07/20] user32/tests: Added raw input device flag precondition tests (try 16) --- dlls/user32/tests/input.c | 136 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 136 insertions(+), 0 deletions(-) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index d737e99..64b81b8 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -2052,6 +2052,141 @@ static void test_basic_register_raw_input_devices(void) "expected 0, got %u\n", count); } +static void test_raw_input_device_flag_preconditions(void) +{ + RAWINPUTDEVICE device; + BOOL ret; + UINT ret2, count; + DWORD error; + + if (!pGetRegisteredRawInputDevices || !pRegisterRawInputDevices) + { + win_skip("GetRegisteredRawInputDevices and RegisterRawInputDevices are not available\n"); + return; + } + + /* Test that RIDEV_REMOVE flags requires hwndTarget to be null*/ + device.usUsagePage = HID_USAGE_PAGE_GENERIC; + device.usUsage = HID_USAGE_GENERIC_MOUSE; + device.dwFlags = RIDEV_REMOVE; + device.hwndTarget = (HWND)-1; + SetLastError(0xdeadbeef); + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Test that RIDEV_PAGEONLY requires usUsage to be 0 */ + device.usUsage = 0xFF; + device.dwFlags = RIDEV_PAGEONLY; + device.hwndTarget = NULL; + SetLastError(0xdeadbeef); + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Test that RIDEV_EXCLUDE requires usUsage to be non-0 */ + device.usUsage = 0; + device.dwFlags = RIDEV_EXCLUDE; + device.hwndTarget = NULL; + SetLastError(0xdeadbeef); + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Test that RIDEV_NOLEGACY cannot be used with other device then mouse and keyboard */ + device.usUsage = 0xFF; + device.dwFlags = RIDEV_NOLEGACY; + device.hwndTarget = NULL; + SetLastError(0xdeadbeef); + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Test that RIDEV_INPUTSINK requires hwndTarget to be non-null */ + device.usUsage = HID_USAGE_GENERIC_MOUSE; + device.dwFlags = RIDEV_INPUTSINK; + device.hwndTarget = NULL; + SetLastError(0xdeadbeef); + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Test that RIDEV_CAPTUREMOUSE must be combined with RIDEV_NOLEGACY + Since RIDEV_CAPTUREMOUSE == RIDEV_NOHOTKEYS, scope it for the mouse device */ + device.usUsage = HID_USAGE_GENERIC_MOUSE; + device.dwFlags = RIDEV_CAPTUREMOUSE; + device.hwndTarget = NULL; + SetLastError(0xdeadbeef); + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_FLAGS, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Test that RIDEV_APPKEYS must be combined with RIDEV_NOLEGACY */ + device.usUsage = HID_USAGE_GENERIC_KEYBOARD; + device.dwFlags = RIDEV_APPKEYS; + device.hwndTarget = NULL; + SetLastError(0xdeadbeef); + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_FLAGS, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Test that RIDEV_APPKEYS cannot be used with mouse */ + device.usUsage = HID_USAGE_GENERIC_MOUSE; + device.dwFlags = RIDEV_NOLEGACY | RIDEV_APPKEYS; + device.hwndTarget = NULL; + SetLastError(0xdeadbeef); + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_FLAGS, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Test that RIDEV_NOHOTKEYS cannot be used with mouse */ + device.usUsage = HID_USAGE_GENERIC_MOUSE; + device.dwFlags = RIDEV_NOHOTKEYS; + device.hwndTarget = NULL; + SetLastError(0xdeadbeef); + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_FLAGS, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Test reaction to an invalid flag */ + SetLastError(0xdeadbeef); + device.usUsagePage = HID_USAGE_PAGE_GENERIC; + device.usUsage = HID_USAGE_GENERIC_MOUSE; + device.dwFlags = 0x80000000; + device.hwndTarget = NULL; + ret = pRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE)); + error = GetLastError(); + todo_wine ok(!ret, "RegisterRawInputDevices should have failed\n"); + todo_wine ok(error == ERROR_INVALID_FLAGS, "RegisterRawInputDevices returned " + "wrong error code: %u\n", error); + + /* Assert 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(); @@ -2077,6 +2212,7 @@ START_TEST(input) test_get_raw_input_device_info_a(); test_basic_get_registered_raw_input_devices(); test_basic_register_raw_input_devices(); + test_raw_input_device_flag_preconditions(); if(pGetMouseMovePointsEx) test_GetMouseMovePointsEx(); -- 1.7.3.4