From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/msxml3/tests/xmldoc.c | 129 +++++++++++++++++++++++++++++++------ 1 file changed, 110 insertions(+), 19 deletions(-)
diff --git a/dlls/msxml3/tests/xmldoc.c b/dlls/msxml3/tests/xmldoc.c index 47a987586c9..d2997b1652a 100644 --- a/dlls/msxml3/tests/xmldoc.c +++ b/dlls/msxml3/tests/xmldoc.c @@ -162,25 +162,6 @@ static void test_xmldoc(void)
ok(stream != NULL, "Expected non-NULL stream\n");
- /* version field */ - hr = IXMLDocument_get_version(doc, NULL); - ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); - - name = NULL; - hr = IXMLDocument_get_version(doc, &name); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(!lstrcmpW(name, L"1.0"), "Expected 1.0, got %s\n", wine_dbgstr_w(name)); - SysFreeString(name); - - /* doctype */ - hr = IXMLDocument_get_doctype(doc, NULL); - ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); - - hr = IXMLDocument_get_doctype(doc, &name); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(!lstrcmpW(name, L"BANKACCOUNT"), "Expected BANKACCOUNT, got %s\n", wine_dbgstr_w(name)); - SysFreeString(name); - hr = IXMLDocument_get_root(doc, &element); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(element != NULL, "Expected non-NULL element\n"); @@ -1110,6 +1091,9 @@ static const char doc_data2[] = static const char doc_data3[] = "<?xml version=\"1.0\" encoding=\"bad\"?><a/>";
+static const char doc_data4[] = + "<?xml version=\"1.1\"?><a/>"; + static void test_xmldoc_charset(void) { IXMLDocument *doc; @@ -1169,6 +1153,111 @@ static void test_xmldoc_charset(void) IXMLDocument_Release(doc); }
+static void test_xmldoc_version(void) +{ + IXMLDocument *doc; + HRESULT hr; + BSTR s; + + hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDocument, (void **)&doc); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXMLDocument_get_version(doc, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + if (strcmp(winetest_platform, "wine")) + { + s = NULL; + hr = IXMLDocument_get_version(doc, &s); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!wcscmp(s, L"1.0"), "Unexpected version %s.\n", wine_dbgstr_w(s)); + SysFreeString(s); + } + + hr = load_document(doc, "<a/>", 4); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + s = NULL; + hr = IXMLDocument_get_version(doc, &s); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!wcscmp(s, L"1.0"), "Unexpected version %s.\n", wine_dbgstr_w(s)); + SysFreeString(s); + + hr = load_document(doc, doc_data4, sizeof(doc_data4) - 1); + todo_wine + ok(hr == XML_E_INVALID_VERSION, "Unexpected hr %#lx.\n", hr); + + IXMLDocument_Release(doc); +} + +static const char doc_data5[] = + "<?xml version=\"1.0\"?>\n" + "<!DOCTYPE name1 SYSTEM \"sys.url\">\n" + "<a/>"; + +static const char doc_data6[] = + "<?xml version=\"1.0\"?>\n" + "<!DOCTYPE name2 PUBLIC \"pudid\" \"pub.url\">\n" + "<a/>"; + +static const char doc_data7[] = + "<?xml version=\"1.0\"?>\n" + "<!DOCTYPE greeting [<!ELEMENT greeting (#PCDATA)>]>\n" + "<a/>"; + +static void test_xmldoc_doctype(void) +{ + IXMLDocument *doc; + HRESULT hr; + BSTR s; + + hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDocument, (void **)&doc); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXMLDocument_get_doctype(doc, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + /* Without doctype. */ + hr = load_document(doc, doc_data2, sizeof(doc_data2) - 1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + s = (void *)0x1; + hr = IXMLDocument_get_doctype(doc, &s); + ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(!s, "Unexpected doctype %s.\n", wine_dbgstr_w(s)); + + /* With doctype. */ + hr = load_document(doc, doc_data5, sizeof(doc_data5) - 1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + s = NULL; + hr = IXMLDocument_get_doctype(doc, &s); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!wcscmp(s, L"NAME1"), "Unexpected doctype %s.\n", wine_dbgstr_w(s)); + SysFreeString(s); + + hr = load_document(doc, doc_data6, sizeof(doc_data6) - 1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + s = NULL; + hr = IXMLDocument_get_doctype(doc, &s); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!wcscmp(s, L"NAME2"), "Unexpected doctype %s.\n", wine_dbgstr_w(s)); + SysFreeString(s); + + hr = load_document(doc, doc_data7, sizeof(doc_data7) - 1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + s = NULL; + hr = IXMLDocument_get_doctype(doc, &s); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!wcscmp(s, L"GREETING"), "Unexpected doctype %s.\n", wine_dbgstr_w(s)); + SysFreeString(s); + + IXMLDocument_Release(doc); +} + START_TEST(xmldoc) { HRESULT hr; @@ -1184,6 +1273,8 @@ START_TEST(xmldoc)
test_xmldoc(); test_xmldoc_charset(); + test_xmldoc_version(); + test_xmldoc_doctype(); test_createElement(); test_persiststreaminit(); test_xmlelem();