wined3d: Handle hull shader control point outputs.
[wine.git] / dlls / wsdapi / tests / discovery.c
blobffe64b063382db9fdf9290bd713524093d00523e
1 /*
2 * Web Services on Devices
3 * Discovery tests
5 * Copyright 2017 Owen Rudge for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define COBJMACROS
24 #include <windows.h>
26 #include "wine/test.h"
27 #include "initguid.h"
28 #include "objbase.h"
29 #include "wsdapi.h"
31 typedef struct IWSDiscoveryPublisherNotifyImpl {
32 IWSDiscoveryPublisherNotify IWSDiscoveryPublisherNotify_iface;
33 LONG ref;
34 } IWSDiscoveryPublisherNotifyImpl;
36 static inline IWSDiscoveryPublisherNotifyImpl *impl_from_IWSDiscoveryPublisherNotify(IWSDiscoveryPublisherNotify *iface)
38 return CONTAINING_RECORD(iface, IWSDiscoveryPublisherNotifyImpl, IWSDiscoveryPublisherNotify_iface);
41 static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_QueryInterface(IWSDiscoveryPublisherNotify *iface, REFIID riid, void **ppv)
43 IWSDiscoveryPublisherNotifyImpl *This = impl_from_IWSDiscoveryPublisherNotify(iface);
45 if (!ppv)
47 return E_INVALIDARG;
50 *ppv = NULL;
52 if (IsEqualIID(riid, &IID_IUnknown) ||
53 IsEqualIID(riid, &IID_IWSDiscoveryPublisherNotify))
55 *ppv = &This->IWSDiscoveryPublisherNotify_iface;
57 else
59 return E_NOINTERFACE;
62 IUnknown_AddRef((IUnknown*)*ppv);
63 return S_OK;
66 static ULONG WINAPI IWSDiscoveryPublisherNotifyImpl_AddRef(IWSDiscoveryPublisherNotify *iface)
68 IWSDiscoveryPublisherNotifyImpl *This = impl_from_IWSDiscoveryPublisherNotify(iface);
69 ULONG ref = InterlockedIncrement(&This->ref);
71 trace("IWSDiscoveryPublisherNotifyImpl_AddRef called (%p, ref = %d)\n", This, ref);
72 return ref;
75 static ULONG WINAPI IWSDiscoveryPublisherNotifyImpl_Release(IWSDiscoveryPublisherNotify *iface)
77 IWSDiscoveryPublisherNotifyImpl *This = impl_from_IWSDiscoveryPublisherNotify(iface);
78 ULONG ref = InterlockedDecrement(&This->ref);
80 trace("IWSDiscoveryPublisherNotifyImpl_Release called (%p, ref = %d)\n", This, ref);
82 if (ref == 0)
84 HeapFree(GetProcessHeap(), 0, This);
87 return ref;
90 static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ProbeHandler(IWSDiscoveryPublisherNotify *This, const WSD_SOAP_MESSAGE *pSoap, IWSDMessageParameters *pMessageParameters)
92 trace("IWSDiscoveryPublisherNotifyImpl_ProbeHandler called (%p, %p, %p)\n", This, pSoap, pMessageParameters);
93 return S_OK;
96 static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ResolveHandler(IWSDiscoveryPublisherNotify *This, const WSD_SOAP_MESSAGE *pSoap, IWSDMessageParameters *pMessageParameters)
98 trace("IWSDiscoveryPublisherNotifyImpl_ResolveHandler called (%p, %p, %p)\n", This, pSoap, pMessageParameters);
99 return S_OK;
102 static const IWSDiscoveryPublisherNotifyVtbl publisherNotify_vtbl =
104 IWSDiscoveryPublisherNotifyImpl_QueryInterface,
105 IWSDiscoveryPublisherNotifyImpl_AddRef,
106 IWSDiscoveryPublisherNotifyImpl_Release,
107 IWSDiscoveryPublisherNotifyImpl_ProbeHandler,
108 IWSDiscoveryPublisherNotifyImpl_ResolveHandler
111 static BOOL create_discovery_publisher_notify(IWSDiscoveryPublisherNotify **publisherNotify)
113 IWSDiscoveryPublisherNotifyImpl *obj;
115 *publisherNotify = NULL;
117 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
119 if (!obj)
121 trace("Out of memory creating IWSDiscoveryPublisherNotify\n");
122 return FALSE;
125 obj->IWSDiscoveryPublisherNotify_iface.lpVtbl = &publisherNotify_vtbl;
126 obj->ref = 1;
128 *publisherNotify = &obj->IWSDiscoveryPublisherNotify_iface;
130 return TRUE;
133 static void CreateDiscoveryPublisher_tests(void)
135 IWSDiscoveryPublisher *publisher = NULL;
136 IWSDiscoveryPublisher *publisher2;
137 IUnknown *unknown;
138 HRESULT rc;
139 ULONG ref;
141 rc = WSDCreateDiscoveryPublisher(NULL, NULL);
142 ok((rc == E_POINTER) || (rc == E_INVALIDARG), "WSDCreateDiscoveryPublisher(NULL, NULL) failed: %08x\n", rc);
144 rc = WSDCreateDiscoveryPublisher(NULL, &publisher);
145 ok(rc == S_OK, "WSDCreateDiscoveryPublisher(NULL, &publisher) failed: %08x\n", rc);
146 ok(publisher != NULL, "WSDCreateDiscoveryPublisher(NULL, &publisher) failed: publisher == NULL\n");
148 /* Try to query for objects */
149 rc = IWSDiscoveryPublisher_QueryInterface(publisher, &IID_IUnknown, (LPVOID*)&unknown);
150 ok(rc == S_OK,"IWSDiscoveryPublisher_QueryInterface(IID_IUnknown) failed: %08x\n", rc);
152 if (rc == S_OK)
153 IUnknown_Release(unknown);
155 rc = IWSDiscoveryPublisher_QueryInterface(publisher, &IID_IWSDiscoveryPublisher, (LPVOID*)&publisher2);
156 ok(rc == S_OK,"IWSDiscoveryPublisher_QueryInterface(IID_IWSDiscoveryPublisher) failed: %08x\n", rc);
158 if (rc == S_OK)
159 IWSDiscoveryPublisher_Release(publisher2);
161 ref = IWSDiscoveryPublisher_Release(publisher);
162 ok(ref == 0, "IWSDiscoveryPublisher_Release() has %d references, should have 0\n", ref);
165 static void Publish_tests(void)
167 IWSDiscoveryPublisher *publisher = NULL;
168 IWSDiscoveryPublisherNotify *sink1 = NULL, *sink2 = NULL;
169 IWSDiscoveryPublisherNotifyImpl *sink1Impl = NULL, *sink2Impl = NULL;
171 HRESULT rc;
172 ULONG ref;
174 rc = WSDCreateDiscoveryPublisher(NULL, &publisher);
175 ok(rc == S_OK, "WSDCreateDiscoveryPublisher(NULL, &publisher) failed: %08x\n", rc);
176 ok(publisher != NULL, "WSDCreateDiscoveryPublisher(NULL, &publisher) failed: publisher == NULL\n");
178 /* Test SetAddressFamily */
179 rc = IWSDiscoveryPublisher_SetAddressFamily(publisher, 12345);
180 ok(rc == E_INVALIDARG, "IWSDiscoveryPublisher_SetAddressFamily(12345) returned unexpected result: %08x\n", rc);
182 rc = IWSDiscoveryPublisher_SetAddressFamily(publisher, WSDAPI_ADDRESSFAMILY_IPV4);
183 ok(rc == S_OK, "IWSDiscoveryPublisher_SetAddressFamily(WSDAPI_ADDRESSFAMILY_IPV4) failed: %08x\n", rc);
185 /* Try to update the address family after already setting it */
186 rc = IWSDiscoveryPublisher_SetAddressFamily(publisher, WSDAPI_ADDRESSFAMILY_IPV6);
187 ok(rc == STG_E_INVALIDFUNCTION, "IWSDiscoveryPublisher_SetAddressFamily(WSDAPI_ADDRESSFAMILY_IPV6) returned unexpected result: %08x\n", rc);
189 /* Create notification sinks */
190 ok(create_discovery_publisher_notify(&sink1) == TRUE, "create_discovery_publisher_notify failed\n");
191 ok(create_discovery_publisher_notify(&sink2) == TRUE, "create_discovery_publisher_notify failed\n");
193 /* Get underlying implementation so we can check the ref count */
194 sink1Impl = impl_from_IWSDiscoveryPublisherNotify(sink1);
195 sink2Impl = impl_from_IWSDiscoveryPublisherNotify(sink2);
197 /* Attempt to unregister sink before registering it */
198 rc = IWSDiscoveryPublisher_UnRegisterNotificationSink(publisher, sink1);
199 ok(rc == E_FAIL, "IWSDiscoveryPublisher_UnRegisterNotificationSink returned unexpected result: %08x\n", rc);
201 /* Register notification sinks */
202 rc = IWSDiscoveryPublisher_RegisterNotificationSink(publisher, sink1);
203 ok(rc == S_OK, "IWSDiscoveryPublisher_RegisterNotificationSink failed: %08x\n", rc);
204 ok(sink1Impl->ref == 2, "Ref count for sink 1 is not as expected: %d\n", sink1Impl->ref);
206 rc = IWSDiscoveryPublisher_RegisterNotificationSink(publisher, sink2);
207 ok(rc == S_OK, "IWSDiscoveryPublisher_RegisterNotificationSink failed: %08x\n", rc);
208 ok(sink2Impl->ref == 2, "Ref count for sink 2 is not as expected: %d\n", sink2Impl->ref);
210 /* Unregister the first sink */
211 rc = IWSDiscoveryPublisher_UnRegisterNotificationSink(publisher, sink1);
212 ok(rc == S_OK, "IWSDiscoveryPublisher_UnRegisterNotificationSink failed: %08x\n", rc);
213 ok(sink1Impl->ref == 1, "Ref count for sink 1 is not as expected: %d\n", sink1Impl->ref);
215 /* TODO: Publish */
217 ref = IWSDiscoveryPublisher_Release(publisher);
218 ok(ref == 0, "IWSDiscoveryPublisher_Release() has %d references, should have 0\n", ref);
220 /* Check that the sinks have been released by the publisher */
221 ok(sink1Impl->ref == 1, "Ref count for sink 1 is not as expected: %d\n", sink1Impl->ref);
222 ok(sink2Impl->ref == 1, "Ref count for sink 2 is not as expected: %d\n", sink2Impl->ref);
224 /* Release the sinks */
225 IWSDiscoveryPublisherNotify_Release(sink1);
226 IWSDiscoveryPublisherNotify_Release(sink2);
229 START_TEST(discovery)
231 CoInitialize(NULL);
233 CreateDiscoveryPublisher_tests();
234 Publish_tests();
236 CoUninitialize();