From: Daniel Lehman dlehman25@gmail.com
--- dlls/msxml3/tests/domdoc.c | 160 ++++++++++++++++++++++++------------- 1 file changed, 105 insertions(+), 55 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index a8b125b54a5..964addf90d1 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13318,22 +13318,45 @@ struct attrtest_t { const char *uri; const char *prefix; const char *href; + MSXML_VERSION versions; + BOOL todo; };
static struct attrtest_t attrtests[] = { - { "xmlns", "http://www.w3.org/2000/xmlns/", "xmlns", "xmlns" }, - { "xmlns", "nondefaulturi", "xmlns", "xmlns" }, + { "xmlns", "http://www.w3.org/2000/xmlns/", "xmlns", "xmlns", ~MSXML6 }, + { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", MSXML6, TRUE }, + { "xmlns", "nondefaulturi", "xmlns", "xmlns", ~MSXML6 }, + { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", MSXML6, 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", "" }, - { "xmlns:c", "nondefaulturi", "xmlns", "" }, + { "xmlns:c", "http://www.w3.org/2000/xmlns/", "xmlns", "", ~MSXML6 }, + { "xmlns:c", "http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2000/xmlns/", MSXML6 }, + { "xmlns:c", "nondefaulturi", "xmlns", "", ~MSXML6 }, + { "xmlns:c", "nondefaulturi", "xmlns", "http://www.w3.org/2000/xmlns/", MSXML6 }, + { 0 } +}; + +typedef struct _create_attribute { + const GUID *guid; + const char *clsid; + MSXML_VERSION ver; +} create_attribute; + +static const create_attribute create_attribute_test_data[] = { + { &CLSID_DOMDocument, "CLSID_DOMDocument", MSXML1 }, + { &CLSID_DOMDocument2, "CLSID_DOMDocument2", MSXML2 }, + { &CLSID_DOMDocument26, "CLSID_DOMDocument26", MSXML26 }, + { &CLSID_DOMDocument30, "CLSID_DOMDocument30", MSXML3 }, + { &CLSID_DOMDocument40, "CLSID_DOMDocument40", MSXML4 }, + { &CLSID_DOMDocument60, "CLSID_DOMDocument60", MSXML6 }, { 0 } };
static void test_create_attribute(void) { - struct attrtest_t *ptr = attrtests; + const create_attribute *entry = create_attribute_test_data; + struct attrtest_t *ptr; IXMLDOMElement *el; IXMLDOMDocument *doc; IXMLDOMNode *node, *node2; @@ -13342,69 +13365,96 @@ static void test_create_attribute(void) int i = 0; BSTR str;
- doc = create_document(&IID_IXMLDOMDocument); - - while (ptr->name) + while (entry->guid) { - V_VT(&var) = VT_I1; - V_I1(&var) = NODE_ATTRIBUTE; - hr = IXMLDOMDocument_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) + if (!is_clsid_supported(entry->guid, &IID_IXMLDOMDocument2)) { - 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); + entry++; + continue; } - else + + ptr = attrtests; + while (ptr->name) { - 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); + if (ptr->versions && !(entry->ver & ptr->versions)) + { + ptr++; + continue; + } + hr = CoCreateInstance(entry->guid, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc); + ok(SUCCEEDED(hr), "Failed to create document %s, hr %#lx.\n", wine_dbgstr_guid(entry->guid), hr);
- 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)), "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), ptr->href); - SysFreeString(str); + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + hr = IXMLDOMDocument_createNode(doc, var, _bstr_(ptr->name), _bstr_(ptr->uri), &node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IXMLDOMNode_Release(node); - free_bstrs(); + str = NULL; + hr = IXMLDOMNode_get_prefix(node, &str); + if (ptr->prefix) + { + /* MSXML4 can report different results with different service packs */ + ok(hr == S_OK || broken(entry->ver == MSXML4 && hr == S_FALSE), + "Failed to get prefix, hr %#lx.\n", hr); + ok(!lstrcmpW(str, _bstr_(ptr->prefix)) || + broken(!str && entry->ver == MSXML4), "got %s\n", wine_dbgstr_w(str)); + } + 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);
- i++; - ptr++; - } + 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 && entry->ver == MSXML6 && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */ + "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), ptr->href); + SysFreeString(str);
- V_VT(&var) = VT_I1; - V_I1(&var) = NODE_ELEMENT; - hr = IXMLDOMDocument_createNode(doc, var, _bstr_("e"), NULL, &node2); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IXMLDOMNode_Release(node); + free_bstrs();
- hr = IXMLDOMNode_QueryInterface(node2, &IID_IXMLDOMElement, (void**)&el); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - IXMLDOMNode_Release(node2); + i++; + ptr++; + }
- V_VT(&var) = VT_I1; - V_I1(&var) = NODE_ATTRIBUTE; - hr = IXMLDOMDocument_createNode(doc, var, _bstr_("xmlns:a"), _bstr_("http://www.w3.org/2000/xmlns/"), &node); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ELEMENT; + hr = IXMLDOMDocument_createNode(doc, var, _bstr_("e"), NULL, &node2); + 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); + hr = IXMLDOMNode_QueryInterface(node2, &IID_IXMLDOMElement, (void**)&el); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IXMLDOMNode_Release(node2);
- /* 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""), "got uri %s\n", wine_dbgstr_w(str)); - SysFreeString(str); + V_VT(&var) = VT_I1; + V_I1(&var) = NODE_ATTRIBUTE; + hr = IXMLDOMDocument_createNode(doc, var, _bstr_("xmlns:a"), _bstr_("http://www.w3.org/2000/xmlns/"), &node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- IXMLDOMNode_Release(node); - IXMLDOMElement_Release(el); - IXMLDOMDocument_Release(doc); - free_bstrs(); + 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, entry->ver == MSXML6 ? L"http://www.w3.org/2000/xmlns/" : L""), + "got uri %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + IXMLDOMNode_Release(node); + IXMLDOMElement_Release(el); + IXMLDOMDocument_Release(doc); + free_bstrs(); + + entry++; + } }
static void test_url(void)