[PATCH 11/11] dinput8/tests: Add some HID joystick IDirectInputDevice8_CreateEffect tests.

Rémi Bernon rbernon at codeweavers.com
Thu Sep 30 03:37:41 CDT 2021


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/dinput/device.c     |  1 +
 dlls/dinput8/tests/hid.c | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 11496640049..d869f439101 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -1578,6 +1578,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface
 {
     IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
     FIXME("(%p)->(%s,%p,%p,%p): stub!\n", This, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
+    if (!ppdef) return E_POINTER;
 
     FIXME("not available in the generic implementation\n");
     *ppdef = NULL;
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index f93c2b471f4..1ab6e645947 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -3682,6 +3682,7 @@ static void test_simple_joystick(void)
     DIEFFECTINFOW effectinfo = {0};
     DIDATAFORMAT dataformat = {0};
     IDirectInputDevice8W *device;
+    IDirectInputEffect *effect;
     DIEFFESCAPE escape = {0};
     DIDEVCAPS caps = {0};
     IDirectInput8W *di;
@@ -4673,9 +4674,21 @@ static void test_simple_joystick(void)
     todo_wine
     ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_SendDeviceData returned %#x\n", hr );
 
+    hr = IDirectInputDevice8_CreateEffect( device, &GUID_Sine, NULL, NULL, NULL );
+    ok( hr == E_POINTER, "IDirectInputDevice8_CreateEffect returned %#x\n", hr );
+    hr = IDirectInputDevice8_CreateEffect( device, NULL, NULL, &effect, NULL );
+    ok( hr == DIERR_UNSUPPORTED, "IDirectInputDevice8_CreateEffect returned %#x\n", hr );
+    hr = IDirectInputDevice8_CreateEffect( device, &GUID_NULL, NULL, &effect, NULL );
+    ok( hr == DIERR_UNSUPPORTED, "IDirectInputDevice8_CreateEffect returned %#x\n", hr );
+    hr = IDirectInputDevice8_CreateEffect( device, &GUID_Sine, NULL, &effect, NULL );
+    ok( hr == DIERR_UNSUPPORTED, "IDirectInputDevice8_CreateEffect returned %#x\n", hr );
+
     hr = IDirectInputDevice8_Unacquire( device );
     ok( hr == DI_OK, "IDirectInputDevice8_Unacquire returned: %#x\n", hr );
 
+    hr = IDirectInputDevice8_CreateEffect( device, &GUID_Sine, NULL, &effect, NULL );
+    ok( hr == DIERR_UNSUPPORTED, "IDirectInputDevice8_CreateEffect returned %#x\n", hr );
+
     hr = IDirectInputDevice8_Escape( device, NULL );
     todo_wine
     ok( hr == E_POINTER, "IDirectInputDevice8_Escape returned: %#x\n", hr );
@@ -5051,6 +5064,30 @@ static BOOL test_device_types(void)
     return success;
 }
 
+static void test_periodic_effect( IDirectInputDevice8W *device, HANDLE file )
+{
+    IDirectInputEffect *effect;
+    HRESULT hr;
+    ULONG ref;
+
+    hr = IDirectInputDevice8_CreateEffect( device, &GUID_Sine, NULL, NULL, NULL );
+    ok( hr == E_POINTER, "IDirectInputDevice8_CreateEffect returned %#x\n", hr );
+    hr = IDirectInputDevice8_CreateEffect( device, NULL, NULL, &effect, NULL );
+    todo_wine
+    ok( hr == E_POINTER, "IDirectInputDevice8_CreateEffect returned %#x\n", hr );
+    hr = IDirectInputDevice8_CreateEffect( device, &GUID_NULL, NULL, &effect, NULL );
+    todo_wine
+    ok( hr == DIERR_DEVICENOTREG, "IDirectInputDevice8_CreateEffect returned %#x\n", hr );
+
+    hr = IDirectInputDevice8_CreateEffect( device, &GUID_Sine, NULL, &effect, NULL );
+    todo_wine
+    ok( hr == DI_OK, "IDirectInputDevice8_CreateEffect returned %#x\n", hr );
+    if (hr != DI_OK) return;
+
+    ref = IDirectInputEffect_Release( effect );
+    ok( ref == 0, "IDirectInputDeviceW_Release returned %d\n", ref );
+}
+
 static void test_force_feedback_joystick( void )
 {
 #include "psh_hid_macros.h"
@@ -5797,6 +5834,8 @@ static void test_force_feedback_joystick( void )
     todo_wine
     ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_SendDeviceData returned %#x\n", hr );
 
+    test_periodic_effect( device, file );
+
     set_hid_expect( file, &expect_dc_reset, sizeof(expect_dc_reset) );
     hr = IDirectInputDevice8_Unacquire( device );
     ok( hr == DI_OK, "IDirectInputDevice8_Unacquire returned: %#x\n", hr );
-- 
2.33.0




More information about the wine-devel mailing list