[PATCH 1/6] dinput/tests: Use dinput_test_(init|exit) for all tests.
Rémi Bernon
wine at gitlab.winehq.org
Wed Jun 8 08:59:52 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 | 20 +++--
dlls/dinput/tests/device8.c | 38 ++-------
dlls/dinput/tests/dinput.c | 133 ++++++++++++++---------------
dlls/dinput/tests/dinput_test.h | 3 +-
dlls/dinput/tests/force_feedback.c | 4 +-
dlls/dinput/tests/hid.c | 51 ++++++-----
dlls/dinput/tests/hotplug.c | 4 +-
dlls/dinput/tests/joystick.c | 32 ++++---
dlls/dinput/tests/joystick8.c | 4 +-
dlls/dinput/tests/keyboard.c | 27 +++---
dlls/dinput/tests/mouse.c | 23 ++---
11 files changed, 158 insertions(+), 181 deletions(-)
diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c
index e907c5e8598..6e1e94ba9c2 100644
--- a/dlls/dinput/tests/device.c
+++ b/dlls/dinput/tests/device.c
@@ -18,14 +18,19 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS
-#include <windows.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <limits.h>
-#include "wine/test.h"
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "windef.h"
+#include "winbase.h"
+
+#define COBJMACROS
#include "dinput.h"
-#include <limits.h>
+#include "dinput_test.h"
static const DIOBJECTDATAFORMAT obj_data_format[] = {
{ &GUID_YAxis, 16, DIDFT_OPTIONAL|DIDFT_AXIS |DIDFT_MAKEINSTANCE(1), 0},
@@ -465,7 +470,6 @@ static void device_tests(void)
{
HRESULT hr;
IDirectInputA *pDI = NULL, *obj = NULL;
- HINSTANCE hInstance = GetModuleHandleW(NULL);
HWND hwnd;
struct enum_data data;
@@ -478,7 +482,7 @@ static void device_tests(void)
ok(SUCCEEDED(hr), "DirectInputCreateA() failed: %#lx\n", hr);
if (FAILED(hr)) return;
- hr = IDirectInput_Initialize(pDI, hInstance, DIRECTINPUT_VERSION);
+ hr = IDirectInput_Initialize(pDI, instance, DIRECTINPUT_VERSION);
ok(SUCCEEDED(hr), "Initialize() failed: %#lx\n", hr);
if (FAILED(hr)) return;
@@ -521,9 +525,9 @@ static void device_tests(void)
START_TEST(device)
{
- CoInitialize(NULL);
+ dinput_test_init();
device_tests();
- CoUninitialize();
+ dinput_test_exit();
}
diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c
index 2586736cb1d..70c3e516f17 100644
--- a/dlls/dinput/tests/device8.c
+++ b/dlls/dinput/tests/device8.c
@@ -31,10 +31,7 @@
#include "dinput.h"
#include "hidusage.h"
-#include "wine/test.h"
-
-static HINSTANCE instance;
-static BOOL localized; /* object names get translated */
+#include "dinput_test.h"
struct enum_data {
IDirectInput8A *pDI;
@@ -382,7 +379,6 @@ static void test_appdata_property_vs_map(struct enum_data *data)
static void test_action_mapping(void)
{
HRESULT hr;
- HINSTANCE hinst = GetModuleHandleA(NULL);
IDirectInput8A *pDI = NULL;
DIACTIONFORMATA af;
DIPROPSTRING dps;
@@ -400,7 +396,7 @@ static void test_action_mapping(void)
ok(SUCCEEDED(hr), "DirectInput8 Create failed: hr=%#lx\n", hr);
if (FAILED(hr)) return;
- hr = IDirectInput8_Initialize(pDI,hinst, DIRECTINPUT_VERSION);
+ hr = IDirectInput8_Initialize(pDI, instance, DIRECTINPUT_VERSION);
if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION)
{
win_skip("ActionMapping requires dinput8\n");
@@ -520,7 +516,6 @@ static void test_action_mapping(void)
static void test_save_settings(void)
{
HRESULT hr;
- HINSTANCE hinst = GetModuleHandleA(NULL);
IDirectInput8A *pDI = NULL;
DIACTIONFORMATA af;
IDirectInputDevice8A *pKey;
@@ -552,7 +547,7 @@ static void test_save_settings(void)
ok (SUCCEEDED(hr), "DirectInput8 Create failed: hr=%#lx\n", hr);
if (FAILED(hr)) return;
- hr = IDirectInput8_Initialize(pDI,hinst, DIRECTINPUT_VERSION);
+ hr = IDirectInput8_Initialize(pDI, instance, DIRECTINPUT_VERSION);
if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION)
{
win_skip("ActionMapping requires dinput8\n");
@@ -955,7 +950,6 @@ static void test_keyboard_events(void)
static void test_appdata_property(void)
{
HRESULT hr;
- HINSTANCE hinst = GetModuleHandleA(NULL);
IDirectInputDevice8A *di_keyboard;
IDirectInput8A *pDI = NULL;
HWND hwnd;
@@ -973,7 +967,7 @@ static void test_appdata_property(void)
ok(SUCCEEDED(hr), "DirectInput8 Create failed: hr=%#lx\n", hr);
if (FAILED(hr)) return;
- hr = IDirectInput8_Initialize(pDI,hinst, DIRECTINPUT_VERSION);
+ hr = IDirectInput8_Initialize(pDI, instance, DIRECTINPUT_VERSION);
if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION)
{
win_skip("DIPROP_APPDATA requires dinput8\n");
@@ -1054,24 +1048,6 @@ static void test_appdata_property(void)
IDirectInput_Release(pDI);
}
-#define check_member_( file, line, val, exp, fmt, member ) \
- ok_( file, line )((val).member == (exp).member, "got " #member " " fmt ", expected " fmt "\n", \
- (val).member, (exp).member)
-#define check_member( val, exp, fmt, member ) \
- check_member_( __FILE__, __LINE__, val, exp, fmt, member )
-
-#define check_member_guid_( file, line, val, exp, member ) \
- ok_( file, line )(IsEqualGUID( &(val).member, &(exp).member ), "got " #member " %s, expected %s\n", \
- debugstr_guid( &(val).member ), debugstr_guid( &(exp).member ))
-#define check_member_guid( val, exp, member ) \
- check_member_guid_( __FILE__, __LINE__, val, exp, member )
-
-#define check_member_wstr_( file, line, val, exp, member ) \
- ok_( file, line )(!wcscmp( (val).member, (exp).member ), "got " #member " %s, expected %s\n", \
- debugstr_w((val).member), debugstr_w((exp).member))
-#define check_member_wstr( val, exp, member ) \
- check_member_wstr_( __FILE__, __LINE__, val, exp, member )
-
struct check_objects_todos
{
BOOL offset;
@@ -1838,9 +1814,7 @@ static void test_keyboard_info(void)
START_TEST(device8)
{
- instance = GetModuleHandleW( NULL );
-
- CoInitialize(NULL);
+ dinput_test_init();
test_mouse_info();
test_keyboard_info();
@@ -1850,5 +1824,5 @@ START_TEST(device8)
test_keyboard_events();
test_appdata_property();
- CoUninitialize();
+ dinput_test_exit();
}
diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c
index 29d17ce378e..7df8f3ace85 100644
--- a/dlls/dinput/tests/dinput.c
+++ b/dlls/dinput/tests/dinput.c
@@ -18,19 +18,21 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS
-#include <windows.h>
-#include "objbase.h"
+#include <stdarg.h>
+#include <stddef.h>
-#include <initguid.h>
-#include <dinput.h>
-#include <dinputd.h>
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "windef.h"
+#include "winbase.h"
-#include "wine/test.h"
+#define COBJMACROS
+#include "dinput.h"
+#include "dinputd.h"
-HINSTANCE hInstance;
+#include "dinput_test.h"
-static HRESULT (WINAPI *pDirectInputCreateEx)(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN);
+#include "initguid.h"
static const DWORD dinput_versions[] =
{
@@ -64,8 +66,8 @@ static REFIID dinput8_interfaces[] =
static HRESULT direct_input_create( DWORD version, IDirectInputA **out )
{
HRESULT hr;
- if (version < 0x800) hr = DirectInputCreateA( hInstance, version, out, NULL );
- else hr = DirectInput8Create( hInstance, version, &IID_IDirectInput8A, (void **)out, NULL );
+ if (version < 0x800) hr = DirectInputCreateA( instance, version, out, NULL );
+ else hr = DirectInput8Create( instance, version, &IID_IDirectInput8A, (void **)out, NULL );
if (FAILED(hr)) win_skip( "Failed to instantiate a IDirectInput instance, hr %#lx\n", hr );
return hr;
}
@@ -236,19 +238,19 @@ static void test_DirectInputCreate( DWORD version )
{NULL, version - 1, NULL, &unknown, NULL, DIERR_INVALIDPARAM},
{NULL, version + 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER},
{NULL, version + 1, NULL, &unknown, NULL, DIERR_INVALIDPARAM},
- {hInstance, 0, NULL, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, 0, NULL, &unknown, NULL, DIERR_NOTINITIALIZED},
- {hInstance, version, NULL, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version - 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version - 1, NULL, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
- {hInstance, version + 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version + 1, NULL, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
+ {instance, 0, NULL, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, 0, NULL, &unknown, NULL, DIERR_NOTINITIALIZED},
+ {instance, version, NULL, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version - 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version - 1, NULL, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
+ {instance, version + 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version + 1, NULL, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
};
HRESULT hr;
int i;
unknown = (void *)0xdeadbeef;
- hr = DirectInputCreateW( hInstance, version, (IDirectInputW **)&unknown, &outer );
+ hr = DirectInputCreateW( instance, version, (IDirectInputW **)&unknown, &outer );
ok( hr == DI_OK, "DirectInputCreateW returned %#lx\n", hr );
ok( unknown == NULL, "got IUnknown %p\n", unknown );
@@ -294,21 +296,21 @@ static void test_DirectInputCreateEx( DWORD version )
{NULL, version + 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE},
{NULL, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
{NULL, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_INVALIDPARAM},
- {hInstance, 0, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE},
- {hInstance, 0, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE},
- {hInstance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOTINITIALIZED},
- {hInstance, version, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE},
- {hInstance, version, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE},
- {hInstance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version - 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE},
- {hInstance, version - 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE},
- {hInstance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version - 1, &IID_IDirectInputA, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
- {hInstance, version + 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE},
- {hInstance, version + 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE},
- {hInstance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version + 1, &IID_IDirectInputA, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
+ {instance, 0, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE},
+ {instance, 0, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE},
+ {instance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOTINITIALIZED},
+ {instance, version, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE},
+ {instance, version, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE},
+ {instance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version - 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE},
+ {instance, version - 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE},
+ {instance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version - 1, &IID_IDirectInputA, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
+ {instance, version + 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE},
+ {instance, version + 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE},
+ {instance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version + 1, &IID_IDirectInputA, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
};
HRESULT hr;
int i;
@@ -320,7 +322,7 @@ static void test_DirectInputCreateEx( DWORD version )
}
unknown = (void *)0xdeadbeef;
- hr = pDirectInputCreateEx( hInstance, version, &IID_IDirectInputW, (void **)&unknown, &outer );
+ hr = pDirectInputCreateEx( instance, version, &IID_IDirectInputW, (void **)&unknown, &outer );
ok( hr == DI_OK, "DirectInputCreateW returned %#lx\n", hr );
ok( unknown == NULL, "got IUnknown %p\n", unknown );
@@ -341,7 +343,7 @@ static void test_DirectInputCreateEx( DWORD version )
{
winetest_push_context( "%u", i );
unknown = (void *)0xdeadbeef;
- hr = pDirectInputCreateEx( hInstance, version, dinput8_interfaces[i], (void **)&unknown, NULL );
+ hr = pDirectInputCreateEx( instance, version, dinput8_interfaces[i], (void **)&unknown, NULL );
ok( hr == DIERR_NOINTERFACE, "DirectInputCreateEx returned %#lx\n", hr );
ok( unknown == (void *)0xdeadbeef, "got IUnknown %p\n", unknown );
winetest_pop_context();
@@ -351,7 +353,7 @@ static void test_DirectInputCreateEx( DWORD version )
{
winetest_push_context( "%u", i );
unknown = NULL;
- hr = pDirectInputCreateEx( hInstance, version, dinput7_interfaces[i], (void **)&unknown, NULL );
+ hr = pDirectInputCreateEx( instance, version, dinput7_interfaces[i], (void **)&unknown, NULL );
if (version < 0x800) ok( hr == DI_OK, "DirectInputCreateEx returned %#lx\n", hr );
else ok( hr == DIERR_OLDDIRECTINPUTVERSION, "DirectInputCreateEx returned %#lx\n", hr );
if (version < 0x800) ok( unknown != NULL, "got IUnknown NULL\n" );
@@ -390,27 +392,27 @@ static void test_DirectInput8Create( DWORD version )
{NULL, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE},
{NULL, version + 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER},
{NULL, version + 1, &IID_IDirectInput8A, &unknown, NULL, DIERR_INVALIDPARAM},
- {hInstance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE},
- {hInstance, 0, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, 0, &IID_IDirectInput8A, &unknown, NULL, DIERR_NOTINITIALIZED},
- {hInstance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE},
- {hInstance, version, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version - 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE},
- {hInstance, version - 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version - 1, &IID_IDirectInput8A, &unknown, NULL, DIERR_BETADIRECTINPUTVERSION},
- {hInstance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE},
- {hInstance, version + 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER},
- {hInstance, version + 1, &IID_IDirectInput8A, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
+ {instance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE},
+ {instance, 0, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, 0, &IID_IDirectInput8A, &unknown, NULL, DIERR_NOTINITIALIZED},
+ {instance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE},
+ {instance, version, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version - 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE},
+ {instance, version - 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version - 1, &IID_IDirectInput8A, &unknown, NULL, DIERR_BETADIRECTINPUTVERSION},
+ {instance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE},
+ {instance, version + 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER},
+ {instance, version + 1, &IID_IDirectInput8A, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION},
};
HRESULT hr;
int i;
unknown = (void *)0xdeadbeef;
- hr = DirectInput8Create( hInstance, version, &IID_IDirectInput8W, (void **)&unknown, &outer );
+ hr = DirectInput8Create( instance, version, &IID_IDirectInput8W, (void **)&unknown, &outer );
ok( hr == DI_OK, "DirectInputCreateW returned %#lx\n", hr );
ok( unknown == NULL, "got IUnknown %p\n", unknown );
@@ -430,7 +432,7 @@ static void test_DirectInput8Create( DWORD version )
{
winetest_push_context( "%u", i );
unknown = (void *)0xdeadbeef;
- hr = DirectInput8Create( hInstance, version, dinput7_interfaces[i], (void **)&unknown, NULL );
+ hr = DirectInput8Create( instance, version, dinput7_interfaces[i], (void **)&unknown, NULL );
ok( hr == DIERR_NOINTERFACE, "DirectInput8Create returned %#lx\n", hr );
ok( unknown == NULL, "got IUnknown %p\n", unknown );
winetest_pop_context();
@@ -440,7 +442,7 @@ static void test_DirectInput8Create( DWORD version )
{
winetest_push_context( "%u", i );
unknown = NULL;
- hr = DirectInput8Create( hInstance, version, dinput8_interfaces[i], (void **)&unknown, NULL );
+ hr = DirectInput8Create( instance, version, dinput8_interfaces[i], (void **)&unknown, NULL );
if (i == 2) ok( hr == DIERR_NOINTERFACE, "DirectInput8Create returned %#lx\n", hr );
else if (version == 0x800) ok( hr == DI_OK, "DirectInput8Create returned %#lx\n", hr );
else ok( hr == DIERR_BETADIRECTINPUTVERSION, "DirectInput8Create returned %#lx\n", hr );
@@ -762,18 +764,18 @@ static void test_Initialize( DWORD version )
if (version == 0x300) todo_wine ok( hr == S_OK, "Initialize returned %#lx\n", hr );
else ok( hr == DIERR_INVALIDPARAM, "Initialize returned %#lx\n", hr );
- hr = IDirectInput_Initialize( dinput, hInstance, 0 );
+ hr = IDirectInput_Initialize( dinput, instance, 0 );
ok( hr == DIERR_NOTINITIALIZED, "Initialize returned %#lx\n", hr );
- hr = IDirectInput_Initialize( dinput, hInstance, version - 1 );
+ hr = IDirectInput_Initialize( dinput, instance, version - 1 );
ok( hr == DIERR_BETADIRECTINPUTVERSION, "Initialize returned %#lx\n", hr );
- hr = IDirectInput_Initialize( dinput, hInstance, version + 1 );
+ hr = IDirectInput_Initialize( dinput, instance, version + 1 );
if (version >= 0x700) ok( hr == DIERR_OLDDIRECTINPUTVERSION, "Initialize returned %#lx\n", hr );
else ok( hr == DIERR_BETADIRECTINPUTVERSION, "Initialize returned %#lx\n", hr );
/* Parameters are still validated after successful initialization. */
- hr = IDirectInput_Initialize( dinput, hInstance, 0 );
+ hr = IDirectInput_Initialize( dinput, instance, 0 );
ok( hr == DIERR_NOTINITIALIZED, "Initialize returned %#lx\n", hr );
ref = IDirectInput_Release( dinput );
@@ -819,7 +821,7 @@ static void test_DirectInputJoyConfig8(void)
HRESULT hr;
int i;
- hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL);
+ hr = DirectInputCreateA(instance, DIRECTINPUT_VERSION, &pDI, NULL);
if (FAILED(hr))
{
win_skip("Failed to instantiate a IDirectInputA instance: 0x%#lx\n", hr);
@@ -933,7 +935,7 @@ static void test_EnumDevicesBySemantics(void)
int device_total = 0;
HRESULT hr;
- hr = DirectInput8Create( hInstance, 0x800, &IID_IDirectInput8A, (void **)&dinput, NULL );
+ hr = DirectInput8Create( instance, 0x800, &IID_IDirectInput8A, (void **)&dinput, NULL );
if (FAILED(hr))
{
win_skip( "Failed to instantiate a IDirectInputA instance: 0x%#lx\n", hr );
@@ -1051,17 +1053,12 @@ static void test_EnumDevicesBySemantics(void)
START_TEST(dinput)
{
- HMODULE dinput_mod = GetModuleHandleA("dinput.dll");
DWORD i;
- hInstance = GetModuleHandleA(NULL);
+ dinput_test_init();
- pDirectInputCreateEx = (void *)GetProcAddress(dinput_mod, "DirectInputCreateEx");
-
- CoInitialize( NULL );
test_CoCreateInstance( 0x700 );
test_CoCreateInstance( 0x800 );
- CoUninitialize();
for (i = 0; i < ARRAY_SIZE(dinput_versions); i++)
{
@@ -1080,4 +1077,6 @@ START_TEST(dinput)
test_DirectInputJoyConfig8();
test_EnumDevicesBySemantics();
+
+ dinput_test_exit();
}
diff --git a/dlls/dinput/tests/dinput_test.h b/dlls/dinput/tests/dinput_test.h
index 677f8c96361..04738cffb44 100644
--- a/dlls/dinput/tests/dinput_test.h
+++ b/dlls/dinput/tests/dinput_test.h
@@ -50,6 +50,7 @@ extern const GUID expect_guid_product;
extern const WCHAR expect_path[];
extern const WCHAR expect_path_end[];
+extern typeof(DirectInputCreateEx) *pDirectInputCreateEx;
extern HANDLE device_added, device_removed;
extern HINSTANCE instance;
extern BOOL localized; /* object names get translated */
@@ -62,7 +63,7 @@ void bus_device_stop(void);
void cleanup_registry_keys(void);
#define dinput_test_init() dinput_test_init_( __FILE__, __LINE__ )
-BOOL dinput_test_init_( const char *file, int line );
+void dinput_test_init_( const char *file, int line );
void dinput_test_exit(void);
HRESULT dinput_test_create_device( DWORD version, DIDEVICEINSTANCEW *devinst, IDirectInputDevice8W **device );
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c
index 30d19cc04a0..1bcd56d685a 100644
--- a/dlls/dinput/tests/force_feedback.c
+++ b/dlls/dinput/tests/force_feedback.c
@@ -6405,10 +6405,9 @@ done:
START_TEST( force_feedback )
{
- if (!dinput_test_init()) return;
+ dinput_test_init();
if (!bus_device_start()) goto done;
- CoInitialize( NULL );
if (test_force_feedback_joystick( 0x800 ))
{
test_force_feedback_joystick( 0x500 );
@@ -6416,7 +6415,6 @@ START_TEST( force_feedback )
test_device_managed_effect();
test_windows_gaming_input();
}
- CoUninitialize();
done:
bus_device_stop();
diff --git a/dlls/dinput/tests/hid.c b/dlls/dinput/tests/hid.c
index 2d7199fa3e5..e1658f1283f 100644
--- a/dlls/dinput/tests/hid.c
+++ b/dlls/dinput/tests/hid.c
@@ -44,7 +44,6 @@
#include "objbase.h"
#define COBJMACROS
-#include "dinput.h"
#include "initguid.h"
#include "ddk/wdm.h"
@@ -52,13 +51,16 @@
#include "ddk/hidsdi.h"
#include "ddk/hidpi.h"
#include "ddk/hidport.h"
-#include "hidusage.h"
#include "devguid.h"
+#include "dinput.h"
+#include "dinputd.h"
+#include "hidusage.h"
#include "wine/mssign.h"
#include "dinput_test.h"
+typeof(DirectInputCreateEx) *pDirectInputCreateEx;
HINSTANCE instance;
BOOL localized; /* object names get translated */
@@ -475,6 +477,8 @@ void bus_device_stop(void)
DWORD size;
BOOL ret;
+ if (!test_data) return;
+
set = SetupDiCreateDeviceInfoList( NULL, NULL );
ok( set != INVALID_HANDLE_VALUE, "failed to create device list, error %lu\n", GetLastError() );
@@ -600,6 +604,8 @@ BOOL bus_device_start(void)
HDEVINFO set;
FILE *f;
+ if (!test_data) return FALSE;
+
old_mute_threshold = winetest_mute_threshold;
winetest_mute_threshold = 1;
@@ -3459,52 +3465,55 @@ DWORD WINAPI monitor_thread_proc( void *stop_event )
return 0;
}
-BOOL dinput_test_init_( const char *file, int line )
+void dinput_test_init_( const char *file, int line )
{
BOOL is_wow64;
monitor_stop = CreateEventW( NULL, FALSE, FALSE, NULL );
- ok( !!monitor_stop, "CreateEventW failed, error %lu\n", GetLastError() );
+ ok_(file, line)( !!monitor_stop, "CreateEventW failed, error %lu\n", GetLastError() );
device_added = CreateEventW( NULL, FALSE, FALSE, NULL );
- ok( !!device_added, "CreateEventW failed, error %lu\n", GetLastError() );
+ ok_(file, line)( !!device_added, "CreateEventW failed, error %lu\n", GetLastError() );
device_removed = CreateEventW( NULL, FALSE, FALSE, NULL );
- ok( !!device_removed, "CreateEventW failed, error %lu\n", GetLastError() );
+ ok_(file, line)( !!device_removed, "CreateEventW failed, error %lu\n", GetLastError() );
monitor_thread = CreateThread( NULL, 0, monitor_thread_proc, monitor_stop, 0, NULL );
- ok( !!monitor_thread, "CreateThread failed, error %lu\n", GetLastError() );
+ ok_(file, line)( !!monitor_thread, "CreateThread failed, error %lu\n", GetLastError() );
+
+ CoInitialize( NULL );
- subtest_(file, line)( "hid" );
instance = GetModuleHandleW( NULL );
localized = GetUserDefaultLCID() != MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
pSignerSign = (void *)GetProcAddress( LoadLibraryW( L"mssign32" ), "SignerSign" );
+ pDirectInputCreateEx = (void *)GetProcAddress( LoadLibraryW(L"dinput.dll"), "DirectInputCreateEx" );
if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64)
{
- skip( "Running in WoW64.\n" );
- return FALSE;
+ skip_(file, line)( "Skipping driver tests: running in wow64.\n" );
+ return;
}
test_data_mapping = CreateFileMappingW( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,
sizeof(*test_data), L"Global\\winetest_dinput_section" );
if (!test_data_mapping && GetLastError() == ERROR_ACCESS_DENIED)
{
- win_skip( "Failed to create test data mapping.\n" );
- return FALSE;
+ win_skip_(file, line)( "Skipping driver tests: failed to create mapping.\n" );
+ return;
}
- ok( !!test_data_mapping, "got error %lu\n", GetLastError() );
+ ok_(file, line)( !!test_data_mapping, "got error %lu\n", GetLastError() );
+
test_data = MapViewOfFile( test_data_mapping, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 1024 );
+ ok_(file, line)( !!test_data, "MapViewOfFile failed, error %lu\n", GetLastError() );
test_data->running_under_wine = !strcmp( winetest_platform, "wine" );
test_data->winetest_report_success = winetest_report_success;
test_data->winetest_debug = winetest_debug;
okfile = CreateFileW( L"C:\\windows\\winetest_dinput_okfile", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL );
- ok( okfile != INVALID_HANDLE_VALUE, "failed to create file, error %lu\n", GetLastError() );
+ ok_(file, line)( okfile != INVALID_HANDLE_VALUE, "failed to create file, error %lu\n", GetLastError() );
- subtest( "driver" );
- subtest( "driver_bus" );
- subtest( "driver_hid" );
- subtest( "driver_hid_poll" );
- return TRUE;
+ subtest_(file, line)( "driver" );
+ subtest_(file, line)( "driver_bus" );
+ subtest_(file, line)( "driver_hid" );
+ subtest_(file, line)( "driver_hid_poll" );
}
void dinput_test_exit(void)
@@ -3520,6 +3529,8 @@ void dinput_test_exit(void)
CloseHandle( monitor_stop );
CloseHandle( device_removed );
CloseHandle( device_added );
+
+ CoUninitialize();
}
BOOL CALLBACK find_test_device( const DIDEVICEINSTANCEW *devinst, void *context )
@@ -3931,7 +3942,7 @@ done:
START_TEST( hid )
{
- if (!dinput_test_init()) return;
+ dinput_test_init();
test_bus_driver();
diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c
index 885d0e036e0..9896e7b480e 100644
--- a/dlls/dinput/tests/hotplug.c
+++ b/dlls/dinput/tests/hotplug.c
@@ -1218,10 +1218,9 @@ next:
START_TEST( hotplug )
{
- if (!dinput_test_init()) return;
+ dinput_test_init();
if (!bus_device_start()) goto done;
- CoInitialize( NULL );
if (test_input_lost( 0x500 ))
{
test_input_lost( 0x700 );
@@ -1230,7 +1229,6 @@ START_TEST( hotplug )
test_RegisterDeviceNotification();
test_windows_gaming_input();
}
- CoUninitialize();
done:
bus_device_stop();
diff --git a/dlls/dinput/tests/joystick.c b/dlls/dinput/tests/joystick.c
index 8647b42cc94..1b85f13f9a7 100644
--- a/dlls/dinput/tests/joystick.c
+++ b/dlls/dinput/tests/joystick.c
@@ -18,18 +18,19 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS
-#include <windows.h>
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <stdarg.h>
+#include <stddef.h>
-#include "wine/test.h"
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "windef.h"
-#include "wingdi.h"
+#include "winbase.h"
+
+#define COBJMACROS
#include "dinput.h"
+#include "dinput_test.h"
+
typedef struct tagUserData {
IDirectInputA *pDI;
DWORD version;
@@ -317,7 +318,6 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
LPDIRECTINPUTEFFECT effect = NULL;
LONG cnt1, cnt2;
HWND real_hWnd;
- HINSTANCE hInstance = GetModuleHandleW(NULL);
DIPROPDWORD dip_gain_set, dip_gain_get;
struct effect_enum effect_data;
@@ -549,7 +549,7 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
* - a visible window
*/
real_hWnd = CreateWindowExA(0, "EDIT", "Test text", 0, 10, 10, 300, 300, NULL, NULL,
- hInstance, NULL);
+ instance, NULL);
ok(real_hWnd!=0,"CreateWindowExA failed: %p\n", real_hWnd);
ShowWindow(real_hWnd, SW_SHOW);
hr = IDirectInputDevice_Unacquire(pJoystick);
@@ -598,7 +598,7 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef)
GUID guid = {0};
DIEFFECT effect_empty;
- hr = IDirectInputEffect_Initialize(effect, hInstance, data->version,
+ hr = IDirectInputEffect_Initialize(effect, instance, data->version,
&effect_data.guid);
ok(hr==DI_OK,"IDirectInputEffect_Initialize failed: %#lx\n", hr);
@@ -915,10 +915,9 @@ static void joystick_tests(DWORD version)
HRESULT hr;
IDirectInputA *pDI;
ULONG ref;
- HINSTANCE hInstance = GetModuleHandleW(NULL);
trace("-- Testing Direct Input Version %#lx --\n", version);
- hr = DirectInputCreateA(hInstance, version, &pDI, NULL);
+ hr = DirectInputCreateA(instance, version, &pDI, NULL);
ok(hr==DI_OK||hr==DIERR_OLDDIRECTINPUTVERSION, "DirectInputCreateA() failed: %#lx\n", hr);
if (hr==DI_OK && pDI!=0) {
UserData data;
@@ -938,9 +937,8 @@ static void test_enum_feedback(void)
HRESULT hr;
IDirectInputA *pDI;
ULONG ref;
- HINSTANCE hInstance = GetModuleHandleW(NULL);
- hr = DirectInputCreateA(hInstance, 0x0700, &pDI, NULL);
+ hr = DirectInputCreateA(instance, 0x0700, &pDI, NULL);
ok(hr==DI_OK||hr==DIERR_OLDDIRECTINPUTVERSION, "DirectInputCreateA() failed: %#lx\n", hr);
if (hr==DI_OK && pDI!=0) {
hr = IDirectInput_EnumDevices(pDI, 0, EnumAllFeedback, NULL, DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK);
@@ -953,7 +951,7 @@ static void test_enum_feedback(void)
START_TEST(joystick)
{
- CoInitialize(NULL);
+ dinput_test_init();
joystick_tests(0x0700);
joystick_tests(0x0500);
@@ -961,5 +959,5 @@ START_TEST(joystick)
test_enum_feedback();
- CoUninitialize();
+ dinput_test_exit();
}
diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c
index 070d9cc2361..62b915af0fa 100644
--- a/dlls/dinput/tests/joystick8.c
+++ b/dlls/dinput/tests/joystick8.c
@@ -4162,10 +4162,9 @@ done:
START_TEST( joystick8 )
{
- if (!dinput_test_init()) return;
+ dinput_test_init();
if (!bus_device_start()) goto done;
- CoInitialize( NULL );
if (test_device_types( 0x800 ))
{
/* This needs to be done before doing anything involving dinput.dll
@@ -4183,7 +4182,6 @@ START_TEST( joystick8 )
test_driving_wheel_axes();
test_windows_gaming_input();
}
- CoUninitialize();
done:
bus_device_stop();
diff --git a/dlls/dinput/tests/keyboard.c b/dlls/dinput/tests/keyboard.c
index 251a12073df..0d3cf7b10c2 100644
--- a/dlls/dinput/tests/keyboard.c
+++ b/dlls/dinput/tests/keyboard.c
@@ -18,20 +18,18 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS
-#include <windows.h>
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <stdarg.h>
+#include <stddef.h>
-#include "wine/test.h"
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "windef.h"
-#include "wingdi.h"
+#include "winbase.h"
+
+#define COBJMACROS
#include "dinput.h"
-/* to make things easier with PSDK without a dinput.lib */
-static HRESULT (WINAPI *pDirectInputCreateA)(HINSTANCE,DWORD,IDirectInputA **,IUnknown *);
+#include "dinput_test.h"
static void pump_messages(void)
{
@@ -513,11 +511,10 @@ static void keyboard_tests(DWORD version)
{
HRESULT hr;
IDirectInputA *pDI = NULL;
- HINSTANCE hInstance = GetModuleHandleW(NULL);
HWND hwnd;
ULONG ref = 0;
- hr = pDirectInputCreateA(hInstance, version, &pDI, NULL);
+ hr = DirectInputCreateA(instance, version, &pDI, NULL);
if (hr == DIERR_OLDDIRECTINPUTVERSION)
{
skip("Tests require a newer dinput version\n");
@@ -554,11 +551,9 @@ static void keyboard_tests(DWORD version)
START_TEST(keyboard)
{
- pDirectInputCreateA = (void *)GetProcAddress(GetModuleHandleA("dinput.dll"), "DirectInputCreateA");
-
- CoInitialize(NULL);
+ dinput_test_init();
keyboard_tests(0x0700);
- CoUninitialize();
+ dinput_test_exit();
}
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c
index 8be808e5da6..2d92fe2b14c 100644
--- a/dlls/dinput/tests/mouse.c
+++ b/dlls/dinput/tests/mouse.c
@@ -19,17 +19,19 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS
-#include <windows.h>
-
-#include <math.h>
-#include <stdlib.h>
+#include <stdarg.h>
+#include <stddef.h>
-#include "wine/test.h"
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "windef.h"
-#include "wingdi.h"
+#include "winbase.h"
+
+#define COBJMACROS
#include "dinput.h"
+#include "dinput_test.h"
+
static const HRESULT SetCoop_null_window[16] = {
E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
@@ -290,11 +292,10 @@ static void mouse_tests(void)
{
HRESULT hr;
IDirectInputA *pDI = NULL;
- HINSTANCE hInstance = GetModuleHandleW(NULL);
HWND hwnd;
ULONG ref = 0;
- hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL);
+ hr = DirectInputCreateA(instance, DIRECTINPUT_VERSION, &pDI, NULL);
if (hr == DIERR_OLDDIRECTINPUTVERSION)
{
skip("Tests require a newer dinput version\n");
@@ -323,9 +324,9 @@ static void mouse_tests(void)
START_TEST(mouse)
{
- CoInitialize(NULL);
+ dinput_test_init();
mouse_tests();
- CoUninitialize();
+ dinput_test_exit();
}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/208
More information about the wine-devel
mailing list