Implement test cases for `IXMLDOMElement_removeAttributeNode()` function. Cover the successful removal and failure codes for double removal and `NULL` pointer removal.
The function is currently unimplemented in wine.
This is the recommended first step according to the contribution documentation (do coverage MR first, then implementation MR).
WineTestBot submission can be found here: https://testbot.winehq.org/JobDetails.pl?Key=159792&f101=exe32.report#k1...
The VMs `debian11` and `debian11b` show the following errors, which should be unrelated to this MR.
``` msxml3 domdoc.c:10563: Test failed: got L"xmlns:rdf" domdoc.c:10563: Test failed: got L"xmlns:dcterms" domdoc.c:10563: Test failed: got L"xmlns:foaf" ```
Once this one is merged I'll create the implementation MR.
I tried to match the formatting. If I've missed something please tell me and I'll fix it.
From: Reinhold Gschweicher pyro4hell+winehq@gmail.com
Implement test cases for `IXMLDOMElement_removeAttributeNode()` function. Cover the successful removal and failure codes for double removal and `NULL` pointer removal.
The function is currently unimplemented in wine. --- dlls/msxml3/tests/domdoc.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 175919b5169..70284d43294 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -2218,6 +2218,7 @@ static void test_domnode( void ) IXMLDOMNode *node = NULL, *next = NULL; IXMLDOMNodeList *list = NULL; IXMLDOMAttribute *attr = NULL; + IXMLDOMAttribute *attr_out = NULL; DOMNodeType type = NODE_INVALID; VARIANT_BOOL b; HRESULT hr; @@ -2324,8 +2325,41 @@ static void test_domnode( void ) IXMLDOMAttribute_Release(attr); }
+ attr = NULL; + hr = IXMLDOMElement_getAttributeNode( element, str, &attr ); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(attr != NULL, "getAttributeNode returned NULL\n"); + if (attr) + { + attr_out = NULL; + hr = IXMLDOMElement_removeAttributeNode(element, attr, &attr_out ); +todo_wine { + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(attr_out != NULL, "removeAttributeNode expected to set attr_out, but got NULL pointer\n"); +} + if (attr_out) + { + /* remove the same attribute again returns invalid arg */ + hr = IXMLDOMElement_removeAttributeNode( element, attr, NULL ); + ok(hr == E_INVALIDARG, "removeAttributeNode removed an already removed node, unexpected hr %#lx.\n", hr); + + /* readd removed attribute to recover previous state */ + hr = IXMLDOMElement_setAttributeNode(element, attr_out, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + IXMLDOMAttribute_Release(attr_out); + } + IXMLDOMAttribute_Release(attr); + } + SysFreeString( str );
+ attr = NULL; + attr_out = (IXMLDOMAttribute*)0xdeadbeef; + hr = IXMLDOMElement_removeAttributeNode( element, attr, &attr_out ); + todo_wine ok(hr == E_INVALIDARG, "removeAttributeNode removed a NULL pointer hr: %#lx.\n", hr); + ok(attr_out == (IXMLDOMAttribute*)0xdeadbeef, "removeAttributeNode expected to not touch attr_out in error case, got (%p)\n", attr_out); + hr = IXMLDOMElement_get_attributes( element, &map ); ok(hr == S_OK, "get_attributes returned wrong code\n"); ok( map != NULL, "should be attributes\n");