Rémi Bernon : dinput8/tests: Add some HID joystick IDirectInput8_CreateDevice tests.

Alexandre Julliard julliard at winehq.org
Thu Sep 16 15:34:30 CDT 2021


Module: wine
Branch: master
Commit: 2972e9973ea4ca4a5f677149da4a3646ba97247e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2972e9973ea4ca4a5f677149da4a3646ba97247e

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Thu Sep 16 10:20:39 2021 +0200

dinput8/tests: Add some HID joystick IDirectInput8_CreateDevice tests.

Creating a device with the instance guid may get the wrong one if a
true controller is plugged in.

This is because driver_hid.dll runs in a different process from
winehid.sys, and so gets another set of rawinput handles.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput8/tests/hid.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index fbcb1e27afb..898dd7a6cdf 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -3443,6 +3443,26 @@ static void test_simple_joystick(void)
     check_member( devinst, expect_devinst, "%04x", wUsagePage );
     check_member( devinst, expect_devinst, "%04x", wUsage );
 
+    hr = IDirectInput8_CreateDevice( di, &devinst.guidInstance, NULL, NULL );
+    ok( hr == E_POINTER, "IDirectInput8_CreateDevice returned %#x\n", hr );
+    hr = IDirectInput8_CreateDevice( di, NULL, &device, NULL );
+    ok( hr == E_POINTER, "IDirectInput8_CreateDevice returned %#x\n", hr );
+    hr = IDirectInput8_CreateDevice( di, &GUID_NULL, &device, NULL );
+    ok( hr == DIERR_DEVICENOTREG, "IDirectInput8_CreateDevice returned %#x\n", hr );
+    hr = IDirectInput8_CreateDevice( di, &devinst.guidInstance, &device, NULL );
+    ok( hr == DI_OK, "IDirectInput8_CreateDevice returned %#x\n", hr );
+
+    prop_dword.dwData = 0xdeadbeef;
+    hr = IDirectInputDevice8_GetProperty( device, DIPROP_VIDPID, &prop_dword.diph );
+    ok( hr == DI_OK, "IDirectInputDevice8_GetProperty DIPROP_VIDPID returned %#x\n", hr );
+    /* Wine may get the wrong device here, because the test driver creates another instance of
+       hidclass.sys, and gets duplicate rawinput handles, which we use in the guidInstance */
+    todo_wine_if( prop_dword.dwData != EXPECT_VIDPID )
+    ok( prop_dword.dwData == EXPECT_VIDPID, "got %#x expected %#x\n", prop_dword.dwData, EXPECT_VIDPID );
+
+    ref = IDirectInputDevice8_Release( device );
+    ok( ref == 0, "IDirectInputDeviceW_Release returned %d\n", ref );
+
     hr = IDirectInput8_CreateDevice( di, &expect_guid_product, &device, NULL );
     ok( hr == DI_OK, "IDirectInput8_CreateDevice returned %#x\n", hr );
 




More information about the wine-cvs mailing list