Owen Rudge : wsdapi: Create default XML context in WSDCreateDiscoveryPublisher if required.
Alexandre Julliard
julliard at winehq.org
Fri Jun 2 17:03:28 CDT 2017
Module: wine
Branch: master
Commit: 9c9180f60677f05824e10f604952a95699dcf5cc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c9180f60677f05824e10f604952a95699dcf5cc
Author: Owen Rudge <orudge at codeweavers.com>
Date: Tue May 30 23:05:56 2017 +0100
wsdapi: Create default XML context in WSDCreateDiscoveryPublisher if required.
Signed-off-by: Owen Rudge <orudge at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wsdapi/discovery.c | 12 ++++++++--
dlls/wsdapi/tests/discovery.c | 51 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/dlls/wsdapi/discovery.c b/dlls/wsdapi/discovery.c
index ea0f34b..c9ef9c2 100644
--- a/dlls/wsdapi/discovery.c
+++ b/dlls/wsdapi/discovery.c
@@ -360,10 +360,18 @@ HRESULT WINAPI WSDCreateDiscoveryPublisher(IWSDXMLContext *pContext, IWSDiscover
obj->IWSDiscoveryPublisher_iface.lpVtbl = &publisher_vtbl;
obj->ref = 1;
- obj->xmlContext = pContext;
- if (pContext != NULL)
+ if (pContext == NULL)
{
+ if (FAILED(WSDXMLCreateContext(&obj->xmlContext)))
+ {
+ WARN("Unable to create XML context\n");
+ return E_OUTOFMEMORY;
+ }
+ }
+ else
+ {
+ obj->xmlContext = pContext;
IWSDXMLContext_AddRef(pContext);
}
diff --git a/dlls/wsdapi/tests/discovery.c b/dlls/wsdapi/tests/discovery.c
index ffe64b0..db5947d 100644
--- a/dlls/wsdapi/tests/discovery.c
+++ b/dlls/wsdapi/tests/discovery.c
@@ -162,6 +162,56 @@ static void CreateDiscoveryPublisher_tests(void)
ok(ref == 0, "IWSDiscoveryPublisher_Release() has %d references, should have 0\n", ref);
}
+static void CreateDiscoveryPublisher_XMLContext_tests(void)
+{
+ IWSDiscoveryPublisher *publisher = NULL;
+ IWSDXMLContext *xmlContext, *returnedContext;
+ HRESULT rc;
+ int ref;
+
+ /* Test creating an XML context and supplying it to WSDCreateDiscoveryPublisher */
+ rc = WSDXMLCreateContext(&xmlContext);
+ ok(rc == S_OK, "WSDXMLCreateContext failed: %08x\n", rc);
+
+ rc = WSDCreateDiscoveryPublisher(xmlContext, &publisher);
+ ok(rc == S_OK, "WSDCreateDiscoveryPublisher(xmlContext, &publisher) failed: %08x\n", rc);
+ ok(publisher != NULL, "WSDCreateDiscoveryPublisher(xmlContext, &publisher) failed: publisher == NULL\n");
+
+ rc = IWSDiscoveryPublisher_GetXMLContext(publisher, NULL);
+ ok(rc == E_INVALIDARG, "GetXMLContext returned unexpected value with NULL argument: %08x\n", rc);
+
+ rc = IWSDiscoveryPublisher_GetXMLContext(publisher, &returnedContext);
+ ok(rc == S_OK, "GetXMLContext failed: %08x\n", rc);
+
+ ok(xmlContext == returnedContext, "GetXMLContext returned unexpected value: returnedContext == %p\n", returnedContext);
+
+ ref = IWSDXMLContext_Release(returnedContext);
+ ok(ref == 2, "IWSDXMLContext_Release() has %d references, should have 2\n", ref);
+
+ ref = IWSDiscoveryPublisher_Release(publisher);
+ ok(ref == 0, "IWSDiscoveryPublisher_Release() has %d references, should have 0\n", ref);
+
+ ref = IWSDXMLContext_Release(returnedContext);
+ ok(ref == 0, "IWSDXMLContext_Release() has %d references, should have 0\n", ref);
+
+ /* Test using a default XML context */
+ publisher = NULL;
+ returnedContext = NULL;
+
+ rc = WSDCreateDiscoveryPublisher(NULL, &publisher);
+ ok(rc == S_OK, "WSDCreateDiscoveryPublisher(NULL, &publisher) failed: %08x\n", rc);
+ ok(publisher != NULL, "WSDCreateDiscoveryPublisher(NULL, &publisher) failed: publisher == NULL\n");
+
+ rc = IWSDiscoveryPublisher_GetXMLContext(publisher, &returnedContext);
+ ok(rc == S_OK, "GetXMLContext failed: %08x\n", rc);
+
+ ref = IWSDXMLContext_Release(returnedContext);
+ ok(ref == 1, "IWSDXMLContext_Release() has %d references, should have 1\n", ref);
+
+ ref = IWSDiscoveryPublisher_Release(publisher);
+ ok(ref == 0, "IWSDiscoveryPublisher_Release() has %d references, should have 0\n", ref);
+}
+
static void Publish_tests(void)
{
IWSDiscoveryPublisher *publisher = NULL;
@@ -231,6 +281,7 @@ START_TEST(discovery)
CoInitialize(NULL);
CreateDiscoveryPublisher_tests();
+ CreateDiscoveryPublisher_XMLContext_tests();
Publish_tests();
CoUninitialize();
More information about the wine-cvs
mailing list