Commit 9a9d73b5 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput/tests: Make combase.dll dependency optional.

parent 3bfbdc6d
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
......
......@@ -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 )
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment