wsdapi/tests: Add tests for Register/UnRegisterNotificationSink.
Signed-off-by: Owen Rudge <orudge@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
44048e06ba
commit
b57c881fb3
|
@ -28,6 +28,108 @@
|
|||
#include "objbase.h"
|
||||
#include "wsdapi.h"
|
||||
|
||||
typedef struct IWSDiscoveryPublisherNotifyImpl {
|
||||
IWSDiscoveryPublisherNotify IWSDiscoveryPublisherNotify_iface;
|
||||
LONG ref;
|
||||
} IWSDiscoveryPublisherNotifyImpl;
|
||||
|
||||
static inline IWSDiscoveryPublisherNotifyImpl *impl_from_IWSDiscoveryPublisherNotify(IWSDiscoveryPublisherNotify *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, IWSDiscoveryPublisherNotifyImpl, IWSDiscoveryPublisherNotify_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_QueryInterface(IWSDiscoveryPublisherNotify *iface, REFIID riid, void **ppv)
|
||||
{
|
||||
IWSDiscoveryPublisherNotifyImpl *This = impl_from_IWSDiscoveryPublisherNotify(iface);
|
||||
|
||||
if (!ppv)
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
*ppv = NULL;
|
||||
|
||||
if (IsEqualIID(riid, &IID_IUnknown) ||
|
||||
IsEqualIID(riid, &IID_IWSDiscoveryPublisherNotify))
|
||||
{
|
||||
*ppv = &This->IWSDiscoveryPublisherNotify_iface;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
IUnknown_AddRef((IUnknown*)*ppv);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IWSDiscoveryPublisherNotifyImpl_AddRef(IWSDiscoveryPublisherNotify *iface)
|
||||
{
|
||||
IWSDiscoveryPublisherNotifyImpl *This = impl_from_IWSDiscoveryPublisherNotify(iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
trace("IWSDiscoveryPublisherNotifyImpl_AddRef called (%p, ref = %d)\n", This, ref);
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IWSDiscoveryPublisherNotifyImpl_Release(IWSDiscoveryPublisherNotify *iface)
|
||||
{
|
||||
IWSDiscoveryPublisherNotifyImpl *This = impl_from_IWSDiscoveryPublisherNotify(iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
trace("IWSDiscoveryPublisherNotifyImpl_Release called (%p, ref = %d)\n", This, ref);
|
||||
|
||||
if (ref == 0)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ProbeHandler(IWSDiscoveryPublisherNotify *This, const WSD_SOAP_MESSAGE *pSoap, IWSDMessageParameters *pMessageParameters)
|
||||
{
|
||||
trace("IWSDiscoveryPublisherNotifyImpl_ProbeHandler called (%p, %p, %p)\n", This, pSoap, pMessageParameters);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ResolveHandler(IWSDiscoveryPublisherNotify *This, const WSD_SOAP_MESSAGE *pSoap, IWSDMessageParameters *pMessageParameters)
|
||||
{
|
||||
trace("IWSDiscoveryPublisherNotifyImpl_ResolveHandler called (%p, %p, %p)\n", This, pSoap, pMessageParameters);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const IWSDiscoveryPublisherNotifyVtbl publisherNotify_vtbl =
|
||||
{
|
||||
IWSDiscoveryPublisherNotifyImpl_QueryInterface,
|
||||
IWSDiscoveryPublisherNotifyImpl_AddRef,
|
||||
IWSDiscoveryPublisherNotifyImpl_Release,
|
||||
IWSDiscoveryPublisherNotifyImpl_ProbeHandler,
|
||||
IWSDiscoveryPublisherNotifyImpl_ResolveHandler
|
||||
};
|
||||
|
||||
static BOOL create_discovery_publisher_notify(IWSDiscoveryPublisherNotify **publisherNotify)
|
||||
{
|
||||
IWSDiscoveryPublisherNotifyImpl *obj;
|
||||
|
||||
*publisherNotify = NULL;
|
||||
|
||||
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
trace("Out of memory creating IWSDiscoveryPublisherNotify\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
obj->IWSDiscoveryPublisherNotify_iface.lpVtbl = &publisherNotify_vtbl;
|
||||
obj->ref = 1;
|
||||
|
||||
*publisherNotify = &obj->IWSDiscoveryPublisherNotify_iface;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void CreateDiscoveryPublisher_tests(void)
|
||||
{
|
||||
IWSDiscoveryPublisher *publisher = NULL;
|
||||
|
@ -63,6 +165,9 @@ static void CreateDiscoveryPublisher_tests(void)
|
|||
static void Publish_tests(void)
|
||||
{
|
||||
IWSDiscoveryPublisher *publisher = NULL;
|
||||
IWSDiscoveryPublisherNotify *sink1 = NULL, *sink2 = NULL;
|
||||
IWSDiscoveryPublisherNotifyImpl *sink1Impl = NULL, *sink2Impl = NULL;
|
||||
|
||||
HRESULT rc;
|
||||
ULONG ref;
|
||||
|
||||
|
@ -81,12 +186,44 @@ static void Publish_tests(void)
|
|||
rc = IWSDiscoveryPublisher_SetAddressFamily(publisher, WSDAPI_ADDRESSFAMILY_IPV6);
|
||||
ok(rc == STG_E_INVALIDFUNCTION, "IWSDiscoveryPublisher_SetAddressFamily(WSDAPI_ADDRESSFAMILY_IPV6) returned unexpected result: %08x\n", rc);
|
||||
|
||||
/* TODO: Register notification sink */
|
||||
/* Create notification sinks */
|
||||
ok(create_discovery_publisher_notify(&sink1) == TRUE, "create_discovery_publisher_notify failed\n");
|
||||
ok(create_discovery_publisher_notify(&sink2) == TRUE, "create_discovery_publisher_notify failed\n");
|
||||
|
||||
/* Get underlying implementation so we can check the ref count */
|
||||
sink1Impl = impl_from_IWSDiscoveryPublisherNotify(sink1);
|
||||
sink2Impl = impl_from_IWSDiscoveryPublisherNotify(sink2);
|
||||
|
||||
/* Attempt to unregister sink before registering it */
|
||||
rc = IWSDiscoveryPublisher_UnRegisterNotificationSink(publisher, sink1);
|
||||
ok(rc == E_FAIL, "IWSDiscoveryPublisher_UnRegisterNotificationSink returned unexpected result: %08x\n", rc);
|
||||
|
||||
/* Register notification sinks */
|
||||
rc = IWSDiscoveryPublisher_RegisterNotificationSink(publisher, sink1);
|
||||
ok(rc == S_OK, "IWSDiscoveryPublisher_RegisterNotificationSink failed: %08x\n", rc);
|
||||
ok(sink1Impl->ref == 2, "Ref count for sink 1 is not as expected: %d\n", sink1Impl->ref);
|
||||
|
||||
rc = IWSDiscoveryPublisher_RegisterNotificationSink(publisher, sink2);
|
||||
ok(rc == S_OK, "IWSDiscoveryPublisher_RegisterNotificationSink failed: %08x\n", rc);
|
||||
ok(sink2Impl->ref == 2, "Ref count for sink 2 is not as expected: %d\n", sink2Impl->ref);
|
||||
|
||||
/* Unregister the first sink */
|
||||
rc = IWSDiscoveryPublisher_UnRegisterNotificationSink(publisher, sink1);
|
||||
ok(rc == S_OK, "IWSDiscoveryPublisher_UnRegisterNotificationSink failed: %08x\n", rc);
|
||||
ok(sink1Impl->ref == 1, "Ref count for sink 1 is not as expected: %d\n", sink1Impl->ref);
|
||||
|
||||
/* TODO: Publish */
|
||||
|
||||
ref = IWSDiscoveryPublisher_Release(publisher);
|
||||
ok(ref == 0, "IWSDiscoveryPublisher_Release() has %d references, should have 0\n", ref);
|
||||
|
||||
/* Check that the sinks have been released by the publisher */
|
||||
ok(sink1Impl->ref == 1, "Ref count for sink 1 is not as expected: %d\n", sink1Impl->ref);
|
||||
ok(sink2Impl->ref == 1, "Ref count for sink 2 is not as expected: %d\n", sink2Impl->ref);
|
||||
|
||||
/* Release the sinks */
|
||||
IWSDiscoveryPublisherNotify_Release(sink1);
|
||||
IWSDiscoveryPublisherNotify_Release(sink2);
|
||||
}
|
||||
|
||||
START_TEST(discovery)
|
||||
|
|
Loading…
Reference in New Issue