Commit 969c8afa authored by Daniel Lehman's avatar Daniel Lehman Committed by Alexandre Julliard

msxml6/tests: Copy create namespace tests.

With changes for msxml6 and TODOs for wine.
parent bd7213ec
......@@ -13327,6 +13327,7 @@ static struct attrtest_t attrtests[] = {
{ 0 }
};
/* see dlls/msxml[46]/tests/domdoc.c */
static void test_create_attribute(void)
{
struct attrtest_t *ptr = attrtests;
......
......@@ -54,6 +54,112 @@ static void free_bstrs(void)
alloced_bstrs_count = 0;
}
struct attrtest_t {
const WCHAR *name;
const WCHAR *uri;
const WCHAR *prefix;
const WCHAR *href;
BOOL todo;
};
static struct attrtest_t attrtests[] = {
{ L"xmlns", L"http://www.w3.org/2000/xmlns/", NULL, L"http://www.w3.org/2000/xmlns/", TRUE },
{ L"xmlns", L"nondefaulturi", NULL, L"http://www.w3.org/2000/xmlns/", TRUE },
{ L"c", L"http://www.w3.org/2000/xmlns/", NULL, L"http://www.w3.org/2000/xmlns/" },
{ L"c", L"nsref1", NULL, L"nsref1" },
{ L"ns:c", L"nsref1", L"ns", L"nsref1" },
{ L"xmlns:c", L"http://www.w3.org/2000/xmlns/", L"xmlns", L"http://www.w3.org/2000/xmlns/" },
{ L"xmlns:c", L"nondefaulturi", L"xmlns", L"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;
VARIANT var;
HRESULT hr;
int i = 0;
BSTR str;
hr = CoCreateInstance(&CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&doc);
ok(hr == S_OK, "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), wine_dbgstr_w(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), wine_dbgstr_w(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_(L"e"), NULL, &node);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMElement, (void**)&el);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IXMLDOMNode_Release(node);
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ATTRIBUTE;
hr = IXMLDOMDocument2_createNode(doc, var, _bstr_(L"xmlns:a"),
_bstr_(L"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)
{
......@@ -240,6 +346,7 @@ START_TEST(domdoc)
IXMLDOMDocument2_Release(doc);
test_namespaces_as_attributes();
test_create_attribute();
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