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 the bug bellow.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57325. --- dlls/msxml3/tests/domdoc.c | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 96b390ee784..3ac930cff55 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -14137,9 +14137,56 @@ static void test_validate_on_parse_values(void) } }
+static void test_indent(void) +{ + HRESULT hr; + VARIANT_BOOL b = VARIANT_FALSE; + BSTR data, str, data_expected; + IXMLDOMDocument *doc; + IXMLDOMElement *element = NULL; + + 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); + + data_expected = SysAllocString(L"<root>\r\n" + "\t<a>\r\n" + "\t\t<b/>\r\n" + "\t</a>\r\n" + "</root>"); + ok(!lstrcmpW(data, data_expected), "incorrect element string, got '%s'\n", wine_dbgstr_w(data)); + + SysFreeString(str); + SysFreeString(data_expected); +} + +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 +14280,12 @@ START_TEST(domdoc) test_mxnamespacemanager_override(); }
+ /* We need to test test_indent in a seperate thread. This is to prevent regressions in multi-threaded + applications where the default indentation is set (e.g. by setting xmlTreeIndentString) in the first + thread but not for new threads, leading to the wrong indentation in subsequent threads. */ + thread = CreateThread(NULL, 0, new_thread, NULL, 0, NULL); + WaitForSingleObject(thread, INFINITE); + CloseHandle(thread); + CoUninitialize(); }