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=159816
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.
edit: remove mention of failing tests, update WineTestBot link, fixed by rebasing on 3cfbf9e3cd99dd01d3215c6952ae18ce88207d22
-- v6: msxml3/tests: add test for IXMLDOMElement_removeAttributeNode.
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 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 175919b5169..dcda4821125 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,37 @@ 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"); + 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_out = (IXMLDOMAttribute*)0xdeadbeef; + hr = IXMLDOMElement_removeAttributeNode( element, NULL, &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");
On Wed Sep 17 20:42:06 2025 +0000, Nikolay Sivov wrote:
Please squash commits.
rebased and squashed :thumbsup:
This merge request was approved by Nikolay Sivov.