Commit f95a1116 authored by Daniel Lehman's avatar Daniel Lehman Committed by Alexandre Julliard

msxml3/tests: Add some more namespaces tests.

parent 4460cb33
......@@ -12850,15 +12850,50 @@ static const namespace_as_attribute_t namespace_as_attribute_test_data[] = {
static void test_namespaces_as_attributes(void)
{
const namespace_as_attribute_t *entry = namespace_as_attribute_test_data;
static const char ns_as_attr_doc[] = {
"<?xml version=\"1.0\"?>"
"<a ns:b=\"b attr\" d=\"d attr\" xmlns:ns=\"nshref\" />"
struct test {
const char *xml;
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 char *prefixes[] = { "ns", NULL, "xmlns" };
static const char *basenames[] = { "b", "d", "ns" };
static const char *uris[] = { "nshref", NULL, "" };
static const char *texts[] = { "b attr", "d attr", "nshref" };
static const struct test tests[] = {
{
"<a ns:b=\"b attr\" d=\"d attr\" xmlns:ns=\"nshref\" />", 3,
{ "ns:b", "d", "xmlns:ns" }, /* nodeName */
{ "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;
IXMLDOMNode *node, *item;
IXMLDOMDocument *doc;
......@@ -12875,10 +12910,12 @@ static void test_namespaces_as_attributes(void)
continue;
}
test = tests;
while (test->xml) {
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);
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);
node = NULL;
......@@ -12891,7 +12928,12 @@ static void test_namespaces_as_attributes(void)
len = -1;
hr = IXMLDOMNamedNodeMap_get_length(map, &len);
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++)
{
......@@ -12902,15 +12944,15 @@ static void test_namespaces_as_attributes(void)
str = NULL;
hr = IXMLDOMNode_get_nodeName(item, &str);
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);
str = NULL;
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(!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);
}
else
......@@ -12919,19 +12961,19 @@ static void test_namespaces_as_attributes(void)
str = NULL;
hr = IXMLDOMNode_get_baseName(item, &str);
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);
str = NULL;
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);
if (prefixes[i] && !strcmp(prefixes[i], "xmlns"))
if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns"))
todo_wine_if(entry->todo)
ok(!lstrcmpW(str, _bstr_(entry->xmlns_uri)), "got %s\n", wine_dbgstr_w(str));
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);
}
else
......@@ -12940,7 +12982,7 @@ static void test_namespaces_as_attributes(void)
str = NULL;
hr = IXMLDOMNode_get_text(item, &str);
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);
IXMLDOMNode_Release(item);
......@@ -12950,6 +12992,9 @@ static void test_namespaces_as_attributes(void)
IXMLDOMNode_Release(node);
IXMLDOMDocument_Release(doc);
test++;
}
entry++;
}
free_bstrs();
......
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