2 * Copyright 2021 Jactry Zeng for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
29 static ULONG
get_refcount(void *iface
)
31 IUnknown
*unknown
= iface
;
32 IUnknown_AddRef(unknown
);
33 return IUnknown_Release(unknown
);
36 static HRESULT WINAPI
outer_QueryInterface(IUnknown
*iface
, REFIID iid
, void **out
)
38 ok(0, "Unexpected call.\n");
42 static ULONG WINAPI
outer_AddRef(IUnknown
*iface
)
44 ok(0, "Unexpected call.\n");
48 static ULONG WINAPI
outer_Release(IUnknown
*iface
)
50 ok(0, "Unexpected call.\n");
54 static const IUnknownVtbl outer_vtbl
=
61 static IUnknown test_outer
= {&outer_vtbl
};
63 static void test_interfaces(void)
65 ISharedPropertyGroupManager
*manager
, *manager1
;
66 ULONG refcount
, expected_refcount
;
71 hr
= CoCreateInstance(&CLSID_SharedPropertyGroupManager
, &test_outer
, CLSCTX_INPROC_SERVER
,
72 &IID_ISharedPropertyGroupManager
, (void **)&manager
);
73 ok(hr
== CLASS_E_NOAGGREGATION
, "Got hr %#lx.\n", hr
);
75 hr
= CoCreateInstance(&CLSID_SharedPropertyGroupManager
, NULL
, CLSCTX_INPROC_SERVER
,
76 &IID_IUnknown
, (void **)&unk
);
77 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
79 expected_refcount
= get_refcount(unk
) + 1;
80 hr
= IUnknown_QueryInterface(unk
, &IID_ISharedPropertyGroupManager
, (void **)&manager
);
81 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
82 refcount
= get_refcount(unk
);
83 ok(refcount
== expected_refcount
, "Got refcount: %lu, expected %lu.\n", refcount
, expected_refcount
);
85 expected_refcount
= get_refcount(manager
) + 1;
86 hr
= CoCreateInstance(&CLSID_SharedPropertyGroupManager
, NULL
, CLSCTX_INPROC_SERVER
,
87 &IID_ISharedPropertyGroupManager
, (void **)&manager1
);
88 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
89 ok(manager1
== manager
, "Got wrong pointer: %p.\n", manager1
);
90 refcount
= get_refcount(manager1
);
91 ok(refcount
== expected_refcount
, "Got refcount: %lu, expected %lu.\n", refcount
, expected_refcount
);
92 refcount
= get_refcount(manager
);
93 ok(refcount
== expected_refcount
, "Got refcount: %lu, expected %lu.\n", refcount
, expected_refcount
);
94 ISharedPropertyGroupManager_Release(manager1
);
96 hr
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void **)&dispatch
);
97 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
98 refcount
= get_refcount(dispatch
);
99 ok(refcount
== expected_refcount
, "Got refcount: %lu, expected %lu.\n", refcount
, expected_refcount
);
100 refcount
= get_refcount(manager
);
101 ok(refcount
== expected_refcount
, "Got refcount: %lu, expected %lu.\n", refcount
, expected_refcount
);
103 IDispatch_Release(dispatch
);
104 IUnknown_Release(unk
);
105 ISharedPropertyGroupManager_Release(manager
);