Rémi Bernon : dinput/tests: Make combase.dll dependency optional.
Alexandre Julliard
julliard at winehq.org
Mon Feb 28 15:50:32 CST 2022
Module: wine
Branch: master
Commit: 9a9d73b572b35450c37a093e6126e0e94025bc40
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9a9d73b572b35450c37a093e6126e0e94025bc40
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Mon Feb 28 09:44:02 2022 +0100
dinput/tests: Make combase.dll dependency optional.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/tests/Makefile.in | 2 +-
dlls/dinput/tests/hotplug.c | 42 ++++++++++++++++++++++++++++---------
dlls/dinput/tests/joystick8.c | 49 +++++++++++++++++++++++++++++++++----------
3 files changed, 71 insertions(+), 22 deletions(-)
diff --git a/dlls/dinput/tests/Makefile.in b/dlls/dinput/tests/Makefile.in
index d32092ca03b..5ba0e5be4d7 100644
--- a/dlls/dinput/tests/Makefile.in
+++ b/dlls/dinput/tests/Makefile.in
@@ -1,5 +1,5 @@
TESTDLL = dinput.dll
-IMPORTS = dinput dinput8 ole32 version user32 advapi32 hid uuid crypt32 newdev setupapi wintrust winmm combase
+IMPORTS = dinput dinput8 ole32 version user32 advapi32 hid uuid crypt32 newdev setupapi wintrust winmm
driver_hid_IMPORTS = winecrt0 ntoskrnl hal hidclass
driver_hid_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c
index 49cc5423807..4dc635932ab 100644
--- a/dlls/dinput/tests/hotplug.c
+++ b/dlls/dinput/tests/hotplug.c
@@ -47,6 +47,31 @@
#define WIDL_using_Windows_Gaming_Input
#include "windows.gaming.input.h"
+#define MAKE_FUNC(f) static typeof(f) *p ## f
+MAKE_FUNC( RoGetActivationFactory );
+MAKE_FUNC( RoInitialize );
+MAKE_FUNC( WindowsCreateString );
+MAKE_FUNC( WindowsDeleteString );
+#undef MAKE_FUNC
+
+static BOOL load_combase_functions(void)
+{
+ HMODULE combase = GetModuleHandleW( L"combase.dll" );
+
+#define LOAD_FUNC(m, f) if (!(p ## f = (void *)GetProcAddress( m, #f ))) goto failed;
+ LOAD_FUNC( combase, RoGetActivationFactory );
+ LOAD_FUNC( combase, RoInitialize );
+ LOAD_FUNC( combase, WindowsCreateString );
+ LOAD_FUNC( combase, WindowsDeleteString );
+#undef LOAD_FUNC
+
+ return TRUE;
+
+failed:
+ win_skip("Failed to load combase.dll functions, skipping tests\n");
+ return FALSE;
+}
+
static BOOL test_input_lost( DWORD version )
{
#include "psh_hid_macros.h"
@@ -529,20 +554,20 @@ static void test_windows_gaming_input(void)
HRESULT hr;
MSG msg;
- hr = RoInitialize( RO_INIT_MULTITHREADED );
+ if (!load_combase_functions()) return;
+
+ hr = pRoInitialize( RO_INIT_MULTITHREADED );
ok( hr == RPC_E_CHANGED_MODE, "RoInitialize failed, hr %#lx\n", hr );
- hr = WindowsCreateString( class_name, wcslen( class_name ), &str );
+ hr = pWindowsCreateString( class_name, wcslen( class_name ), &str );
ok( hr == S_OK, "WindowsCreateString failed, hr %#lx\n", hr );
-
- hr = RoGetActivationFactory( str, &IID_IRawGameControllerStatics, (void **)&statics );
+ hr = pRoGetActivationFactory( str, &IID_IRawGameControllerStatics, (void **)&statics );
ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "RoGetActivationFactory failed, hr %#lx\n", hr );
- WindowsDeleteString( str );
+ pWindowsDeleteString( str );
if (hr == REGDB_E_CLASSNOTREG)
{
win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) );
- RoUninitialize();
return;
}
@@ -551,7 +576,7 @@ static void test_windows_gaming_input(void)
ok( hr == S_OK, "add_RawGameControllerAdded returned %#lx\n", hr );
todo_wine
ok( controller_added_token.value, "got token %I64u\n", controller_added_token.value );
- if (!controller_added_token.value) goto done;
+ if (!controller_added_token.value) return;
hr = IRawGameControllerStatics_add_RawGameControllerRemoved( statics, &controller_removed.IEventHandler_RawGameController_iface,
&controller_removed_token );
@@ -642,9 +667,6 @@ static void test_windows_gaming_input(void)
DestroyWindow( hwnd );
UnregisterClassW( class.lpszClassName, class.hInstance );
-
-done:
- RoUninitialize();
}
START_TEST( hotplug )
diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c
index f01bed08030..e65e3ca9970 100644
--- a/dlls/dinput/tests/joystick8.c
+++ b/dlls/dinput/tests/joystick8.c
@@ -46,6 +46,33 @@
#define WIDL_using_Windows_Gaming_Input
#include "windows.gaming.input.h"
+#define MAKE_FUNC(f) static typeof(f) *p ## f
+MAKE_FUNC( RoGetActivationFactory );
+MAKE_FUNC( RoInitialize );
+MAKE_FUNC( WindowsCreateString );
+MAKE_FUNC( WindowsDeleteString );
+MAKE_FUNC( WindowsGetStringRawBuffer );
+#undef MAKE_FUNC
+
+static BOOL load_combase_functions(void)
+{
+ HMODULE combase = GetModuleHandleW( L"combase.dll" );
+
+#define LOAD_FUNC(m, f) if (!(p ## f = (void *)GetProcAddress( m, #f ))) goto failed;
+ LOAD_FUNC( combase, RoGetActivationFactory );
+ LOAD_FUNC( combase, RoInitialize );
+ LOAD_FUNC( combase, WindowsCreateString );
+ LOAD_FUNC( combase, WindowsDeleteString );
+ LOAD_FUNC( combase, WindowsGetStringRawBuffer );
+#undef LOAD_FUNC
+
+ return TRUE;
+
+failed:
+ win_skip("Failed to load combase.dll functions, skipping tests\n");
+ return FALSE;
+}
+
struct check_objects_todos
{
BOOL type;
@@ -3214,9 +3241,9 @@ static void check_runtimeclass_( int line, IInspectable *inspectable, const WCHA
hr = IInspectable_GetRuntimeClassName( inspectable, &str );
ok_ (__FILE__, line)( hr == S_OK, "GetRuntimeClassName returned %#lx\n", hr );
- buffer = WindowsGetStringRawBuffer( str, &length );
+ buffer = pWindowsGetStringRawBuffer( str, &length );
ok_ (__FILE__, line)( !wcscmp( buffer, class_name ), "got class name %s\n", debugstr_w(buffer) );
- WindowsDeleteString( str );
+ pWindowsDeleteString( str );
}
static void test_windows_gaming_input(void)
@@ -3284,20 +3311,22 @@ static void test_windows_gaming_input(void)
HSTRING str;
HRESULT hr;
+ if (!load_combase_functions()) return;
+
GetCurrentDirectoryW( ARRAY_SIZE(cwd), cwd );
GetTempPathW( ARRAY_SIZE(tempdir), tempdir );
SetCurrentDirectoryW( tempdir );
cleanup_registry_keys();
- hr = RoInitialize( RO_INIT_MULTITHREADED );
+ hr = pRoInitialize( RO_INIT_MULTITHREADED );
ok( hr == RPC_E_CHANGED_MODE, "RoInitialize returned %#lx\n", hr );
- hr = WindowsCreateString( controller_class_name, wcslen( controller_class_name ), &str );
+ hr = pWindowsCreateString( controller_class_name, wcslen( controller_class_name ), &str );
ok( hr == S_OK, "WindowsCreateString returned %#lx\n", hr );
- hr = RoGetActivationFactory( str, &IID_IRawGameControllerStatics, (void **)&controller_statics );
+ hr = pRoGetActivationFactory( str, &IID_IRawGameControllerStatics, (void **)&controller_statics );
ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "RoGetActivationFactory returned %#lx\n", hr );
- WindowsDeleteString( str );
+ pWindowsDeleteString( str );
if (hr == REGDB_E_CLASSNOTREG)
{
@@ -3336,11 +3365,11 @@ static void test_windows_gaming_input(void)
/* HID gamepads aren't exposed as WGI gamepads on Windows */
- hr = WindowsCreateString( gamepad_class_name, wcslen( gamepad_class_name ), &str );
+ hr = pWindowsCreateString( gamepad_class_name, wcslen( gamepad_class_name ), &str );
ok( hr == S_OK, "WindowsCreateString returned %#lx\n", hr );
- hr = RoGetActivationFactory( str, &IID_IGamepadStatics, (void **)&gamepad_statics );
+ hr = pRoGetActivationFactory( str, &IID_IGamepadStatics, (void **)&gamepad_statics );
ok( hr == S_OK, "RoGetActivationFactory returned %#lx\n", hr );
- WindowsDeleteString( str );
+ pWindowsDeleteString( str );
hr = IGamepadStatics_get_Gamepads( gamepad_statics, &gamepads_view );
ok( hr == S_OK, "get_Gamepads returned %#lx\n", hr );
hr = IVectorView_Gamepad_get_Size( gamepads_view, &size );
@@ -3384,8 +3413,6 @@ done:
pnp_driver_stop();
cleanup_registry_keys();
SetCurrentDirectoryW( cwd );
-
- RoUninitialize();
}
START_TEST( joystick8 )
More information about the wine-cvs
mailing list