Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/ole32/tests/propvariant.c | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
diff --git a/dlls/ole32/tests/propvariant.c b/dlls/ole32/tests/propvariant.c index 97c4eec4ca..8c9f79e8d6 100644 --- a/dlls/ole32/tests/propvariant.c +++ b/dlls/ole32/tests/propvariant.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define COBJMACROS + #include "windows.h" #include "wtypes.h" #include "ddeml.h" @@ -298,10 +300,55 @@ static void test_validtypes(void) } }
+struct unk_impl +{ + IUnknown IUnknown_iface; + LONG ref; +}; + +static inline struct unk_impl *impl_from_IUnknown(IUnknown *iface) +{ + return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface); +} + +static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) +{ + struct unk_impl *This = impl_from_IUnknown(iface); + if(winetest_debug > 1) + trace("Call to unk_QueryInterface()\n"); + *ppv = &This->IUnknown_iface; + IUnknown_AddRef(iface); + return S_OK; +} + +static ULONG WINAPI unk_AddRef(IUnknown *iface) +{ + struct unk_impl *This = impl_from_IUnknown(iface); + if(winetest_debug > 1) + trace("Call to unk_AddRef()\n"); + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI unk_Release(IUnknown *iface) +{ + struct unk_impl *This = impl_from_IUnknown(iface); + if(winetest_debug > 1) + trace("Call to unk_Release()\n"); + return InterlockedDecrement(&This->ref); +} + +static const IUnknownVtbl unk_vtbl = +{ + unk_QueryInterface, + unk_AddRef, + unk_Release +}; + static void test_copy(void) { static char szTestString[] = "Test String"; static WCHAR wszTestString[] = {'T','e','s','t',' ','S','t','r','i','n','g',0}; + struct unk_impl unk_obj = {{&unk_vtbl}, 1}; PROPVARIANT propvarSrc; PROPVARIANT propvarDst; HRESULT hr; @@ -334,6 +381,17 @@ static void test_copy(void) hr = PropVariantClear(&propvarDst); ok(hr == S_OK, "PropVariantClear(...VT_LPSTR...) failed\n"); memset(&propvarSrc, 0, sizeof(propvarSrc)); + + propvarSrc.vt = VT_UNKNOWN; + U(propvarSrc).punkVal = &unk_obj.IUnknown_iface; + hr = PropVariantCopy(&propvarDst, &propvarSrc); + ok(hr == S_OK, "PropVariantCopy(...VT_UNKNOWN...) failed: 0x%08x.\n", hr); + ok(U(propvarDst).punkVal == &unk_obj.IUnknown_iface, "Got wrong IUnknown pointer\n"); + ok(unk_obj.ref == 2, "got wrong refcount: %d.\n", unk_obj.ref); + hr = PropVariantClear(&propvarDst); + ok(hr == S_OK, "PropVariantClear(...VT_UNKNOWN...) failed: 0x%08x.\n", hr); + ok(unk_obj.ref == 1, "got wrong refcount: %d.\n", unk_obj.ref); + memset(&propvarSrc, 0, sizeof(propvarSrc)); }
struct _PMemoryAllocator_vtable {