There's already some in dinput, but this is a more appropriate location.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/user32/tests/input.c | 79 +++++++++++++++++++++++++++++++++++++--
1 file changed, 75 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index d4b0e34fa91..92457af01cd 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -1766,11 +1766,15 @@ static void test_GetRawInputData(void)
static void test_RegisterRawInputDevices(void)
{
HWND hwnd;
- RAWINPUTDEVICE raw_devices[1];
+ RAWINPUTDEVICE raw_devices[2];
+ UINT count, raw_devices_count;
BOOL res;
+ memset(raw_devices, 0, sizeof(raw_devices));
raw_devices[0].usUsagePage = 0x01;
raw_devices[0].usUsage = 0x05;
+ raw_devices[1].usUsagePage = 0x01;
+ raw_devices[1].usUsage = 0x04;
hwnd = CreateWindowExA(WS_EX_TOPMOST, "static", "dinput", WS_POPUP | WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, NULL, NULL);
ok(hwnd != NULL, "CreateWindowExA failed\n");
@@ -1780,9 +1784,6 @@ static void test_RegisterRawInputDevices(void)
ok(res == FALSE, "RegisterRawInputDevices succeeded\n");
- raw_devices[0].dwFlags = 0;
- raw_devices[0].hwndTarget = 0;
-
SetLastError(0xdeadbeef);
res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), 0);
ok(res == FALSE, "RegisterRawInputDevices succeeded\n");
@@ -1793,10 +1794,76 @@ static void test_RegisterRawInputDevices(void)
ok(res == TRUE, "RegisterRawInputDevices failed\n");
ok(GetLastError() == 0xdeadbeef, "RegisterRawInputDevices returned %08x\n", GetLastError());
+ SetLastError(0xdeadbeef);
+ count = GetRegisteredRawInputDevices(NULL, NULL, 0);
+ todo_wine
+ ok(count == ~0U, "GetRegisteredRawInputDevices returned %u\n", count);
+ todo_wine
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRegisteredRawInputDevices unexpected error %08x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ raw_devices_count = 0;
+ count = GetRegisteredRawInputDevices(NULL, &raw_devices_count, 0);
+ todo_wine
+ ok(count == ~0U, "GetRegisteredRawInputDevices returned %u\n", count);
+ ok(raw_devices_count == 0, "Unexpected registered devices count: %u\n", raw_devices_count);
+ todo_wine
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRegisteredRawInputDevices unexpected error %08x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ raw_devices_count = 0;
+ count = GetRegisteredRawInputDevices(NULL, &raw_devices_count, sizeof(RAWINPUTDEVICE));
+ ok(count == 0, "GetRegisteredRawInputDevices returned %u\n", count);
+ todo_wine
+ ok(raw_devices_count == 2, "Unexpected registered devices count: %u\n", raw_devices_count);
+ ok(GetLastError() == 0xdeadbeef, "GetRegisteredRawInputDevices unexpected error %08x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ raw_devices_count = 0;
+ count = GetRegisteredRawInputDevices(raw_devices, &raw_devices_count, sizeof(RAWINPUTDEVICE));
+ if (broken(count == 0) /* depends on windows versions */)
+ win_skip("Ignoring GetRegisteredRawInputDevices success\n");
+ else
+ {
+ todo_wine
+ ok(count == ~0U, "GetRegisteredRawInputDevices returned %u\n", count);
+ ok(raw_devices_count == 0, "Unexpected registered devices count: %u\n", raw_devices_count);
+ todo_wine
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetRegisteredRawInputDevices unexpected error %08x\n", GetLastError());
+ }
+
+ SetLastError(0xdeadbeef);
+ raw_devices_count = 1;
+ count = GetRegisteredRawInputDevices(raw_devices, &raw_devices_count, sizeof(RAWINPUTDEVICE));
+ todo_wine
+ ok(count == ~0U, "GetRegisteredRawInputDevices returned %u\n", count);
+ todo_wine
+ ok(raw_devices_count == 2, "Unexpected registered devices count: %u\n", raw_devices_count);
+ todo_wine
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetRegisteredRawInputDevices unexpected error %08x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ memset(raw_devices, 0, sizeof(raw_devices));
+ raw_devices_count = ARRAY_SIZE(raw_devices);
+ count = GetRegisteredRawInputDevices(raw_devices, &raw_devices_count, sizeof(RAWINPUTDEVICE));
+ todo_wine
+ ok(count == 2, "GetRegisteredRawInputDevices returned %u\n", count);
+ ok(raw_devices_count == 2, "Unexpected registered devices count: %u\n", raw_devices_count);
+ ok(GetLastError() == 0xdeadbeef, "GetRegisteredRawInputDevices unexpected error %08x\n", GetLastError());
+ todo_wine
+ ok(raw_devices[0].usUsagePage == 0x01, "Unexpected usage page: %x\n", raw_devices[0].usUsagePage);
+ todo_wine
+ ok(raw_devices[0].usUsage == 0x04, "Unexpected usage: %x\n", raw_devices[0].usUsage);
+ todo_wine
+ ok(raw_devices[1].usUsagePage == 0x01, "Unexpected usage page: %x\n", raw_devices[1].usUsagePage);
+ todo_wine
+ ok(raw_devices[1].usUsage == 0x05, "Unexpected usage: %x\n", raw_devices[1].usUsage);
/* RIDEV_REMOVE requires hwndTarget == NULL */
raw_devices[0].dwFlags = RIDEV_REMOVE;
raw_devices[0].hwndTarget = hwnd;
+ raw_devices[1].dwFlags = RIDEV_REMOVE;
+ raw_devices[1].hwndTarget = hwnd;
SetLastError(0xdeadbeef);
res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
@@ -1804,6 +1871,7 @@ static void test_RegisterRawInputDevices(void)
ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError());
raw_devices[0].hwndTarget = 0;
+ raw_devices[1].hwndTarget = 0;
SetLastError(0xdeadbeef);
res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
@@ -1814,6 +1882,8 @@ static void test_RegisterRawInputDevices(void)
/* RIDEV_INPUTSINK requires hwndTarget != NULL */
raw_devices[0].dwFlags = RIDEV_INPUTSINK;
raw_devices[0].hwndTarget = 0;
+ raw_devices[1].dwFlags = RIDEV_INPUTSINK;
+ raw_devices[1].hwndTarget = 0;
SetLastError(0xdeadbeef);
res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
@@ -1821,6 +1891,7 @@ static void test_RegisterRawInputDevices(void)
ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError());
raw_devices[0].hwndTarget = hwnd;
+ raw_devices[1].hwndTarget = hwnd;
SetLastError(0xdeadbeef);
res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
--
2.28.0