Rémi Bernon : dinput/tests: Add some CoCreateInstance and aggregation tests.

Alexandre Julliard julliard at winehq.org
Mon Feb 7 15:56:05 CST 2022


Module: wine
Branch: master
Commit: 22663565428264c32aeb00243b28baa2bbfe85de
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=22663565428264c32aeb00243b28baa2bbfe85de

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Mon Feb  7 09:23:25 2022 +0100

dinput/tests: Add some CoCreateInstance and aggregation tests.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/tests/dinput.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c
index 795a9ed39c6..a2c7f5dbd8d 100644
--- a/dlls/dinput/tests/dinput.c
+++ b/dlls/dinput/tests/dinput.c
@@ -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 );




More information about the wine-cvs mailing list