From: Daniel Lehman dlehman25@gmail.com
with changes for msxml6 and TODOs for wine --- dlls/msxml6/tests/domdoc.c | 105 +++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+)
diff --git a/dlls/msxml6/tests/domdoc.c b/dlls/msxml6/tests/domdoc.c index a943d58b835..741a4ff7d09 100644 --- a/dlls/msxml6/tests/domdoc.c +++ b/dlls/msxml6/tests/domdoc.c @@ -62,6 +62,110 @@ static void free_bstrs(void) alloced_bstrs_count = 0; }
+struct attrtest_t { + const char *name; + const char *uri; + const char *prefix; + const char *href; + BOOL todo; +}; + +static struct attrtest_t attrtests[] = { + { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", TRUE }, + { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", TRUE }, + { "c", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/" }, + { "c", "nsref1", NULL, "nsref1" }, + { "ns:c", "nsref1", "ns", "nsref1" }, + { "xmlns:c", "http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2000/xmlns/" }, + { "xmlns:c", "nondefaulturi", "xmlns", "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, *node2; + VARIANT var; + HRESULT hr; + int i = 0; + BSTR str; + + hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); + ok(SUCCEEDED(hr), "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), ptr->prefix); + } + else + { + todo_wine_if(ptr->todo) { + 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); + todo_wine_if(ptr->todo) + 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), 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_("e"), NULL, &node2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXMLDOMNode_QueryInterface(node2, &IID_IXMLDOMElement, (void**)&el); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IXMLDOMNode_Release(node2); + + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + hr = IXMLDOMDocument2_createNode(doc, var, _bstr_("xmlns:a"), _bstr_("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) { @@ -222,6 +326,7 @@ START_TEST(domdoc) ok( hr == S_OK, "failed to init com\n"); if (hr != S_OK) return;
+ test_create_attribute(); test_namespaces_as_attributes();
CoUninitialize();