Adding a test to make sure the indentation of xml elements is a tab even after moving to another thread. To prevent regressions like the bug bellow.
From: Orin Varley ovarley@codeweavers.com
Adding a test to make sure the indentation of xml elements is a tab even after moving to another thread. To prevent regressions like https://bugs.winehq.org/show_bug.cgi?id=57325. --- dlls/msxml3/tests/domdoc.c | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 96b390ee784..6bb4962a600 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -14137,9 +14137,54 @@ static void test_validate_on_parse_values(void) } }
+static void test_indent(void) +{ + HRESULT hr; + VARIANT_BOOL b = VARIANT_FALSE; + BSTR data, str; + IXMLDOMDocument *doc; + IXMLDOMElement *element = NULL; + int i, nTab = 0; + + str = SysAllocString(L"<?xml version='1.0' encoding='Windows-1252'?>\n" + "<root>\n" + "<a>\n" + "<b/>\n" + "</a>\n" + "</root>\n"); + hr = CoCreateInstance(&CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void **)&doc); + ok(hr == S_OK, "Unable to create instance hr %#lx.\n", hr); + hr = IXMLDOMDocument_loadXML(doc, str, &b); + ok(hr == S_OK, "Unable to load XML hr %#lx.\n", hr); + hr = IXMLDOMDocument_get_documentElement(doc, &element); + ok(hr == S_OK, "Unable to get element hr %#lx.\n", hr); + hr = IXMLDOMElement_get_xml(element, &data); + ok(hr == S_OK, "Unable to get XML hr %#lx.\n", hr); + + for (i = 0; i < SysStringLen(data); i ++) + if ((data)[i] == '\t') + nTab++; + ok(nTab == 4, "Wrong indentation, found %i tabs (expected 4)\n", nTab); + + SysFreeString(str); +} + +static DWORD WINAPI new_thread(void *arg) +{ + HRESULT hr = CoInitialize(NULL); + ok(hr == S_OK, "failed to init com\n"); + if (hr != S_OK) return 1; + + test_indent(); + + CoUninitialize(); + return 0; +} + START_TEST(domdoc) { HRESULT hr; + HANDLE thread;
hr = CoInitialize( NULL ); ok( hr == S_OK, "failed to init com\n"); @@ -14233,5 +14278,10 @@ START_TEST(domdoc) test_mxnamespacemanager_override(); }
+ /* We need to test test_indent in a seperate thread */ + thread = CreateThread(NULL, 0, new_thread, NULL, 0, NULL); + WaitForSingleObject(thread, INFINITE); + CloseHandle(thread); + CoUninitialize(); }
Nikolay Sivov (@nsivov) commented about dlls/msxml3/tests/domdoc.c:
test_mxnamespacemanager_override(); }
- /* We need to test test_indent in a seperate thread */
Please extend this comment to explain why we need to run this on a new thread.
Nikolay Sivov (@nsivov) commented about dlls/msxml3/tests/domdoc.c:
"<b/>\n"
"</a>\n"
"</root>\n");
- hr = CoCreateInstance(&CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (void **)&doc);
- ok(hr == S_OK, "Unable to create instance hr %#lx.\n", hr);
- hr = IXMLDOMDocument_loadXML(doc, str, &b);
- ok(hr == S_OK, "Unable to load XML hr %#lx.\n", hr);
- hr = IXMLDOMDocument_get_documentElement(doc, &element);
- ok(hr == S_OK, "Unable to get element hr %#lx.\n", hr);
- hr = IXMLDOMElement_get_xml(element, &data);
- ok(hr == S_OK, "Unable to get XML hr %#lx.\n", hr);
- for (i = 0; i < SysStringLen(data); i ++)
if ((data)[i] == '\t')
nTab++;
- ok(nTab == 4, "Wrong indentation, found %i tabs (expected 4)\n", nTab);
Could we check the whole string instead?
On Fri Nov 22 15:30:01 2024 +0000, Nikolay Sivov wrote:
Could we check the whole string instead?
Yeah sure, can do. I'll put that in now
On Fri Nov 22 15:30:01 2024 +0000, Nikolay Sivov wrote:
Please extend this comment to explain why we need to run this on a new thread.
Will do