4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2007-2008 Alistair Leslie-Hughes
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/test.h"
34 static const WCHAR szEmpty
[] = { 0 };
35 static const WCHAR szIncomplete
[] = {
36 '<','?','x','m','l',' ',
37 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
39 static const WCHAR szComplete1
[] = {
40 '<','?','x','m','l',' ',
41 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
42 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
44 static const WCHAR szComplete2
[] = {
45 '<','?','x','m','l',' ',
46 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
47 '<','o','>','<','/','o','>','\n',0
49 static const WCHAR szComplete3
[] = {
50 '<','?','x','m','l',' ',
51 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
52 '<','a','>','<','/','a','>','\n',0
54 static const WCHAR szComplete4
[] = {
55 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
56 '<','l','c',' ','d','l','=','\'','s','t','r','1','\'','>','\n',
57 '<','b','s',' ','v','r','=','\'','s','t','r','2','\'',' ','s','z','=','\'','1','2','3','4','\'','>',
58 'f','n','1','.','t','x','t','\n',
59 '<','/','b','s','>','\n',
60 '<','p','r',' ','i','d','=','\'','s','t','r','3','\'',' ','v','r','=','\'','1','.','2','.','3','\'',' ',
61 'p','n','=','\'','w','i','n','e',' ','2','0','0','5','0','8','0','4','\'','>','\n',
62 'f','n','2','.','t','x','t','\n',
63 '<','/','p','r','>','\n',
64 '<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
68 '<','/','b','a','>','\n',
69 '<','/','f','o','>','\n',
70 '<','/','l','c','>','\n',0
72 static const WCHAR szComplete5
[] = {
73 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
74 'x','m','l','n','s',':','C','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y','"',
75 ' ','x','m','l','n','s',':','S','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y',':','s','e','a','r','c','h','"','>',
76 '<','S',':','s','c','o','p','e','>',
77 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
78 '<','/','S',':','s','c','o','p','e','>',
79 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
80 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
81 'c','o','m','p','u','t','e','r',
82 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
83 '<','/','S',':','s','e','a','r','c','h','>',0
86 static const CHAR szExampleXML
[] =
87 "<?xml version='1.0' encoding='utf-8'?>\n"
88 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
93 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
94 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
95 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
103 " <c type=\"old\">C2 field</c>\n"
106 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
115 " <foo:c>C4 field</foo:c>\n"
119 static const CHAR szTransformXML
[] =
120 "<?xml version=\"1.0\"?>\n"
125 static const CHAR szTransformSSXML
[] =
126 "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n"
127 " <xsl:output method=\"html\"/>\n"
128 " <xsl:template match=\"/\">\n"
129 " <xsl:apply-templates select=\"greeting\"/>\n"
131 " <xsl:template match=\"greeting\">\n"
135 " <xsl:value-of select=\".\"/>\n"
142 static const CHAR szTransformOutput
[] =
145 "</h1></body></html>";
147 static const WCHAR szNonExistentFile
[] = {
148 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
150 static const WCHAR szDocument
[] = {
151 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
154 static const WCHAR szOpen
[] = { 'o','p','e','n',0 };
155 static WCHAR szdl
[] = { 'd','l',0 };
156 static const WCHAR szvr
[] = { 'v','r',0 };
157 static const WCHAR szlc
[] = { 'l','c',0 };
158 static WCHAR szbs
[] = { 'b','s',0 };
159 static const WCHAR szstr1
[] = { 's','t','r','1',0 };
160 static const WCHAR szstr2
[] = { 's','t','r','2',0 };
161 static const WCHAR szstar
[] = { '*',0 };
162 static const WCHAR szfn1_txt
[] = {'f','n','1','.','t','x','t',0};
164 static WCHAR szComment
[] = {'A',' ','C','o','m','m','e','n','t',0 };
165 static WCHAR szCommentXML
[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
166 static WCHAR szCommentNodeText
[] = {'#','c','o','m','m','e','n','t',0 };
168 static WCHAR szElement
[] = {'E','l','e','T','e','s','t', 0 };
169 static WCHAR szElementXML
[] = {'<','E','l','e','T','e','s','t','/','>',0 };
170 static WCHAR szElementXML2
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
171 static WCHAR szElementXML3
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
172 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
174 static WCHAR szAttribute
[] = {'A','t','t','r',0 };
175 static WCHAR szAttributeXML
[] = {'A','t','t','r','=','"','"',0 };
177 static WCHAR szCData
[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
178 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
179 static WCHAR szCDataXML
[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
180 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
182 static WCHAR szCDataNodeText
[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
183 static WCHAR szDocFragmentText
[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
185 static WCHAR szEntityRef
[] = {'e','n','t','i','t','y','r','e','f',0 };
186 static WCHAR szEntityRefXML
[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
188 #define expect_bstr_eq_and_free(bstr, expect) { \
189 BSTR bstrExp = alloc_str_from_narrow(expect); \
190 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
191 SysFreeString(bstr); \
192 SysFreeString(bstrExp); \
195 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
197 #define ole_check(expr) { \
199 ok(r == S_OK, #expr " returned %x\n", r); \
202 #define ole_expect(expr, expect) { \
204 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
207 static BSTR
alloc_str_from_narrow(const char *str
)
209 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
210 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
211 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
215 BSTR alloced_bstrs
[256];
216 int alloced_bstrs_count
= 0;
218 static BSTR
_bstr_(const char *str
)
220 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
221 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
222 return alloced_bstrs
[alloced_bstrs_count
++];
225 static void free_bstrs(void)
228 for (i
= 0; i
< alloced_bstrs_count
; i
++)
229 SysFreeString(alloced_bstrs
[i
]);
230 alloced_bstrs_count
= 0;
233 static VARIANT
_variantbstr_(const char *str
)
237 V_BSTR(&v
) = _bstr_(str
);
241 static BOOL
compareIgnoreReturns(BSTR sLeft
, BSTR sRight
)
245 while (*sLeft
== '\r' || *sLeft
== '\n') sLeft
++;
246 while (*sRight
== '\r' || *sRight
== '\n') sRight
++;
247 if (*sLeft
!= *sRight
) return FALSE
;
248 if (!*sLeft
) return TRUE
;
254 static void get_str_for_type(DOMNodeType type
, char *buf
)
268 wsprintfA(buf
, "[%d]", type
);
272 static int get_node_position(IXMLDOMNode
*node
)
277 IXMLDOMNode_AddRef(node
);
280 IXMLDOMNode
*new_node
;
283 r
= IXMLDOMNode_get_previousSibling(node
, &new_node
);
284 ok(!FAILED(r
), "get_previousSibling failed\n");
285 IXMLDOMNode_Release(node
);
291 static void node_to_string(IXMLDOMNode
*node
, char *buf
)
298 lstrcpyA(buf
, "(null)");
302 IXMLDOMNode_AddRef(node
);
305 IXMLDOMNode
*new_node
;
307 ole_check(IXMLDOMNode_get_nodeType(node
, &type
));
308 get_str_for_type(type
, buf
);
311 if (type
== NODE_ATTRIBUTE
)
314 ole_check(IXMLDOMNode_get_nodeName(node
, &bstr
));
316 wsprintfA(buf
, "%ws", bstr
);
321 r
= IXMLDOMNode_selectSingleNode(node
, _bstr_(".."), &new_node
);
325 int pos
= get_node_position(node
);
326 DOMNodeType parent_type
= NODE_INVALID
;
327 r
= IXMLDOMNode_get_parentNode(node
, &new_node
);
329 /* currently wine doesn't create a node for the <?xml ... ?>. To be able to test query
330 * results we "fix" it */
332 ole_check(IXMLDOMNode_get_nodeType(new_node
, &parent_type
));
333 if ((parent_type
== NODE_DOCUMENT
) && type
!= NODE_PROCESSING_INSTRUCTION
&& pos
==1)
335 todo_wine
ok(FALSE
, "The first child of the document node in MSXML is the <?xml ... ?> processing instruction\n");
338 wsprintf(buf
, "%d", pos
);
342 ok(!FAILED(r
), "get_parentNode failed (%08x)\n", r
);
343 IXMLDOMNode_Release(node
);
352 static char *list_to_string(IXMLDOMNodeList
*list
)
354 static char buf
[4096];
361 lstrcpyA(buf
, "(null)");
364 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
365 for (i
= 0; i
< len
; i
++)
370 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
371 node_to_string(node
, pos
);
373 IXMLDOMNode_Release(node
);
379 #define expect_node(node, expstr) { char str[4096]; node_to_string(node, str); ok(strcmp(str, expstr)==0, "Invalid node: %s, exptected %s\n", str, expstr); }
380 #define expect_list_and_release(list, expstr) { char *str = list_to_string(list); ok(strcmp(str, expstr)==0, "Invalid node list: %s, exptected %s\n", str, expstr); if (list) IXMLDOMNodeList_Release(list); }
382 static void test_domdoc( void )
385 IXMLDOMDocument
*doc
= NULL
;
386 IXMLDOMParseError
*error
;
387 IXMLDOMElement
*element
= NULL
;
389 IXMLDOMText
*nodetext
= NULL
;
390 IXMLDOMComment
*node_comment
= NULL
;
391 IXMLDOMAttribute
*node_attr
= NULL
;
392 IXMLDOMNode
*nodeChild
= NULL
;
393 IXMLDOMProcessingInstruction
*nodePI
= NULL
;
400 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
401 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
405 /* try some stupid things */
406 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
407 ok( r
== S_FALSE
, "loadXML failed\n");
410 r
= IXMLDOMDocument_loadXML( doc
, NULL
, &b
);
411 ok( r
== S_FALSE
, "loadXML failed\n");
412 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
414 /* try to load a document from a nonexistent file */
416 str
= SysAllocString( szNonExistentFile
);
418 V_VT(&var
) = VT_BSTR
;
421 r
= IXMLDOMDocument_load( doc
, var
, &b
);
422 ok( r
== S_FALSE
, "load (from file) failed\n");
423 ok( b
== VARIANT_FALSE
, "failed to load XML file\n");
424 SysFreeString( str
);
426 /* try load an empty document */
428 str
= SysAllocString( szEmpty
);
429 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
430 ok( r
== S_FALSE
, "loadXML failed\n");
431 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
432 SysFreeString( str
);
434 /* check that there's no document element */
436 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
437 ok( r
== S_FALSE
, "should be no document element\n");
439 /* try finding a node */
441 str
= SysAllocString( szstr1
);
442 r
= IXMLDOMDocument_selectSingleNode( doc
, str
, &node
);
443 ok( r
== S_FALSE
, "ret %08x\n", r
);
444 SysFreeString( str
);
447 str
= SysAllocString( szIncomplete
);
448 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
449 ok( r
== S_FALSE
, "loadXML failed\n");
450 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
451 SysFreeString( str
);
453 /* check that there's no document element */
454 element
= (IXMLDOMElement
*)1;
455 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
456 ok( r
== S_FALSE
, "should be no document element\n");
457 ok( element
== NULL
, "Element should be NULL\n");
459 /* try to load something valid */
461 str
= SysAllocString( szComplete1
);
462 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
463 ok( r
== S_OK
, "loadXML failed\n");
464 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
465 SysFreeString( str
);
467 /* check if nodename is correct */
468 r
= IXMLDOMDocument_get_nodeName( doc
, NULL
);
469 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
471 /* content doesn't matter here */
473 r
= IXMLDOMDocument_get_nodeName( doc
, &str
);
474 ok ( r
== S_OK
, "get_nodeName wrong code\n");
475 ok ( str
!= NULL
, "str is null\n");
476 ok( !lstrcmpW( str
, szDocument
), "incorrect nodeName\n");
477 SysFreeString( str
);
480 r
= IXMLDOMDocument_put_text( doc
, _bstr_("Should Fail") );
481 ok( r
== E_FAIL
, "ret %08x\n", r
);
483 /* check that there's a document element */
485 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
486 ok( r
== S_OK
, "should be a document element\n");
491 /* check if the tag is correct */
492 r
= IXMLDOMElement_get_tagName( element
, &tag
);
493 ok( r
== S_OK
, "couldn't get tag name\n");
494 ok( tag
!= NULL
, "tag was null\n");
495 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
496 SysFreeString( tag
);
498 /* figure out what happens if we try to reload the document */
499 str
= SysAllocString( szComplete2
);
500 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
501 ok( r
== S_OK
, "loadXML failed\n");
502 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
503 SysFreeString( str
);
505 /* check if the tag is still correct */
507 r
= IXMLDOMElement_get_tagName( element
, &tag
);
508 ok( r
== S_OK
, "couldn't get tag name\n");
509 ok( tag
!= NULL
, "tag was null\n");
510 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
511 SysFreeString( tag
);
513 IXMLDOMElement_Release( element
);
517 /* as soon as we call loadXML again, the document element will disappear */
519 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
520 ok( r
== S_FALSE
, "loadXML failed\n");
521 ok( b
== 2, "variant modified\n");
522 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
523 ok( r
== S_FALSE
, "should be no document element\n");
525 /* try to load something else simple and valid */
527 str
= SysAllocString( szComplete3
);
528 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
529 ok( r
== S_OK
, "loadXML failed\n");
530 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
531 SysFreeString( str
);
533 /* try something a little more complicated */
535 str
= SysAllocString( szComplete4
);
536 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
537 ok( r
== S_OK
, "loadXML failed\n");
538 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
539 SysFreeString( str
);
541 r
= IXMLDOMDocument_get_parseError( doc
, &error
);
542 ok( r
== S_OK
, "returns %08x\n", r
);
544 r
= IXMLDOMParseError_get_errorCode( error
, &code
);
545 ok( r
== S_FALSE
, "returns %08x\n", r
);
546 ok( code
== 0, "code %ld\n", code
);
547 IXMLDOMParseError_Release( error
);
549 /* test createTextNode */
550 str
= SysAllocString( szOpen
);
551 r
= IXMLDOMDocument_createTextNode(doc
, str
, NULL
);
552 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
553 r
= IXMLDOMDocument_createTextNode(doc
, str
, &nodetext
);
554 ok( r
== S_OK
, "returns %08x\n", r
);
555 SysFreeString( str
);
558 IXMLDOMNamedNodeMap
*pAttribs
;
560 /* Text Last Child Checks */
561 r
= IXMLDOMText_get_lastChild(nodetext
, NULL
);
562 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
564 nodeChild
= (IXMLDOMNode
*)0x1;
565 r
= IXMLDOMText_get_lastChild(nodetext
, &nodeChild
);
566 ok(r
== S_FALSE
, "ret %08x\n", r
);
567 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
569 /* test get_attributes */
570 r
= IXMLDOMText_get_attributes( nodetext
, NULL
);
571 ok( r
== E_INVALIDARG
, "get_attributes returned wrong code\n");
573 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
574 r
= IXMLDOMText_get_attributes( nodetext
, &pAttribs
);
575 ok(r
== S_FALSE
, "ret %08x\n", r
);
576 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
578 /* test get_dataType */
579 r
= IXMLDOMText_get_dataType(nodetext
, &var
);
580 ok(r
== S_FALSE
, "ret %08x\n", r
);
581 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
584 /* test length property */
585 r
= IXMLDOMText_get_length(nodetext
, NULL
);
586 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
588 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
589 ok(r
== S_OK
, "ret %08x\n", r
);
590 ok(nLength
== 4, "expected 4 got %ld\n", nLength
);
592 /* test nodeTypeString */
593 r
= IXMLDOMText_get_nodeTypeString(nodetext
, &str
);
594 ok(r
== S_OK
, "ret %08x\n", r
);
595 ok( !lstrcmpW( str
, _bstr_("text") ), "incorrect nodeTypeString string\n");
599 r
= IXMLDOMText_put_data(nodetext
, _bstr_("This &is a ; test <>\\"));
600 ok(r
== S_OK
, "ret %08x\n", r
);
603 r
= IXMLDOMText_get_data(nodetext
, &str
);
604 ok(r
== S_OK
, "ret %08x\n", r
);
605 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
608 /* Confirm XML text is good */
609 r
= IXMLDOMText_get_xml(nodetext
, &str
);
610 ok(r
== S_OK
, "ret %08x\n", r
);
611 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
614 /* Confirm we get the put_data Text back */
615 r
= IXMLDOMText_get_text(nodetext
, &str
);
616 ok(r
== S_OK
, "ret %08x\n", r
);
617 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
620 /* test substringData */
621 r
= IXMLDOMText_substringData(nodetext
, 0, 4, NULL
);
622 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
624 /* test substringData - Invalid offset */
625 str
= (BSTR
)&szElement
;
626 r
= IXMLDOMText_substringData(nodetext
, -1, 4, &str
);
627 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
628 ok( str
== NULL
, "incorrect string\n");
630 /* test substringData - Invalid offset */
631 str
= (BSTR
)&szElement
;
632 r
= IXMLDOMText_substringData(nodetext
, 30, 0, &str
);
633 ok(r
== S_FALSE
, "ret %08x\n", r
);
634 ok( str
== NULL
, "incorrect string\n");
636 /* test substringData - Invalid size */
637 str
= (BSTR
)&szElement
;
638 r
= IXMLDOMText_substringData(nodetext
, 0, -1, &str
);
639 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
640 ok( str
== NULL
, "incorrect string\n");
642 /* test substringData - Invalid size */
643 str
= (BSTR
)&szElement
;
644 r
= IXMLDOMText_substringData(nodetext
, 2, 0, &str
);
645 ok(r
== S_FALSE
, "ret %08x\n", r
);
646 ok( str
== NULL
, "incorrect string\n");
648 /* test substringData - Start of string */
649 r
= IXMLDOMText_substringData(nodetext
, 0, 4, &str
);
650 ok(r
== S_OK
, "ret %08x\n", r
);
651 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
654 /* test substringData - Middle of string */
655 r
= IXMLDOMText_substringData(nodetext
, 13, 4, &str
);
656 ok(r
== S_OK
, "ret %08x\n", r
);
657 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
660 /* test substringData - End of string */
661 r
= IXMLDOMText_substringData(nodetext
, 20, 4, &str
);
662 ok(r
== S_OK
, "ret %08x\n", r
);
663 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
666 /* test appendData */
667 r
= IXMLDOMText_appendData(nodetext
, NULL
);
668 ok(r
== S_OK
, "ret %08x\n", r
);
670 r
= IXMLDOMText_appendData(nodetext
, _bstr_(""));
671 ok(r
== S_OK
, "ret %08x\n", r
);
673 r
= IXMLDOMText_appendData(nodetext
, _bstr_("Append"));
674 ok(r
== S_OK
, "ret %08x\n", r
);
676 r
= IXMLDOMText_get_text(nodetext
, &str
);
677 ok(r
== S_OK
, "ret %08x\n", r
);
678 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
681 /* test insertData */
682 str
= SysAllocStringLen(NULL
, 0);
683 r
= IXMLDOMText_insertData(nodetext
, -1, str
);
684 ok(r
== S_OK
, "ret %08x\n", r
);
686 r
= IXMLDOMText_insertData(nodetext
, -1, NULL
);
687 ok(r
== S_OK
, "ret %08x\n", r
);
689 r
= IXMLDOMText_insertData(nodetext
, 1000, str
);
690 ok(r
== S_OK
, "ret %08x\n", r
);
692 r
= IXMLDOMText_insertData(nodetext
, 1000, NULL
);
693 ok(r
== S_OK
, "ret %08x\n", r
);
695 r
= IXMLDOMText_insertData(nodetext
, 0, NULL
);
696 ok(r
== S_OK
, "ret %08x\n", r
);
698 r
= IXMLDOMText_insertData(nodetext
, 0, str
);
699 ok(r
== S_OK
, "ret %08x\n", r
);
702 r
= IXMLDOMText_insertData(nodetext
, -1, _bstr_("Inserting"));
703 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
705 r
= IXMLDOMText_insertData(nodetext
, 1000, _bstr_("Inserting"));
706 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
708 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("Begin "));
709 ok(r
== S_OK
, "ret %08x\n", r
);
711 r
= IXMLDOMText_insertData(nodetext
, 17, _bstr_("Middle"));
712 ok(r
== S_OK
, "ret %08x\n", r
);
714 r
= IXMLDOMText_insertData(nodetext
, 39, _bstr_(" End"));
715 ok(r
== S_OK
, "ret %08x\n", r
);
717 r
= IXMLDOMText_get_text(nodetext
, &str
);
718 ok(r
== S_OK
, "ret %08x\n", r
);
719 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
722 IXMLDOMText_Release( nodetext
);
725 /* test Create Comment */
726 r
= IXMLDOMDocument_createComment(doc
, NULL
, NULL
);
727 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
728 r
= IXMLDOMDocument_createComment(doc
, szComment
, &node_comment
);
729 ok( r
== S_OK
, "returns %08x\n", r
);
732 /* Last Child Checks */
733 r
= IXMLDOMComment_get_lastChild(node_comment
, NULL
);
734 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
736 nodeChild
= (IXMLDOMNode
*)0x1;
737 r
= IXMLDOMComment_get_lastChild(node_comment
, &nodeChild
);
738 ok(r
== S_FALSE
, "ret %08x\n", r
);
739 ok(nodeChild
== NULL
, "pLastChild not NULL\n");
741 IXMLDOMComment_Release( node_comment
);
744 /* test Create Attribute */
745 r
= IXMLDOMDocument_createAttribute(doc
, NULL
, NULL
);
746 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
747 r
= IXMLDOMDocument_createAttribute(doc
, szAttribute
, &node_attr
);
748 ok( r
== S_OK
, "returns %08x\n", r
);
749 IXMLDOMText_Release( node_attr
);
751 /* test Processing Instruction */
752 str
= SysAllocStringLen(NULL
, 0);
753 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, NULL
);
754 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
755 r
= IXMLDOMDocument_createProcessingInstruction(doc
, NULL
, str
, &nodePI
);
756 ok( r
== E_FAIL
, "returns %08x\n", r
);
757 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, &nodePI
);
758 ok( r
== E_FAIL
, "returns %08x\n", r
);
761 r
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI
);
762 ok( r
== S_OK
, "returns %08x\n", r
);
765 /* Last Child Checks */
766 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, NULL
);
767 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
769 nodeChild
= (IXMLDOMNode
*)0x1;
770 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, &nodeChild
);
771 ok(r
== S_FALSE
, "ret %08x\n", r
);
772 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
774 r
= IXMLDOMProcessingInstruction_get_dataType(nodePI
, &var
);
775 ok(r
== S_FALSE
, "ret %08x\n", r
);
776 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
780 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
781 ok(r
== S_OK
, "ret %08x\n", r
);
782 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
786 r
= IXMLDOMProcessingInstruction_get_target(nodePI
, &str
);
787 ok(r
== S_OK
, "ret %08x\n", r
);
788 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect target string\n");
791 /* test nodeTypeString */
792 r
= IXMLDOMProcessingInstruction_get_nodeTypeString(nodePI
, &str
);
793 ok(r
== S_OK
, "ret %08x\n", r
);
794 ok( !lstrcmpW( str
, _bstr_("processinginstruction") ), "incorrect nodeTypeString string\n");
797 /* test get_nodeValue */
798 r
= IXMLDOMProcessingInstruction_get_nodeValue(nodePI
, &var
);
799 ok(r
== S_OK
, "ret %08x\n", r
);
800 ok( !lstrcmpW( V_BSTR(&var
), _bstr_("version=\"1.0\"") ), "incorrect data string\n");
804 r
= IXMLDOMProcessingInstruction_get_data(nodePI
, &str
);
805 ok(r
== S_OK
, "ret %08x\n", r
);
806 ok( !lstrcmpW( str
, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
810 r
= IXMLDOMProcessingInstruction_put_data(nodePI
, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
811 ok(r
== E_FAIL
, "ret %08x\n", r
);
814 V_VT(&var
) = VT_BSTR
;
815 V_BSTR(&var
) = SysAllocString(szOpen
); /* Doesn't matter what the string is, cannot set an xml node. */
816 r
= IXMLDOMProcessingInstruction_put_nodeValue(nodePI
, var
);
817 ok(r
== E_FAIL
, "ret %08x\n", r
);
820 /* test get nodeName */
821 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
822 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
823 ok(r
== S_OK
, "ret %08x\n", r
);
826 IXMLDOMProcessingInstruction_Release(nodePI
);
829 r
= IXMLDOMDocument_Release( doc
);
830 ok( r
== 0, "document ref count incorrect\n");
835 static void test_domnode( void )
838 IXMLDOMDocument
*doc
= NULL
, *owner
= NULL
;
839 IXMLDOMElement
*element
= NULL
;
840 IXMLDOMNamedNodeMap
*map
= NULL
;
841 IXMLDOMNode
*node
= NULL
, *next
= NULL
;
842 IXMLDOMNodeList
*list
= NULL
;
843 IXMLDOMAttribute
*attr
= NULL
;
844 DOMNodeType type
= NODE_INVALID
;
850 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
851 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
856 str
= SysAllocString( szComplete4
);
857 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
858 ok( r
== S_OK
, "loadXML failed\n");
859 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
860 SysFreeString( str
);
865 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
866 ok( r
== S_OK
, "hasChildNoes bad return\n");
867 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
869 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
870 ok( r
== S_OK
, "should be a document element\n");
871 ok( element
!= NULL
, "should be an element\n");
874 ok( FALSE
, "no document\n");
877 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
879 r
= IXMLDOMNode_get_nodeValue( doc
, NULL
);
880 ok(r
== E_INVALIDARG
, "get_nodeValue ret %08x\n", r
);
882 r
= IXMLDOMNode_get_nodeValue( doc
, &var
);
883 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
884 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
885 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
890 r
= IXMLDOMNode_get_ownerDocument( element
, &owner
);
891 ok( r
== S_OK
, "get_ownerDocument return code\n");
892 ok( owner
!= doc
, "get_ownerDocument return\n");
895 r
= IXMLDOMNode_get_nodeType( element
, &type
);
896 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
897 ok( type
== NODE_ELEMENT
, "node not an element\n");
900 r
= IXMLDOMNode_get_baseName( element
, &str
);
901 ok( r
== S_OK
, "get_baseName returned wrong code\n");
902 ok( lstrcmpW(str
,szlc
) == 0, "basename was wrong\n");
905 /* check if nodename is correct */
906 r
= IXMLDOMElement_get_nodeName( element
, NULL
);
907 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
909 /* content doesn't matter here */
911 r
= IXMLDOMElement_get_nodeName( element
, &str
);
912 ok ( r
== S_OK
, "get_nodeName wrong code\n");
913 ok ( str
!= NULL
, "str is null\n");
914 ok( !lstrcmpW( str
, szlc
), "incorrect nodeName\n");
915 SysFreeString( str
);
917 str
= SysAllocString( szNonExistentFile
);
920 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
921 ok( r
== E_FAIL
, "getAttribute ret %08x\n", r
);
922 ok( V_VT(&var
) == VT_NULL
|| V_VT(&var
) == VT_EMPTY
, "vt = %x\n", V_VT(&var
));
925 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
926 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
927 ok( r
== E_FAIL
, "getAttributeNode ret %08x\n", r
);
928 ok( attr
== NULL
, "getAttributeNode ret %p, expected NULL\n", attr
);
929 SysFreeString( str
);
931 str
= SysAllocString( szdl
);
934 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
935 ok( r
== S_OK
, "getAttribute ret %08x\n", r
);
936 ok( V_VT(&var
) == VT_BSTR
, "vt = %x\n", V_VT(&var
));
937 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "wrong attr value\n");
938 VariantClear( &var
);
940 r
= IXMLDOMElement_getAttribute( element
, NULL
, &var
);
941 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
943 r
= IXMLDOMElement_getAttribute( element
, str
, NULL
);
944 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
947 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
948 ok( r
== S_OK
, "GetAttributeNode ret %08x\n", r
);
949 ok( attr
!= NULL
, "getAttributeNode returned NULL\n" );
951 IXMLDOMAttribute_Release(attr
);
953 SysFreeString( str
);
955 r
= IXMLDOMElement_get_attributes( element
, &map
);
956 ok( r
== S_OK
, "get_attributes returned wrong code\n");
957 ok( map
!= NULL
, "should be attributes\n");
960 r
= IXMLDOMNode_hasChildNodes( element
, &b
);
961 ok( r
== S_OK
, "hasChildNoes bad return\n");
962 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
965 ok( FALSE
, "no element\n");
969 ISupportErrorInfo
*support_error
;
970 r
= IXMLDOMNamedNodeMap_QueryInterface( map
, &IID_ISupportErrorInfo
, (LPVOID
*)&support_error
);
971 ok( r
== S_OK
, "ret %08x\n", r
);
973 r
= ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error
, &IID_IXMLDOMNamedNodeMap
);
976 ok( r
== S_OK
, "ret %08x\n", r
);
978 ISupportErrorInfo_Release( support_error
);
980 str
= SysAllocString( szdl
);
981 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
982 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
983 ok( node
!= NULL
, "should be attributes\n");
984 IXMLDOMNode_Release(node
);
985 SysFreeString( str
);
987 str
= SysAllocString( szdl
);
988 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, NULL
);
989 ok( r
== E_INVALIDARG
, "getNamedItem should return E_INVALIDARG\n");
990 SysFreeString( str
);
992 /* something that isn't in szComplete4 */
993 str
= SysAllocString( szOpen
);
994 node
= (IXMLDOMNode
*) 1;
995 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
996 ok( r
= S_FALSE
, "getNamedItem found a node that wasn't there\n");
997 ok( node
== NULL
, "getNamedItem should have returned NULL\n");
998 SysFreeString( str
);
1000 /* test indexed access of attributes */
1001 r
= IXMLDOMNamedNodeMap_get_length( map
, &count
);
1002 ok ( r
== S_OK
, "get_length wrong code\n");
1003 ok ( count
== 1, "get_length != 1\n");
1006 r
= IXMLDOMNamedNodeMap_get_item( map
, -1, &node
);
1007 ok ( r
== S_FALSE
, "get_item (-1) wrong code\n");
1008 ok ( node
== NULL
, "there is no node\n");
1011 r
= IXMLDOMNamedNodeMap_get_item( map
, 1, &node
);
1012 ok ( r
== S_FALSE
, "get_item (1) wrong code\n");
1013 ok ( node
== NULL
, "there is no attribute\n");
1016 r
= IXMLDOMNamedNodeMap_get_item( map
, 0, &node
);
1017 ok ( r
== S_OK
, "get_item (0) wrong code\n");
1018 ok ( node
!= NULL
, "should be attribute\n");
1020 r
= IXMLDOMNode_get_nodeName( node
, NULL
);
1021 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1023 /* content doesn't matter here */
1025 r
= IXMLDOMNode_get_nodeName( node
, &str
);
1026 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1027 ok ( str
!= NULL
, "str is null\n");
1028 ok( !lstrcmpW( str
, szdl
), "incorrect node name\n");
1029 SysFreeString( str
);
1031 /* test sequential access of attributes */
1033 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1034 ok ( r
== S_OK
, "nextNode (first time) wrong code\n");
1035 ok ( node
!= NULL
, "nextNode, should be attribute\n");
1037 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1038 ok ( r
!= S_OK
, "nextNode (second time) wrong code\n");
1039 ok ( node
== NULL
, "nextNode, there is no attribute\n");
1041 r
= IXMLDOMNamedNodeMap_reset( map
);
1042 ok ( r
== S_OK
, "reset should return S_OK\n");
1044 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1045 ok ( r
== S_OK
, "nextNode (third time) wrong code\n");
1046 ok ( node
!= NULL
, "nextNode, should be attribute\n");
1049 ok( FALSE
, "no map\n");
1053 type
= NODE_INVALID
;
1054 r
= IXMLDOMNode_get_nodeType( node
, &type
);
1055 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1056 ok( type
== NODE_ATTRIBUTE
, "node not an attribute\n");
1059 r
= IXMLDOMNode_get_baseName( node
, NULL
);
1060 ok( r
== E_INVALIDARG
, "get_baseName returned wrong code\n");
1063 r
= IXMLDOMNode_get_baseName( node
, &str
);
1064 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1065 ok( lstrcmpW(str
,szdl
) == 0, "basename was wrong\n");
1066 SysFreeString( str
);
1068 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
1069 ok( r
== S_OK
, "returns %08x\n", r
);
1070 ok( V_VT(&var
) == VT_BSTR
, "vt %x\n", V_VT(&var
));
1071 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "nodeValue incorrect\n");
1074 r
= IXMLDOMNode_get_childNodes( node
, NULL
);
1075 ok( r
== E_INVALIDARG
, "get_childNodes returned wrong code\n");
1077 r
= IXMLDOMNode_get_childNodes( node
, &list
);
1078 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
1082 r
= IXMLDOMNodeList_nextNode( list
, &next
);
1083 ok( r
== S_OK
, "nextNode returned wrong code\n");
1086 ok( FALSE
, "no childlist\n");
1091 r
= IXMLDOMNode_hasChildNodes( next
, &b
);
1092 ok( r
== S_FALSE
, "hasChildNoes bad return\n");
1093 ok( b
== VARIANT_FALSE
, "hasChildNoes wrong result\n");
1095 type
= NODE_INVALID
;
1096 r
= IXMLDOMNode_get_nodeType( next
, &type
);
1097 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1098 ok( type
== NODE_TEXT
, "node not text\n");
1101 r
= IXMLDOMNode_get_baseName( next
, &str
);
1102 ok( r
== S_FALSE
, "get_baseName returned wrong code\n");
1103 ok( str
== NULL
, "basename was wrong\n");
1107 ok( FALSE
, "no next\n");
1110 IXMLDOMNode_Release( next
);
1113 IXMLDOMNodeList_Release( list
);
1116 IXMLDOMNode_Release( node
);
1119 ok( FALSE
, "no node\n");
1123 IXMLDOMNamedNodeMap_Release( map
);
1125 /* now traverse the tree from the root element */
1129 r
= IXMLDOMNode_get_childNodes( element
, &list
);
1130 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
1132 /* using get_item for child list doesn't advance the position */
1133 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
1134 expect_node(node
, "E2.E2.D1");
1135 IXMLDOMNode_Release(node
);
1136 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
1137 expect_node(node
, "E1.E2.D1");
1138 IXMLDOMNode_Release(node
);
1139 ole_check(IXMLDOMNodeList_reset(list
));
1141 IXMLDOMNodeList_AddRef(list
);
1142 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
1143 ole_check(IXMLDOMNodeList_reset(list
));
1146 ok( FALSE
, "no element\n");
1148 node
= (void*)0xdeadbeef;
1149 r
= IXMLDOMNode_selectSingleNode( element
, szdl
, &node
);
1150 ok( r
== S_FALSE
, "ret %08x\n", r
);
1151 ok( node
== NULL
, "node %p\n", node
);
1152 r
= IXMLDOMNode_selectSingleNode( element
, szbs
, &node
);
1153 ok( r
== S_OK
, "ret %08x\n", r
);
1154 r
= IXMLDOMNode_Release( node
);
1155 ok( r
== 0, "ret %08x\n", r
);
1159 r
= IXMLDOMNodeList_QueryInterface(list
, &IID_IDispatch
, NULL
);
1160 ok( r
== E_INVALIDARG
|| r
== E_POINTER
, "ret %08x\n", r
);
1162 r
= IXMLDOMNodeList_get_item(list
, 0, NULL
);
1163 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1165 r
= IXMLDOMNodeList_get_length(list
, NULL
);
1166 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1168 r
= IXMLDOMNodeList_get_length( list
, &count
);
1169 ok( r
== S_OK
, "get_length returns %08x\n", r
);
1170 ok( count
== 4, "get_length got %ld\n", count
);
1172 r
= IXMLDOMNodeList_nextNode(list
, NULL
);
1173 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1175 r
= IXMLDOMNodeList_nextNode( list
, &node
);
1176 ok( r
== S_OK
, "nextNode returned wrong code\n");
1179 ok( FALSE
, "no list\n");
1183 type
= NODE_INVALID
;
1184 r
= IXMLDOMNode_get_nodeType( node
, &type
);
1185 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1186 ok( type
== NODE_ELEMENT
, "node not text\n");
1189 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
1190 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
1191 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
1192 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
1193 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
1195 r
= IXMLDOMNode_hasChildNodes( node
, NULL
);
1196 ok( r
== E_INVALIDARG
, "hasChildNoes bad return\n");
1199 r
= IXMLDOMNode_hasChildNodes( node
, &b
);
1200 ok( r
== S_OK
, "hasChildNoes bad return\n");
1201 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1204 r
= IXMLDOMNode_get_baseName( node
, &str
);
1205 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1206 ok( lstrcmpW(str
,szbs
) == 0, "basename was wrong\n");
1210 ok( FALSE
, "no node\n");
1213 IXMLDOMNode_Release( node
);
1215 IXMLDOMNodeList_Release( list
);
1217 IXMLDOMElement_Release( element
);
1220 str
= SysAllocString( szComplete5
);
1221 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1222 ok( r
== S_OK
, "loadXML failed\n");
1223 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1224 SysFreeString( str
);
1227 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
1228 ok( r
== S_OK
, "hasChildNoes bad return\n");
1229 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1231 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1232 ok( r
== S_OK
, "should be a document element\n");
1233 ok( element
!= NULL
, "should be an element\n");
1237 static const WCHAR szSSearch
[] = {'S',':','s','e','a','r','c','h',0};
1240 /* check if the tag is correct */
1241 r
= IXMLDOMElement_get_tagName( element
, &tag
);
1242 ok( r
== S_OK
, "couldn't get tag name\n");
1243 ok( tag
!= NULL
, "tag was null\n");
1244 ok( !lstrcmpW( tag
, szSSearch
), "incorrect tag name\n");
1245 SysFreeString( tag
);
1249 IXMLDOMElement_Release( element
);
1251 ok(IXMLDOMDocument_Release( doc
) == 0, "document is not destroyed\n");
1254 static void test_refs(void)
1259 IXMLDOMDocument
*doc
= NULL
;
1260 IXMLDOMElement
*element
= NULL
;
1261 IXMLDOMNode
*node
= NULL
, *node2
;
1262 IXMLDOMNodeList
*node_list
= NULL
;
1264 IUnknown
*unk
, *unk2
;
1266 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1267 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1270 ref
= IXMLDOMDocument_Release(doc
);
1271 ok( ref
== 0, "ref %d\n", ref
);
1273 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1274 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1278 str
= SysAllocString( szComplete4
);
1279 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1280 ok( r
== S_OK
, "loadXML failed\n");
1281 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1282 SysFreeString( str
);
1284 ref
= IXMLDOMDocument_AddRef( doc
);
1285 ok( ref
== 2, "ref %d\n", ref
);
1286 ref
= IXMLDOMDocument_AddRef( doc
);
1287 ok( ref
== 3, "ref %d\n", ref
);
1288 IXMLDOMDocument_Release( doc
);
1289 IXMLDOMDocument_Release( doc
);
1291 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1292 ok( r
== S_OK
, "should be a document element\n");
1293 ok( element
!= NULL
, "should be an element\n");
1295 ref
= IXMLDOMDocument_AddRef( doc
);
1296 ok( ref
== 2, "ref %d\n", ref
);
1297 IXMLDOMDocument_Release( doc
);
1299 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
1300 ok( r
== S_OK
, "rets %08x\n", r
);
1301 ref
= IXMLDOMNodeList_AddRef( node_list
);
1302 ok( ref
== 2, "ref %d\n", ref
);
1303 IXMLDOMNodeList_Release( node_list
);
1305 IXMLDOMNodeList_get_item( node_list
, 0, &node
);
1306 ok( r
== S_OK
, "rets %08x\n", r
);
1308 IXMLDOMNodeList_get_item( node_list
, 0, &node2
);
1309 ok( r
== S_OK
, "rets %08x\n", r
);
1311 ref
= IXMLDOMNode_AddRef( node
);
1312 ok( ref
== 2, "ref %d\n", ref
);
1313 IXMLDOMNode_Release( node
);
1315 ref
= IXMLDOMNode_Release( node
);
1316 ok( ref
== 0, "ref %d\n", ref
);
1317 ref
= IXMLDOMNode_Release( node2
);
1318 ok( ref
== 0, "ref %d\n", ref
);
1320 ref
= IXMLDOMNodeList_Release( node_list
);
1321 ok( ref
== 0, "ref %d\n", ref
);
1323 ok( node
!= node2
, "node %p node2 %p\n", node
, node2
);
1325 ref
= IXMLDOMDocument_Release( doc
);
1326 ok( ref
== 0, "ref %d\n", ref
);
1328 ref
= IXMLDOMElement_AddRef( element
);
1330 ok( ref
== 3, "ref %d\n", ref
);
1332 IXMLDOMElement_Release( element
);
1334 /* IUnknown must be unique however we obtain it */
1335 r
= IXMLDOMElement_QueryInterface( element
, &IID_IUnknown
, (LPVOID
*)&unk
);
1336 ok( r
== S_OK
, "rets %08x\n", r
);
1337 r
= IXMLDOMElement_QueryInterface( element
, &IID_IXMLDOMNode
, (LPVOID
*)&node
);
1338 ok( r
== S_OK
, "rets %08x\n", r
);
1339 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (LPVOID
*)&unk2
);
1340 ok( r
== S_OK
, "rets %08x\n", r
);
1341 ok( unk
== unk2
, "unk %p unk2 %p\n", unk
, unk2
);
1343 IUnknown_Release( unk2
);
1344 IUnknown_Release( unk
);
1345 IXMLDOMNode_Release( node
);
1347 IXMLDOMElement_Release( element
);
1351 static void test_create(void)
1356 IXMLDOMDocument
*doc
;
1357 IXMLDOMElement
*element
;
1358 IXMLDOMNode
*root
, *node
, *child
;
1359 IXMLDOMNamedNodeMap
*attr_map
;
1364 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1365 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1370 V_I4(&var
) = NODE_ELEMENT
;
1371 str
= SysAllocString( szlc
);
1372 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1373 ok( r
== S_OK
, "returns %08x\n", r
);
1374 r
= IXMLDOMDocument_appendChild( doc
, node
, &root
);
1375 ok( r
== S_OK
, "returns %08x\n", r
);
1376 ok( node
== root
, "%p %p\n", node
, root
);
1378 ref
= IXMLDOMNode_AddRef( node
);
1379 ok(ref
== 3, "ref %d\n", ref
);
1380 IXMLDOMNode_Release( node
);
1382 ref
= IXMLDOMNode_Release( node
);
1383 ok(ref
== 1, "ref %d\n", ref
);
1384 SysFreeString( str
);
1387 V_I4(&var
) = NODE_ELEMENT
;
1388 str
= SysAllocString( szbs
);
1389 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1390 ok( r
== S_OK
, "returns %08x\n", r
);
1392 ref
= IXMLDOMNode_AddRef( node
);
1393 ok(ref
== 2, "ref = %d\n", ref
);
1394 IXMLDOMNode_Release( node
);
1396 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (LPVOID
*)&unk
);
1397 ok( r
== S_OK
, "returns %08x\n", r
);
1399 ref
= IXMLDOMNode_AddRef( unk
);
1400 ok(ref
== 3, "ref = %d\n", ref
);
1401 IXMLDOMNode_Release( unk
);
1403 V_VT(&var
) = VT_EMPTY
;
1404 r
= IXMLDOMNode_insertBefore( root
, (IXMLDOMNode
*)unk
, var
, &child
);
1405 ok( r
== S_OK
, "returns %08x\n", r
);
1406 ok( unk
== (IUnknown
*)child
, "%p %p\n", unk
, child
);
1407 IXMLDOMNode_Release( child
);
1408 IUnknown_Release( unk
);
1411 V_VT(&var
) = VT_NULL
;
1412 V_DISPATCH(&var
) = (IDispatch
*)node
;
1413 r
= IXMLDOMNode_insertBefore( root
, node
, var
, &child
);
1414 ok( r
== S_OK
, "returns %08x\n", r
);
1415 ok( node
== child
, "%p %p\n", node
, child
);
1416 IXMLDOMNode_Release( child
);
1419 V_VT(&var
) = VT_NULL
;
1420 V_DISPATCH(&var
) = (IDispatch
*)node
;
1421 r
= IXMLDOMNode_insertBefore( root
, node
, var
, NULL
);
1422 ok( r
== S_OK
, "returns %08x\n", r
);
1423 IXMLDOMNode_Release( node
);
1425 r
= IXMLDOMNode_QueryInterface( root
, &IID_IXMLDOMElement
, (LPVOID
*)&element
);
1426 ok( r
== S_OK
, "returns %08x\n", r
);
1428 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
1429 ok( r
== S_OK
, "returns %08x\n", r
);
1430 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
1431 ok( r
== S_OK
, "returns %08x\n", r
);
1432 ok( num
== 0, "num %ld\n", num
);
1433 IXMLDOMNamedNodeMap_Release( attr_map
);
1435 V_VT(&var
) = VT_BSTR
;
1436 V_BSTR(&var
) = SysAllocString( szstr1
);
1437 name
= SysAllocString( szdl
);
1438 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
1439 ok( r
== S_OK
, "returns %08x\n", r
);
1440 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
1441 ok( r
== S_OK
, "returns %08x\n", r
);
1442 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
1443 ok( r
== S_OK
, "returns %08x\n", r
);
1444 ok( num
== 1, "num %ld\n", num
);
1445 IXMLDOMNamedNodeMap_Release( attr_map
);
1448 V_VT(&var
) = VT_BSTR
;
1449 V_BSTR(&var
) = SysAllocString( szstr2
);
1450 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
1451 ok( r
== S_OK
, "returns %08x\n", r
);
1452 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
1453 ok( r
== S_OK
, "returns %08x\n", r
);
1454 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
1455 ok( r
== S_OK
, "returns %08x\n", r
);
1456 ok( num
== 1, "num %ld\n", num
);
1457 IXMLDOMNamedNodeMap_Release( attr_map
);
1459 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
1460 ok( r
== S_OK
, "returns %08x\n", r
);
1461 ok( !lstrcmpW(V_BSTR(&var
), szstr2
), "wrong attr value\n");
1463 SysFreeString(name
);
1465 V_VT(&var
) = VT_BSTR
;
1466 V_BSTR(&var
) = SysAllocString( szstr1
);
1467 name
= SysAllocString( szlc
);
1468 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
1469 ok( r
== S_OK
, "returns %08x\n", r
);
1470 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
1471 ok( r
== S_OK
, "returns %08x\n", r
);
1472 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
1473 ok( r
== S_OK
, "returns %08x\n", r
);
1474 ok( num
== 2, "num %ld\n", num
);
1475 IXMLDOMNamedNodeMap_Release( attr_map
);
1477 SysFreeString(name
);
1481 name
= SysAllocString( szbs
);
1482 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
1483 ok( r
== S_OK
, "returns %08x\n", r
);
1485 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
1486 ok( r
== S_OK
, "returns %08x\n", r
);
1487 ok( V_VT(&var
) == VT_BSTR
, "variant type %x\n", V_VT(&var
));
1489 SysFreeString(name
);
1491 /* Create an Attribute */
1493 V_I4(&var
) = NODE_ATTRIBUTE
;
1494 str
= SysAllocString( szAttribute
);
1495 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1496 ok( r
== S_OK
, "returns %08x\n", r
);
1497 ok( node
!= NULL
, "node was null\n");
1502 r
= IXMLDOMNode_get_nodeTypeString(node
, &str
);
1503 ok( r
== S_OK
, "returns %08x\n", r
);
1504 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
1506 IXMLDOMNode_Release( node
);
1509 IXMLDOMElement_Release( element
);
1510 IXMLDOMNode_Release( root
);
1511 IXMLDOMDocument_Release( doc
);
1514 static void test_getElementsByTagName(void)
1519 IXMLDOMDocument
*doc
;
1520 IXMLDOMNodeList
*node_list
;
1523 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1524 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1528 str
= SysAllocString( szComplete4
);
1529 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1530 ok( r
== S_OK
, "loadXML failed\n");
1531 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1532 SysFreeString( str
);
1534 str
= SysAllocString( szstar
);
1535 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
1536 ok( r
== S_OK
, "ret %08x\n", r
);
1537 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1538 ok( r
== S_OK
, "ret %08x\n", r
);
1539 ok( len
== 6, "len %ld\n", len
);
1540 IXMLDOMNodeList_Release( node_list
);
1541 SysFreeString( str
);
1543 str
= SysAllocString( szbs
);
1544 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
1545 ok( r
== S_OK
, "ret %08x\n", r
);
1546 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1547 ok( r
== S_OK
, "ret %08x\n", r
);
1548 ok( len
== 1, "len %ld\n", len
);
1549 IXMLDOMNodeList_Release( node_list
);
1550 SysFreeString( str
);
1552 str
= SysAllocString( szdl
);
1553 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
1554 ok( r
== S_OK
, "ret %08x\n", r
);
1555 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1556 ok( r
== S_OK
, "ret %08x\n", r
);
1557 ok( len
== 0, "len %ld\n", len
);
1558 IXMLDOMNodeList_Release( node_list
);
1559 SysFreeString( str
);
1561 str
= SysAllocString( szstr1
);
1562 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
1563 ok( r
== S_OK
, "ret %08x\n", r
);
1564 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1565 ok( r
== S_OK
, "ret %08x\n", r
);
1566 ok( len
== 0, "len %ld\n", len
);
1567 IXMLDOMNodeList_Release( node_list
);
1568 SysFreeString( str
);
1570 IXMLDOMDocument_Release( doc
);
1573 static void test_get_text(void)
1578 IXMLDOMDocument
*doc
;
1579 IXMLDOMNode
*node
, *node2
, *node3
;
1580 IXMLDOMNodeList
*node_list
;
1581 IXMLDOMNamedNodeMap
*node_map
;
1584 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1585 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1589 str
= SysAllocString( szComplete4
);
1590 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1591 ok( r
== S_OK
, "loadXML failed\n");
1592 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1593 SysFreeString( str
);
1595 str
= SysAllocString( szbs
);
1596 r
= IXMLDOMDocument_getElementsByTagName( doc
, str
, &node_list
);
1597 ok( r
== S_OK
, "ret %08x\n", r
);
1601 /* this test crashes on win9x */
1602 r
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IDispatch
, NULL
);
1603 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1606 r
= IXMLDOMNodeList_get_length( node_list
, NULL
);
1607 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1609 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1610 ok( r
== S_OK
, "ret %08x\n", r
);
1611 ok( len
== 1, "expect 1 got %ld\n", len
);
1613 r
= IXMLDOMNodeList_get_item( node_list
, 0, NULL
);
1614 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1616 r
= IXMLDOMNodeList_nextNode( node_list
, NULL
);
1617 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1619 r
= IXMLDOMNodeList_get_item( node_list
, 0, &node
);
1620 ok( r
== S_OK
, "ret %08x\n", r
);
1621 IXMLDOMNodeList_Release( node_list
);
1623 /* Invalid output parameter*/
1624 r
= IXMLDOMNode_get_text( node
, NULL
);
1625 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1627 r
= IXMLDOMNode_get_text( node
, &str
);
1628 ok( r
== S_OK
, "ret %08x\n", r
);
1630 ok( !memcmp(str
, szfn1_txt
, sizeof(szfn1_txt
)), "wrong string\n" );
1632 ok( !memcmp(str
, szfn1_txt
, sizeof(szfn1_txt
)-4), "wrong string\n" );
1635 r
= IXMLDOMNode_get_attributes( node
, &node_map
);
1636 ok( r
== S_OK
, "ret %08x\n", r
);
1638 str
= SysAllocString( szvr
);
1639 r
= IXMLDOMNamedNodeMap_getNamedItem( node_map
, str
, &node2
);
1640 ok( r
== S_OK
, "ret %08x\n", r
);
1643 r
= IXMLDOMNode_get_text( node2
, &str
);
1644 ok( r
== S_OK
, "ret %08x\n", r
);
1645 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
1648 r
= IXMLDOMNode_get_firstChild( node2
, &node3
);
1649 ok( r
== S_OK
, "ret %08x\n", r
);
1651 r
= IXMLDOMNode_get_text( node3
, &str
);
1652 ok( r
== S_OK
, "ret %08x\n", r
);
1653 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
1657 IXMLDOMNode_Release( node3
);
1658 IXMLDOMNode_Release( node2
);
1659 IXMLDOMNamedNodeMap_Release( node_map
);
1660 IXMLDOMNode_Release( node
);
1661 IXMLDOMDocument_Release( doc
);
1664 static void test_get_childNodes(void)
1669 IXMLDOMDocument
*doc
;
1670 IXMLDOMElement
*element
;
1671 IXMLDOMNode
*node
, *node2
;
1672 IXMLDOMNodeList
*node_list
, *node_list2
;
1675 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1676 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1680 str
= SysAllocString( szComplete4
);
1681 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1682 ok( r
== S_OK
, "loadXML failed\n");
1683 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1684 SysFreeString( str
);
1686 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1687 ok( r
== S_OK
, "ret %08x\n", r
);
1689 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
1690 ok( r
== S_OK
, "ret %08x\n", r
);
1692 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1693 ok( r
== S_OK
, "ret %08x\n", r
);
1694 ok( len
== 4, "len %ld\n", len
);
1696 r
= IXMLDOMNodeList_get_item( node_list
, 2, &node
);
1697 ok( r
== S_OK
, "ret %08x\n", r
);
1699 r
= IXMLDOMNode_get_childNodes( node
, &node_list2
);
1700 ok( r
== S_OK
, "ret %08x\n", r
);
1702 r
= IXMLDOMNodeList_get_length( node_list2
, &len
);
1703 ok( r
== S_OK
, "ret %08x\n", r
);
1704 ok( len
== 0, "len %ld\n", len
);
1706 r
= IXMLDOMNodeList_get_item( node_list2
, 0, &node2
);
1707 ok( r
== S_FALSE
, "ret %08x\n", r
);
1709 IXMLDOMNodeList_Release( node_list2
);
1710 IXMLDOMNode_Release( node
);
1711 IXMLDOMNodeList_Release( node_list
);
1712 IXMLDOMElement_Release( element
);
1713 IXMLDOMDocument_Release( doc
);
1716 static void test_removeChild(void)
1721 IXMLDOMDocument
*doc
;
1722 IXMLDOMElement
*element
;
1723 IXMLDOMNode
*node
, *node2
, *node3
, *node4
;
1724 IXMLDOMNodeList
*node_list
, *node_list2
;
1726 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1727 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1731 str
= SysAllocString( szComplete4
);
1732 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1733 ok( r
== S_OK
, "loadXML failed\n");
1734 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1735 SysFreeString( str
);
1737 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1738 ok( r
== S_OK
, "ret %08x\n", r
);
1740 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
1741 ok( r
== S_OK
, "ret %08x\n", r
);
1743 r
= IXMLDOMNodeList_get_item( node_list
, 3, &node
);
1744 ok( r
== S_OK
, "ret %08x\n", r
);
1746 r
= IXMLDOMNode_get_childNodes( node
, &node_list2
);
1747 ok( r
== S_OK
, "ret %08x\n", r
);
1749 r
= IXMLDOMNodeList_get_item( node_list
, 0, &node4
);
1750 ok( r
== S_OK
, "ret %08x\n", r
);
1752 r
= IXMLDOMElement_removeChild( element
, NULL
, &node2
);
1753 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1755 r
= IXMLDOMElement_removeChild( element
, node4
, &node2
);
1756 ok( r
== S_OK
, "ret %08x\n", r
);
1757 ok( node4
== node2
, "node %p node2 %p\n", node4
, node2
);
1759 r
= IXMLDOMNode_get_parentNode( node4
, &node3
);
1760 ok( r
== S_FALSE
, "ret %08x\n", r
);
1761 ok( node3
== NULL
, "%p\n", node3
);
1763 IXMLDOMNode_Release( node2
);
1764 IXMLDOMNode_Release( node4
);
1766 r
= IXMLDOMNodeList_get_item( node_list
, 0, &node4
);
1767 ok( r
== S_OK
, "ret %08x\n", r
);
1769 r
= IXMLDOMElement_removeChild( element
, node4
, NULL
);
1770 ok( r
== S_OK
, "ret %08x\n", r
);
1772 r
= IXMLDOMNode_get_parentNode( node4
, &node3
);
1773 ok( r
== S_FALSE
, "ret %08x\n", r
);
1774 ok( node3
== NULL
, "%p\n", node3
);
1776 IXMLDOMNode_Release( node4
);
1777 IXMLDOMNodeList_Release( node_list2
);
1778 IXMLDOMNode_Release( node
);
1779 IXMLDOMNodeList_Release( node_list
);
1780 IXMLDOMElement_Release( element
);
1781 IXMLDOMDocument_Release( doc
);
1784 static void test_XMLHTTP(void)
1786 static const WCHAR wszBody
[] = {'m','o','d','e','=','T','e','s','t',0};
1787 static WCHAR wszPOST
[] = {'P','O','S','T',0};
1788 static WCHAR wszUrl
[] = {'h','t','t','p',':','/','/',
1789 'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
1790 'p','o','s','t','t','e','s','t','.','p','h','p',0};
1791 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
1792 IXMLHttpRequest
*pXMLHttpRequest
;
1797 HRESULT hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
,
1798 CLSCTX_INPROC_SERVER
, &IID_IXMLHttpRequest
,
1799 (void **)&pXMLHttpRequest
);
1801 ok(hr
== S_OK
, "CoCreateInstance(CLSID_XMLHTTPRequest) should have succeeded instead of failing with 0x%08x\n", hr
);
1806 VariantInit(&dummy
);
1807 V_VT(&dummy
) = VT_ERROR
;
1808 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
1809 VariantInit(&varfalse
);
1810 V_VT(&varfalse
) = VT_BOOL
;
1811 V_BOOL(&varfalse
) = VARIANT_FALSE
;
1812 V_VT(&varbody
) = VT_BSTR
;
1813 V_BSTR(&varbody
) = SysAllocString(wszBody
);
1815 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, wszPOST
, wszUrl
, varfalse
, dummy
, dummy
);
1816 ok(hr
== S_OK
, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr
);
1818 hr
= IXMLHttpRequest_send(pXMLHttpRequest
, varbody
);
1819 ok(hr
== S_OK
, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr
);
1820 VariantClear(&varbody
);
1822 hr
= IXMLHttpRequest_get_responseText(pXMLHttpRequest
, &bstrResponse
);
1823 ok(hr
== S_OK
, "IXMLHttpRequest_get_responseText should have succeeded instead of failing with 0x%08x\n", hr
);
1824 /* the server currently returns "FAILED" because the Content-Type header is
1825 * not what the server expects */
1826 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)), "bstrResponse differs from what was expected\n");
1827 SysFreeString(bstrResponse
);
1830 static void test_IXMLDOMDocument2(void)
1835 IXMLDOMDocument
*doc
;
1836 IXMLDOMDocument2
*doc2
;
1840 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1841 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1845 str
= SysAllocString( szComplete4
);
1846 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1847 ok( r
== S_OK
, "loadXML failed\n");
1848 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1849 SysFreeString( str
);
1851 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IXMLDOMDocument2
, (void**)&doc2
);
1852 ok( r
== S_OK
, "ret %08x\n", r
);
1853 ok( doc
== (IXMLDOMDocument
*)doc2
, "interfaces differ\n");
1855 /* we will check if the variant got cleared */
1856 ref
= IXMLDOMDocument2_AddRef(doc2
);
1857 expect_eq(ref
, 3, int, "%d"); /* doc, doc2, AddRef*/
1858 V_VT(&var
) = VT_UNKNOWN
;
1859 V_UNKNOWN(&var
) = (IUnknown
*)doc2
;
1862 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("askldhfaklsdf"), &var
), E_FAIL
);
1863 expect_eq(V_VT(&var
), VT_UNKNOWN
, int, "%x");
1864 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), NULL
), E_INVALIDARG
);
1867 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
1868 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
1869 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
1872 /* the variant didn't get cleared*/
1873 expect_eq(IXMLDOMDocument2_Release(doc2
), 2, int, "%d");
1875 /* setProperty tests */
1876 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("askldhfaklsdf"), var
), E_FAIL
);
1877 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), var
), E_FAIL
);
1878 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL
);
1879 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
1880 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
1881 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
1883 /* contrary to what MSDN claims you can switch back from XPath to XSLPattern */
1884 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
1885 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
1886 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
1888 IXMLDOMDocument2_Release( doc2
);
1889 IXMLDOMDocument_Release( doc
);
1893 static void test_XPath(void)
1898 IXMLDOMDocument2
*doc
;
1899 IXMLDOMNode
*rootNode
;
1900 IXMLDOMNode
*elem1Node
;
1902 IXMLDOMNodeList
*list
;
1904 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1905 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
1909 ole_check(IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &b
));
1910 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
1912 /* switch to XPath */
1913 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
1915 /* some simple queries*/
1916 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root"), &list
));
1917 ole_check(IXMLDOMNodeList_get_item(list
, 0, &rootNode
));
1918 ole_check(IXMLDOMNodeList_reset(list
));
1919 expect_list_and_release(list
, "E2.D1");
1920 if (rootNode
== NULL
)
1923 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//c"), &list
));
1924 expect_list_and_release(list
, "E3.E1.E2.D1 E3.E2.E2.D1");
1926 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//c[@type]"), &list
));
1927 expect_list_and_release(list
, "E3.E2.E2.D1");
1929 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem"), &list
));
1930 /* using get_item for query results advances the position */
1931 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
1932 expect_node(node
, "E2.E2.D1");
1933 IXMLDOMNode_Release(node
);
1934 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
1935 expect_node(node
, "E4.E2.D1");
1936 IXMLDOMNode_Release(node
);
1937 ole_check(IXMLDOMNodeList_reset(list
));
1938 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
1940 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("."), &list
));
1941 expect_list_and_release(list
, "E2.D1");
1943 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem[3]/preceding-sibling::*"), &list
));
1944 ole_check(IXMLDOMNodeList_get_item(list
, 0, &elem1Node
));
1945 ole_check(IXMLDOMNodeList_reset(list
));
1946 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
1948 /* select an attribute */
1949 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//@type"), &list
));
1950 expect_list_and_release(list
, "A'type'.E3.E2.E2.D1");
1952 /* would evaluate to a number */
1953 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("count(*)"), &list
), E_FAIL
);
1954 /* would evaluate to a boolean */
1955 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("position()>0"), &list
), E_FAIL
);
1956 /* would evaluate to a string */
1957 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("name()"), &list
), E_FAIL
);
1960 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("c"), &list
));
1961 expect_list_and_release(list
, "");
1962 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("elem//c"), &list
));
1963 expect_list_and_release(list
, "");
1964 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//elem[4]"), &list
));
1965 expect_list_and_release(list
, "");
1967 /* foo undeclared in document node */
1968 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
1969 /* undeclared in <root> node */
1970 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//foo:c"), &list
), E_FAIL
);
1971 /* undeclared in <elem> node */
1972 ole_expect(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//foo:c"), &list
), E_FAIL
);
1973 /* but this trick can be used */
1974 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//*[name()='foo:c']"), &list
));
1975 expect_list_and_release(list
, "E3.E4.E2.D1");
1977 /* it has to be declared in SelectionNamespaces */
1978 todo_wine
ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
1979 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
1981 /* now the namespace can be used */
1982 todo_wine
ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//test:c"), &list
));
1983 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
1984 todo_wine
ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//test:c"), &list
));
1985 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
1986 todo_wine
ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//test:c"), &list
));
1987 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
1988 todo_wine
ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_(".//test:x"), &list
));
1989 todo_wine
expect_list_and_release(list
, "E5.E1.E4.E1.E2.D1");
1991 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
1992 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
1993 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL
);
1995 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
1998 todo_wine
ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
1999 todo_wine
expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
2000 if (V_VT(&var
) == VT_BSTR
)
2001 expect_bstr_eq_and_free(V_BSTR(&var
), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
2003 /* extra attributes - same thing*/
2004 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
2005 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL
);
2006 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
2008 IXMLDOMNode_Release(rootNode
);
2009 IXMLDOMNode_Release(elem1Node
);
2010 IXMLDOMDocument_Release(doc
);
2014 static void test_cloneNode(void )
2016 IXMLDOMDocument
*doc
= NULL
;
2018 IXMLDOMNodeList
*pList
;
2019 IXMLDOMNamedNodeMap
*mapAttr
;
2020 long nLength
= 0, nLength1
= 0;
2021 long nAttrCnt
= 0, nAttrCnt1
= 0;
2023 IXMLDOMNode
*node_clone
;
2026 static const WCHAR szSearch
[] = { 'l', 'c', '/', 'p', 'r', 0 };
2028 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
2032 str
= SysAllocString( szComplete4
);
2033 ole_check(IXMLDOMDocument_loadXML(doc
, str
, &b
));
2034 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
2040 str
= SysAllocString( szSearch
);
2041 r
= IXMLDOMNode_selectSingleNode(doc
, str
, &node
);
2042 ok( r
== S_OK
, "ret %08x\n", r
);
2043 ok( node
!= NULL
, "node %p\n", node
);
2048 IXMLDOMDocument_Release(doc
);
2052 /* Check invalid parameter */
2053 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, NULL
);
2054 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2057 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, &node_clone
);
2058 ok( r
== S_OK
, "ret %08x\n", r
);
2059 ok( node_clone
!= NULL
, "node %p\n", node
);
2063 IXMLDOMDocument_Release(doc
);
2064 IXMLDOMNode_Release(node
);
2068 r
= IXMLDOMNode_get_childNodes(node
, &pList
);
2069 ok( r
== S_OK
, "ret %08x\n", r
);
2072 IXMLDOMNodeList_get_length(pList
, &nLength
);
2073 IXMLDOMNodeList_Release(pList
);
2076 r
= IXMLDOMNode_get_attributes(node
, &mapAttr
);
2077 ok( r
== S_OK
, "ret %08x\n", r
);
2080 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt
);
2081 IXMLDOMNamedNodeMap_Release(mapAttr
);
2084 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
2085 ok( r
== S_OK
, "ret %08x\n", r
);
2088 IXMLDOMNodeList_get_length(pList
, &nLength1
);
2089 IXMLDOMNodeList_Release(pList
);
2092 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
2093 ok( r
== S_OK
, "ret %08x\n", r
);
2096 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
2097 IXMLDOMNamedNodeMap_Release(mapAttr
);
2100 ok(nLength
== nLength1
, "wrong Child count (%ld, %ld)\n", nLength
, nLength1
);
2101 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%ld, %ld)\n", nAttrCnt
, nAttrCnt1
);
2102 IXMLDOMNode_Release(node_clone
);
2105 r
= IXMLDOMNode_cloneNode(node
, VARIANT_FALSE
, &node_clone
);
2106 ok( r
== S_OK
, "ret %08x\n", r
);
2107 ok( node_clone
!= NULL
, "node %p\n", node
);
2111 IXMLDOMDocument_Release(doc
);
2112 IXMLDOMNode_Release(node
);
2116 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
2117 ok( r
== S_OK
, "ret %08x\n", r
);
2120 IXMLDOMNodeList_get_length(pList
, &nLength1
);
2121 ok( nLength1
== 0, "Length should be 0 (%ld)\n", nLength1
);
2122 IXMLDOMNodeList_Release(pList
);
2125 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
2126 ok( r
== S_OK
, "ret %08x\n", r
);
2129 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
2130 ok( nAttrCnt1
== 3, "Attribute count should be 3 (%ld)\n", nAttrCnt1
);
2131 IXMLDOMNamedNodeMap_Release(mapAttr
);
2134 ok(nLength
!= nLength1
, "wrong Child count (%ld, %ld)\n", nLength
, nLength1
);
2135 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%ld, %ld)\n", nAttrCnt
, nAttrCnt1
);
2136 IXMLDOMNode_Release(node_clone
);
2139 IXMLDOMNode_Release(node
);
2140 IXMLDOMDocument_Release(doc
);
2143 static void test_xmlTypes(void)
2145 IXMLDOMDocument
*doc
= NULL
;
2146 IXMLDOMElement
*pRoot
;
2148 IXMLDOMComment
*pComment
;
2149 IXMLDOMElement
*pElement
;
2150 IXMLDOMAttribute
*pAttrubute
;
2151 IXMLDOMNamedNodeMap
*pAttribs
;
2152 IXMLDOMCDATASection
*pCDataSec
;
2153 IXMLDOMImplementation
*pIXMLDOMImplementation
= NULL
;
2154 IXMLDOMDocumentFragment
*pDocFrag
= NULL
;
2155 IXMLDOMEntityReference
*pEntityRef
= NULL
;
2157 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1; /* Used for testing Siblings */
2161 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
2165 hr
= IXMLDOMDocument_get_nextSibling(doc
, NULL
);
2166 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2168 hr
= IXMLDOMDocument_get_nextSibling(doc
, &pNextChild
);
2169 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2170 ok(pNextChild
== NULL
, "pDocChild not NULL\n");
2172 /* test previous Sibling */
2173 hr
= IXMLDOMDocument_get_previousSibling(doc
, NULL
);
2174 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2176 pNextChild
= (IXMLDOMNode
*)0x1;
2177 hr
= IXMLDOMDocument_get_previousSibling(doc
, &pNextChild
);
2178 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2179 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
2181 /* test get_attributes */
2182 hr
= IXMLDOMDocument_get_attributes( doc
, NULL
);
2183 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
2185 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
2186 hr
= IXMLDOMDocument_get_attributes( doc
, &pAttribs
);
2187 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2188 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
2190 /* test get_dataType */
2191 hr
= IXMLDOMDocument_get_dataType(doc
, &v
);
2192 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2193 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
2196 /* test nodeTypeString */
2197 hr
= IXMLDOMDocument_get_nodeTypeString(doc
, &str
);
2198 ok(hr
== S_OK
, "ret %08x\n", hr
);
2199 ok( !lstrcmpW( str
, _bstr_("document") ), "incorrect nodeTypeString string\n");
2202 /* test implementation */
2203 hr
= IXMLDOMDocument_get_implementation(doc
, NULL
);
2204 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2206 hr
= IXMLDOMDocument_get_implementation(doc
, &pIXMLDOMImplementation
);
2207 ok(hr
== S_OK
, "ret %08x\n", hr
);
2210 VARIANT_BOOL hasFeature
= VARIANT_TRUE
;
2211 BSTR sEmpty
= SysAllocStringLen(NULL
, 0);
2213 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, NULL
, sEmpty
, &hasFeature
);
2214 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2216 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, NULL
);
2217 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2219 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
2220 ok(hr
== S_OK
, "ret %08x\n", hr
);
2221 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
2223 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, &hasFeature
);
2224 ok(hr
== S_OK
, "ret %08x\n", hr
);
2225 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned true\n");
2227 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), NULL
, &hasFeature
);
2228 ok(hr
== S_OK
, "ret %08x\n", hr
);
2229 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned false\n");
2231 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
2232 ok(hr
== S_OK
, "ret %08x\n", hr
);
2233 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
2235 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), _bstr_("1.0"), &hasFeature
);
2236 ok(hr
== S_OK
, "ret %08x\n", hr
);
2237 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
2239 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("XML"), _bstr_("1.0"), &hasFeature
);
2240 ok(hr
== S_OK
, "ret %08x\n", hr
);
2241 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
2243 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature
);
2244 ok(hr
== S_OK
, "ret %08x\n", hr
);
2245 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
2247 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("SSS"), NULL
, &hasFeature
);
2248 ok(hr
== S_OK
, "ret %08x\n", hr
);
2249 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
2251 SysFreeString(sEmpty
);
2252 IXMLDOMImplementation_Release(pIXMLDOMImplementation
);
2257 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
2258 ok(hr
== S_OK
, "ret %08x\n", hr
);
2261 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
2262 ok(hr
== S_OK
, "ret %08x\n", hr
);
2266 hr
= IXMLDOMDocument_createComment(doc
, szComment
, &pComment
);
2267 ok(hr
== S_OK
, "ret %08x\n", hr
);
2270 /* test get_attributes */
2271 hr
= IXMLDOMComment_get_attributes( pComment
, NULL
);
2272 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
2274 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
2275 hr
= IXMLDOMComment_get_attributes( pComment
, &pAttribs
);
2276 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2277 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
2279 /* test nodeTypeString */
2280 hr
= IXMLDOMComment_get_nodeTypeString(pComment
, &str
);
2281 ok(hr
== S_OK
, "ret %08x\n", hr
);
2282 ok( !lstrcmpW( str
, _bstr_("comment") ), "incorrect nodeTypeString string\n");
2285 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pComment
, NULL
);
2286 ok(hr
== S_OK
, "ret %08x\n", hr
);
2288 hr
= IXMLDOMComment_get_nodeName(pComment
, &str
);
2289 ok(hr
== S_OK
, "ret %08x\n", hr
);
2290 ok( !lstrcmpW( str
, szCommentNodeText
), "incorrect comment node Name\n");
2293 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
2294 ok(hr
== S_OK
, "ret %08x\n", hr
);
2295 ok( !lstrcmpW( str
, szCommentXML
), "incorrect comment xml\n");
2298 hr
= IXMLDOMComment_get_dataType(pComment
, &v
);
2299 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2300 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
2303 /* put data Tests */
2304 hr
= IXMLDOMComment_put_data(pComment
, _bstr_("This &is a ; test <>\\"));
2305 ok(hr
== S_OK
, "ret %08x\n", hr
);
2307 /* get data Tests */
2308 hr
= IXMLDOMComment_get_data(pComment
, &str
);
2309 ok(hr
== S_OK
, "ret %08x\n", hr
);
2310 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
2313 /* get data Tests */
2314 hr
= IXMLDOMComment_get_nodeValue(pComment
, &v
);
2315 ok(hr
== S_OK
, "ret %08x\n", hr
);
2316 ok( V_VT(&v
) == VT_BSTR
, "incorrect dataType type\n");
2317 ok( !lstrcmpW( V_BSTR(&v
), _bstr_("This &is a ; test <>\\") ), "incorrect get_nodeValue string\n");
2320 /* Confirm XML text is good */
2321 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
2322 ok(hr
== S_OK
, "ret %08x\n", hr
);
2323 ok( !lstrcmpW( str
, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
2326 /* Confirm we get the put_data Text back */
2327 hr
= IXMLDOMComment_get_text(pComment
, &str
);
2328 ok(hr
== S_OK
, "ret %08x\n", hr
);
2329 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
2332 /* test length property */
2333 hr
= IXMLDOMComment_get_length(pComment
, &len
);
2334 ok(hr
== S_OK
, "ret %08x\n", hr
);
2335 ok(len
== 21, "expected 21 got %ld\n", len
);
2337 /* test substringData */
2338 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, NULL
);
2339 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2341 /* test substringData - Invalid offset */
2342 str
= (BSTR
)&szElement
;
2343 hr
= IXMLDOMComment_substringData(pComment
, -1, 4, &str
);
2344 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2345 ok( str
== NULL
, "incorrect string\n");
2347 /* test substringData - Invalid offset */
2348 str
= (BSTR
)&szElement
;
2349 hr
= IXMLDOMComment_substringData(pComment
, 30, 0, &str
);
2350 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2351 ok( str
== NULL
, "incorrect string\n");
2353 /* test substringData - Invalid size */
2354 str
= (BSTR
)&szElement
;
2355 hr
= IXMLDOMComment_substringData(pComment
, 0, -1, &str
);
2356 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2357 ok( str
== NULL
, "incorrect string\n");
2359 /* test substringData - Invalid size */
2360 str
= (BSTR
)&szElement
;
2361 hr
= IXMLDOMComment_substringData(pComment
, 2, 0, &str
);
2362 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2363 ok( str
== NULL
, "incorrect string\n");
2365 /* test substringData - Start of string */
2366 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, &str
);
2367 ok(hr
== S_OK
, "ret %08x\n", hr
);
2368 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
2371 /* test substringData - Middle of string */
2372 hr
= IXMLDOMComment_substringData(pComment
, 13, 4, &str
);
2373 ok(hr
== S_OK
, "ret %08x\n", hr
);
2374 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
2377 /* test substringData - End of string */
2378 hr
= IXMLDOMComment_substringData(pComment
, 20, 4, &str
);
2379 ok(hr
== S_OK
, "ret %08x\n", hr
);
2380 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
2383 /* test appendData */
2384 hr
= IXMLDOMComment_appendData(pComment
, NULL
);
2385 ok(hr
== S_OK
, "ret %08x\n", hr
);
2387 hr
= IXMLDOMComment_appendData(pComment
, _bstr_(""));
2388 ok(hr
== S_OK
, "ret %08x\n", hr
);
2390 hr
= IXMLDOMComment_appendData(pComment
, _bstr_("Append"));
2391 ok(hr
== S_OK
, "ret %08x\n", hr
);
2393 hr
= IXMLDOMComment_get_text(pComment
, &str
);
2394 ok(hr
== S_OK
, "ret %08x\n", hr
);
2395 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
2398 /* test insertData */
2399 str
= SysAllocStringLen(NULL
, 0);
2400 hr
= IXMLDOMComment_insertData(pComment
, -1, str
);
2401 ok(hr
== S_OK
, "ret %08x\n", hr
);
2403 hr
= IXMLDOMComment_insertData(pComment
, -1, NULL
);
2404 ok(hr
== S_OK
, "ret %08x\n", hr
);
2406 hr
= IXMLDOMComment_insertData(pComment
, 1000, str
);
2407 ok(hr
== S_OK
, "ret %08x\n", hr
);
2409 hr
= IXMLDOMComment_insertData(pComment
, 1000, NULL
);
2410 ok(hr
== S_OK
, "ret %08x\n", hr
);
2412 hr
= IXMLDOMComment_insertData(pComment
, 0, NULL
);
2413 ok(hr
== S_OK
, "ret %08x\n", hr
);
2415 hr
= IXMLDOMComment_insertData(pComment
, 0, str
);
2416 ok(hr
== S_OK
, "ret %08x\n", hr
);
2419 hr
= IXMLDOMComment_insertData(pComment
, -1, _bstr_("Inserting"));
2420 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2422 hr
= IXMLDOMComment_insertData(pComment
, 1000, _bstr_("Inserting"));
2423 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2425 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("Begin "));
2426 ok(hr
== S_OK
, "ret %08x\n", hr
);
2428 hr
= IXMLDOMComment_insertData(pComment
, 17, _bstr_("Middle"));
2429 ok(hr
== S_OK
, "ret %08x\n", hr
);
2431 hr
= IXMLDOMComment_insertData(pComment
, 39, _bstr_(" End"));
2432 ok(hr
== S_OK
, "ret %08x\n", hr
);
2434 hr
= IXMLDOMComment_get_text(pComment
, &str
);
2435 ok(hr
== S_OK
, "ret %08x\n", hr
);
2436 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
2439 IXMLDOMComment_Release(pComment
);
2443 hr
= IXMLDOMDocument_createElement(doc
, szElement
, &pElement
);
2444 ok(hr
== S_OK
, "ret %08x\n", hr
);
2447 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
2448 ok(hr
== S_OK
, "ret %08x\n", hr
);
2450 /* test nodeTypeString */
2451 hr
= IXMLDOMDocument_get_nodeTypeString(pElement
, &str
);
2452 ok(hr
== S_OK
, "ret %08x\n", hr
);
2453 ok( !lstrcmpW( str
, _bstr_("element") ), "incorrect nodeTypeString string\n");
2456 hr
= IXMLDOMElement_get_nodeName(pElement
, &str
);
2457 ok(hr
== S_OK
, "ret %08x\n", hr
);
2458 ok( !lstrcmpW( str
, szElement
), "incorrect element node Name\n");
2461 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
2462 ok(hr
== S_OK
, "ret %08x\n", hr
);
2463 ok( !lstrcmpW( str
, szElementXML
), "incorrect element xml\n");
2466 hr
= IXMLDOMElement_get_dataType(pElement
, &v
);
2467 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2468 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
2472 hr
= IXMLDOMDocument_createAttribute(doc
, szAttribute
, &pAttrubute
);
2473 ok(hr
== S_OK
, "ret %08x\n", hr
);
2476 IXMLDOMNode
*pNewChild
= (IXMLDOMNode
*)0x1;
2478 hr
= IXMLDOMAttribute_get_nextSibling(pAttrubute
, NULL
);
2479 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2481 pNextChild
= (IXMLDOMNode
*)0x1;
2482 hr
= IXMLDOMAttribute_get_nextSibling(pAttrubute
, &pNextChild
);
2483 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2484 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
2486 /* test Previous Sibling*/
2487 hr
= IXMLDOMAttribute_get_previousSibling(pAttrubute
, NULL
);
2488 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2490 pNextChild
= (IXMLDOMNode
*)0x1;
2491 hr
= IXMLDOMAttribute_get_previousSibling(pAttrubute
, &pNextChild
);
2492 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2493 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
2495 /* test get_attributes */
2496 hr
= IXMLDOMAttribute_get_attributes( pAttrubute
, NULL
);
2497 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
2499 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
2500 hr
= IXMLDOMAttribute_get_attributes( pAttrubute
, &pAttribs
);
2501 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2502 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
2504 hr
= IXMLDOMElement_appendChild(pElement
, (IXMLDOMNode
*)pAttrubute
, &pNewChild
);
2505 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
2506 ok(pNewChild
== NULL
, "pNewChild not NULL\n");
2508 hr
= IXMLDOMElement_get_attributes(pElement
, &pAttribs
);
2509 ok(hr
== S_OK
, "ret %08x\n", hr
);
2512 hr
= IXMLDOMNamedNodeMap_setNamedItem(pAttribs
, (IXMLDOMNode
*)pAttrubute
, NULL
);
2513 ok(hr
== S_OK
, "ret %08x\n", hr
);
2515 IXMLDOMNamedNodeMap_Release(pAttribs
);
2518 hr
= IXMLDOMAttribute_get_nodeName(pAttrubute
, &str
);
2519 ok(hr
== S_OK
, "ret %08x\n", hr
);
2520 ok( !lstrcmpW( str
, szAttribute
), "incorrect attribute node Name\n");
2523 /* test nodeTypeString */
2524 hr
= IXMLDOMAttribute_get_nodeTypeString(pAttrubute
, &str
);
2525 ok(hr
== S_OK
, "ret %08x\n", hr
);
2526 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
2530 hr
= IXMLDOMAttribute_get_nodeName(pAttrubute
, &str
);
2531 ok(hr
== S_OK
, "ret %08x\n", hr
);
2532 ok( !lstrcmpW( str
, szAttribute
), "incorrect nodeName string\n");
2535 /* test name property */
2536 hr
= IXMLDOMAttribute_get_name(pAttrubute
, &str
);
2537 ok(hr
== S_OK
, "ret %08x\n", hr
);
2538 ok( !lstrcmpW( str
, szAttribute
), "incorrect name string\n");
2541 hr
= IXMLDOMAttribute_get_xml(pAttrubute
, &str
);
2542 ok(hr
== S_OK
, "ret %08x\n", hr
);
2543 ok( !lstrcmpW( str
, szAttributeXML
), "incorrect attribute xml\n");
2546 hr
= IXMLDOMAttribute_get_dataType(pAttrubute
, &v
);
2547 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2548 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
2551 IXMLDOMAttribute_Release(pAttrubute
);
2553 /* Check Element again with the Add Attribute*/
2554 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
2555 ok(hr
== S_OK
, "ret %08x\n", hr
);
2556 ok( !lstrcmpW( str
, szElementXML2
), "incorrect element xml\n");
2560 hr
= IXMLDOMElement_put_text(pElement
, _bstr_("TestingNode"));
2561 ok(hr
== S_OK
, "ret %08x\n", hr
);
2563 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
2564 ok(hr
== S_OK
, "ret %08x\n", hr
);
2565 ok( !lstrcmpW( str
, szElementXML3
), "incorrect element xml\n");
2568 IXMLDOMElement_Release(pElement
);
2572 hr
= IXMLDOMDocument_createCDATASection(doc
, szCData
, NULL
);
2573 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2575 hr
= IXMLDOMDocument_createCDATASection(doc
, szCData
, &pCDataSec
);
2576 ok(hr
== S_OK
, "ret %08x\n", hr
);
2579 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1;
2582 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pCDataSec
, NULL
);
2583 ok(hr
== S_OK
, "ret %08x\n", hr
);
2585 /* get Attribute Tests */
2586 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, NULL
);
2587 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2589 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
2590 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, &pAttribs
);
2591 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2592 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
2594 hr
= IXMLDOMCDATASection_get_nodeName(pCDataSec
, &str
);
2595 ok(hr
== S_OK
, "ret %08x\n", hr
);
2596 ok( !lstrcmpW( str
, szCDataNodeText
), "incorrect cdata node Name\n");
2599 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
2600 ok(hr
== S_OK
, "ret %08x\n", hr
);
2601 ok( !lstrcmpW( str
, szCDataXML
), "incorrect cdata xml\n");
2604 /* test lastChild */
2605 pNextChild
= (IXMLDOMNode
*)0x1;
2606 hr
= IXMLDOMCDATASection_get_lastChild(pCDataSec
, &pNextChild
);
2607 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2608 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
2610 /* test get_dataType */
2611 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, NULL
);
2612 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2614 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, &v
);
2615 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2616 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
2619 /* test nodeTypeString */
2620 hr
= IXMLDOMCDATASection_get_nodeTypeString(pCDataSec
, &str
);
2621 ok(hr
== S_OK
, "ret %08x\n", hr
);
2622 ok( !lstrcmpW( str
, _bstr_("cdatasection") ), "incorrect nodeTypeString string\n");
2625 /* put data Tests */
2626 hr
= IXMLDOMCDATASection_put_data(pCDataSec
, _bstr_("This &is a ; test <>\\"));
2627 ok(hr
== S_OK
, "ret %08x\n", hr
);
2629 /* Confirm XML text is good */
2630 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
2631 ok(hr
== S_OK
, "ret %08x\n", hr
);
2632 ok( !lstrcmpW( str
, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
2635 /* Confirm we get the put_data Text back */
2636 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
2637 ok(hr
== S_OK
, "ret %08x\n", hr
);
2638 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
2641 /* test length property */
2642 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
2643 ok(hr
== S_OK
, "ret %08x\n", hr
);
2644 ok(len
== 21, "expected 21 got %ld\n", len
);
2646 /* test get nodeValue */
2647 hr
= IXMLDOMCDATASection_get_nodeValue(pCDataSec
, &var
);
2648 ok(hr
== S_OK
, "ret %08x\n", hr
);
2649 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
2653 hr
= IXMLDOMCDATASection_get_data(pCDataSec
, &str
);
2654 ok(hr
== S_OK
, "ret %08x\n", hr
);
2655 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
2658 /* test substringData */
2659 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, NULL
);
2660 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2662 /* test substringData - Invalid offset */
2663 str
= (BSTR
)&szElement
;
2664 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, -1, 4, &str
);
2665 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2666 ok( str
== NULL
, "incorrect string\n");
2668 /* test substringData - Invalid offset */
2669 str
= (BSTR
)&szElement
;
2670 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 30, 0, &str
);
2671 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2672 ok( str
== NULL
, "incorrect string\n");
2674 /* test substringData - Invalid size */
2675 str
= (BSTR
)&szElement
;
2676 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, -1, &str
);
2677 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2678 ok( str
== NULL
, "incorrect string\n");
2680 /* test substringData - Invalid size */
2681 str
= (BSTR
)&szElement
;
2682 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 2, 0, &str
);
2683 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2684 ok( str
== NULL
, "incorrect string\n");
2686 /* test substringData - Start of string */
2687 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, &str
);
2688 ok(hr
== S_OK
, "ret %08x\n", hr
);
2689 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
2692 /* test substringData - Middle of string */
2693 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 13, 4, &str
);
2694 ok(hr
== S_OK
, "ret %08x\n", hr
);
2695 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
2698 /* test substringData - End of string */
2699 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 20, 4, &str
);
2700 ok(hr
== S_OK
, "ret %08x\n", hr
);
2701 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
2704 /* test appendData */
2705 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, NULL
);
2706 ok(hr
== S_OK
, "ret %08x\n", hr
);
2708 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_(""));
2709 ok(hr
== S_OK
, "ret %08x\n", hr
);
2711 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_("Append"));
2712 ok(hr
== S_OK
, "ret %08x\n", hr
);
2714 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
2715 ok(hr
== S_OK
, "ret %08x\n", hr
);
2716 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
2719 /* test insertData */
2720 str
= SysAllocStringLen(NULL
, 0);
2721 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, str
);
2722 ok(hr
== S_OK
, "ret %08x\n", hr
);
2724 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, NULL
);
2725 ok(hr
== S_OK
, "ret %08x\n", hr
);
2727 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, str
);
2728 ok(hr
== S_OK
, "ret %08x\n", hr
);
2730 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, NULL
);
2731 ok(hr
== S_OK
, "ret %08x\n", hr
);
2733 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, NULL
);
2734 ok(hr
== S_OK
, "ret %08x\n", hr
);
2736 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, str
);
2737 ok(hr
== S_OK
, "ret %08x\n", hr
);
2740 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, _bstr_("Inserting"));
2741 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2743 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, _bstr_("Inserting"));
2744 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2746 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("Begin "));
2747 ok(hr
== S_OK
, "ret %08x\n", hr
);
2749 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 17, _bstr_("Middle"));
2750 ok(hr
== S_OK
, "ret %08x\n", hr
);
2752 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 39, _bstr_(" End"));
2753 ok(hr
== S_OK
, "ret %08x\n", hr
);
2755 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
2756 ok(hr
== S_OK
, "ret %08x\n", hr
);
2757 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
2760 IXMLDOMCDATASection_Release(pCDataSec
);
2763 /* Document Fragments */
2764 hr
= IXMLDOMDocument_createDocumentFragment(doc
, NULL
);
2765 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2767 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &pDocFrag
);
2768 ok(hr
== S_OK
, "ret %08x\n", hr
);
2771 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1;
2773 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pDocFrag
, NULL
);
2774 ok(hr
== S_OK
, "ret %08x\n", hr
);
2776 /* get Attribute Tests */
2777 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, NULL
);
2778 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2780 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
2781 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, &pAttribs
);
2782 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2783 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
2785 hr
= IXMLDOMDocumentFragment_get_nodeName(pDocFrag
, &str
);
2786 ok(hr
== S_OK
, "ret %08x\n", hr
);
2787 ok( !lstrcmpW( str
, szDocFragmentText
), "incorrect docfragment node Name\n");
2790 /* test next Sibling*/
2791 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, NULL
);
2792 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2794 pNextChild
= (IXMLDOMNode
*)0x1;
2795 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, &pNextChild
);
2796 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2797 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
2799 /* test Previous Sibling*/
2800 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, NULL
);
2801 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2803 pNextChild
= (IXMLDOMNode
*)0x1;
2804 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, &pNextChild
);
2805 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2806 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
2808 /* test get_dataType */
2809 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, NULL
);
2810 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2812 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, &v
);
2813 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2814 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
2817 /* test nodeTypeString */
2818 hr
= IXMLDOMDocumentFragment_get_nodeTypeString(pDocFrag
, &str
);
2819 ok(hr
== S_OK
, "ret %08x\n", hr
);
2820 ok( !lstrcmpW( str
, _bstr_("documentfragment") ), "incorrect nodeTypeString string\n");
2823 IXMLDOMDocumentFragment_Release(pDocFrag
);
2826 /* Entity References */
2827 hr
= IXMLDOMDocument_createEntityReference(doc
, szEntityRef
, NULL
);
2828 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2830 hr
= IXMLDOMDocument_createEntityReference(doc
, szEntityRef
, &pEntityRef
);
2831 ok(hr
== S_OK
, "ret %08x\n", hr
);
2834 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pEntityRef
, NULL
);
2835 ok(hr
== S_OK
, "ret %08x\n", hr
);
2837 /* get Attribute Tests */
2838 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, NULL
);
2839 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2841 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
2842 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, &pAttribs
);
2843 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2844 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
2847 hr
= IXMLDOMEntityReference_get_dataType(pEntityRef
, &v
);
2848 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2849 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
2852 /* test nodeTypeString */
2853 hr
= IXMLDOMEntityReference_get_nodeTypeString(pEntityRef
, &str
);
2854 ok(hr
== S_OK
, "ret %08x\n", hr
);
2855 ok( !lstrcmpW( str
, _bstr_("entityreference") ), "incorrect nodeTypeString string\n");
2859 hr
= IXMLDOMEntityReference_get_xml(pEntityRef
, &str
);
2860 ok(hr
== S_OK
, "ret %08x\n", hr
);
2861 ok( !lstrcmpW( str
, szEntityRefXML
), "incorrect xml string\n");
2864 IXMLDOMEntityReference_Release(pEntityRef
);
2867 IXMLDOMElement_Release( pRoot
);
2871 IXMLDOMDocument_Release(doc
);
2876 static void test_nodeTypeTests( void )
2878 IXMLDOMDocument
*doc
= NULL
;
2879 IXMLDOMElement
*pRoot
;
2880 IXMLDOMElement
*pElement
;
2883 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
2887 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
2888 ok(hr
== S_OK
, "ret %08x\n", hr
);
2891 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
2892 ok(hr
== S_OK
, "ret %08x\n", hr
);
2895 hr
= IXMLDOMElement_put_dataType(pRoot
, NULL
);
2896 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2899 hr
= IXMLDOMElement_put_dataType(pRoot
, _bstr_("abcdefg") );
2900 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
2903 * The name passed into put_dataType is case-insensitive. So many of the names
2904 * have been changed to reflect this.
2907 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Boolean"), &pElement
);
2908 ok(hr
== S_OK
, "ret %08x\n", hr
);
2911 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
2913 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Boolean") );
2914 ok(hr
== S_OK
, "ret %08x\n", hr
);
2916 IXMLDOMElement_Release(pElement
);
2920 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_String"), &pElement
);
2921 ok(hr
== S_OK
, "ret %08x\n", hr
);
2924 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
2926 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("String") );
2927 ok(hr
== S_OK
, "ret %08x\n", hr
);
2929 IXMLDOMElement_Release(pElement
);
2933 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Number"), &pElement
);
2934 ok(hr
== S_OK
, "ret %08x\n", hr
);
2937 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
2939 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("number") );
2940 ok(hr
== S_OK
, "ret %08x\n", hr
);
2942 IXMLDOMElement_Release(pElement
);
2946 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Int"), &pElement
);
2947 ok(hr
== S_OK
, "ret %08x\n", hr
);
2950 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
2952 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("InT") );
2953 ok(hr
== S_OK
, "ret %08x\n", hr
);
2955 IXMLDOMElement_Release(pElement
);
2959 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Fixed"), &pElement
);
2960 ok(hr
== S_OK
, "ret %08x\n", hr
);
2963 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
2965 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("fixed.14.4") );
2966 ok(hr
== S_OK
, "ret %08x\n", hr
);
2968 IXMLDOMElement_Release(pElement
);
2972 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime"), &pElement
);
2973 ok(hr
== S_OK
, "ret %08x\n", hr
);
2976 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
2978 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime") );
2979 ok(hr
== S_OK
, "ret %08x\n", hr
);
2981 IXMLDOMElement_Release(pElement
);
2985 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime_tz"), &pElement
);
2986 ok(hr
== S_OK
, "ret %08x\n", hr
);
2989 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
2991 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
2992 ok(hr
== S_OK
, "ret %08x\n", hr
);
2994 IXMLDOMElement_Release(pElement
);
2998 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Date"), &pElement
);
2999 ok(hr
== S_OK
, "ret %08x\n", hr
);
3002 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3004 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Date") );
3005 ok(hr
== S_OK
, "ret %08x\n", hr
);
3007 IXMLDOMElement_Release(pElement
);
3011 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time"), &pElement
);
3012 ok(hr
== S_OK
, "ret %08x\n", hr
);
3015 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3017 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time") );
3018 ok(hr
== S_OK
, "ret %08x\n", hr
);
3020 IXMLDOMElement_Release(pElement
);
3024 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time_TZ"), &pElement
);
3025 ok(hr
== S_OK
, "ret %08x\n", hr
);
3028 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3030 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time.tz") );
3031 ok(hr
== S_OK
, "ret %08x\n", hr
);
3033 IXMLDOMElement_Release(pElement
);
3037 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I1"), &pElement
);
3038 ok(hr
== S_OK
, "ret %08x\n", hr
);
3041 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3043 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I1") );
3044 ok(hr
== S_OK
, "ret %08x\n", hr
);
3046 IXMLDOMElement_Release(pElement
);
3050 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I2"), &pElement
);
3051 ok(hr
== S_OK
, "ret %08x\n", hr
);
3054 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3056 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I2") );
3057 ok(hr
== S_OK
, "ret %08x\n", hr
);
3059 IXMLDOMElement_Release(pElement
);
3063 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I4"), &pElement
);
3064 ok(hr
== S_OK
, "ret %08x\n", hr
);
3067 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3069 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I4") );
3070 ok(hr
== S_OK
, "ret %08x\n", hr
);
3072 IXMLDOMElement_Release(pElement
);
3076 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI1"), &pElement
);
3077 ok(hr
== S_OK
, "ret %08x\n", hr
);
3080 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3082 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI1") );
3083 ok(hr
== S_OK
, "ret %08x\n", hr
);
3085 IXMLDOMElement_Release(pElement
);
3089 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI2"), &pElement
);
3090 ok(hr
== S_OK
, "ret %08x\n", hr
);
3093 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3095 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI2") );
3096 ok(hr
== S_OK
, "ret %08x\n", hr
);
3098 IXMLDOMElement_Release(pElement
);
3102 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI4"), &pElement
);
3103 ok(hr
== S_OK
, "ret %08x\n", hr
);
3106 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3108 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI4") );
3109 ok(hr
== S_OK
, "ret %08x\n", hr
);
3111 IXMLDOMElement_Release(pElement
);
3115 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r4"), &pElement
);
3116 ok(hr
== S_OK
, "ret %08x\n", hr
);
3119 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3121 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r4") );
3122 ok(hr
== S_OK
, "ret %08x\n", hr
);
3124 IXMLDOMElement_Release(pElement
);
3128 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r8"), &pElement
);
3129 ok(hr
== S_OK
, "ret %08x\n", hr
);
3132 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3134 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r8") );
3135 ok(hr
== S_OK
, "ret %08x\n", hr
);
3137 IXMLDOMElement_Release(pElement
);
3141 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_float"), &pElement
);
3142 ok(hr
== S_OK
, "ret %08x\n", hr
);
3145 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3147 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("float") );
3148 ok(hr
== S_OK
, "ret %08x\n", hr
);
3150 IXMLDOMElement_Release(pElement
);
3154 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_uuid"), &pElement
);
3155 ok(hr
== S_OK
, "ret %08x\n", hr
);
3158 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3160 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UuId") );
3161 ok(hr
== S_OK
, "ret %08x\n", hr
);
3163 IXMLDOMElement_Release(pElement
);
3167 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_hex"), &pElement
);
3168 ok(hr
== S_OK
, "ret %08x\n", hr
);
3171 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3173 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.hex") );
3174 ok(hr
== S_OK
, "ret %08x\n", hr
);
3176 IXMLDOMElement_Release(pElement
);
3180 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_base64"), &pElement
);
3181 ok(hr
== S_OK
, "ret %08x\n", hr
);
3184 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3186 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.base64") );
3187 ok(hr
== S_OK
, "ret %08x\n", hr
);
3189 IXMLDOMElement_Release(pElement
);
3192 /* Check changing types */
3193 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Change"), &pElement
);
3194 ok(hr
== S_OK
, "ret %08x\n", hr
);
3197 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3199 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
3200 ok(hr
== S_OK
, "ret %08x\n", hr
);
3202 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("string") );
3203 ok(hr
== S_OK
, "ret %08x\n", hr
);
3205 IXMLDOMElement_Release(pElement
);
3208 IXMLDOMElement_Release(pRoot
);
3212 IXMLDOMDocument_Release(doc
);
3217 static void test_DocumentSaveToDocument(void)
3219 IXMLDOMDocument
*doc
= NULL
;
3220 IXMLDOMDocument
*doc2
= NULL
;
3221 IXMLDOMElement
*pRoot
;
3225 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3229 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc2
);
3232 IXMLDOMDocument_Release(doc
);
3236 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
3237 ok(hr
== S_OK
, "ret %08x\n", hr
);
3240 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
3241 ok(hr
== S_OK
, "ret %08x\n", hr
);
3248 V_VT(&vDoc
) = VT_UNKNOWN
;
3249 V_UNKNOWN(&vDoc
) = (IUnknown
*)doc2
;
3251 hr
= IXMLDOMDocument_save(doc
, vDoc
);
3252 ok(hr
== S_OK
, "ret %08x\n", hr
);
3254 hr
= IXMLDOMDocument_get_xml(doc
, &sOrig
);
3255 ok(hr
== S_OK
, "ret %08x\n", hr
);
3257 hr
= IXMLDOMDocument_get_xml(doc2
, &sNew
);
3258 ok(hr
== S_OK
, "ret %08x\n", hr
);
3260 ok( !lstrcmpW( sOrig
, sNew
), "New document is not the same as origial\n");
3262 SysFreeString(sOrig
);
3263 SysFreeString(sNew
);
3267 IXMLDOMDocument_Release(doc2
);
3268 IXMLDOMDocument_Release(doc
);
3271 static void test_DocumentSaveToFile(void)
3273 IXMLDOMDocument
*doc
= NULL
;
3274 IXMLDOMElement
*pRoot
;
3280 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3284 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
3285 ok(hr
== S_OK
, "ret %08x\n", hr
);
3288 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
3289 ok(hr
== S_OK
, "ret %08x\n", hr
);
3294 V_VT(&vFile
) = VT_BSTR
;
3295 V_BSTR(&vFile
) = _bstr_("test.xml");
3297 hr
= IXMLDOMDocument_save(doc
, vFile
);
3298 ok(hr
== S_OK
, "ret %08x\n", hr
);
3302 IXMLDOMElement_Release(pRoot
);
3303 IXMLDOMDocument_Release(doc
);
3305 file
= CreateFile("test.xml", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
3306 ok(file
!= INVALID_HANDLE_VALUE
, "Could not open file: %u\n", GetLastError());
3307 if(file
== INVALID_HANDLE_VALUE
)
3310 ReadFile(file
, buffer
, sizeof(buffer
), &read
, NULL
);
3311 ok(read
!= 0, "could not read file\n");
3312 ok(buffer
[0] != '<' || buffer
[1] != '?', "File contains processing instruction\n");
3315 DeleteFile("test.xml");
3318 static void test_testTransforms(void)
3320 IXMLDOMDocument
*doc
= NULL
;
3321 IXMLDOMDocument
*docSS
= NULL
;
3327 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3331 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&docSS
);
3334 IXMLDOMDocument_Release(doc
);
3338 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTransformXML
), &bSucc
);
3339 ok(hr
== S_OK
, "ret %08x\n", hr
);
3341 hr
= IXMLDOMDocument_loadXML(docSS
, _bstr_(szTransformSSXML
), &bSucc
);
3342 ok(hr
== S_OK
, "ret %08x\n", hr
);
3344 hr
= IXMLDOMDocument_QueryInterface(docSS
, &IID_IXMLDOMNode
, (LPVOID
*)&pNode
);
3345 ok(hr
== S_OK
, "ret %08x\n", hr
);
3350 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &bOut
);
3351 ok(hr
== S_OK
, "ret %08x\n", hr
);
3352 ok( compareIgnoreReturns( bOut
, _bstr_(szTransformOutput
)), "Stylesheet output not correct\n");
3354 IXMLDOMNode_Release(pNode
);
3357 IXMLDOMDocument_Release(docSS
);
3358 IXMLDOMDocument_Release(doc
);
3363 static void test_Namespaces(void)
3365 IXMLDOMDocument2
*doc
= NULL
;
3367 IXMLDOMNode
*pNode2
= NULL
;
3371 static const CHAR szNamespacesXML
[] =
3372 "<?xml version=\"1.0\"?>\n"
3373 "<root xmlns:WEB='http://www.winehq.org'>\n"
3374 "<WEB:Site version=\"1.0\" />\n"
3377 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3381 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szNamespacesXML
), &bSucc
);
3382 ok(hr
== S_OK
, "ret %08x\n", hr
);
3383 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
3385 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root"), &pNode
);
3386 ok(hr
== S_OK
, "ret %08x\n", hr
);
3389 hr
= IXMLDOMNode_get_firstChild( pNode
, &pNode2
);
3390 ok( hr
== S_OK
, "ret %08x\n", hr
);
3391 ok( pNode2
!= NULL
, "pNode2 == NULL\n");
3393 /* Test get_prefix */
3394 hr
= IXMLDOMNode_get_prefix(pNode2
, NULL
);
3395 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3396 /* NOTE: Need to test that arg2 gets cleared on Error. */
3398 hr
= IXMLDOMNode_get_prefix(pNode2
, &str
);
3399 ok( hr
== S_OK
, "ret %08x\n", hr
);
3400 ok( !lstrcmpW( str
, _bstr_("WEB")), "incorrect prefix string\n");
3403 /* Test get_namespaceURI */
3404 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, NULL
);
3405 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3406 /* NOTE: Need to test that arg2 gets cleared on Error. */
3408 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, &str
);
3409 ok( hr
== S_OK
, "ret %08x\n", hr
);
3410 ok( !lstrcmpW( str
, _bstr_("http://www.winehq.org")), "incorrect namespaceURI string\n");
3413 IXMLDOMNode_Release(pNode2
);
3414 IXMLDOMNode_Release(pNode
);
3417 IXMLDOMDocument2_Release(doc
);
3426 r
= CoInitialize( NULL
);
3427 ok( r
== S_OK
, "failed to init com\n");
3433 test_getElementsByTagName();
3435 test_get_childNodes();
3438 test_IXMLDOMDocument2();
3442 test_nodeTypeTests();
3443 test_DocumentSaveToDocument();
3444 test_DocumentSaveToFile();
3445 test_testTransforms();