Rémi Bernon : dinput8/tests: Add some IDirectInput(8)_EnumDevices tests.
Alexandre Julliard
julliard at winehq.org
Tue Nov 16 16:32:26 CST 2021
Module: wine
Branch: master
Commit: e14254ee2be5e5f2b0147b3bab7a8fe3c02d26c4
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e14254ee2be5e5f2b0147b3bab7a8fe3c02d26c4
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Tue Nov 16 08:23:38 2021 +0100
dinput8/tests: Add some IDirectInput(8)_EnumDevices tests.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput8/tests/hid.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 110 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index d553fa92ef7..3c8492842e4 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -3453,6 +3453,13 @@ static BOOL CALLBACK check_created_effect_objects( IDirectInputEffect *effect, v
return DIENUM_CONTINUE;
}
+static BOOL CALLBACK enum_device_count( const DIDEVICEINSTANCEW *devinst, void *context )
+{
+ DWORD *count = context;
+ *count = *count + 1;
+ return DIENUM_CONTINUE;
+}
+
static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst, IDirectInputDevice8W **device )
{
DIPROPDWORD prop_dword =
@@ -3466,8 +3473,8 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst,
};
IDirectInput8W *di8;
IDirectInputW *di;
+ ULONG ref, count;
HRESULT hr;
- ULONG ref;
if (version >= 0x800)
{
@@ -3488,6 +3495,57 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst,
return DIERR_DEVICENOTREG;
}
+ hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_ALL, NULL, NULL, DIEDFL_ALLDEVICES );
+ ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
+ hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_ALL, enum_device_count, &count, 0xdeadbeef );
+ ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
+ hr = IDirectInput8_EnumDevices( di8, 0xdeadbeef, enum_device_count, &count, DIEDFL_ALLDEVICES );
+ ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
+
+ count = 0;
+ hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_ALL, enum_device_count, &count, DIEDFL_ALLDEVICES );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ ok( count == 3, "got count %u, expected 0\n", count );
+ count = 0;
+ hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_DEVICE, enum_device_count, &count, DIEDFL_ALLDEVICES );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ ok( count == 0, "got count %u, expected 0\n", count );
+ count = 0;
+ hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_POINTER, enum_device_count, &count,
+ DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ todo_wine
+ ok( count == 3, "got count %u, expected 3\n", count );
+ count = 0;
+ hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_KEYBOARD, enum_device_count, &count,
+ DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ todo_wine
+ ok( count == 3, "got count %u, expected 3\n", count );
+ count = 0;
+ hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_GAMECTRL, enum_device_count, &count,
+ DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ ok( count == 1, "got count %u, expected 1\n", count );
+
+ count = 0;
+ hr = IDirectInput8_EnumDevices( di8, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_ALLDEVICES );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ todo_wine
+ ok( count == 1, "got count %u, expected 1\n", count );
+
+ count = 0;
+ hr = IDirectInput8_EnumDevices( di8, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_FORCEFEEDBACK );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ if (IsEqualGUID( &devinst->guidFFDriver, &GUID_NULL )) ok( count == 0, "got count %u, expected 0\n", count );
+ else todo_wine ok( count == 1, "got count %u, expected 1\n", count );
+
+ count = 0;
+ hr = IDirectInput8_EnumDevices( di8, (devinst->dwDevType & 0xff) + 1, enum_device_count, &count, DIEDFL_ALLDEVICES );
+ if ((devinst->dwDevType & 0xff) != DI8DEVTYPE_SUPPLEMENTAL) ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ else ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
+ ok( count == 0, "got count %u, expected 0\n", count );
+
hr = IDirectInput8_CreateDevice( di8, &devinst->guidInstance, NULL, NULL );
ok( hr == E_POINTER, "CreateDevice returned %#x\n", hr );
hr = IDirectInput8_CreateDevice( di8, NULL, device, NULL );
@@ -3535,6 +3593,57 @@ static HRESULT create_dinput_device( DWORD version, DIDEVICEINSTANCEW *devinst,
return DIERR_DEVICENOTREG;
}
+ hr = IDirectInput_EnumDevices( di, 0, NULL, NULL, DIEDFL_ALLDEVICES );
+ ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
+ hr = IDirectInput_EnumDevices( di, 0, enum_device_count, &count, 0xdeadbeef );
+ ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
+ hr = IDirectInput_EnumDevices( di, 0xdeadbeef, enum_device_count, &count, DIEDFL_ALLDEVICES );
+ ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
+ hr = IDirectInput_EnumDevices( di, 0, enum_device_count, &count, DIEDFL_INCLUDEHIDDEN );
+ todo_wine
+ ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
+
+ count = 0;
+ hr = IDirectInput_EnumDevices( di, 0, enum_device_count, &count, DIEDFL_ALLDEVICES );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ ok( count == 3, "got count %u, expected 0\n", count );
+ count = 0;
+ hr = IDirectInput_EnumDevices( di, DIDEVTYPE_DEVICE, enum_device_count, &count, DIEDFL_ALLDEVICES );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ ok( count == 0, "got count %u, expected 0\n", count );
+ count = 0;
+ hr = IDirectInput_EnumDevices( di, DIDEVTYPE_MOUSE, enum_device_count, &count,
+ DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ todo_wine
+ ok( count == 3, "got count %u, expected 3\n", count );
+ count = 0;
+ hr = IDirectInput_EnumDevices( di, DIDEVTYPE_KEYBOARD, enum_device_count, &count,
+ DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ todo_wine
+ ok( count == 3, "got count %u, expected 3\n", count );
+ count = 0;
+ hr = IDirectInput_EnumDevices( di, DIDEVTYPE_JOYSTICK, enum_device_count, &count,
+ DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ ok( count == 1, "got count %u, expected 1\n", count );
+
+ count = 0;
+ hr = IDirectInput_EnumDevices( di, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_ALLDEVICES );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ ok( count == 1, "got count %u, expected 1\n", count );
+
+ count = 0;
+ hr = IDirectInput_EnumDevices( di, (devinst->dwDevType & 0xff), enum_device_count, &count, DIEDFL_FORCEFEEDBACK );
+ ok( hr == DI_OK, "EnumDevices returned: %#x\n", hr );
+ if (IsEqualGUID( &devinst->guidFFDriver, &GUID_NULL )) todo_wine ok( count == 0, "got count %u, expected 0\n", count );
+ else ok( count == 1, "got count %u, expected 1\n", count );
+
+ hr = IDirectInput_EnumDevices( di, 0x14, enum_device_count, &count, DIEDFL_ALLDEVICES );
+ todo_wine
+ ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned: %#x\n", hr );
+
hr = IDirectInput_CreateDevice( di, &expect_guid_product, (IDirectInputDeviceW **)device, NULL );
ok( hr == DI_OK, "CreateDevice returned %#x\n", hr );
More information about the wine-cvs
mailing list