Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
b57c881f
Commit
b57c881f
authored
Apr 18, 2017
by
Owen Rudge
Committed by
Alexandre Julliard
Apr 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wsdapi/tests: Add tests for Register/UnRegisterNotificationSink.
Signed-off-by:
Owen Rudge
<
orudge@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
44048e06
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
138 additions
and
1 deletion
+138
-1
discovery.c
dlls/wsdapi/tests/discovery.c
+138
-1
No files found.
dlls/wsdapi/tests/discovery.c
View file @
b57c881f
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment