wined3d: Use return type to return result from read_dword.
[wine.git] / dlls / comsvcs / tests / property.c
blob08ab8ec978ace6db7f74388d5694e3e884609a75
1 /*
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
19 #define COBJMACROS
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "comsvcs.h"
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");
39 return E_NOINTERFACE;
42 static ULONG WINAPI outer_AddRef(IUnknown *iface)
44 ok(0, "Unexpected call.\n");
45 return 1;
48 static ULONG WINAPI outer_Release(IUnknown *iface)
50 ok(0, "Unexpected call.\n");
51 return 0;
54 static const IUnknownVtbl outer_vtbl =
56 outer_QueryInterface,
57 outer_AddRef,
58 outer_Release,
61 static IUnknown test_outer = {&outer_vtbl};
63 static void test_interfaces(void)
65 ISharedPropertyGroupManager *manager, *manager1;
66 ULONG refcount, expected_refcount;
67 IDispatch *dispatch;
68 IUnknown *unk;
69 HRESULT hr;
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);
108 START_TEST(property)
110 CoInitialize(NULL);
112 test_interfaces();
114 CoUninitialize();