[PATCH 5/6] dinput/tests: Run mouse info tests for every dinput version.
Rémi Bernon
wine at gitlab.winehq.org
Wed Jun 8 08:59:56 CDT 2022
From: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/dinput/tests/device.c | 82 +++++++++++++++++++++++++++-------
dlls/dinput/tests/mouse.c | 90 --------------------------------------
2 files changed, 65 insertions(+), 107 deletions(-)
diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c
index 6bb1111b2ce..84a993f958d 100644
--- a/dlls/dinput/tests/device.c
+++ b/dlls/dinput/tests/device.c
@@ -98,6 +98,30 @@ static void flush_events(void)
}
}
+static HRESULT create_dinput_device( DWORD version, const GUID *guid, IDirectInputDevice8W **device )
+{
+ IDirectInputW *dinput;
+ HRESULT hr;
+ ULONG ref;
+
+ if (version < 0x800) hr = DirectInputCreateW( instance, version, &dinput, NULL );
+ else hr = DirectInput8Create( instance, version, &IID_IDirectInput8W, (void **)&dinput, NULL );
+ if (FAILED(hr))
+ {
+ win_skip( "Failed to instantiate a IDirectInput instance, hr %#lx\n", hr );
+ return hr;
+ }
+
+ hr = IDirectInput_CreateDevice( dinput, guid, (IDirectInputDeviceW **)device, NULL );
+ ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr );
+
+ ref = IDirectInput_Release( dinput );
+ todo_wine
+ ok( ref == 0, "Release returned %ld\n", ref );
+
+ return DI_OK;
+}
+
static HRESULT direct_input_create( DWORD version, IDirectInputA **out )
{
HRESULT hr;
@@ -1445,13 +1469,14 @@ static BOOL CALLBACK check_object_count( const DIDEVICEOBJECTINSTANCEW *obj, voi
return DIENUM_CONTINUE;
}
-static void test_mouse_info(void)
+static void test_sys_mouse( DWORD version )
{
- static const DIDEVCAPS expect_caps =
+ const DIDEVCAPS expect_caps =
{
.dwSize = sizeof(DIDEVCAPS),
.dwFlags = DIDC_ATTACHED | DIDC_EMULATED,
- .dwDevType = (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE,
+ .dwDevType = version < 0x800 ? (DIDEVTYPEMOUSE_UNKNOWN << 8) | DIDEVTYPE_MOUSE
+ : (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE,
.dwAxes = 3,
.dwButtons = 5,
};
@@ -1460,7 +1485,8 @@ static void test_mouse_info(void)
.dwSize = sizeof(DIDEVICEINSTANCEW),
.guidInstance = GUID_SysMouse,
.guidProduct = GUID_SysMouse,
- .dwDevType = (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE,
+ .dwDevType = version < 0x800 ? (DIDEVTYPEMOUSE_UNKNOWN << 8) | DIDEVTYPE_MOUSE
+ : (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE,
.tszInstanceName = L"Mouse",
.tszProductName = L"Mouse",
.guidFFDriver = GUID_NULL,
@@ -1573,21 +1599,19 @@ static void test_mouse_info(void)
};
DIDEVICEOBJECTINSTANCEW objinst = {0};
DIDEVICEINSTANCEW devinst = {0};
+ BOOL old_localized = localized;
IDirectInputDevice8W *device;
DIDEVCAPS caps = {0};
- IDirectInput8W *di;
ULONG res, ref;
HRESULT hr;
GUID guid;
- localized = LOWORD( GetKeyboardLayout( 0 ) ) != 0x0409;
+ if (FAILED(create_dinput_device( version, &GUID_SysMouse, &device ))) return;
- hr = DirectInput8Create( instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void **)&di, NULL );
- ok( hr == DI_OK, "DirectInput8Create returned %#lx\n", hr );
- hr = IDirectInput8_CreateDevice( di, &GUID_SysMouse, &device, NULL );
- ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr );
+ localized = LOWORD( GetKeyboardLayout( 0 ) ) != 0x0409;
+ winetest_push_context( "%#lx", version );
- hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &GUID_SysMouseEm );
+ hr = IDirectInputDevice8_Initialize( device, instance, version, &GUID_SysMouseEm );
ok( hr == DI_OK, "Initialize returned %#lx\n", hr );
guid = GUID_SysMouseEm;
memset( &devinst, 0, sizeof(devinst) );
@@ -1597,7 +1621,7 @@ static void test_mouse_info(void)
ok( IsEqualGUID( &guid, &GUID_SysMouseEm ), "got %s expected %s\n", debugstr_guid( &guid ),
debugstr_guid( &GUID_SysMouseEm ) );
- hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &GUID_SysMouse );
+ hr = IDirectInputDevice8_Initialize( device, instance, version, &GUID_SysMouse );
ok( hr == DI_OK, "Initialize returned %#lx\n", hr );
memset( &devinst, 0, sizeof(devinst) );
@@ -1615,6 +1639,16 @@ static void test_mouse_info(void)
check_member( devinst, expect_devinst, "%04x", wUsagePage );
check_member( devinst, expect_devinst, "%04x", wUsage );
+ devinst.dwSize = sizeof(DIDEVICEINSTANCE_DX3W);
+ hr = IDirectInputDevice8_GetDeviceInfo( device, &devinst );
+ ok( hr == DI_OK, "GetDeviceInfo returned %#lx\n", hr );
+ check_member_guid( devinst, expect_devinst, guidInstance );
+ check_member_guid( devinst, expect_devinst, guidProduct );
+ todo_wine
+ check_member( devinst, expect_devinst, "%#lx", dwDevType );
+ if (!localized) check_member_wstr( devinst, expect_devinst, tszInstanceName );
+ if (!localized) todo_wine check_member_wstr( devinst, expect_devinst, tszProductName );
+
caps.dwSize = sizeof(DIDEVCAPS);
hr = IDirectInputDevice8_GetCapabilities( device, &caps );
ok( hr == DI_OK, "GetCapabilities returned %#lx\n", hr );
@@ -1689,8 +1723,13 @@ static void test_mouse_info(void)
hr = IDirectInputDevice8_GetProperty( device, DIPROP_TYPENAME, &prop_string.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_TYPENAME returned %#lx\n", hr );
hr = IDirectInputDevice8_GetProperty( device, DIPROP_USERNAME, &prop_string.diph );
- ok( hr == S_FALSE, "GetProperty DIPROP_USERNAME returned %#lx\n", hr );
- ok( !wcscmp( prop_string.wsz, L"" ), "got user %s\n", debugstr_w(prop_string.wsz) );
+ if (version < 0x0800)
+ ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_USERNAME returned %#lx\n", hr );
+ else
+ {
+ ok( hr == DI_NOEFFECT, "GetProperty DIPROP_USERNAME returned %#lx\n", hr );
+ ok( !wcscmp( prop_string.wsz, L"" ), "got user %s\n", debugstr_w(prop_string.wsz) );
+ }
hr = IDirectInputDevice8_GetProperty( device, DIPROP_JOYSTICKID, &prop_dword.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_VIDPID returned %#lx\n", hr );
@@ -1711,6 +1750,12 @@ static void test_mouse_info(void)
hr = IDirectInputDevice8_GetProperty( device, DIPROP_GRANULARITY, &prop_dword.diph );
ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_GRANULARITY returned %#lx\n", hr );
+ prop_dword.diph.dwHow = DIPH_BYID;
+ prop_dword.diph.dwObj = DIDFT_MAKEINSTANCE(1) | DIDFT_RELAXIS;
+ prop_dword.dwData = 0xdeadbeef;
+ hr = IDirectInputDevice8_GetProperty( device, DIPROP_GRANULARITY, &prop_dword.diph );
+ ok( hr == DI_OK, "GetProperty DIPROP_GRANULARITY returned %#lx\n", hr );
+ ok( prop_dword.dwData == 1, "got %ld expected 1\n", prop_dword.dwData );
prop_dword.diph.dwHow = DIPH_BYOFFSET;
prop_dword.diph.dwObj = DIMOFS_X;
prop_dword.dwData = 0xdeadbeef;
@@ -1810,8 +1855,8 @@ static void test_mouse_info(void)
ref = IDirectInputDevice8_Release( device );
ok( ref == 0, "Release returned %ld\n", ref );
- ref = IDirectInput8_Release( di );
- ok( ref == 0, "Release returned %ld\n", ref );
+ winetest_pop_context();
+ localized = old_localized;
}
static void test_keyboard_info(void)
@@ -2160,7 +2205,10 @@ START_TEST(device)
test_overlapped_format( 0x700 );
test_overlapped_format( 0x800 );
- test_mouse_info();
+ test_sys_mouse( 0x500 );
+ test_sys_mouse( 0x700 );
+ test_sys_mouse( 0x800 );
+
test_keyboard_info();
test_action_mapping();
test_save_settings();
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c
index 2d92fe2b14c..2079c5e1408 100644
--- a/dlls/dinput/tests/mouse.c
+++ b/dlls/dinput/tests/mouse.c
@@ -195,99 +195,11 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd)
hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0);
ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt);
- /* Check for granularity property using BYOFFSET */
- memset(&di_op, 0, sizeof(di_op));
- di_op.diph.dwHow = DIPH_BYOFFSET;
- di_op.diph.dwObj = DIMOFS_Y;
- di_op.diph.dwSize = sizeof(DIPROPDWORD);
- di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph);
- /* Granularity of Y axis should be 1! */
- ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %#lx, dwData: %lu but should be 1.\n", hr, di_op.dwData);
-
- /* Check for granularity property using BYID */
- memset(&di_op, 0, sizeof(di_op));
- di_op.diph.dwHow = DIPH_BYID;
- /* WINE_MOUSE_Y_AXIS_INSTANCE := 1 */
- di_op.diph.dwObj = (DIDFT_MAKEINSTANCE(1) | DIDFT_RELAXIS);
- di_op.diph.dwSize = sizeof(DIPROPDWORD);
- di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph);
- /* Granularity of Y axis should be 1! */
- ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %#lx, dwData: %lu but should be 1.\n", hr, di_op.dwData);
-
- memset(&di_op, 0, sizeof(di_op));
- di_op.diph.dwSize = sizeof(DIPROPDWORD);
- di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER);
- di_op.diph.dwHow = DIPH_DEVICE;
- di_op.diph.dwObj = 0;
- hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_VIDPID, &di_op.diph);
- ok(hr == DIERR_UNSUPPORTED, "got %#lx\n", hr);
-
IUnknown_Release(pMouse);
DestroyWindow( hwnd2 );
}
-static void test_GetDeviceInfo(IDirectInputA *pDI)
-{
- HRESULT hr;
- IDirectInputDeviceA *pMouse = NULL;
- DIDEVICEINSTANCEA instA;
- DIDEVICEINSTANCE_DX3A inst3A;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- instA.dwSize = sizeof(instA);
- hr = IDirectInputDevice_GetDeviceInfo(pMouse, &instA);
- ok(SUCCEEDED(hr), "got %#lx\n", hr);
-
- inst3A.dwSize = sizeof(inst3A);
- hr = IDirectInputDevice_GetDeviceInfo(pMouse, (DIDEVICEINSTANCEA *)&inst3A);
- ok(SUCCEEDED(hr), "got %#lx\n", hr);
-
- ok(instA.dwSize != inst3A.dwSize, "got %lu, %lu\n", instA.dwSize, inst3A.dwSize);
- ok(IsEqualGUID(&instA.guidInstance, &inst3A.guidInstance), "got %s, %s\n",
- wine_dbgstr_guid(&instA.guidInstance), wine_dbgstr_guid(&inst3A.guidInstance) );
- ok(IsEqualGUID(&instA.guidProduct, &inst3A.guidProduct), "got %s, %s\n",
- wine_dbgstr_guid(&instA.guidProduct), wine_dbgstr_guid(&inst3A.guidProduct) );
- ok(instA.dwDevType == inst3A.dwDevType, "got %lu, %lu\n", instA.dwDevType, inst3A.dwDevType);
-
- IUnknown_Release(pMouse);
-}
-
-static BOOL CALLBACK EnumAxes(const DIDEVICEOBJECTINSTANCEA *pdidoi, void *pContext)
-{
- if (IsEqualIID(&pdidoi->guidType, &GUID_XAxis) ||
- IsEqualIID(&pdidoi->guidType, &GUID_YAxis) ||
- IsEqualIID(&pdidoi->guidType, &GUID_ZAxis))
- {
- ok(pdidoi->dwFlags & DIDOI_ASPECTPOSITION, "Missing DIDOI_ASPECTPOSITION, flags are %#lx\n",
- pdidoi->dwFlags);
- }
- else
- ok(pdidoi->dwFlags == 0, "Flags are %#lx\n", pdidoi->dwFlags);
-
- return DIENUM_CONTINUE;
-}
-
-static void test_mouse_EnumObjects(IDirectInputA *pDI)
-{
- HRESULT hr;
- IDirectInputDeviceA *pMouse = NULL;
-
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL);
- ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
- if (FAILED(hr)) return;
-
- hr = IDirectInputDevice_EnumObjects(pMouse, EnumAxes, NULL, DIDFT_ALL);
- ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %#lx\n", hr);
-
- IUnknown_Release(pMouse);
-}
-
static void mouse_tests(void)
{
HRESULT hr;
@@ -313,8 +225,6 @@ static void mouse_tests(void)
test_set_coop(pDI, hwnd);
test_acquire(pDI, hwnd);
- test_GetDeviceInfo(pDI);
- test_mouse_EnumObjects(pDI);
DestroyWindow(hwnd);
}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/208
More information about the wine-devel
mailing list