[MSXML6_WINETEST] Import from wine-10.0

This commit is contained in:
Timo Kreuzer
2025-12-01 11:17:46 +02:00
parent 7f27f2633b
commit 01fe6475f4
7 changed files with 3717 additions and 0 deletions

View File

@@ -77,6 +77,7 @@ add_subdirectory(msvcrtd)
add_subdirectory(msvfw32)
add_subdirectory(msxml3)
add_subdirectory(msxml4)
add_subdirectory(msxml6)
add_subdirectory(netapi32)
add_subdirectory(netcfgx)
add_subdirectory(ntdll)

View File

@@ -0,0 +1,27 @@
remove_definitions(-D_CRT_NON_CONFORMING_SWPRINTFS)
add_definitions(-DUSE_WINE_TODOS)
list(APPEND SOURCE
domdoc.c
saxreader.c
schema.c)
list(APPEND PCH_SKIP_SOURCE
guid.c
testlist.c)
add_executable(msxml6_winetest
${SOURCE}
${PCH_SKIP_SOURCE})
add_dependencies(msxml6_winetest xmlparser_idlheader_test)
set_module_type(msxml6_winetest win32cui)
add_importlibs(msxml6_winetest ole32 oleaut32 msvcrt kernel32)
if(MSVC)
add_importlibs(msxml6_winetest ntdll)
endif()
add_rostests_file(TARGET msxml6_winetest)

View File

@@ -0,0 +1,344 @@
/*
* XML test
*
* Copyright 2005 Mike McCormack for CodeWeavers
* Copyright 2007-2008 Alistair Leslie-Hughes
* Copyright 2010-2011 Adam Martinson for CodeWeavers
* Copyright 2010-2013 Nikolay Sivov for CodeWeavers
* Copyright 2023 Daniel Lehman
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#define CONST_VTABLE
#include <stdio.h>
#include <assert.h>
#include "windows.h"
#include "initguid.h"
#include "msxml6.h"
#include "wine/test.h"
static BSTR alloced_bstrs[256];
static int alloced_bstrs_count;
static BSTR _bstr_(const WCHAR *str)
{
assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs));
alloced_bstrs[alloced_bstrs_count] = SysAllocString(str);
return alloced_bstrs[alloced_bstrs_count++];
}
static void free_bstrs(void)
{
int i;
for (i = 0; i < alloced_bstrs_count; i++)
SysFreeString(alloced_bstrs[i]);
alloced_bstrs_count = 0;
}
struct attrtest_t {
const WCHAR *name;
const WCHAR *uri;
const WCHAR *prefix;
const WCHAR *href;
};
static struct attrtest_t attrtests[] = {
{ L"xmlns", L"http://www.w3.org/2000/xmlns/", NULL, L"http://www.w3.org/2000/xmlns/" },
{ L"xmlns", L"nondefaulturi", NULL, L"http://www.w3.org/2000/xmlns/" },
{ L"c", L"http://www.w3.org/2000/xmlns/", NULL, L"http://www.w3.org/2000/xmlns/" },
{ L"c", L"nsref1", NULL, L"nsref1" },
{ L"ns:c", L"nsref1", L"ns", L"nsref1" },
{ L"xmlns:c", L"http://www.w3.org/2000/xmlns/", L"xmlns", L"http://www.w3.org/2000/xmlns/" },
{ L"xmlns:c", L"nondefaulturi", L"xmlns", L"http://www.w3.org/2000/xmlns/" },
{ 0 }
};
/* see dlls/msxml[34]/tests/domdoc.c */
static void test_create_attribute(void)
{
struct attrtest_t *ptr = attrtests;
IXMLDOMElement *el;
IXMLDOMDocument2 *doc;
IXMLDOMNode *node;
VARIANT var;
HRESULT hr;
int i = 0;
BSTR str;
hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
ok(hr == S_OK, "Failed to create DOMDocument60, hr %#lx.\n", hr);
while (ptr->name)
{
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ATTRIBUTE;
hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(ptr->name), _bstr_(ptr->uri), &node);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
str = NULL;
hr = IXMLDOMNode_get_prefix(node, &str);
if (ptr->prefix)
{
ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr);
ok(!lstrcmpW(str, _bstr_(ptr->prefix)), "%d: got prefix %s, expected %s\n",
i, wine_dbgstr_w(str), wine_dbgstr_w(ptr->prefix));
}
else
{
ok(hr == S_FALSE, "%d: unexpected hr %#lx\n", i, hr);
ok(str == NULL, "%d: got prefix %s\n", i, wine_dbgstr_w(str));
}
SysFreeString(str);
str = NULL;
hr = IXMLDOMNode_get_namespaceURI(node, &str);
ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr);
ok(!lstrcmpW(str, _bstr_(ptr->href)) ||
broken(!ptr->prefix && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */
"%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), wine_dbgstr_w(ptr->href));
SysFreeString(str);
IXMLDOMNode_Release(node);
free_bstrs();
i++;
ptr++;
}
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ELEMENT;
hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(L"e"), NULL, &node);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMElement, (void**)&el);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IXMLDOMNode_Release(node);
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ATTRIBUTE;
hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(L"xmlns:a"),
_bstr_(L"http://www.w3.org/2000/xmlns/"), &node);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMElement_setAttributeNode(el, (IXMLDOMAttribute*)node, NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
/* for some reason default namespace uri is not reported */
hr = IXMLDOMNode_get_namespaceURI(node, &str);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/") ||
broken(!ptr->prefix && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */
"got uri %s\n", wine_dbgstr_w(str));
SysFreeString(str);
IXMLDOMNode_Release(node);
IXMLDOMElement_Release(el);
IXMLDOMDocument2_Release(doc);
free_bstrs();
}
/* see dlls/msxml[34]/tests/domdoc.c */
static void test_namespaces_as_attributes(void)
{
struct test
{
const WCHAR *xml;
int explen;
const WCHAR *names[3];
const WCHAR *prefixes[3];
const WCHAR *basenames[3];
const WCHAR *uris[3];
const WCHAR *texts[3];
const WCHAR *xmls[3];
};
static const struct test tests[] =
{
{
L"<a ns:b=\"b attr\" d=\"d attr\" xmlns:ns=\"nshref\" />", 3,
{ L"ns:b", L"d", L"xmlns:ns" }, /* nodeName */
{ L"ns", NULL, L"xmlns" }, /* prefix */
{ L"b", L"d", L"ns" }, /* baseName */
{ L"nshref", NULL, L"" }, /* namespaceURI */
{ L"b attr", L"d attr", L"nshref" }, /* text */
{ L"ns:b=\"b attr\"", L"d=\"d attr\"", L"xmlns:ns=\"nshref\"" }, /* xml */
},
/* property only */
{
L"<a d=\"d attr\" />", 1,
{ L"d" }, /* nodeName */
{ NULL }, /* prefix */
{ L"d" }, /* baseName */
{ NULL }, /* namespaceURI */
{ L"d attr" }, /* text */
{ L"d=\"d attr\"" }, /* xml */
},
/* namespace only */
{
L"<a xmlns:ns=\"nshref\" />", 1,
{ L"xmlns:ns" }, /* nodeName */
{ L"xmlns" }, /* prefix */
{ L"ns" }, /* baseName */
{ L"" }, /* namespaceURI */
{ L"nshref" }, /* text */
{ L"xmlns:ns=\"nshref\"" }, /* xml */
},
/* default namespace */
{
L"<a xmlns=\"nshref\" />", 1,
{ L"xmlns" }, /* nodeName */
{ NULL }, /* prefix */
{ L"xmlns" }, /* baseName */
{ L"http://www.w3.org/2000/xmlns/" }, /* namespaceURI */
{ L"nshref" }, /* text */
{ L"xmlns=\"nshref\"" }, /* xml */
},
/* no properties or namespaces */
{
L"<a />", 0,
},
{ NULL }
};
const struct test *test;
IXMLDOMNamedNodeMap *map;
IXMLDOMNode *node, *item;
IXMLDOMDocument2 *doc;
VARIANT_BOOL b;
LONG len, i;
HRESULT hr;
BSTR str;
test = tests;
while (test->xml)
{
hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMDocument2_loadXML(doc, _bstr_(test->xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
node = NULL;
hr = IXMLDOMDocument2_get_firstChild(doc, &node);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMNode_get_attributes(node, &map);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
len = -1;
hr = IXMLDOMNamedNodeMap_get_length(map, &len);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(len == test->explen, "got %ld\n", len);
item = NULL;
hr = IXMLDOMNamedNodeMap_get_item(map, test->explen+1, &item);
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
ok(!item, "Item should be NULL\n");
for (i = 0; i < len; i++)
{
item = NULL;
hr = IXMLDOMNamedNodeMap_get_item(map, i, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
str = NULL;
hr = IXMLDOMNode_get_nodeName(item, &str);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!lstrcmpW(str, test->names[i]), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str);
str = NULL;
hr = IXMLDOMNode_get_prefix(item, &str);
if (test->prefixes[i])
{
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!lstrcmpW(str, test->prefixes[i]), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str);
}
else
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr );
str = NULL;
hr = IXMLDOMNode_get_baseName(item, &str);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!lstrcmpW(str, test->basenames[i]), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str);
str = NULL;
hr = IXMLDOMNode_get_namespaceURI(item, &str);
if (test->uris[i])
{
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (test->prefixes[i] && !lstrcmpW(test->prefixes[i], L"xmlns"))
ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/"),
"got %s\n", wine_dbgstr_w(str));
else
ok(!lstrcmpW(str, test->uris[i]), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str);
}
else
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr );
str = NULL;
hr = IXMLDOMNode_get_text(item, &str);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!lstrcmpW(str, test->texts[i]), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str);
str = NULL;
hr = IXMLDOMNode_get_xml(item, &str);
ok(SUCCEEDED(hr), "Failed to get node xml, hr %#lx.\n", hr);
ok(!lstrcmpW(str, test->xmls[i]), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str);
IXMLDOMNode_Release(item);
}
IXMLDOMNamedNodeMap_Release(map);
IXMLDOMNode_Release(node);
IXMLDOMDocument2_Release(doc);
test++;
}
free_bstrs();
}
START_TEST(domdoc)
{
HRESULT hr;
IXMLDOMDocument2 *doc;
hr = CoInitialize(NULL);
ok(hr == S_OK, "failed to init com\n");
hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
if (hr != S_OK)
{
win_skip("class &CLSID_DOMDocument60 not supported\n");
return;
}
IXMLDOMDocument2_Release(doc);
test_namespaces_as_attributes();
test_create_attribute();
CoUninitialize();
}

