Commit 19b7f33a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml/tests: Move version-specific schema tests to corresponding modules.

parent 91f3d8b0
......@@ -34,21 +34,6 @@
#include "wine/test.h"
#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 const WCHAR xdr_schema1_uri[] = L"x-schema:test1.xdr";
static const WCHAR xdr_schema1_xml[] =
L"<?xml version='1.0'?>"
......@@ -100,46 +85,6 @@ L"<?xml version='1.0'?>"
"</Schema>";
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>";
static const WCHAR xsd_schema2_uri[] = L"x-schema:test2.xsd";
static const WCHAR xsd_schema2_xml[] =
L"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test2.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>";
static const WCHAR xsd_schema3_uri[] = L"x-schema:test3.xsd";
static const WCHAR xsd_schema3_xml[] =
L"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test3.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>";
static const WCHAR szDatatypeXDR[] =
L"<Schema xmlns='urn:schemas-microsoft-com:xml-data'\n"
......@@ -986,9 +931,9 @@ static void test_length(void)
static void test_collection_content(void)
{
IXMLDOMDocument2 *schema1, *schema2, *schema3, *schema4, *schema5;
IXMLDOMDocument2 *schema1, *schema2, *schema3;
BSTR content[5] = {NULL, NULL, NULL, NULL, NULL};
IXMLDOMSchemaCollection *cache1, *cache2;
IXMLDOMSchemaCollection *cache1;
VARIANT_BOOL b;
LONG length;
HRESULT hr;
......@@ -1000,7 +945,6 @@ static void test_collection_content(void)
schema3 = create_document_version(30, &IID_IXMLDOMDocument2);
cache1 = create_cache_version(30, &IID_IXMLDOMSchemaCollection);
cache2 = create_cache_version(40, &IID_IXMLDOMSchemaCollection);
if (!schema1 || !schema2 || !schema3 || !cache1)
{
......@@ -1041,53 +985,6 @@ static void test_collection_content(void)
IXMLDOMDocument2_Release(schema2);
IXMLDOMDocument2_Release(schema3);
if (cache2)
{
schema1 = create_document_version(40, &IID_IXMLDOMDocument2);
schema2 = create_document_version(40, &IID_IXMLDOMDocument2);
schema3 = create_document_version(40, &IID_IXMLDOMDocument2);
schema4 = create_document_version(40, &IID_IXMLDOMDocument2);
schema5 = create_document_version(40, &IID_IXMLDOMDocument2);
hr = IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
hr = IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
hr = IXMLDOMDocument2_loadXML(schema3, _bstr_(xsd_schema1_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
hr = IXMLDOMDocument2_loadXML(schema4, _bstr_(xsd_schema2_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
hr = IXMLDOMDocument2_loadXML(schema5, _bstr_(xsd_schema3_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
/* combining XDR and XSD schemas in the same cache is fine */
hr = IXMLDOMSchemaCollection_add(cache2, _bstr_(xdr_schema1_uri), _variantdoc_(schema1));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection_add(cache2, _bstr_(xdr_schema2_uri), _variantdoc_(schema2));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection_add(cache2, _bstr_(xsd_schema1_uri), _variantdoc_(schema3));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection_add(cache2, _bstr_(xsd_schema2_uri), _variantdoc_(schema4));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection_add(cache2, _bstr_(xsd_schema3_uri), _variantdoc_(schema5));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
length = -1;
hr = IXMLDOMSchemaCollection_get_length(cache2, &length);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(length == 5, "Unexpected length %ld.\n", length);
IXMLDOMDocument2_Release(schema1);
IXMLDOMDocument2_Release(schema2);
IXMLDOMDocument2_Release(schema3);
IXMLDOMDocument2_Release(schema4);
IXMLDOMDocument2_Release(schema5);
}
bstr = (void*)0xdeadbeef;
/* error if index is out of range */
hr = IXMLDOMSchemaCollection_get_namespaceURI(cache1, 3, &bstr);
......@@ -1131,30 +1028,7 @@ static void test_collection_content(void)
content[i] = NULL;
}
if (cache2)
{
for (i = 0; i < 5; ++i)
{
bstr = NULL;
hr = IXMLDOMSchemaCollection_get_namespaceURI(cache2, i, &bstr);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(bstr != NULL && *bstr, "expected non-empty string\n");
for (j = 0; j < i; ++j)
ok(wcscmp(content[j], bstr), "got duplicate entry\n");
content[i] = bstr;
}
for (i = 0; i < 5; ++i)
{
SysFreeString(content[i]);
content[i] = NULL;
}
}
IXMLDOMSchemaCollection_Release(cache1);
if (cache2) IXMLDOMSchemaCollection_Release(cache2);
free_bstrs();
}
......@@ -1569,26 +1443,6 @@ static void test_XDR_datatypes(void)
free_bstrs();
}
static void test_validate_on_load(void)
{
IXMLDOMSchemaCollection2 *cache;
VARIANT_BOOL b;
HRESULT hr;
cache = create_cache_version(40, &IID_IXMLDOMSchemaCollection2);
if (!cache) return;
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);
}
static void test_obj_dispex(IUnknown *obj)
{
DISPID dispid = DISPID_SAX_XMLREADER_GETFEATURE;
......@@ -1677,158 +1531,6 @@ static void test_dispex(void)
IDispatchEx_Release(dispex);
IXMLDOMSchemaCollection_Release(cache);
cache = create_cache_version(60, &IID_IXMLDOMSchemaCollection);
if (cache)
{
test_obj_dispex((IUnknown*)cache);
IXMLDOMSchemaCollection_Release(cache);
}
}
static void test_get(void)
{
IXMLDOMSchemaCollection2 *cache;
IXMLDOMNode *node;
HRESULT hr;
cache = create_cache_version(60, &IID_IXMLDOMSchemaCollection2);
if (!cache) return;
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);
cache = create_cache_version(40, &IID_IXMLDOMSchemaCollection2);
if (!cache) return;
hr = IXMLDOMSchemaCollection2_get(cache, NULL, NULL);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection2_get(cache, _bstr_(L"uri"), &node);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IXMLDOMSchemaCollection2_Release(cache);
free_bstrs();
}
static void test_remove(void)
{
IXMLDOMSchemaCollection2 *cache;
IXMLDOMDocument *doc;
VARIANT_BOOL b;
HRESULT hr;
VARIANT v;
LONG len;
cache = create_cache_version(60, &IID_IXMLDOMSchemaCollection2);
if (!cache) return;
doc = create_document_version(60, &IID_IXMLDOMDocument);
ok(doc != NULL, "got %p\n", doc);
hr = IXMLDOMDocument_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);
IXMLDOMDocument_Release(doc);
IXMLDOMSchemaCollection2_Release(cache);
free_bstrs();
/* ::remove() works for version 4 */
cache = create_cache_version(40, &IID_IXMLDOMSchemaCollection2);
if (!cache) return;
doc = create_document_version(40, &IID_IXMLDOMDocument);
ok(doc != NULL, "got %p\n", doc);
hr = IXMLDOMDocument_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);
hr = IXMLDOMSchemaCollection2_remove(cache, NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(L"invaliduri"));
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);
hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(xsd_schema1_uri));
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 == 0, "Unexpected length %ld.\n", len);
IXMLDOMDocument_Release(doc);
IXMLDOMSchemaCollection2_Release(cache);
free_bstrs();
}
static void test_ifaces(void)
{
IXMLDOMSchemaCollection2 *cache;
IUnknown *unk;
HRESULT hr;
cache = create_cache_version(60, &IID_IXMLDOMSchemaCollection2);
if (!cache) return;
/* 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, "unk != cache\n");
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);
}
START_TEST(schema)
......@@ -1844,11 +1546,7 @@ START_TEST(schema)
test_collection_content();
test_XDR_schemas();
test_XDR_datatypes();
test_validate_on_load();
test_dispex();
test_get();
test_remove();
test_ifaces();
CoUninitialize();
}
......@@ -28,6 +28,108 @@
#include "wine/test.h"
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>";
static const WCHAR xsd_schema2_uri[] = L"x-schema:test2.xsd";
static const WCHAR xsd_schema2_xml[] =
L"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test2.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>";
static const WCHAR xsd_schema3_uri[] = L"x-schema:test3.xsd";
static const WCHAR xsd_schema3_xml[] =
L"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test3.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>";
static const WCHAR xdr_schema1_uri[] = L"x-schema:test1.xdr";
static const WCHAR xdr_schema1_xml[] =
L"<?xml version='1.0'?>"
"<Schema xmlns='urn:schemas-microsoft-com:xml-data'"
" xmlns:dt='urn:schemas-microsoft-com:datatypes'"
" name='test1.xdr'>"
" <ElementType name='x' dt:type='boolean'/>"
" <ElementType name='y'>"
" <datatype dt:type='int'/>"
" </ElementType>"
" <ElementType name='z'/>"
" <ElementType name='root' content='eltOnly' model='open' order='seq'>"
" <element type='x'/>"
" <element type='y'/>"
" <element type='z'/>"
" </ElementType>"
"</Schema>";
static const WCHAR xdr_schema2_uri[] = L"x-schema:test2.xdr";
static const WCHAR xdr_schema2_xml[] =
L"<?xml version='1.0'?>"
"<Schema xmlns='urn:schemas-microsoft-com:xml-data'"
" xmlns:dt='urn:schemas-microsoft-com:datatypes'"
" name='test2.xdr'>"
" <ElementType name='x' dt:type='bin.base64'/>"
" <ElementType name='y' dt:type='uuid'/>"
" <ElementType name='z'/>"
" <ElementType name='root' content='eltOnly' model='closed' order='one'>"
" <element type='x'/>"
" <element type='y'/>"
" <element type='z'/>"
" </ElementType>"
"</Schema>";
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 VARIANT _variantdoc_(void* doc)
{
VARIANT v;
V_VT(&v) = VT_DISPATCH;
V_DISPATCH(&v) = (IDispatch*)doc;
return v;
}
static IXMLDOMDocument2 *create_document(void)
{
IXMLDOMDocument2 *obj = NULL;
......@@ -39,12 +141,12 @@ static IXMLDOMDocument2 *create_document(void)
return obj;
}
static IXMLDOMSchemaCollection *create_cache(void)
static void *create_cache(REFIID riid)
{
IXMLDOMSchemaCollection *obj = NULL;
void *obj = NULL;
HRESULT hr;
hr = CoCreateInstance(&CLSID_XMLSchemaCache40, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMSchemaCollection, (void **)&obj);
hr = CoCreateInstance(&CLSID_XMLSchemaCache40, NULL, CLSCTX_INPROC_SERVER, riid, &obj);
ok(hr == S_OK, "Failed to create a document object, hr %#lx.\n", hr);
return obj;
......@@ -176,7 +278,7 @@ static void test_regex(void)
doc = create_document();
schema = create_document();
cache = create_cache();
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);
......@@ -192,6 +294,175 @@ static void test_regex(void)
}
}
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_POINTER, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection2_get(cache, _bstr_(L"uri"), &node);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IXMLDOMSchemaCollection2_Release(cache);
free_bstrs();
}
static void test_remove(void)
{
IXMLDOMSchemaCollection2 *cache;
IXMLDOMDocument2 *doc;
VARIANT_BOOL b;
HRESULT hr;
VARIANT v;
LONG len;
/* ::remove() works for version 4 */
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);
hr = IXMLDOMSchemaCollection2_remove(cache, NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(L"invaliduri"));
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);
hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(xsd_schema1_uri));
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 == 0, "Unexpected length %ld.\n", len);
IXMLDOMDocument2_Release(doc);
IXMLDOMSchemaCollection2_Release(cache);
free_bstrs();
}
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);
}
static void test_collection_content(void)
{
IXMLDOMDocument2 *schema1, *schema2, *schema3, *schema4, *schema5;
IXMLDOMSchemaCollection *cache;
BSTR content[5] = { 0 };
VARIANT_BOOL b;
LONG length;
HRESULT hr;
BSTR bstr;
int i, j;
schema1 = create_document();
schema2 = create_document();
schema3 = create_document();
schema4 = create_document();
schema5 = create_document();
cache = create_cache(&IID_IXMLDOMSchemaCollection);
hr = IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
hr = IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
hr = IXMLDOMDocument2_loadXML(schema3, _bstr_(xsd_schema1_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
hr = IXMLDOMDocument2_loadXML(schema4, _bstr_(xsd_schema2_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
hr = IXMLDOMDocument2_loadXML(schema5, _bstr_(xsd_schema3_xml), &b);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(b == VARIANT_TRUE, "failed to load XML\n");
/* combining XDR and XSD schemas in the same cache is fine */
hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema1_uri), _variantdoc_(schema1));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema2_uri), _variantdoc_(schema2));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xsd_schema1_uri), _variantdoc_(schema3));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xsd_schema2_uri), _variantdoc_(schema4));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xsd_schema3_uri), _variantdoc_(schema5));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
length = -1;
hr = IXMLDOMSchemaCollection_get_length(cache, &length);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(length == 5, "Unexpected length %ld.\n", length);
for (i = 0; i < 5; ++i)
{
bstr = NULL;
hr = IXMLDOMSchemaCollection_get_namespaceURI(cache, i, &bstr);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(bstr != NULL && *bstr, "expected non-empty string\n");
for (j = 0; j < i; ++j)
ok(wcscmp(content[j], bstr), "got duplicate entry\n");
content[i] = bstr;
}
for (i = 0; i < 5; ++i)
{
SysFreeString(content[i]);
content[i] = NULL;
}
IXMLDOMDocument2_Release(schema1);
IXMLDOMDocument2_Release(schema2);
IXMLDOMDocument2_Release(schema3);
IXMLDOMDocument2_Release(schema4);
IXMLDOMDocument2_Release(schema5);
IXMLDOMSchemaCollection_Release(cache);
free_bstrs();
}
START_TEST(schema)
{
IUnknown *obj;
......@@ -210,6 +481,10 @@ START_TEST(schema)
IUnknown_Release(obj);
test_regex();
test_get();
test_remove();
test_validate_on_load();
test_collection_content();
CoUninitialize();
}
......@@ -25,9 +25,62 @@
#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;
......@@ -39,12 +92,12 @@ static IXMLDOMDocument2 *create_document(void)
return obj;
}
static IXMLDOMSchemaCollection *create_cache(void)
static void *create_cache(REFIID riid)
{
IXMLDOMSchemaCollection *obj = NULL;
void *obj = NULL;
HRESULT hr;
hr = CoCreateInstance(&CLSID_XMLSchemaCache60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMSchemaCollection, (void **)&obj);
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;
......@@ -176,7 +229,7 @@ static void test_regex(void)
doc = create_document();
schema = create_document();
cache = create_cache();
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);
......@@ -192,6 +245,180 @@ static void test_regex(void)
}
}
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;
......@@ -210,6 +437,11 @@ START_TEST(schema)
IUnknown_Release(obj);
test_regex();
test_get();
test_ifaces();
test_remove();
test_dispex();
test_validate_on_load();
CoUninitialize();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment