wsdapi/tests: Add tests for WSDXMLAddSibling.

Signed-off-by: Owen Rudge <orudge@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Owen Rudge 2017-05-03 23:55:58 +01:00 committed by Alexandre Julliard
parent 19241ca6f7
commit e90aaaabe6
1 changed files with 89 additions and 0 deletions

View File

@ -194,8 +194,97 @@ static void AddChild_tests(void)
WSDFreeLinkedMemory(parent);
}
static void AddSibling_tests(void)
{
WSDXML_ELEMENT *parent, *child1, *child2, *child3;
WSDXML_NAME parentName, child1Name, child2Name;
WSDXML_NAMESPACE ns;
WCHAR parentNameText[] = {'D','a','d',0};
WCHAR child1NameText[] = {'T','i','m',0};
WCHAR child2NameText[] = {'B','o','b',0};
static const WCHAR uri[] = {'h','t','t','p',':','/','/','t','e','s','t','.','t','e','s','t','/',0};
static const WCHAR prefix[] = {'t',0};
HRESULT hr;
/* Test invalid values */
hr = WSDXMLAddSibling(NULL, NULL);
ok(hr == E_INVALIDARG, "WSDXMLAddSibling failed with %08x\n", hr);
hr = WSDXMLAddSibling(child1, NULL);
ok(hr == E_INVALIDARG, "WSDXMLAddSibling failed with %08x\n", hr);
hr = WSDXMLAddSibling(NULL, child2);
ok(hr == E_INVALIDARG, "WSDXMLAddSibling failed with %08x\n", hr);
/* Populate structures */
ns.Uri = uri;
ns.PreferredPrefix = prefix;
parentName.LocalName = parentNameText;
parentName.Space = &ns;
child1Name.LocalName = child1NameText;
child1Name.Space = &ns;
child2Name.LocalName = child2NameText;
child2Name.Space = &ns;
/* Create some elements */
hr = WSDXMLBuildAnyForSingleElement(&parentName, NULL, &parent);
ok(hr == S_OK, "BuildAnyForSingleElement failed with %08x\n", hr);
hr = WSDXMLBuildAnyForSingleElement(&child1Name, child1NameText, &child1);
ok(hr == S_OK, "BuildAnyForSingleElement failed with %08x\n", hr);
hr = WSDXMLBuildAnyForSingleElement(&child2Name, NULL, &child2);
ok(hr == S_OK, "BuildAnyForSingleElement failed with %08x\n", hr);
hr = WSDXMLBuildAnyForSingleElement(&child2Name, NULL, &child3);
ok(hr == S_OK, "BuildAnyForSingleElement failed with %08x\n", hr);
/* Add child1 to parent */
hr = WSDXMLAddChild(parent, child1);
ok(hr == S_OK, "WSDXMLAddChild failed with %08x\n", hr);
ok(parent->Node.Parent == NULL, "parent->Node.Parent == %p\n", parent->Node.Parent);
ok(parent->FirstChild == (WSDXML_NODE *)child1, "parent->FirstChild == %p\n", parent->FirstChild);
ok(parent->Node.Next == NULL, "parent->Node.Next == %p\n", parent->Node.Next);
ok(child1->Node.Parent == parent, "child1->Node.Parent == %p\n", child1->Node.Parent);
ok(child1->FirstChild != NULL, "child1->FirstChild == NULL\n");
ok(child1->FirstChild->Type == TextType, "child1->FirstChild.Type == %d\n", child1->FirstChild->Type);
ok(child1->Node.Next == NULL, "child1->Node.Next == %p\n", child1->Node.Next);
ok(child2->Node.Parent == NULL, "child2->Node.Parent == %p\n", child2->Node.Parent);
ok(child2->FirstChild == NULL, "child2->FirstChild == %p\n", child2->FirstChild);
ok(child2->Node.Next == NULL, "child2->Node.Next == %p\n", child2->Node.Next);
/* Try to add child2 as sibling of child1 */
hr = WSDXMLAddSibling(child1, child2);
ok(hr == S_OK, "WSDXMLAddSibling failed with %08x\n", hr);
ok(child1->Node.Parent == parent, "child1->Node.Parent == %p\n", child1->Node.Parent);
ok(child1->Node.Next == (WSDXML_NODE *)child2, "child1->Node.Next == %p\n", child1->Node.Next);
ok(child2->Node.Parent == parent, "child2->Node.Parent == %p\n", child2->Node.Parent);
ok(child2->Node.Next == NULL, "child2->Node.Next == %p\n", child2->Node.Next);
ok(parent->FirstChild == (WSDXML_NODE *)child1, "parent->FirstChild == %p\n", parent->FirstChild);
/* Try to add child3 as sibling of child1 */
hr = WSDXMLAddSibling(child1, child3);
ok(hr == S_OK, "WSDXMLAddSibling failed with %08x\n", hr);
ok(child1->Node.Parent == parent, "child1->Node.Parent == %p\n", child1->Node.Parent);
ok(child1->Node.Next == (WSDXML_NODE *)child2, "child1->Node.Next == %p\n", child1->Node.Next);
ok(child2->Node.Parent == parent, "child2->Node.Parent == %p\n", child2->Node.Parent);
ok(child2->Node.Next == (WSDXML_NODE *)child3, "child2->Node.Next == %p\n", child2->Node.Next);
ok(child3->Node.Parent == parent, "child2->Node.Parent == %p\n", child2->Node.Parent);
ok(child3->Node.Next == NULL, "child2->Node.Next == %p\n", child2->Node.Next);
ok(parent->FirstChild == (WSDXML_NODE *)child1, "parent->FirstChild == %p\n", parent->FirstChild);
WSDFreeLinkedMemory(parent);
}
START_TEST(xml)
{
BuildAnyForSingleElement_tests();
AddChild_tests();
AddSibling_tests();
}