View File

@@ -0,0 +1,11 @@
/* DO NOT USE THE PRECOMPILED HEADER FOR THIS FILE! */
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#include <windef.h>
#include <winbase.h>
#include <initguid.h>
#include <objsafe.h>
/* NO CODE HERE, THIS IS JUST REQUIRED FOR THE GUID DEFINITIONS */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,447 @@
/*
* Schema test
*
* Copyright 2007 Huw Davies
* Copyright 2010 Adam Martinson for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <assert.h>
#define COBJMACROS
#include "ole2.h"
#include "msxml6.h"
#include "msxml6did.h"
#include "dispex.h"
#include "wine/test.h"
#include "initguid.h"
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
static const WCHAR xsd_schema1_uri[] = L"x-schema:test1.xsd";
static const WCHAR xsd_schema1_xml[] =
L"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test1.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>";
#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
{
IUnknown *iface = iface_ptr;
HRESULT hr, expected_hr;
IUnknown *unk;
expected_hr = supported ? S_OK : E_NOINTERFACE;
hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#lx, expected %#lx.\n", hr, expected_hr);
if (SUCCEEDED(hr))
IUnknown_Release(unk);
}
static BSTR alloced_bstrs[256];
static int alloced_bstrs_count;
static BSTR _bstr_(const WCHAR *str)
{
assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs));
alloced_bstrs[alloced_bstrs_count] = SysAllocString(str);
return alloced_bstrs[alloced_bstrs_count++];
}
static void free_bstrs(void)
{
int i;
for (i = 0; i < alloced_bstrs_count; i++)
SysFreeString(alloced_bstrs[i]);
alloced_bstrs_count = 0;
}
static IXMLDOMDocument2 *create_document(void)
{
IXMLDOMDocument2 *obj = NULL;
HRESULT hr;
hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&obj);
ok(hr == S_OK, "Failed to create a document object, hr %#lx.\n", hr);
return obj;
}
static void *create_cache(REFIID riid)
{
void *obj = NULL;
HRESULT hr;
hr = CoCreateInstance(&CLSID_XMLSchemaCache60, NULL, CLSCTX_INPROC_SERVER, riid, &obj);
ok(hr == S_OK, "Failed to create a document object, hr %#lx.\n", hr);
return obj;
}
static HRESULT validate_regex_document(IXMLDOMDocument2 *doc, IXMLDOMDocument2 *schema, IXMLDOMSchemaCollection* cache,
const WCHAR *regex, const WCHAR *input)
{
static const WCHAR regex_doc[] =
L""
"<?xml version='1.0'?>"
"<root xmlns='urn:test'>%s</root>";
static const WCHAR regex_schema[] =
L"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='urn:test'>"
" <element name='root'>"
" <simpleType>"
" <restriction base='string'>"
" <pattern value='%s'/>"
" </restriction>"
" </simpleType>"
" </element>"
"</schema>";
WCHAR buffer[1024];
IXMLDOMParseError* err;
BSTR namespace, bstr;
VARIANT_BOOL b;
HRESULT hr;
VARIANT v;
VariantInit(&v);
swprintf(buffer, ARRAY_SIZE(buffer), regex_doc, input);
bstr = SysAllocString(buffer);
hr = IXMLDOMDocument2_loadXML(doc, bstr, &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
SysFreeString(bstr);
swprintf(buffer, ARRAY_SIZE(buffer), regex_schema, regex);
bstr = SysAllocString(buffer);
hr = IXMLDOMDocument2_loadXML(schema, bstr, &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
SysFreeString(bstr);
/* add the schema to the cache */
V_VT(&v) = VT_DISPATCH;
V_DISPATCH(&v) = NULL;
hr = IXMLDOMDocument2_QueryInterface(schema, &IID_IDispatch, (void**)&V_DISPATCH(&v));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
namespace = SysAllocString(L"urn:test");
hr = IXMLDOMSchemaCollection_add(cache, namespace, v);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
SysFreeString(namespace);
VariantClear(&v);
/*
if (FAILED(hr))
return hr;
*/
/* associate the cache to the doc */
V_VT(&v) = VT_DISPATCH;
V_DISPATCH(&v) = NULL;
hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
hr = IXMLDOMDocument2_putref_schemas(doc, v);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
VariantClear(&v);
/* validate the doc
* only declared elements in the declared order
* this is fine */
err = NULL;
bstr = NULL;
hr = IXMLDOMDocument2_validate(doc, &err);
ok(err != NULL, "domdoc_validate() should always set err\n");
if (IXMLDOMParseError_get_reason(err, &bstr) != S_FALSE)
trace("got error: %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
IXMLDOMParseError_Release(err);
return hr;
}
static void test_regex(void)
{
static const struct regex_test
{
const WCHAR *regex;
const WCHAR *input;
}
tests[] =
{
{ L"\\!", L"!" },
{ L"\\\"", L"\"" },
{ L"\\#", L"#" },
{ L"\\$", L"$" },
{ L"\\%", L"%" },
{ L"\\,", L"," },
{ L"\\/", L"/" },
{ L"\\:", L":" },
{ L"\\;", L";" },
{ L"\\=", L"=" },
{ L"\\>", L">" },
{ L"\\@", L"@" },
{ L"\\`", L"`" },
{ L"\\~", L"~" },
{ L"\\uCAFE", L"\xCAFE" },
/* non-BMP character in surrogate pairs: */
{ L"\\uD83D\\uDE00", L"\xD83D\xDE00" },
/* "x{,2}" is non-standard and only works on libxml2 <= v2.9.10 */
{ L"x{0,2}", L"x" }
};
unsigned int i;
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
const struct regex_test *test = &tests[i];
IXMLDOMDocument2 *doc, *schema;
IXMLDOMSchemaCollection *cache;
HRESULT hr;
winetest_push_context("Test %s", wine_dbgstr_w(test->regex));
doc = create_document();
schema = create_document();
cache = create_cache(&IID_IXMLDOMSchemaCollection);
hr = validate_regex_document(doc, schema, cache, tests->regex, tests->input);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (doc)
IXMLDOMDocument2_Release(doc);
if (schema)
IXMLDOMDocument2_Release(schema);
if (cache)
IXMLDOMSchemaCollection_Release(cache);
winetest_pop_context();
}
}
static void test_get(void)
{
IXMLDOMSchemaCollection2 *cache;
IXMLDOMNode *node;
HRESULT hr;
cache = create_cache(&IID_IXMLDOMSchemaCollection2);
hr = IXMLDOMSchemaCollection2_get(cache, NULL, NULL);
ok(hr == E_NOTIMPL || hr == E_POINTER /* win8 */, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection2_get(cache, _bstr_(L"uri"), &node);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
IXMLDOMSchemaCollection2_Release(cache);
free_bstrs();
}
static void test_ifaces(void)
{
IXMLDOMSchemaCollection2 *cache;
IUnknown *unk;
HRESULT hr;
cache = create_cache(&IID_IXMLDOMSchemaCollection2);
/* CLSID_XMLSchemaCache60 is returned as an interface (the same as IXMLDOMSchemaCollection2). */
hr = IXMLDOMSchemaCollection2_QueryInterface(cache, &CLSID_XMLSchemaCache60, (void**)&unk);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(unk == (IUnknown *)cache, "Unexpected pointer %p.\n", unk);
IUnknown_Release(unk);
check_interface(cache, &IID_IXMLDOMSchemaCollection, TRUE);
check_interface(cache, &IID_IXMLDOMSchemaCollection2, TRUE);
check_interface(cache, &IID_IDispatch, TRUE);
check_interface(cache, &IID_IDispatchEx, TRUE);
IXMLDOMSchemaCollection2_Release(cache);
}
static void test_remove(void)
{
IXMLDOMSchemaCollection2 *cache;
IXMLDOMDocument2 *doc;
VARIANT_BOOL b;
HRESULT hr;
VARIANT v;
LONG len;
cache = create_cache(&IID_IXMLDOMSchemaCollection2);
doc = create_document();
ok(doc != NULL, "got %p\n", doc);
hr = IXMLDOMDocument2_loadXML(doc, _bstr_(xsd_schema1_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
V_VT(&v) = VT_DISPATCH;
V_DISPATCH(&v) = (IDispatch*)doc;
hr = IXMLDOMSchemaCollection2_add(cache, _bstr_(xsd_schema1_uri), v);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
len = -1;
hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(len == 1, "Unexpected length %ld.\n", len);
/* ::remove() is a stub for version 6 */
hr = IXMLDOMSchemaCollection2_remove(cache, NULL);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(L"invaliduri"));
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(xsd_schema1_uri));
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
len = -1;
hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(len == 1, "Unexpected length %ld.\n", len);
IXMLDOMDocument2_Release(doc);
IXMLDOMSchemaCollection2_Release(cache);
free_bstrs();
}
static void test_obj_dispex(IUnknown *obj)
{
DISPID dispid = DISPID_SAX_XMLREADER_GETFEATURE;
IDispatchEx *dispex;
IUnknown *unk;
DWORD props;
UINT ticnt;
HRESULT hr;
BSTR name;
hr = IUnknown_QueryInterface(obj, &IID_IDispatchEx, (void**)&dispex);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (FAILED(hr)) return;
ticnt = 0;
hr = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(ticnt == 1, "ticnt=%u\n", ticnt);
name = SysAllocString(L"*");
hr = IDispatchEx_DeleteMemberByName(dispex, name, fdexNameCaseSensitive);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
SysFreeString(name);
hr = IDispatchEx_DeleteMemberByDispID(dispex, dispid);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
props = 0;
hr = IDispatchEx_GetMemberProperties(dispex, dispid, grfdexPropCanAll, &props);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
ok(props == 0, "expected 0 got %ld\n", props);
hr = IDispatchEx_GetMemberName(dispex, dispid, &name);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
if (SUCCEEDED(hr)) SysFreeString(name);
hr = IDispatchEx_GetNextDispID(dispex, fdexEnumDefault, DISPID_XMLDOM_SCHEMACOLLECTION_ADD, &dispid);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
unk = (IUnknown*)0xdeadbeef;
hr = IDispatchEx_GetNameSpaceParent(dispex, &unk);
ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
ok(unk == (IUnknown*)0xdeadbeef, "got %p\n", unk);
name = SysAllocString(L"testprop");
hr = IDispatchEx_GetDispID(dispex, name, fdexNameEnsure, &dispid);
ok(hr == DISP_E_UNKNOWNNAME, "Unexpected hr %#lx.\n", hr);
SysFreeString(name);
IDispatchEx_Release(dispex);
}
static void test_dispex(void)
{
IXMLDOMSchemaCollection *cache;
IUnknown *unk;
HRESULT hr;
cache = create_cache(&IID_IXMLDOMSchemaCollection);
hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IUnknown, (void**)&unk);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
test_obj_dispex(unk);
IUnknown_Release(unk);
IXMLDOMSchemaCollection_Release(cache);
}
static void test_validate_on_load(void)
{
IXMLDOMSchemaCollection2 *cache;
VARIANT_BOOL b;
HRESULT hr;
cache = create_cache(&IID_IXMLDOMSchemaCollection2);
hr = IXMLDOMSchemaCollection2_get_validateOnLoad(cache, NULL);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
b = VARIANT_FALSE;
hr = IXMLDOMSchemaCollection2_get_validateOnLoad(cache, &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "got %d\n", b);
IXMLDOMSchemaCollection2_Release(cache);
}
START_TEST(schema)
{
IUnknown *obj;
HRESULT hr;
hr = CoInitialize(NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&obj);
if (FAILED(hr))
{
win_skip("DOMDocument60 is not supported.\n");
CoUninitialize();
return;
}
IUnknown_Release(obj);
test_regex();
test_get();
test_ifaces();
test_remove();
test_dispex();
test_validate_on_load();
CoUninitialize();
}

View File

@@ -0,0 +1,16 @@
/* Automatically generated file; DO NOT EDIT!! */
#define STANDALONE
#include <wine/test.h>
extern void func_domdoc(void);
extern void func_saxreader(void);
extern void func_schema(void);
const struct test winetest_testlist[] =
{
{ "domdoc", func_domdoc },
{ "saxreader", func_saxreader },
{ "schema", func_schema },
{ 0, 0 }
};