dinput/tests: Add some CoCreateInstance and aggregation tests.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-02-07 09:23:25 +01:00 committed by Alexandre Julliard
parent 0c3686f549
commit 2266356542
1 changed files with 67 additions and 0 deletions

View File

@ -76,6 +76,41 @@ static BOOL CALLBACK dummy_callback(const DIDEVICEINSTANCEA *instance, void *con
return DIENUM_STOP;
}
static HRESULT WINAPI outer_QueryInterface( IUnknown *iface, REFIID iid, void **obj )
{
ok( 0, "unexpected call %s\n", debugstr_guid( iid ) );
if (IsEqualGUID( iid, &IID_IUnknown ))
{
*obj = (IUnknown *)iface;
return S_OK;
}
ok( 0, "unexpected call %s\n", debugstr_guid( iid ) );
return E_NOINTERFACE;
}
static ULONG WINAPI outer_AddRef( IUnknown *iface )
{
ok( 0, "unexpected call\n" );
return 2;
}
static ULONG WINAPI outer_Release( IUnknown *iface )
{
ok( 0, "unexpected call\n" );
return 1;
}
static IUnknownVtbl outer_vtbl =
{
outer_QueryInterface,
outer_AddRef,
outer_Release,
};
static IUnknown outer = {&outer_vtbl};
static void test_CoCreateInstance( DWORD version )
{
static const struct
@ -113,6 +148,7 @@ static void test_CoCreateInstance( DWORD version )
IDirectInputDeviceA *device;
IDirectInputA *dinput;
IUnknown *unknown;
HRESULT hr;
LONG ref;
int i;
@ -127,6 +163,14 @@ static void test_CoCreateInstance( DWORD version )
return;
}
if (version < 0x800) hr = CoCreateInstance( &CLSID_DirectInput, &outer, CLSCTX_INPROC_SERVER,
&IID_IDirectInputA, (void **)&unknown );
else hr = CoCreateInstance( &CLSID_DirectInput8, &outer, CLSCTX_INPROC_SERVER,
&IID_IDirectInput8A, (void **)&unknown );
todo_wine
ok( hr == CLASS_E_NOAGGREGATION, "CoCreateInstance returned %#x\n", hr );
if (SUCCEEDED( hr )) IUnknown_Release( unknown );
for (i = 0; i < ARRAY_SIZE(create_device_tests); i++)
{
winetest_push_context( "%u", i );
@ -204,6 +248,14 @@ static void test_DirectInputCreate( DWORD version )
HRESULT hr;
int i;
unknown = (void *)0xdeadbeef;
hr = DirectInputCreateW( hInstance, version, (IDirectInputW **)&unknown, &outer );
todo_wine_if(version == 0x800)
ok( hr == DI_OK, "DirectInputCreateW returned %#x\n", hr );
todo_wine_if(version <= 0x700)
ok( unknown == NULL, "got IUnknown %p\n", unknown );
if (unknown) IUnknown_Release( unknown );
for (i = 0; i < ARRAY_SIZE(create_tests); i++)
{
winetest_push_context( "%u", i );
@ -271,6 +323,14 @@ static void test_DirectInputCreateEx( DWORD version )
return;
}
unknown = (void *)0xdeadbeef;
hr = pDirectInputCreateEx( hInstance, version, &IID_IDirectInputW, (void **)&unknown, &outer );
todo_wine_if(version == 0x800)
ok( hr == DI_OK, "DirectInputCreateW returned %#x\n", hr );
todo_wine_if(version <= 0x700)
ok( unknown == NULL, "got IUnknown %p\n", unknown );
if (unknown) IUnknown_Release( unknown );
for (i = 0; i < ARRAY_SIZE(create_tests); i++)
{
winetest_push_context( "%u", i );
@ -356,6 +416,13 @@ static void test_DirectInput8Create( DWORD version )
HRESULT hr;
int i;
unknown = (void *)0xdeadbeef;
hr = DirectInput8Create( hInstance, version, &IID_IDirectInput8W, (void **)&unknown, &outer );
ok( hr == DI_OK, "DirectInputCreateW returned %#x\n", hr );
todo_wine
ok( unknown == NULL, "got IUnknown %p\n", unknown );
if (unknown) IUnknown_Release( unknown );
for (i = 0; i < ARRAY_SIZE(create_tests); i++)
{
winetest_push_context( "%u", i );