msxml3/tests: Add some more namespaces tests.

Signed-off-by: Daniel Lehman <dlehman25@gmail.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Daniel Lehman 2018-10-15 21:14:35 -07:00 committed by Alexandre Julliard
parent 4460cb3377
commit f95a111608
1 changed files with 111 additions and 66 deletions

View File

@ -12850,15 +12850,50 @@ static const namespace_as_attribute_t namespace_as_attribute_test_data[] = {
static void test_namespaces_as_attributes(void) static void test_namespaces_as_attributes(void)
{ {
const namespace_as_attribute_t *entry = namespace_as_attribute_test_data; const namespace_as_attribute_t *entry = namespace_as_attribute_test_data;
static const char ns_as_attr_doc[] = { struct test {
"<?xml version=\"1.0\"?>" const char *xml;
"<a ns:b=\"b attr\" d=\"d attr\" xmlns:ns=\"nshref\" />" int explen;
const char *names[3];
const char *prefixes[3];
const char *basenames[3];
const char *uris[3];
const char *texts[3];
}; };
static const char *names[] = { "ns:b", "d", "xmlns:ns" }; static const struct test tests[] = {
static const char *prefixes[] = { "ns", NULL, "xmlns" }; {
static const char *basenames[] = { "b", "d", "ns" }; "<a ns:b=\"b attr\" d=\"d attr\" xmlns:ns=\"nshref\" />", 3,
static const char *uris[] = { "nshref", NULL, "" }; { "ns:b", "d", "xmlns:ns" }, /* nodeName */
static const char *texts[] = { "b attr", "d attr", "nshref" }; { "ns", NULL, "xmlns" }, /* prefix */
{ "b", "d", "ns" }, /* baseName */
{ "nshref", NULL, "" }, /* namespaceURI */
{ "b attr", "d attr", "nshref" }, /* text */
},
/* property only */
{
"<a d=\"d attr\" />", 1,
{ "d" }, /* nodeName */
{ NULL }, /* prefix */
{ "d" }, /* baseName */
{ NULL }, /* namespaceURI */
{ "d attr" }, /* text */
},
/* namespace only */
{
"<a xmlns:ns=\"nshref\" />", 1,
{ "xmlns:ns" }, /* nodeName */
{ "xmlns" }, /* prefix */
{ "ns" }, /* baseName */
{ "" }, /* namespaceURI */
{ "nshref" }, /* text */
},
/* no properties or namespaces */
{
"<a />", 0,
},
{ NULL }
};
const struct test *test;
IXMLDOMNamedNodeMap *map; IXMLDOMNamedNodeMap *map;
IXMLDOMNode *node, *item; IXMLDOMNode *node, *item;
IXMLDOMDocument *doc; IXMLDOMDocument *doc;
@ -12875,10 +12910,12 @@ static void test_namespaces_as_attributes(void)
continue; continue;
} }
test = tests;
while (test->xml) {
hr = CoCreateInstance(entry->guid, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); hr = CoCreateInstance(entry->guid, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
ok(SUCCEEDED(hr), "Failed to create document %s, hr %#x.\n", wine_dbgstr_guid(entry->guid), hr); ok(SUCCEEDED(hr), "Failed to create document %s, hr %#x.\n", wine_dbgstr_guid(entry->guid), hr);
hr = IXMLDOMDocument_loadXML(doc, _bstr_(ns_as_attr_doc), &b); hr = IXMLDOMDocument_loadXML(doc, _bstr_(test->xml), &b);
ok(hr == S_OK, "Failed to load xml, hr %#x.\n", hr); ok(hr == S_OK, "Failed to load xml, hr %#x.\n", hr);
node = NULL; node = NULL;
@ -12891,7 +12928,12 @@ static void test_namespaces_as_attributes(void)
len = -1; len = -1;
hr = IXMLDOMNamedNodeMap_get_length(map, &len); hr = IXMLDOMNamedNodeMap_get_length(map, &len);
ok(SUCCEEDED(hr), "Failed to get map length, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to get map length, hr %#x.\n", hr);
ok(len == 3, "got %d\n", len); ok(len == test->explen, "got %d\n", len);
item = NULL;
hr = IXMLDOMNamedNodeMap_get_item(map, test->explen+1, &item);
ok(hr == S_FALSE, "Failed to get item, hr %#x.\n", hr);
ok(!item, "Item should be NULL\n");
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
@ -12902,15 +12944,15 @@ static void test_namespaces_as_attributes(void)
str = NULL; str = NULL;
hr = IXMLDOMNode_get_nodeName(item, &str); hr = IXMLDOMNode_get_nodeName(item, &str);
ok(SUCCEEDED(hr), "Failed to get node name, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to get node name, hr %#x.\n", hr);
ok(!lstrcmpW(str, _bstr_(names[i])), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, _bstr_(test->names[i])), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str); SysFreeString(str);
str = NULL; str = NULL;
hr = IXMLDOMNode_get_prefix(item, &str); hr = IXMLDOMNode_get_prefix(item, &str);
if (prefixes[i]) if (test->prefixes[i])
{ {
ok(hr == S_OK, "Failed to get node name, hr %#x.\n", hr); ok(hr == S_OK, "Failed to get node name, hr %#x.\n", hr);
ok(!lstrcmpW(str, _bstr_(prefixes[i])), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str); SysFreeString(str);
} }
else else
@ -12919,19 +12961,19 @@ static void test_namespaces_as_attributes(void)
str = NULL; str = NULL;
hr = IXMLDOMNode_get_baseName(item, &str); hr = IXMLDOMNode_get_baseName(item, &str);
ok(SUCCEEDED(hr), "Failed to get base name, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to get base name, hr %#x.\n", hr);
ok(!lstrcmpW(str, _bstr_(basenames[i])), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, _bstr_(test->basenames[i])), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str); SysFreeString(str);
str = NULL; str = NULL;
hr = IXMLDOMNode_get_namespaceURI(item, &str); hr = IXMLDOMNode_get_namespaceURI(item, &str);
if (uris[i]) if (test->uris[i])
{ {
ok(hr == S_OK, "Failed to get node name, hr %#x.\n", hr); ok(hr == S_OK, "Failed to get node name, hr %#x.\n", hr);
if (prefixes[i] && !strcmp(prefixes[i], "xmlns")) if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns"))
todo_wine_if(entry->todo) todo_wine_if(entry->todo)
ok(!lstrcmpW(str, _bstr_(entry->xmlns_uri)), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, _bstr_(entry->xmlns_uri)), "got %s\n", wine_dbgstr_w(str));
else else
ok(!lstrcmpW(str, _bstr_(uris[i])), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str); SysFreeString(str);
} }
else else
@ -12940,7 +12982,7 @@ static void test_namespaces_as_attributes(void)
str = NULL; str = NULL;
hr = IXMLDOMNode_get_text(item, &str); hr = IXMLDOMNode_get_text(item, &str);
ok(SUCCEEDED(hr), "Failed to get node text, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to get node text, hr %#x.\n", hr);
ok(!lstrcmpW(str, _bstr_(texts[i])), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, _bstr_(test->texts[i])), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str); SysFreeString(str);
IXMLDOMNode_Release(item); IXMLDOMNode_Release(item);
@ -12950,6 +12992,9 @@ static void test_namespaces_as_attributes(void)
IXMLDOMNode_Release(node); IXMLDOMNode_Release(node);
IXMLDOMDocument_Release(doc); IXMLDOMDocument_Release(doc);
test++;
}
entry++; entry++;
} }
free_bstrs(); free_bstrs();