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
29 #include "msxml2did.h"
34 #include "wine/test.h"
36 static const WCHAR szEmpty
[] = { 0 };
37 static const WCHAR szIncomplete
[] = {
38 '<','?','x','m','l',' ',
39 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
41 static const WCHAR szComplete1
[] = {
42 '<','?','x','m','l',' ',
43 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
44 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
46 static const WCHAR szComplete2
[] = {
47 '<','?','x','m','l',' ',
48 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
49 '<','o','>','<','/','o','>','\n',0
51 static const WCHAR szComplete3
[] = {
52 '<','?','x','m','l',' ',
53 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
54 '<','a','>','<','/','a','>','\n',0
56 static const WCHAR szComplete4
[] = {
57 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
58 '<','l','c',' ','d','l','=','\'','s','t','r','1','\'','>','\n',
59 '<','b','s',' ','v','r','=','\'','s','t','r','2','\'',' ','s','z','=','\'','1','2','3','4','\'','>',
60 'f','n','1','.','t','x','t','\n',
61 '<','/','b','s','>','\n',
62 '<','p','r',' ','i','d','=','\'','s','t','r','3','\'',' ','v','r','=','\'','1','.','2','.','3','\'',' ',
63 'p','n','=','\'','w','i','n','e',' ','2','0','0','5','0','8','0','4','\'','>','\n',
64 'f','n','2','.','t','x','t','\n',
65 '<','/','p','r','>','\n',
66 '<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
70 '<','/','b','a','>','\n',
71 '<','/','f','o','>','\n',
72 '<','/','l','c','>','\n',0
74 static const WCHAR szComplete5
[] = {
75 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
76 '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','"',
77 ' ','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','"','>',
78 '<','S',':','s','c','o','p','e','>',
79 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
80 '<','/','S',':','s','c','o','p','e','>',
81 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
82 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
83 'c','o','m','p','u','t','e','r',
84 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
85 '<','/','S',':','s','e','a','r','c','h','>',0
88 static const CHAR szExampleXML
[] =
89 "<?xml version='1.0' encoding='utf-8'?>\n"
90 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
95 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
96 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
97 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
105 " <c type=\"old\">C2 field</c>\n"
108 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
117 " <foo:c>C4 field</foo:c>\n"
121 static const CHAR szTransformXML
[] =
122 "<?xml version=\"1.0\"?>\n"
127 static const CHAR szTransformSSXML
[] =
128 "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n"
129 " <xsl:output method=\"html\"/>\n"
130 " <xsl:template match=\"/\">\n"
131 " <xsl:apply-templates select=\"greeting\"/>\n"
133 " <xsl:template match=\"greeting\">\n"
137 " <xsl:value-of select=\".\"/>\n"
144 static const CHAR szTransformOutput
[] =
147 "</h1></body></html>";
149 static const CHAR szTypeValueXML
[] =
150 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
151 "<root xmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n"
152 " <string>Wine</string>\n"
153 " <string2 dt:dt=\"string\">String</string2>\n"
154 " <number dt:dt=\"number\">12.44</number>\n"
155 " <number2 dt:dt=\"NUMbEr\">-3.71e3</number2>\n"
156 " <int dt:dt=\"int\">-13</int>\n"
157 " <fixed dt:dt=\"fixed.14.4\">7322.9371</fixed>\n"
158 " <bool dt:dt=\"boolean\">1</bool>\n"
159 " <datetime dt:dt=\"datetime\">2009-11-18T03:21:33.12</datetime>\n"
160 " <datetimetz dt:dt=\"datetime.tz\">2003-07-11T11:13:57+03:00</datetimetz>\n"
161 " <date dt:dt=\"date\">3721-11-01</date>\n"
162 " <time dt:dt=\"time\">13:57:12.31321</time>\n"
163 " <timetz dt:dt=\"time.tz\">23:21:01.13+03:21</timetz>\n"
164 " <i1 dt:dt=\"i1\">-13</i1>\n"
165 " <i2 dt:dt=\"i2\">31915</i2>\n"
166 " <i4 dt:dt=\"i4\">-312232</i4>\n"
167 " <ui1 dt:dt=\"ui1\">123</ui1>\n"
168 " <ui2 dt:dt=\"ui2\">48282</ui2>\n"
169 " <ui4 dt:dt=\"ui4\">949281</ui4>\n"
170 " <r4 dt:dt=\"r4\">213124.0</r4>\n"
171 " <r8 dt:dt=\"r8\">0.412</r8>\n"
172 " <float dt:dt=\"float\">41221.421</float>\n"
173 " <uuid dt:dt=\"uuid\">333C7BC4-460F-11D0-BC04-0080C7055a83</uuid>\n"
174 " <binhex dt:dt=\"bin.hex\">fffca012003c</binhex>\n"
175 " <binbase64 dt:dt=\"bin.base64\">YmFzZTY0IHRlc3Q=</binbase64>\n"
178 static const CHAR szBasicTransformSSXMLPart1
[] =
179 "<?xml version=\"1.0\"?>"
180 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >"
181 "<xsl:output method=\"html\"/>\n"
182 "<xsl:template match=\"/\">"
183 "<HTML><BODY><TABLE>"
184 " <xsl:apply-templates select='document(\"";
186 static const CHAR szBasicTransformSSXMLPart2
[] =
188 " <xsl:sort select=\"cost\"/><xsl:sort select=\"name\"/>"
189 " </xsl:apply-templates>"
190 "</TABLE></BODY></HTML>"
192 "<xsl:template match=\"bottle\">"
193 " <TR><xsl:apply-templates select=\"name\" /><xsl:apply-templates select=\"cost\" /></TR>"
195 "<xsl:template match=\"name\">"
196 " <TD><xsl:apply-templates /></TD>"
198 "<xsl:template match=\"cost\">"
199 " <TD><xsl:apply-templates /></TD>"
203 static const CHAR szBasicTransformXML
[] =
204 "<?xml version=\"1.0\"?><bottle><wine><name>Wine</name><cost>$25.00</cost></wine></bottle>";
206 static const CHAR szBasicTransformOutput
[] =
207 "<HTML><BODY><TABLE><TD>Wine</TD><TD>$25.00</TD></TABLE></BODY></HTML>";
209 static const WCHAR szNonExistentFile
[] = {
210 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
212 static const WCHAR szNonExistentAttribute
[] = {
213 'n','o','n','E','x','i','s','i','t','i','n','g','A','t','t','r','i','b','u','t','e',0
215 static const WCHAR szDocument
[] = {
216 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
219 static const WCHAR szOpen
[] = { 'o','p','e','n',0 };
220 static WCHAR szdl
[] = { 'd','l',0 };
221 static const WCHAR szvr
[] = { 'v','r',0 };
222 static const WCHAR szlc
[] = { 'l','c',0 };
223 static WCHAR szbs
[] = { 'b','s',0 };
224 static const WCHAR szstr1
[] = { 's','t','r','1',0 };
225 static const WCHAR szstr2
[] = { 's','t','r','2',0 };
226 static const WCHAR szstar
[] = { '*',0 };
227 static const WCHAR szfn1_txt
[] = {'f','n','1','.','t','x','t',0};
229 static WCHAR szComment
[] = {'A',' ','C','o','m','m','e','n','t',0 };
230 static WCHAR szCommentXML
[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
231 static WCHAR szCommentNodeText
[] = {'#','c','o','m','m','e','n','t',0 };
233 static WCHAR szElement
[] = {'E','l','e','T','e','s','t', 0 };
234 static WCHAR szElementXML
[] = {'<','E','l','e','T','e','s','t','/','>',0 };
235 static WCHAR szElementXML2
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
236 static WCHAR szElementXML3
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
237 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
238 static WCHAR szElementXML4
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
239 '&','a','m','p',';','x',' ',0x2103,'<','/','E','l','e','T','e','s','t','>',0 };
241 static WCHAR szAttribute
[] = {'A','t','t','r',0 };
242 static WCHAR szAttributeXML
[] = {'A','t','t','r','=','"','"',0 };
244 static WCHAR szCData
[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
245 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
246 static WCHAR szCDataXML
[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
247 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
249 static WCHAR szCDataNodeText
[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
250 static WCHAR szDocFragmentText
[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
252 static WCHAR szEntityRef
[] = {'e','n','t','i','t','y','r','e','f',0 };
253 static WCHAR szEntityRefXML
[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
254 static WCHAR szStrangeChars
[] = {'&','x',' ',0x2103, 0};
256 #define expect_bstr_eq_and_free(bstr, expect) { \
257 BSTR bstrExp = alloc_str_from_narrow(expect); \
258 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
259 SysFreeString(bstr); \
260 SysFreeString(bstrExp); \
263 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
265 #define ole_check(expr) { \
267 ok(r == S_OK, #expr " returned %x\n", r); \
270 #define ole_expect(expr, expect) { \
272 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
275 #define double_eq(x, y) ok((x)-(y)<=1e-14*(x) && (x)-(y)>=-1e-14*(x), "expected %.16g, got %.16g\n", x, y)
277 static BSTR
alloc_str_from_narrow(const char *str
)
279 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
280 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
281 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
285 BSTR alloced_bstrs
[256];
286 int alloced_bstrs_count
= 0;
288 static BSTR
_bstr_(const char *str
)
290 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
291 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
292 return alloced_bstrs
[alloced_bstrs_count
++];
295 static void free_bstrs(void)
298 for (i
= 0; i
< alloced_bstrs_count
; i
++)
299 SysFreeString(alloced_bstrs
[i
]);
300 alloced_bstrs_count
= 0;
303 static VARIANT
_variantbstr_(const char *str
)
307 V_BSTR(&v
) = _bstr_(str
);
311 static BOOL
compareIgnoreReturns(BSTR sLeft
, BSTR sRight
)
315 while (*sLeft
== '\r' || *sLeft
== '\n') sLeft
++;
316 while (*sRight
== '\r' || *sRight
== '\n') sRight
++;
317 if (*sLeft
!= *sRight
) return FALSE
;
318 if (!*sLeft
) return TRUE
;
324 static BOOL
compareIgnoreReturnsWhitespace(BSTR sLeft
, BSTR sRight
)
326 /* MSXML3 inserts whitespace where as libxml doesn't. */
329 while (*sLeft
== '\r' || *sLeft
== '\n' || *sLeft
== ' ') sLeft
++;
330 while (*sRight
== '\r' || *sRight
== '\n' || *sRight
== ' ') sRight
++;
331 if (*sLeft
!= *sRight
) return FALSE
;
332 if (!*sLeft
) return TRUE
;
338 static void get_str_for_type(DOMNodeType type
, char *buf
)
352 wsprintfA(buf
, "[%d]", type
);
356 #define test_disp(u) _test_disp(__LINE__,u)
357 static void _test_disp(unsigned line
, IUnknown
*unk
)
359 DISPID dispid
= DISPID_XMLDOM_NODELIST_RESET
;
367 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
368 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatch: %08x\n", hres
);
373 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
374 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
375 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
377 sName
= SysAllocString( szstar
);
378 hres
= IDispatchEx_DeleteMemberByName(dispex
, sName
, fdexNameCaseSensitive
);
379 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
380 SysFreeString( sName
);
382 hres
= IDispatchEx_DeleteMemberByDispID(dispex
, dispid
);
383 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
385 hres
= IDispatchEx_GetMemberProperties(dispex
, dispid
, grfdexPropCanAll
, &dwProps
);
386 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
387 ok(dwProps
== 0, "expected 0 got %d\n", dwProps
);
389 hres
= IDispatchEx_GetMemberName(dispex
, dispid
, &sName
);
390 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
392 SysFreeString(sName
);
394 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumDefault
, DISPID_XMLDOM_NODELIST_RESET
, &dispid
);
395 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
397 hres
= IDispatchEx_GetNameSpaceParent(dispex
, &pUnk
);
398 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
399 if(hres
== S_OK
&& pUnk
)
400 IUnknown_Release(pUnk
);
402 IDispatchEx_Release(dispex
);
405 static int get_node_position(IXMLDOMNode
*node
)
410 IXMLDOMNode_AddRef(node
);
413 IXMLDOMNode
*new_node
;
416 r
= IXMLDOMNode_get_previousSibling(node
, &new_node
);
417 ok(SUCCEEDED(r
), "get_previousSibling failed\n");
418 IXMLDOMNode_Release(node
);
424 static void node_to_string(IXMLDOMNode
*node
, char *buf
)
431 lstrcpyA(buf
, "(null)");
435 IXMLDOMNode_AddRef(node
);
438 IXMLDOMNode
*new_node
;
440 ole_check(IXMLDOMNode_get_nodeType(node
, &type
));
441 get_str_for_type(type
, buf
);
444 if (type
== NODE_ATTRIBUTE
)
447 ole_check(IXMLDOMNode_get_nodeName(node
, &bstr
));
449 wsprintfA(buf
, "%ws", bstr
);
454 r
= IXMLDOMNode_selectSingleNode(node
, _bstr_(".."), &new_node
);
458 int pos
= get_node_position(node
);
459 DOMNodeType parent_type
= NODE_INVALID
;
460 r
= IXMLDOMNode_get_parentNode(node
, &new_node
);
462 /* currently wine doesn't create a node for the <?xml ... ?>. To be able to test query
463 * results we "fix" it */
465 ole_check(IXMLDOMNode_get_nodeType(new_node
, &parent_type
));
466 if ((parent_type
== NODE_DOCUMENT
) && type
!= NODE_PROCESSING_INSTRUCTION
&& pos
==1)
468 todo_wine
ok(FALSE
, "The first child of the document node in MSXML is the <?xml ... ?> processing instruction\n");
471 wsprintf(buf
, "%d", pos
);
475 ok(SUCCEEDED(r
), "get_parentNode failed (%08x)\n", r
);
476 IXMLDOMNode_Release(node
);
485 static char *list_to_string(IXMLDOMNodeList
*list
)
487 static char buf
[4096];
494 lstrcpyA(buf
, "(null)");
497 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
498 for (i
= 0; i
< len
; i
++)
503 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
504 node_to_string(node
, pos
);
506 IXMLDOMNode_Release(node
);
512 #define expect_node(node, expstr) { char str[4096]; node_to_string(node, str); ok(strcmp(str, expstr)==0, "Invalid node: %s, expected %s\n", str, expstr); }
513 #define expect_list_and_release(list, expstr) { char *str = list_to_string(list); ok(strcmp(str, expstr)==0, "Invalid node list: %s, expected %s\n", str, expstr); if (list) IXMLDOMNodeList_Release(list); }
515 static void test_domdoc( void )
518 IXMLDOMDocument
*doc
= NULL
;
519 IXMLDOMParseError
*error
;
520 IXMLDOMElement
*element
= NULL
;
522 IXMLDOMText
*nodetext
= NULL
;
523 IXMLDOMComment
*node_comment
= NULL
;
524 IXMLDOMAttribute
*node_attr
= NULL
;
525 IXMLDOMNode
*nodeChild
= NULL
;
526 IXMLDOMProcessingInstruction
*nodePI
= NULL
;
527 ISupportErrorInfo
*support_error
= NULL
;
534 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
535 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
539 test_disp((IUnknown
*)doc
);
541 /* try some stupid things */
542 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
543 ok( r
== S_FALSE
, "loadXML failed\n");
546 r
= IXMLDOMDocument_loadXML( doc
, NULL
, &b
);
547 ok( r
== S_FALSE
, "loadXML failed\n");
548 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
550 /* try to load a document from a nonexistent file */
552 str
= SysAllocString( szNonExistentFile
);
554 V_VT(&var
) = VT_BSTR
;
557 r
= IXMLDOMDocument_load( doc
, var
, &b
);
558 ok( r
== S_FALSE
, "load (from file) failed\n");
559 ok( b
== VARIANT_FALSE
, "failed to load XML file\n");
560 SysFreeString( str
);
562 /* try load an empty document */
564 str
= SysAllocString( szEmpty
);
565 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
566 ok( r
== S_FALSE
, "loadXML failed\n");
567 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
568 SysFreeString( str
);
570 r
= IXMLDOMDocument_get_async( doc
, &b
);
571 ok( r
== S_OK
, "get_async failed (%08x)\n", r
);
572 ok( b
== VARIANT_TRUE
, "Wrong default value\n");
574 /* check that there's no document element */
576 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
577 ok( r
== S_FALSE
, "should be no document element\n");
579 /* try finding a node */
581 str
= SysAllocString( szstr1
);
582 r
= IXMLDOMDocument_selectSingleNode( doc
, str
, &node
);
583 ok( r
== S_FALSE
, "ret %08x\n", r
);
584 SysFreeString( str
);
587 str
= SysAllocString( szIncomplete
);
588 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
589 ok( r
== S_FALSE
, "loadXML failed\n");
590 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
591 SysFreeString( str
);
593 /* check that there's no document element */
594 element
= (IXMLDOMElement
*)1;
595 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
596 ok( r
== S_FALSE
, "should be no document element\n");
597 ok( element
== NULL
, "Element should be NULL\n");
599 /* try to load something valid */
601 str
= SysAllocString( szComplete1
);
602 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
603 ok( r
== S_OK
, "loadXML failed\n");
604 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
605 SysFreeString( str
);
607 /* check if nodename is correct */
608 r
= IXMLDOMDocument_get_nodeName( doc
, NULL
);
609 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
611 /* content doesn't matter here */
613 r
= IXMLDOMDocument_get_nodeName( doc
, &str
);
614 ok ( r
== S_OK
, "get_nodeName wrong code\n");
615 ok ( str
!= NULL
, "str is null\n");
616 ok( !lstrcmpW( str
, szDocument
), "incorrect nodeName\n");
617 SysFreeString( str
);
620 r
= IXMLDOMDocument_put_text( doc
, _bstr_("Should Fail") );
621 ok( r
== E_FAIL
, "ret %08x\n", r
);
623 /* check that there's a document element */
625 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
626 ok( r
== S_OK
, "should be a document element\n");
629 IObjectIdentity
*ident
;
632 test_disp((IUnknown
*)element
);
634 r
= IXMLDOMElement_QueryInterface( element
, &IID_IObjectIdentity
, (LPVOID
*)&ident
);
635 ok( r
== E_NOINTERFACE
, "ret %08x\n", r
);
637 /* check if the tag is correct */
638 r
= IXMLDOMElement_get_tagName( element
, &tag
);
639 ok( r
== S_OK
, "couldn't get tag name\n");
640 ok( tag
!= NULL
, "tag was null\n");
641 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
642 SysFreeString( tag
);
644 /* figure out what happens if we try to reload the document */
645 str
= SysAllocString( szComplete2
);
646 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
647 ok( r
== S_OK
, "loadXML failed\n");
648 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
649 SysFreeString( str
);
651 /* check if the tag is still correct */
653 r
= IXMLDOMElement_get_tagName( element
, &tag
);
654 ok( r
== S_OK
, "couldn't get tag name\n");
655 ok( tag
!= NULL
, "tag was null\n");
656 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
657 SysFreeString( tag
);
659 IXMLDOMElement_Release( element
);
663 /* as soon as we call loadXML again, the document element will disappear */
665 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
666 ok( r
== S_FALSE
, "loadXML failed\n");
667 ok( b
== 2, "variant modified\n");
668 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
669 ok( r
== S_FALSE
, "should be no document element\n");
671 /* try to load something else simple and valid */
673 str
= SysAllocString( szComplete3
);
674 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
675 ok( r
== S_OK
, "loadXML failed\n");
676 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
677 SysFreeString( str
);
679 /* try something a little more complicated */
681 str
= SysAllocString( szComplete4
);
682 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
683 ok( r
== S_OK
, "loadXML failed\n");
684 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
685 SysFreeString( str
);
687 r
= IXMLDOMDocument_get_parseError( doc
, &error
);
688 ok( r
== S_OK
, "returns %08x\n", r
);
690 r
= IXMLDOMParseError_get_errorCode( error
, &code
);
691 ok( r
== S_FALSE
, "returns %08x\n", r
);
692 ok( code
== 0, "code %d\n", code
);
693 IXMLDOMParseError_Release( error
);
695 /* test createTextNode */
696 str
= SysAllocString( szOpen
);
697 r
= IXMLDOMDocument_createTextNode(doc
, str
, NULL
);
698 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
699 r
= IXMLDOMDocument_createTextNode(doc
, str
, &nodetext
);
700 ok( r
== S_OK
, "returns %08x\n", r
);
701 SysFreeString( str
);
704 IXMLDOMNamedNodeMap
*pAttribs
;
706 r
= IXMLDOMText_QueryInterface(nodetext
, &IID_IXMLDOMElement
, (LPVOID
*)&element
);
707 ok(r
== E_NOINTERFACE
, "ret %08x\n", r
);
709 /* Text Last Child Checks */
710 r
= IXMLDOMText_get_lastChild(nodetext
, NULL
);
711 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
713 nodeChild
= (IXMLDOMNode
*)0x1;
714 r
= IXMLDOMText_get_lastChild(nodetext
, &nodeChild
);
715 ok(r
== S_FALSE
, "ret %08x\n", r
);
716 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
718 /* test get_attributes */
719 r
= IXMLDOMText_get_attributes( nodetext
, NULL
);
720 ok( r
== E_INVALIDARG
, "get_attributes returned wrong code\n");
722 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
723 r
= IXMLDOMText_get_attributes( nodetext
, &pAttribs
);
724 ok(r
== S_FALSE
, "ret %08x\n", r
);
725 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
727 /* test get_dataType */
728 r
= IXMLDOMText_get_dataType(nodetext
, &var
);
729 ok(r
== S_FALSE
, "ret %08x\n", r
);
730 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
733 /* test length property */
734 r
= IXMLDOMText_get_length(nodetext
, NULL
);
735 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
737 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
738 ok(r
== S_OK
, "ret %08x\n", r
);
739 ok(nLength
== 4, "expected 4 got %d\n", nLength
);
741 /* test nodeTypeString */
742 r
= IXMLDOMText_get_nodeTypeString(nodetext
, &str
);
743 ok(r
== S_OK
, "ret %08x\n", r
);
744 ok( !lstrcmpW( str
, _bstr_("text") ), "incorrect nodeTypeString string\n");
748 r
= IXMLDOMText_put_data(nodetext
, _bstr_("This &is a ; test <>\\"));
749 ok(r
== S_OK
, "ret %08x\n", r
);
752 r
= IXMLDOMText_get_data(nodetext
, &str
);
753 ok(r
== S_OK
, "ret %08x\n", r
);
754 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
757 /* Confirm XML text is good */
758 r
= IXMLDOMText_get_xml(nodetext
, &str
);
759 ok(r
== S_OK
, "ret %08x\n", r
);
760 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
763 /* Confirm we get the put_data Text back */
764 r
= IXMLDOMText_get_text(nodetext
, &str
);
765 ok(r
== S_OK
, "ret %08x\n", r
);
766 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
769 /* test substringData */
770 r
= IXMLDOMText_substringData(nodetext
, 0, 4, NULL
);
771 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
773 /* test substringData - Invalid offset */
774 str
= (BSTR
)&szElement
;
775 r
= IXMLDOMText_substringData(nodetext
, -1, 4, &str
);
776 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
777 ok( str
== NULL
, "incorrect string\n");
779 /* test substringData - Invalid offset */
780 str
= (BSTR
)&szElement
;
781 r
= IXMLDOMText_substringData(nodetext
, 30, 0, &str
);
782 ok(r
== S_FALSE
, "ret %08x\n", r
);
783 ok( str
== NULL
, "incorrect string\n");
785 /* test substringData - Invalid size */
786 str
= (BSTR
)&szElement
;
787 r
= IXMLDOMText_substringData(nodetext
, 0, -1, &str
);
788 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
789 ok( str
== NULL
, "incorrect string\n");
791 /* test substringData - Invalid size */
792 str
= (BSTR
)&szElement
;
793 r
= IXMLDOMText_substringData(nodetext
, 2, 0, &str
);
794 ok(r
== S_FALSE
, "ret %08x\n", r
);
795 ok( str
== NULL
, "incorrect string\n");
797 /* test substringData - Start of string */
798 r
= IXMLDOMText_substringData(nodetext
, 0, 4, &str
);
799 ok(r
== S_OK
, "ret %08x\n", r
);
800 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
803 /* test substringData - Middle of string */
804 r
= IXMLDOMText_substringData(nodetext
, 13, 4, &str
);
805 ok(r
== S_OK
, "ret %08x\n", r
);
806 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
809 /* test substringData - End of string */
810 r
= IXMLDOMText_substringData(nodetext
, 20, 4, &str
);
811 ok(r
== S_OK
, "ret %08x\n", r
);
812 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
815 /* test appendData */
816 r
= IXMLDOMText_appendData(nodetext
, NULL
);
817 ok(r
== S_OK
, "ret %08x\n", r
);
819 r
= IXMLDOMText_appendData(nodetext
, _bstr_(""));
820 ok(r
== S_OK
, "ret %08x\n", r
);
822 r
= IXMLDOMText_appendData(nodetext
, _bstr_("Append"));
823 ok(r
== S_OK
, "ret %08x\n", r
);
825 r
= IXMLDOMText_get_text(nodetext
, &str
);
826 ok(r
== S_OK
, "ret %08x\n", r
);
827 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
830 /* test insertData */
831 str
= SysAllocStringLen(NULL
, 0);
832 r
= IXMLDOMText_insertData(nodetext
, -1, str
);
833 ok(r
== S_OK
, "ret %08x\n", r
);
835 r
= IXMLDOMText_insertData(nodetext
, -1, NULL
);
836 ok(r
== S_OK
, "ret %08x\n", r
);
838 r
= IXMLDOMText_insertData(nodetext
, 1000, str
);
839 ok(r
== S_OK
, "ret %08x\n", r
);
841 r
= IXMLDOMText_insertData(nodetext
, 1000, NULL
);
842 ok(r
== S_OK
, "ret %08x\n", r
);
844 r
= IXMLDOMText_insertData(nodetext
, 0, NULL
);
845 ok(r
== S_OK
, "ret %08x\n", r
);
847 r
= IXMLDOMText_insertData(nodetext
, 0, str
);
848 ok(r
== S_OK
, "ret %08x\n", r
);
851 r
= IXMLDOMText_insertData(nodetext
, -1, _bstr_("Inserting"));
852 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
854 r
= IXMLDOMText_insertData(nodetext
, 1000, _bstr_("Inserting"));
855 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
857 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("Begin "));
858 ok(r
== S_OK
, "ret %08x\n", r
);
860 r
= IXMLDOMText_insertData(nodetext
, 17, _bstr_("Middle"));
861 ok(r
== S_OK
, "ret %08x\n", r
);
863 r
= IXMLDOMText_insertData(nodetext
, 39, _bstr_(" End"));
864 ok(r
== S_OK
, "ret %08x\n", r
);
866 r
= IXMLDOMText_get_text(nodetext
, &str
);
867 ok(r
== S_OK
, "ret %08x\n", r
);
868 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
872 V_VT(&var
) = VT_BSTR
;
873 V_BSTR(&var
) = SysAllocString(szstr1
);
874 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
875 ok(r
== S_OK
, "ret %08x\n", r
);
878 r
= IXMLDOMText_get_text(nodetext
, &str
);
879 ok(r
== S_OK
, "ret %08x\n", r
);
880 ok( !lstrcmpW( str
, szstr1
), "incorrect get_text string\n");
886 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
887 ok(r
== S_OK
, "ret %08x\n", r
);
890 r
= IXMLDOMText_get_text(nodetext
, &str
);
891 ok(r
== S_OK
, "ret %08x\n", r
);
892 ok( !lstrcmpW( str
, _bstr_("99") ), "incorrect get_text string\n");
895 IXMLDOMText_Release( nodetext
);
898 /* test Create Comment */
899 r
= IXMLDOMDocument_createComment(doc
, NULL
, NULL
);
900 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
901 r
= IXMLDOMDocument_createComment(doc
, szComment
, &node_comment
);
902 ok( r
== S_OK
, "returns %08x\n", r
);
905 /* Last Child Checks */
906 r
= IXMLDOMComment_get_lastChild(node_comment
, NULL
);
907 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
909 nodeChild
= (IXMLDOMNode
*)0x1;
910 r
= IXMLDOMComment_get_lastChild(node_comment
, &nodeChild
);
911 ok(r
== S_FALSE
, "ret %08x\n", r
);
912 ok(nodeChild
== NULL
, "pLastChild not NULL\n");
914 IXMLDOMComment_Release( node_comment
);
917 /* test Create Attribute */
918 r
= IXMLDOMDocument_createAttribute(doc
, NULL
, NULL
);
919 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
920 r
= IXMLDOMDocument_createAttribute(doc
, szAttribute
, &node_attr
);
921 ok( r
== S_OK
, "returns %08x\n", r
);
922 IXMLDOMText_Release( node_attr
);
924 /* test Processing Instruction */
925 str
= SysAllocStringLen(NULL
, 0);
926 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, NULL
);
927 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
928 r
= IXMLDOMDocument_createProcessingInstruction(doc
, NULL
, str
, &nodePI
);
929 ok( r
== E_FAIL
, "returns %08x\n", r
);
930 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, &nodePI
);
931 ok( r
== E_FAIL
, "returns %08x\n", r
);
934 r
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI
);
935 ok( r
== S_OK
, "returns %08x\n", r
);
938 /* Last Child Checks */
939 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, NULL
);
940 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
942 nodeChild
= (IXMLDOMNode
*)0x1;
943 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, &nodeChild
);
944 ok(r
== S_FALSE
, "ret %08x\n", r
);
945 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
947 r
= IXMLDOMProcessingInstruction_get_dataType(nodePI
, &var
);
948 ok(r
== S_FALSE
, "ret %08x\n", r
);
949 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
953 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
954 ok(r
== S_OK
, "ret %08x\n", r
);
955 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
959 r
= IXMLDOMProcessingInstruction_get_target(nodePI
, &str
);
960 ok(r
== S_OK
, "ret %08x\n", r
);
961 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect target string\n");
964 /* test nodeTypeString */
965 r
= IXMLDOMProcessingInstruction_get_nodeTypeString(nodePI
, &str
);
966 ok(r
== S_OK
, "ret %08x\n", r
);
967 ok( !lstrcmpW( str
, _bstr_("processinginstruction") ), "incorrect nodeTypeString string\n");
970 /* test get_nodeValue */
971 r
= IXMLDOMProcessingInstruction_get_nodeValue(nodePI
, &var
);
972 ok(r
== S_OK
, "ret %08x\n", r
);
973 ok( !lstrcmpW( V_BSTR(&var
), _bstr_("version=\"1.0\"") ), "incorrect data string\n");
977 r
= IXMLDOMProcessingInstruction_get_data(nodePI
, &str
);
978 ok(r
== S_OK
, "ret %08x\n", r
);
979 ok( !lstrcmpW( str
, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
983 r
= IXMLDOMProcessingInstruction_put_data(nodePI
, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
984 ok(r
== E_FAIL
, "ret %08x\n", r
);
987 V_VT(&var
) = VT_BSTR
;
988 V_BSTR(&var
) = SysAllocString(szOpen
); /* Doesn't matter what the string is, cannot set an xml node. */
989 r
= IXMLDOMProcessingInstruction_put_nodeValue(nodePI
, var
);
990 ok(r
== E_FAIL
, "ret %08x\n", r
);
993 /* test get nodeName */
994 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
995 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
996 ok(r
== S_OK
, "ret %08x\n", r
);
999 IXMLDOMProcessingInstruction_Release(nodePI
);
1002 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_ISupportErrorInfo
, (LPVOID
*)&support_error
);
1003 ok( r
== S_OK
, "ret %08x\n", r
);
1006 r
= ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error
, &IID_IXMLDOMDocument
);
1007 todo_wine
ok( r
== S_OK
, "ret %08x\n", r
);
1008 ISupportErrorInfo_Release( support_error
);
1011 r
= IXMLDOMDocument_Release( doc
);
1012 ok( r
== 0, "document ref count incorrect\n");
1017 static void test_domnode( void )
1020 IXMLDOMDocument
*doc
= NULL
, *owner
= NULL
;
1021 IXMLDOMElement
*element
= NULL
;
1022 IXMLDOMNamedNodeMap
*map
= NULL
;
1023 IXMLDOMNode
*node
= NULL
, *next
= NULL
;
1024 IXMLDOMNodeList
*list
= NULL
;
1025 IXMLDOMAttribute
*attr
= NULL
;
1026 DOMNodeType type
= NODE_INVALID
;
1032 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1033 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1037 ok( FALSE
, "no document\n");
1042 str
= SysAllocString( szComplete4
);
1043 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1044 ok( r
== S_OK
, "loadXML failed\n");
1045 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1046 SysFreeString( str
);
1049 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
1050 ok( r
== S_OK
, "hasChildNoes bad return\n");
1051 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1053 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1054 ok( r
== S_OK
, "should be a document element\n");
1055 ok( element
!= NULL
, "should be an element\n");
1058 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
1060 r
= IXMLDOMNode_get_nodeValue( doc
, NULL
);
1061 ok(r
== E_INVALIDARG
, "get_nodeValue ret %08x\n", r
);
1063 r
= IXMLDOMNode_get_nodeValue( doc
, &var
);
1064 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
1065 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
1066 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
1071 r
= IXMLDOMNode_get_ownerDocument( element
, &owner
);
1072 ok( r
== S_OK
, "get_ownerDocument return code\n");
1073 ok( owner
!= doc
, "get_ownerDocument return\n");
1074 IXMLDOMDocument_Release(owner
);
1076 type
= NODE_INVALID
;
1077 r
= IXMLDOMNode_get_nodeType( element
, &type
);
1078 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1079 ok( type
== NODE_ELEMENT
, "node not an element\n");
1082 r
= IXMLDOMNode_get_baseName( element
, &str
);
1083 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1084 ok( lstrcmpW(str
,szlc
) == 0, "basename was wrong\n");
1087 /* check if nodename is correct */
1088 r
= IXMLDOMElement_get_nodeName( element
, NULL
);
1089 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1091 /* content doesn't matter here */
1093 r
= IXMLDOMElement_get_nodeName( element
, &str
);
1094 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1095 ok ( str
!= NULL
, "str is null\n");
1096 ok( !lstrcmpW( str
, szlc
), "incorrect nodeName\n");
1097 SysFreeString( str
);
1099 str
= SysAllocString( szNonExistentFile
);
1101 V_I4(&var
) = 0x1234;
1102 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1103 ok( r
== E_FAIL
, "getAttribute ret %08x\n", r
);
1104 ok( V_VT(&var
) == VT_NULL
|| V_VT(&var
) == VT_EMPTY
, "vt = %x\n", V_VT(&var
));
1107 r
= IXMLDOMElement_getAttributeNode( element
, str
, NULL
);
1108 ok( r
== E_FAIL
, "getAttributeNode ret %08x\n", r
);
1110 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
1111 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1112 ok( r
== E_FAIL
, "getAttributeNode ret %08x\n", r
);
1113 ok( attr
== NULL
, "getAttributeNode ret %p, expected NULL\n", attr
);
1114 SysFreeString( str
);
1116 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
1117 str
= SysAllocString( szNonExistentAttribute
);
1118 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1119 ok( r
== S_FALSE
, "getAttributeNode ret %08x\n", r
);
1120 ok( attr
== NULL
, "getAttributeNode ret %p, expected NULL\n", attr
);
1121 SysFreeString( str
);
1123 str
= SysAllocString( szdl
);
1125 V_I4(&var
) = 0x1234;
1126 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1127 ok( r
== S_OK
, "getAttribute ret %08x\n", r
);
1128 ok( V_VT(&var
) == VT_BSTR
, "vt = %x\n", V_VT(&var
));
1129 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "wrong attr value\n");
1130 VariantClear( &var
);
1132 r
= IXMLDOMElement_getAttribute( element
, NULL
, &var
);
1133 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1135 r
= IXMLDOMElement_getAttribute( element
, str
, NULL
);
1136 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1139 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1140 ok( r
== S_OK
, "GetAttributeNode ret %08x\n", r
);
1141 ok( attr
!= NULL
, "getAttributeNode returned NULL\n" );
1143 IXMLDOMAttribute_Release(attr
);
1145 SysFreeString( str
);
1147 r
= IXMLDOMElement_get_attributes( element
, &map
);
1148 ok( r
== S_OK
, "get_attributes returned wrong code\n");
1149 ok( map
!= NULL
, "should be attributes\n");
1152 r
= IXMLDOMNode_hasChildNodes( element
, &b
);
1153 ok( r
== S_OK
, "hasChildNoes bad return\n");
1154 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1157 ok( FALSE
, "no element\n");
1161 ISupportErrorInfo
*support_error
;
1162 r
= IXMLDOMNamedNodeMap_QueryInterface( map
, &IID_ISupportErrorInfo
, (LPVOID
*)&support_error
);
1163 ok( r
== S_OK
, "ret %08x\n", r
);
1165 r
= ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error
, &IID_IXMLDOMNamedNodeMap
);
1168 ok( r
== S_OK
, "ret %08x\n", r
);
1170 ISupportErrorInfo_Release( support_error
);
1172 str
= SysAllocString( szdl
);
1173 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
1174 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1175 ok( node
!= NULL
, "should be attributes\n");
1176 IXMLDOMNode_Release(node
);
1177 SysFreeString( str
);
1179 str
= SysAllocString( szdl
);
1180 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, NULL
);
1181 ok( r
== E_INVALIDARG
, "getNamedItem should return E_INVALIDARG\n");
1182 SysFreeString( str
);
1184 /* something that isn't in szComplete4 */
1185 str
= SysAllocString( szOpen
);
1186 node
= (IXMLDOMNode
*) 1;
1187 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
1188 ok( r
== S_FALSE
, "getNamedItem found a node that wasn't there\n");
1189 ok( node
== NULL
, "getNamedItem should have returned NULL\n");
1190 SysFreeString( str
);
1192 /* test indexed access of attributes */
1193 r
= IXMLDOMNamedNodeMap_get_length( map
, NULL
);
1194 ok ( r
== E_INVALIDARG
, "get_length should return E_INVALIDARG\n");
1196 r
= IXMLDOMNamedNodeMap_get_length( map
, &count
);
1197 ok ( r
== S_OK
, "get_length wrong code\n");
1198 ok ( count
== 1, "get_length != 1\n");
1201 r
= IXMLDOMNamedNodeMap_get_item( map
, -1, &node
);
1202 ok ( r
== S_FALSE
, "get_item (-1) wrong code\n");
1203 ok ( node
== NULL
, "there is no node\n");
1206 r
= IXMLDOMNamedNodeMap_get_item( map
, 1, &node
);
1207 ok ( r
== S_FALSE
, "get_item (1) wrong code\n");
1208 ok ( node
== NULL
, "there is no attribute\n");
1211 r
= IXMLDOMNamedNodeMap_get_item( map
, 0, &node
);
1212 ok ( r
== S_OK
, "get_item (0) wrong code\n");
1213 ok ( node
!= NULL
, "should be attribute\n");
1215 r
= IXMLDOMNode_get_nodeName( node
, NULL
);
1216 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1218 /* content doesn't matter here */
1220 r
= IXMLDOMNode_get_nodeName( node
, &str
);
1221 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1222 ok ( str
!= NULL
, "str is null\n");
1223 ok( !lstrcmpW( str
, szdl
), "incorrect node name\n");
1224 SysFreeString( str
);
1226 /* test sequential access of attributes */
1228 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1229 ok ( r
== S_OK
, "nextNode (first time) wrong code\n");
1230 ok ( node
!= NULL
, "nextNode, should be attribute\n");
1232 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1233 ok ( r
!= S_OK
, "nextNode (second time) wrong code\n");
1234 ok ( node
== NULL
, "nextNode, there is no attribute\n");
1236 r
= IXMLDOMNamedNodeMap_reset( map
);
1237 ok ( r
== S_OK
, "reset should return S_OK\n");
1239 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1240 ok ( r
== S_OK
, "nextNode (third time) wrong code\n");
1241 ok ( node
!= NULL
, "nextNode, should be attribute\n");
1244 ok( FALSE
, "no map\n");
1248 type
= NODE_INVALID
;
1249 r
= IXMLDOMNode_get_nodeType( node
, &type
);
1250 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1251 ok( type
== NODE_ATTRIBUTE
, "node not an attribute\n");
1254 r
= IXMLDOMNode_get_baseName( node
, NULL
);
1255 ok( r
== E_INVALIDARG
, "get_baseName returned wrong code\n");
1258 r
= IXMLDOMNode_get_baseName( node
, &str
);
1259 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1260 ok( lstrcmpW(str
,szdl
) == 0, "basename was wrong\n");
1261 SysFreeString( str
);
1263 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
1264 ok( r
== S_OK
, "returns %08x\n", r
);
1265 ok( V_VT(&var
) == VT_BSTR
, "vt %x\n", V_VT(&var
));
1266 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "nodeValue incorrect\n");
1269 r
= IXMLDOMNode_get_childNodes( node
, NULL
);
1270 ok( r
== E_INVALIDARG
, "get_childNodes returned wrong code\n");
1272 r
= IXMLDOMNode_get_childNodes( node
, &list
);
1273 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
1277 r
= IXMLDOMNodeList_nextNode( list
, &next
);
1278 ok( r
== S_OK
, "nextNode returned wrong code\n");
1281 ok( FALSE
, "no childlist\n");
1286 r
= IXMLDOMNode_hasChildNodes( next
, &b
);
1287 ok( r
== S_FALSE
, "hasChildNoes bad return\n");
1288 ok( b
== VARIANT_FALSE
, "hasChildNoes wrong result\n");
1290 type
= NODE_INVALID
;
1291 r
= IXMLDOMNode_get_nodeType( next
, &type
);
1292 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1293 ok( type
== NODE_TEXT
, "node not text\n");
1296 r
= IXMLDOMNode_get_baseName( next
, &str
);
1297 ok( r
== S_FALSE
, "get_baseName returned wrong code\n");
1298 ok( str
== NULL
, "basename was wrong\n");
1302 ok( FALSE
, "no next\n");
1305 IXMLDOMNode_Release( next
);
1308 IXMLDOMNodeList_Release( list
);
1311 IXMLDOMNode_Release( node
);
1314 ok( FALSE
, "no node\n");
1318 IXMLDOMNamedNodeMap_Release( map
);
1320 /* now traverse the tree from the root element */
1323 r
= IXMLDOMNode_get_childNodes( element
, &list
);
1324 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
1326 /* using get_item for child list doesn't advance the position */
1327 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
1328 expect_node(node
, "E2.E2.D1");
1329 IXMLDOMNode_Release(node
);
1330 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
1331 expect_node(node
, "E1.E2.D1");
1332 IXMLDOMNode_Release(node
);
1333 ole_check(IXMLDOMNodeList_reset(list
));
1335 IXMLDOMNodeList_AddRef(list
);
1336 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
1337 ole_check(IXMLDOMNodeList_reset(list
));
1339 node
= (void*)0xdeadbeef;
1340 r
= IXMLDOMNode_selectSingleNode( element
, szdl
, &node
);
1341 ok( r
== S_FALSE
, "ret %08x\n", r
);
1342 ok( node
== NULL
, "node %p\n", node
);
1343 r
= IXMLDOMNode_selectSingleNode( element
, szbs
, &node
);
1344 ok( r
== S_OK
, "ret %08x\n", r
);
1345 r
= IXMLDOMNode_Release( node
);
1346 ok( r
== 0, "ret %08x\n", r
);
1349 ok( FALSE
, "no element\n");
1353 r
= IXMLDOMNodeList_QueryInterface(list
, &IID_IDispatch
, NULL
);
1354 ok( r
== E_INVALIDARG
|| r
== E_POINTER
, "ret %08x\n", r
);
1356 r
= IXMLDOMNodeList_get_item(list
, 0, NULL
);
1357 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1359 r
= IXMLDOMNodeList_get_length(list
, NULL
);
1360 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1362 r
= IXMLDOMNodeList_get_length( list
, &count
);
1363 ok( r
== S_OK
, "get_length returns %08x\n", r
);
1364 ok( count
== 4, "get_length got %d\n", count
);
1366 r
= IXMLDOMNodeList_nextNode(list
, NULL
);
1367 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1369 r
= IXMLDOMNodeList_nextNode( list
, &node
);
1370 ok( r
== S_OK
, "nextNode returned wrong code\n");
1373 ok( FALSE
, "no list\n");
1377 type
= NODE_INVALID
;
1378 r
= IXMLDOMNode_get_nodeType( node
, &type
);
1379 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1380 ok( type
== NODE_ELEMENT
, "node not text\n");
1383 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
1384 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
1385 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
1386 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
1387 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
1389 r
= IXMLDOMNode_hasChildNodes( node
, NULL
);
1390 ok( r
== E_INVALIDARG
, "hasChildNoes bad return\n");
1393 r
= IXMLDOMNode_hasChildNodes( node
, &b
);
1394 ok( r
== S_OK
, "hasChildNoes bad return\n");
1395 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1398 r
= IXMLDOMNode_get_baseName( node
, &str
);
1399 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1400 ok( lstrcmpW(str
,szbs
) == 0, "basename was wrong\n");
1404 ok( FALSE
, "no node\n");
1407 IXMLDOMNode_Release( node
);
1409 IXMLDOMNodeList_Release( list
);
1411 IXMLDOMElement_Release( element
);
1414 str
= SysAllocString( szComplete5
);
1415 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1416 ok( r
== S_OK
, "loadXML failed\n");
1417 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1418 SysFreeString( str
);
1421 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
1422 ok( r
== S_OK
, "hasChildNoes bad return\n");
1423 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1425 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1426 ok( r
== S_OK
, "should be a document element\n");
1427 ok( element
!= NULL
, "should be an element\n");
1431 static const WCHAR szSSearch
[] = {'S',':','s','e','a','r','c','h',0};
1434 /* check if the tag is correct */
1435 r
= IXMLDOMElement_get_tagName( element
, &tag
);
1436 ok( r
== S_OK
, "couldn't get tag name\n");
1437 ok( tag
!= NULL
, "tag was null\n");
1438 ok( !lstrcmpW( tag
, szSSearch
), "incorrect tag name\n");
1439 SysFreeString( tag
);
1443 IXMLDOMElement_Release( element
);
1444 ok(IXMLDOMDocument_Release( doc
) == 0, "document is not destroyed\n");
1447 static void test_refs(void)
1452 IXMLDOMDocument
*doc
= NULL
;
1453 IXMLDOMElement
*element
= NULL
;
1454 IXMLDOMNode
*node
= NULL
, *node2
;
1455 IXMLDOMNodeList
*node_list
= NULL
;
1457 IUnknown
*unk
, *unk2
;
1459 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1460 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1463 ref
= IXMLDOMDocument_Release(doc
);
1464 ok( ref
== 0, "ref %d\n", ref
);
1466 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1467 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1471 str
= SysAllocString( szComplete4
);
1472 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1473 ok( r
== S_OK
, "loadXML failed\n");
1474 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1475 SysFreeString( str
);
1477 ref
= IXMLDOMDocument_AddRef( doc
);
1478 ok( ref
== 2, "ref %d\n", ref
);
1479 ref
= IXMLDOMDocument_AddRef( doc
);
1480 ok( ref
== 3, "ref %d\n", ref
);
1481 IXMLDOMDocument_Release( doc
);
1482 IXMLDOMDocument_Release( doc
);
1484 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1485 ok( r
== S_OK
, "should be a document element\n");
1486 ok( element
!= NULL
, "should be an element\n");
1488 ref
= IXMLDOMDocument_AddRef( doc
);
1489 ok( ref
== 2, "ref %d\n", ref
);
1490 IXMLDOMDocument_Release( doc
);
1492 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
1493 ok( r
== S_OK
, "rets %08x\n", r
);
1495 ref
= IXMLDOMNodeList_AddRef( node_list
);
1496 ok( ref
== 2, "ref %d\n", ref
);
1497 IXMLDOMNodeList_Release( node_list
);
1499 IXMLDOMNodeList_get_item( node_list
, 0, &node
);
1500 ok( r
== S_OK
, "rets %08x\n", r
);
1502 IXMLDOMNodeList_get_item( node_list
, 0, &node2
);
1503 ok( r
== S_OK
, "rets %08x\n", r
);
1505 ref
= IXMLDOMNode_AddRef( node
);
1506 ok( ref
== 2, "ref %d\n", ref
);
1507 IXMLDOMNode_Release( node
);
1509 ref
= IXMLDOMNode_Release( node
);
1510 ok( ref
== 0, "ref %d\n", ref
);
1511 ref
= IXMLDOMNode_Release( node2
);
1512 ok( ref
== 0, "ref %d\n", ref
);
1514 ref
= IXMLDOMNodeList_Release( node_list
);
1515 ok( ref
== 0, "ref %d\n", ref
);
1517 ok( node
!= node2
, "node %p node2 %p\n", node
, node2
);
1519 ref
= IXMLDOMDocument_Release( doc
);
1520 ok( ref
== 0, "ref %d\n", ref
);
1522 ref
= IXMLDOMElement_AddRef( element
);
1524 ok( ref
== 3, "ref %d\n", ref
);
1526 IXMLDOMElement_Release( element
);
1528 /* IUnknown must be unique however we obtain it */
1529 r
= IXMLDOMElement_QueryInterface( element
, &IID_IUnknown
, (LPVOID
*)&unk
);
1530 ok( r
== S_OK
, "rets %08x\n", r
);
1531 r
= IXMLDOMElement_QueryInterface( element
, &IID_IXMLDOMNode
, (LPVOID
*)&node
);
1532 ok( r
== S_OK
, "rets %08x\n", r
);
1533 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (LPVOID
*)&unk2
);
1534 ok( r
== S_OK
, "rets %08x\n", r
);
1535 ok( unk
== unk2
, "unk %p unk2 %p\n", unk
, unk2
);
1537 IUnknown_Release( unk2
);
1538 IUnknown_Release( unk
);
1539 IXMLDOMNode_Release( node
);
1541 IXMLDOMElement_Release( element
);
1545 static void test_create(void)
1547 static const WCHAR szOne
[] = {'1',0};
1548 static const WCHAR szOneGarbage
[] = {'1','G','a','r','b','a','g','e',0};
1552 IXMLDOMDocument
*doc
;
1553 IXMLDOMElement
*element
;
1554 IXMLDOMNode
*root
, *node
, *child
;
1555 IXMLDOMNamedNodeMap
*attr_map
;
1560 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1561 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1566 V_I1(&var
) = NODE_ELEMENT
;
1567 str
= SysAllocString( szlc
);
1568 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1569 ok( r
== S_OK
, "returns %08x\n", r
);
1570 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
1573 V_R4(&var
) = NODE_ELEMENT
;
1574 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1575 ok( r
== S_OK
, "returns %08x\n", r
);
1576 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
1578 V_VT(&var
) = VT_BSTR
;
1579 V_BSTR(&var
) = SysAllocString( szOne
);
1580 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1581 ok( r
== S_OK
, "returns %08x\n", r
);
1582 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
1585 V_VT(&var
) = VT_BSTR
;
1586 V_BSTR(&var
) = SysAllocString( szOneGarbage
);
1587 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1588 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1589 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
1593 V_I4(&var
) = NODE_ELEMENT
;
1594 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1595 ok( r
== S_OK
, "returns %08x\n", r
);
1596 r
= IXMLDOMDocument_appendChild( doc
, node
, &root
);
1597 ok( r
== S_OK
, "returns %08x\n", r
);
1598 ok( node
== root
, "%p %p\n", node
, root
);
1600 ref
= IXMLDOMNode_AddRef( node
);
1601 ok(ref
== 3, "ref %d\n", ref
);
1602 IXMLDOMNode_Release( node
);
1604 ref
= IXMLDOMNode_Release( node
);
1605 ok(ref
== 1, "ref %d\n", ref
);
1606 SysFreeString( str
);
1609 V_I4(&var
) = NODE_ELEMENT
;
1610 str
= SysAllocString( szbs
);
1611 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1612 ok( r
== S_OK
, "returns %08x\n", r
);
1613 SysFreeString( str
);
1615 ref
= IXMLDOMNode_AddRef( node
);
1616 ok(ref
== 2, "ref = %d\n", ref
);
1617 IXMLDOMNode_Release( node
);
1619 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (LPVOID
*)&unk
);
1620 ok( r
== S_OK
, "returns %08x\n", r
);
1622 ref
= IXMLDOMNode_AddRef( unk
);
1623 ok(ref
== 3, "ref = %d\n", ref
);
1624 IXMLDOMNode_Release( unk
);
1626 V_VT(&var
) = VT_EMPTY
;
1627 r
= IXMLDOMNode_insertBefore( root
, (IXMLDOMNode
*)unk
, var
, &child
);
1628 ok( r
== S_OK
, "returns %08x\n", r
);
1629 ok( unk
== (IUnknown
*)child
, "%p %p\n", unk
, child
);
1630 IXMLDOMNode_Release( child
);
1631 IUnknown_Release( unk
);
1634 V_VT(&var
) = VT_NULL
;
1635 V_DISPATCH(&var
) = (IDispatch
*)node
;
1636 r
= IXMLDOMNode_insertBefore( root
, node
, var
, &child
);
1637 ok( r
== S_OK
, "returns %08x\n", r
);
1638 ok( node
== child
, "%p %p\n", node
, child
);
1639 IXMLDOMNode_Release( child
);
1642 V_VT(&var
) = VT_NULL
;
1643 V_DISPATCH(&var
) = (IDispatch
*)node
;
1644 r
= IXMLDOMNode_insertBefore( root
, node
, var
, NULL
);
1645 ok( r
== S_OK
, "returns %08x\n", r
);
1646 IXMLDOMNode_Release( node
);
1648 r
= IXMLDOMNode_QueryInterface( root
, &IID_IXMLDOMElement
, (LPVOID
*)&element
);
1649 ok( r
== S_OK
, "returns %08x\n", r
);
1651 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
1652 ok( r
== S_OK
, "returns %08x\n", r
);
1653 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
1654 ok( r
== S_OK
, "returns %08x\n", r
);
1655 ok( num
== 0, "num %d\n", num
);
1656 IXMLDOMNamedNodeMap_Release( attr_map
);
1658 V_VT(&var
) = VT_BSTR
;
1659 V_BSTR(&var
) = SysAllocString( szstr1
);
1660 name
= SysAllocString( szdl
);
1661 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
1662 ok( r
== S_OK
, "returns %08x\n", r
);
1663 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
1664 ok( r
== S_OK
, "returns %08x\n", r
);
1665 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
1666 ok( r
== S_OK
, "returns %08x\n", r
);
1667 ok( num
== 1, "num %d\n", num
);
1668 IXMLDOMNamedNodeMap_Release( attr_map
);
1671 V_VT(&var
) = VT_BSTR
;
1672 V_BSTR(&var
) = SysAllocString( szstr2
);
1673 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
1674 ok( r
== S_OK
, "returns %08x\n", r
);
1675 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
1676 ok( r
== S_OK
, "returns %08x\n", r
);
1677 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
1678 ok( r
== S_OK
, "returns %08x\n", r
);
1679 ok( num
== 1, "num %d\n", num
);
1680 IXMLDOMNamedNodeMap_Release( attr_map
);
1682 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
1683 ok( r
== S_OK
, "returns %08x\n", r
);
1684 ok( !lstrcmpW(V_BSTR(&var
), szstr2
), "wrong attr value\n");
1686 SysFreeString(name
);
1688 V_VT(&var
) = VT_BSTR
;
1689 V_BSTR(&var
) = SysAllocString( szstr1
);
1690 name
= SysAllocString( szlc
);
1691 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
1692 ok( r
== S_OK
, "returns %08x\n", r
);
1693 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
1694 ok( r
== S_OK
, "returns %08x\n", r
);
1695 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
1696 ok( r
== S_OK
, "returns %08x\n", r
);
1697 ok( num
== 2, "num %d\n", num
);
1698 IXMLDOMNamedNodeMap_Release( attr_map
);
1700 SysFreeString(name
);
1704 name
= SysAllocString( szbs
);
1705 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
1706 ok( r
== S_OK
, "returns %08x\n", r
);
1708 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
1709 ok( r
== S_OK
, "returns %08x\n", r
);
1710 ok( V_VT(&var
) == VT_BSTR
, "variant type %x\n", V_VT(&var
));
1712 SysFreeString(name
);
1714 /* Create an Attribute */
1716 V_I4(&var
) = NODE_ATTRIBUTE
;
1717 str
= SysAllocString( szAttribute
);
1718 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1719 ok( r
== S_OK
, "returns %08x\n", r
);
1720 ok( node
!= NULL
, "node was null\n");
1725 r
= IXMLDOMNode_get_nodeTypeString(node
, &str
);
1726 ok( r
== S_OK
, "returns %08x\n", r
);
1727 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
1729 IXMLDOMNode_Release( node
);
1732 IXMLDOMElement_Release( element
);
1733 IXMLDOMNode_Release( root
);
1734 IXMLDOMDocument_Release( doc
);
1737 static void test_getElementsByTagName(void)
1742 IXMLDOMDocument
*doc
;
1743 IXMLDOMNodeList
*node_list
;
1746 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1747 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1751 str
= SysAllocString( szComplete4
);
1752 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1753 ok( r
== S_OK
, "loadXML failed\n");
1754 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1755 SysFreeString( str
);
1757 str
= SysAllocString( szstar
);
1758 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
1759 ok( r
== S_OK
, "ret %08x\n", r
);
1760 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1761 ok( r
== S_OK
, "ret %08x\n", r
);
1762 ok( len
== 6, "len %d\n", len
);
1764 test_disp((IUnknown
*)node_list
);
1766 IXMLDOMNodeList_Release( node_list
);
1767 SysFreeString( str
);
1769 str
= SysAllocString( szbs
);
1770 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
1771 ok( r
== S_OK
, "ret %08x\n", r
);
1772 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1773 ok( r
== S_OK
, "ret %08x\n", r
);
1774 ok( len
== 1, "len %d\n", len
);
1775 IXMLDOMNodeList_Release( node_list
);
1776 SysFreeString( str
);
1778 str
= SysAllocString( szdl
);
1779 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
1780 ok( r
== S_OK
, "ret %08x\n", r
);
1781 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1782 ok( r
== S_OK
, "ret %08x\n", r
);
1783 ok( len
== 0, "len %d\n", len
);
1784 IXMLDOMNodeList_Release( node_list
);
1785 SysFreeString( str
);
1787 str
= SysAllocString( szstr1
);
1788 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
1789 ok( r
== S_OK
, "ret %08x\n", r
);
1790 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1791 ok( r
== S_OK
, "ret %08x\n", r
);
1792 ok( len
== 0, "len %d\n", len
);
1793 IXMLDOMNodeList_Release( node_list
);
1794 SysFreeString( str
);
1796 IXMLDOMDocument_Release( doc
);
1799 static void test_get_text(void)
1804 IXMLDOMDocument
*doc
;
1805 IXMLDOMNode
*node
, *node2
, *node3
;
1806 IXMLDOMNode
*nodeRoot
;
1807 IXMLDOMNodeList
*node_list
;
1808 IXMLDOMNamedNodeMap
*node_map
;
1811 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1812 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1816 str
= SysAllocString( szComplete4
);
1817 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1818 ok( r
== S_OK
, "loadXML failed\n");
1819 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1820 SysFreeString( str
);
1822 str
= SysAllocString( szbs
);
1823 r
= IXMLDOMDocument_getElementsByTagName( doc
, str
, &node_list
);
1824 ok( r
== S_OK
, "ret %08x\n", r
);
1827 /* Test to get all child node text. */
1828 r
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (LPVOID
*)&nodeRoot
);
1829 ok( r
== S_OK
, "ret %08x\n", r
);
1832 r
= IXMLDOMNode_get_text( nodeRoot
, &str
);
1833 ok( r
== S_OK
, "ret %08x\n", r
);
1834 ok( compareIgnoreReturnsWhitespace(str
, _bstr_("fn1.txt\n\n fn2.txt \n\nf1\n")), "wrong get_text\n");
1837 IXMLDOMNode_Release(nodeRoot
);
1841 /* this test crashes on win9x */
1842 r
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IDispatch
, NULL
);
1843 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1846 r
= IXMLDOMNodeList_get_length( node_list
, NULL
);
1847 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1849 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1850 ok( r
== S_OK
, "ret %08x\n", r
);
1851 ok( len
== 1, "expect 1 got %d\n", len
);
1853 r
= IXMLDOMNodeList_get_item( node_list
, 0, NULL
);
1854 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1856 r
= IXMLDOMNodeList_nextNode( node_list
, NULL
);
1857 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1859 r
= IXMLDOMNodeList_get_item( node_list
, 0, &node
);
1860 ok( r
== S_OK
, "ret %08x\n", r
);
1861 IXMLDOMNodeList_Release( node_list
);
1863 /* Invalid output parameter*/
1864 r
= IXMLDOMNode_get_text( node
, NULL
);
1865 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1867 r
= IXMLDOMNode_get_text( node
, &str
);
1868 ok( r
== S_OK
, "ret %08x\n", r
);
1869 ok( !memcmp(str
, szfn1_txt
, lstrlenW(szfn1_txt
) ), "wrong string\n" );
1872 r
= IXMLDOMNode_get_attributes( node
, &node_map
);
1873 ok( r
== S_OK
, "ret %08x\n", r
);
1875 str
= SysAllocString( szvr
);
1876 r
= IXMLDOMNamedNodeMap_getNamedItem( node_map
, str
, &node2
);
1877 ok( r
== S_OK
, "ret %08x\n", r
);
1880 r
= IXMLDOMNode_get_text( node2
, &str
);
1881 ok( r
== S_OK
, "ret %08x\n", r
);
1882 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
1885 r
= IXMLDOMNode_get_firstChild( node2
, &node3
);
1886 ok( r
== S_OK
, "ret %08x\n", r
);
1888 r
= IXMLDOMNode_get_text( node3
, &str
);
1889 ok( r
== S_OK
, "ret %08x\n", r
);
1890 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
1894 IXMLDOMNode_Release( node3
);
1895 IXMLDOMNode_Release( node2
);
1896 IXMLDOMNamedNodeMap_Release( node_map
);
1897 IXMLDOMNode_Release( node
);
1898 IXMLDOMDocument_Release( doc
);
1901 static void test_get_childNodes(void)
1906 IXMLDOMDocument
*doc
;
1907 IXMLDOMElement
*element
;
1908 IXMLDOMNode
*node
, *node2
;
1909 IXMLDOMNodeList
*node_list
, *node_list2
;
1912 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1913 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1917 str
= SysAllocString( szComplete4
);
1918 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1919 ok( r
== S_OK
, "loadXML failed\n");
1920 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1921 SysFreeString( str
);
1923 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1924 ok( r
== S_OK
, "ret %08x\n", r
);
1926 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
1927 ok( r
== S_OK
, "ret %08x\n", r
);
1929 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
1930 ok( r
== S_OK
, "ret %08x\n", r
);
1931 ok( len
== 4, "len %d\n", len
);
1933 r
= IXMLDOMNodeList_get_item( node_list
, 2, &node
);
1934 ok( r
== S_OK
, "ret %08x\n", r
);
1936 r
= IXMLDOMNode_get_childNodes( node
, &node_list2
);
1937 ok( r
== S_OK
, "ret %08x\n", r
);
1939 r
= IXMLDOMNodeList_get_length( node_list2
, &len
);
1940 ok( r
== S_OK
, "ret %08x\n", r
);
1941 ok( len
== 0, "len %d\n", len
);
1943 r
= IXMLDOMNodeList_get_item( node_list2
, 0, &node2
);
1944 ok( r
== S_FALSE
, "ret %08x\n", r
);
1946 IXMLDOMNodeList_Release( node_list2
);
1947 IXMLDOMNode_Release( node
);
1948 IXMLDOMNodeList_Release( node_list
);
1949 IXMLDOMElement_Release( element
);
1950 IXMLDOMDocument_Release( doc
);
1953 static void test_removeChild(void)
1958 IXMLDOMDocument
*doc
;
1959 IXMLDOMElement
*element
, *lc_element
;
1960 IXMLDOMNode
*fo_node
, *ba_node
, *removed_node
, *temp_node
, *lc_node
;
1961 IXMLDOMNodeList
*root_list
, *fo_list
;
1963 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1964 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1968 str
= SysAllocString( szComplete4
);
1969 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1970 ok( r
== S_OK
, "loadXML failed\n");
1971 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1972 SysFreeString( str
);
1974 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1975 ok( r
== S_OK
, "ret %08x\n", r
);
1977 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
1978 ok( r
== S_OK
, "ret %08x\n", r
);
1980 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
1981 ok( r
== S_OK
, "ret %08x\n", r
);
1983 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
1984 ok( r
== S_OK
, "ret %08x\n", r
);
1986 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
1987 ok( r
== S_OK
, "ret %08x\n", r
);
1989 /* invalid parameter: NULL ptr */
1990 removed_node
= (void*)0xdeadbeef;
1991 r
= IXMLDOMElement_removeChild( element
, NULL
, &removed_node
);
1992 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1993 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
1995 /* ba_node is a descendant of element, but not a direct child. */
1996 removed_node
= (void*)0xdeadbeef;
1997 r
= IXMLDOMElement_removeChild( element
, ba_node
, &removed_node
);
1998 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1999 ok( removed_node
== NULL
, "%p\n", removed_node
);
2001 r
= IXMLDOMElement_removeChild( element
, fo_node
, &removed_node
);
2002 ok( r
== S_OK
, "ret %08x\n", r
);
2003 ok( fo_node
== removed_node
, "node %p node2 %p\n", fo_node
, removed_node
);
2005 /* try removing already removed child */
2006 temp_node
= (void*)0xdeadbeef;
2007 r
= IXMLDOMElement_removeChild( element
, fo_node
, &temp_node
);
2008 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2009 ok( temp_node
== NULL
, "%p\n", temp_node
);
2011 /* the removed node has no parent anymore */
2012 r
= IXMLDOMNode_get_parentNode( removed_node
, &temp_node
);
2013 ok( r
== S_FALSE
, "ret %08x\n", r
);
2014 ok( temp_node
== NULL
, "%p\n", temp_node
);
2016 IXMLDOMNode_Release( removed_node
);
2017 IXMLDOMNode_Release( ba_node
);
2018 IXMLDOMNodeList_Release( fo_list
);
2020 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
2021 ok( r
== S_OK
, "ret %08x\n", r
);
2023 r
= IXMLDOMElement_QueryInterface( lc_node
, &IID_IXMLDOMElement
, (LPVOID
*)&lc_element
);
2024 ok( r
== S_OK
, "ret %08x\n", r
);
2026 /* MS quirk: passing wrong interface pointer works, too */
2027 r
= IXMLDOMElement_removeChild( element
, (IXMLDOMNode
*)lc_element
, NULL
);
2028 ok( r
== S_OK
, "ret %08x\n", r
);
2030 r
= IXMLDOMNode_get_parentNode( lc_node
, &temp_node
);
2031 ok( r
== S_FALSE
, "ret %08x\n", r
);
2032 ok( temp_node
== NULL
, "%p\n", temp_node
);
2034 IXMLDOMNode_Release( lc_node
);
2035 IXMLDOMNodeList_Release( root_list
);
2036 IXMLDOMElement_Release( element
);
2037 IXMLDOMDocument_Release( doc
);
2040 static void test_replaceChild(void)
2045 IXMLDOMDocument
*doc
;
2046 IXMLDOMElement
*element
, *ba_element
;
2047 IXMLDOMNode
*fo_node
, *ba_node
, *lc_node
, *removed_node
, *temp_node
;
2048 IXMLDOMNodeList
*root_list
, *fo_list
;
2049 IUnknown
* unk1
, *unk2
;
2052 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2053 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2057 str
= SysAllocString( szComplete4
);
2058 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2059 ok( r
== S_OK
, "loadXML failed\n");
2060 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2061 SysFreeString( str
);
2063 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2064 ok( r
== S_OK
, "ret %08x\n", r
);
2066 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
2067 ok( r
== S_OK
, "ret %08x\n", r
);
2069 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
2070 ok( r
== S_OK
, "ret %08x\n", r
);
2072 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
2073 ok( r
== S_OK
, "ret %08x\n", r
);
2075 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
2076 ok( r
== S_OK
, "ret %08x\n", r
);
2078 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
2079 ok( r
== S_OK
, "ret %08x\n", r
);
2081 IXMLDOMNodeList_Release( fo_list
);
2083 /* invalid parameter: NULL ptr for element to remove */
2084 removed_node
= (void*)0xdeadbeef;
2085 r
= IXMLDOMElement_replaceChild( element
, ba_node
, NULL
, &removed_node
);
2086 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2087 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
2089 /* invalid parameter: NULL for replacement element. (Sic!) */
2090 removed_node
= (void*)0xdeadbeef;
2091 r
= IXMLDOMElement_replaceChild( element
, NULL
, fo_node
, &removed_node
);
2092 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2093 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
2095 /* invalid parameter: OldNode is not a child */
2096 removed_node
= (void*)0xdeadbeef;
2097 r
= IXMLDOMElement_replaceChild( element
, lc_node
, ba_node
, &removed_node
);
2098 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2099 ok( removed_node
== NULL
, "%p\n", removed_node
);
2101 /* invalid parameter: would create loop */
2102 removed_node
= (void*)0xdeadbeef;
2103 r
= IXMLDOMNode_replaceChild( fo_node
, fo_node
, ba_node
, &removed_node
);
2104 ok( r
== E_FAIL
, "ret %08x\n", r
);
2105 ok( removed_node
== NULL
, "%p\n", removed_node
);
2107 r
= IXMLDOMElement_replaceChild( element
, ba_node
, fo_node
, NULL
);
2108 ok( r
== S_OK
, "ret %08x\n", r
);
2110 r
= IXMLDOMNodeList_get_item( root_list
, 3, &temp_node
);
2111 ok( r
== S_OK
, "ret %08x\n", r
);
2113 /* ba_node and temp_node refer to the same node, yet they
2114 are different interface pointers */
2115 ok( ba_node
!= temp_node
, "ba_node %p temp_node %p\n", ba_node
, temp_node
);
2116 r
= IXMLDOMNode_QueryInterface( temp_node
, &IID_IUnknown
, (void**)&unk1
);
2117 ok( r
== S_OK
, "ret %08x\n", r
);
2118 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IUnknown
, (void**)&unk2
);
2119 ok( r
== S_OK
, "ret %08x\n", r
);
2120 todo_wine
ok( unk1
== unk2
, "unk1 %p unk2 %p\n", unk1
, unk2
);
2122 IUnknown_Release( unk1
);
2123 IUnknown_Release( unk2
);
2125 /* ba_node should have been removed from below fo_node */
2126 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
2127 ok( r
== S_OK
, "ret %08x\n", r
);
2129 /* MS quirk: replaceChild also accepts elements instead of nodes */
2130 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IXMLDOMElement
, (void**)&ba_element
);
2131 ok( r
== S_OK
, "ret %08x\n", r
);
2133 r
= IXMLDOMElement_replaceChild( element
, ba_node
, (IXMLDOMNode
*)ba_element
, &removed_node
);
2134 ok( r
== S_OK
, "ret %08x\n", r
);
2136 r
= IXMLDOMNodeList_get_length( fo_list
, &len
);
2137 ok( r
== S_OK
, "ret %08x\n", r
);
2138 ok( len
== 0, "len %d\n", len
);
2140 IXMLDOMNodeList_Release( fo_list
);
2142 IXMLDOMNode_Release(ba_node
);
2143 IXMLDOMNode_Release(fo_node
);
2144 IXMLDOMNode_Release(temp_node
);
2145 IXMLDOMNodeList_Release( root_list
);
2146 IXMLDOMElement_Release( element
);
2147 IXMLDOMDocument_Release( doc
);
2150 static void test_removeNamedItem(void)
2152 IXMLDOMDocument
*doc
;
2153 IXMLDOMElement
*element
;
2154 IXMLDOMNode
*pr_node
, *removed_node
, *removed_node2
;
2155 IXMLDOMNodeList
*root_list
;
2156 IXMLDOMNamedNodeMap
* pr_attrs
;
2162 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2163 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2167 str
= SysAllocString( szComplete4
);
2168 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2169 ok( r
== S_OK
, "loadXML failed\n");
2170 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2171 SysFreeString( str
);
2173 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2174 ok( r
== S_OK
, "ret %08x\n", r
);
2176 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
2177 ok( r
== S_OK
, "ret %08x\n", r
);
2179 r
= IXMLDOMNodeList_get_item( root_list
, 1, &pr_node
);
2180 ok( r
== S_OK
, "ret %08x\n", r
);
2182 r
= IXMLDOMNode_get_attributes( pr_node
, &pr_attrs
);
2183 ok( r
== S_OK
, "ret %08x\n", r
);
2185 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2186 ok( r
== S_OK
, "ret %08x\n", r
);
2187 ok( len
== 3, "length %d\n", len
);
2189 removed_node
= (void*)0xdeadbeef;
2190 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, NULL
, &removed_node
);
2191 ok ( r
== E_INVALIDARG
, "ret %08x\n", r
);
2192 ok ( removed_node
== (void*)0xdeadbeef, "removed_node == %p\n", removed_node
);
2194 removed_node
= (void*)0xdeadbeef;
2195 str
= SysAllocString(szvr
);
2196 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node
);
2197 ok ( r
== S_OK
, "ret %08x\n", r
);
2199 removed_node2
= (void*)0xdeadbeef;
2200 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node2
);
2201 ok ( r
== S_FALSE
, "ret %08x\n", r
);
2202 ok ( removed_node2
== NULL
, "removed_node == %p\n", removed_node2
);
2204 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2205 ok( r
== S_OK
, "ret %08x\n", r
);
2206 ok( len
== 2, "length %d\n", len
);
2208 r
= IXMLDOMNamedNodeMap_setNamedItem( pr_attrs
, removed_node
, NULL
);
2209 ok ( r
== S_OK
, "ret %08x\n", r
);
2210 IXMLDOMNode_Release(removed_node
);
2212 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2213 ok( r
== S_OK
, "ret %08x\n", r
);
2214 ok( len
== 3, "length %d\n", len
);
2216 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
2217 ok ( r
== S_OK
, "ret %08x\n", r
);
2219 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2220 ok( r
== S_OK
, "ret %08x\n", r
);
2221 ok( len
== 2, "length %d\n", len
);
2223 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
2224 ok ( r
== S_FALSE
, "ret %08x\n", r
);
2228 IXMLDOMNamedNodeMap_Release( pr_attrs
);
2229 IXMLDOMNode_Release( pr_node
);
2230 IXMLDOMNodeList_Release( root_list
);
2231 IXMLDOMElement_Release( element
);
2232 IXMLDOMDocument_Release( doc
);
2235 static void test_XMLHTTP(void)
2237 static const WCHAR wszBody
[] = {'m','o','d','e','=','T','e','s','t',0};
2238 static WCHAR wszPOST
[] = {'P','O','S','T',0};
2239 static WCHAR wszUrl
[] = {'h','t','t','p',':','/','/',
2240 'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
2241 'p','o','s','t','t','e','s','t','.','p','h','p',0};
2242 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
2243 IXMLHttpRequest
*pXMLHttpRequest
;
2248 HRESULT hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
,
2249 CLSCTX_INPROC_SERVER
, &IID_IXMLHttpRequest
,
2250 (void **)&pXMLHttpRequest
);
2251 ok(hr
== S_OK
, "CoCreateInstance(CLSID_XMLHTTPRequest) should have succeeded instead of failing with 0x%08x\n", hr
);
2255 VariantInit(&dummy
);
2256 V_VT(&dummy
) = VT_ERROR
;
2257 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
2258 VariantInit(&varfalse
);
2259 V_VT(&varfalse
) = VT_BOOL
;
2260 V_BOOL(&varfalse
) = VARIANT_FALSE
;
2261 V_VT(&varbody
) = VT_BSTR
;
2262 V_BSTR(&varbody
) = SysAllocString(wszBody
);
2264 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, wszPOST
, wszUrl
, varfalse
, dummy
, dummy
);
2265 todo_wine
ok(hr
== S_OK
, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr
);
2267 hr
= IXMLHttpRequest_send(pXMLHttpRequest
, varbody
);
2268 todo_wine
ok(hr
== S_OK
, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr
);
2269 VariantClear(&varbody
);
2271 hr
= IXMLHttpRequest_get_responseText(pXMLHttpRequest
, &bstrResponse
);
2272 todo_wine
ok(hr
== S_OK
, "IXMLHttpRequest_get_responseText should have succeeded instead of failing with 0x%08x\n", hr
);
2273 /* the server currently returns "FAILED" because the Content-Type header is
2274 * not what the server expects */
2277 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)), "bstrResponse differs from what was expected\n");
2278 SysFreeString(bstrResponse
);
2281 IXMLHttpRequest_Release(pXMLHttpRequest
);
2284 static void test_IXMLDOMDocument2(void)
2289 IXMLDOMDocument
*doc
;
2290 IXMLDOMDocument2
*doc2
;
2291 IDispatchEx
*dispex
;
2295 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2296 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2300 str
= SysAllocString( szComplete4
);
2301 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2302 ok( r
== S_OK
, "loadXML failed\n");
2303 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2304 SysFreeString( str
);
2306 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IXMLDOMDocument2
, (void**)&doc2
);
2307 ok( r
== S_OK
, "ret %08x\n", r
);
2308 ok( doc
== (IXMLDOMDocument
*)doc2
, "interfaces differ\n");
2310 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IDispatchEx
, (void**)&dispex
);
2311 ok( r
== S_OK
, "ret %08x\n", r
);
2314 IDispatchEx_Release(dispex
);
2317 /* we will check if the variant got cleared */
2318 ref
= IXMLDOMDocument2_AddRef(doc2
);
2319 expect_eq(ref
, 3, int, "%d"); /* doc, doc2, AddRef*/
2320 V_VT(&var
) = VT_UNKNOWN
;
2321 V_UNKNOWN(&var
) = (IUnknown
*)doc2
;
2324 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("askldhfaklsdf"), &var
), E_FAIL
);
2325 expect_eq(V_VT(&var
), VT_UNKNOWN
, int, "%x");
2326 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), NULL
), E_INVALIDARG
);
2329 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
2330 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
2331 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
2334 /* the variant didn't get cleared*/
2335 expect_eq(IXMLDOMDocument2_Release(doc2
), 2, int, "%d");
2337 /* setProperty tests */
2338 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("askldhfaklsdf"), var
), E_FAIL
);
2339 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), var
), E_FAIL
);
2340 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL
);
2341 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
2342 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
2343 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
2345 /* contrary to what MSDN claims you can switch back from XPath to XSLPattern */
2346 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
2347 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
2348 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
2350 IXMLDOMDocument2_Release( doc2
);
2351 IXMLDOMDocument_Release( doc
);
2355 static void test_XPath(void)
2360 IXMLDOMDocument2
*doc
;
2361 IXMLDOMNode
*rootNode
;
2362 IXMLDOMNode
*elem1Node
;
2364 IXMLDOMNodeList
*list
;
2366 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2367 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
2371 ole_check(IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &b
));
2372 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
2374 /* switch to XPath */
2375 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
2377 /* some simple queries*/
2378 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root"), &list
));
2379 ole_check(IXMLDOMNodeList_get_item(list
, 0, &rootNode
));
2380 ole_check(IXMLDOMNodeList_reset(list
));
2381 expect_list_and_release(list
, "E2.D1");
2382 if (rootNode
== NULL
)
2385 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//c"), &list
));
2386 expect_list_and_release(list
, "E3.E1.E2.D1 E3.E2.E2.D1");
2388 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//c[@type]"), &list
));
2389 expect_list_and_release(list
, "E3.E2.E2.D1");
2391 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem"), &list
));
2392 /* using get_item for query results advances the position */
2393 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
2394 expect_node(node
, "E2.E2.D1");
2395 IXMLDOMNode_Release(node
);
2396 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
2397 expect_node(node
, "E4.E2.D1");
2398 IXMLDOMNode_Release(node
);
2399 ole_check(IXMLDOMNodeList_reset(list
));
2400 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
2402 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("."), &list
));
2403 expect_list_and_release(list
, "E2.D1");
2405 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem[3]/preceding-sibling::*"), &list
));
2406 ole_check(IXMLDOMNodeList_get_item(list
, 0, &elem1Node
));
2407 ole_check(IXMLDOMNodeList_reset(list
));
2408 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
2410 /* select an attribute */
2411 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//@type"), &list
));
2412 expect_list_and_release(list
, "A'type'.E3.E2.E2.D1");
2414 /* would evaluate to a number */
2415 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("count(*)"), &list
), E_FAIL
);
2416 /* would evaluate to a boolean */
2417 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("position()>0"), &list
), E_FAIL
);
2418 /* would evaluate to a string */
2419 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("name()"), &list
), E_FAIL
);
2422 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("c"), &list
));
2423 expect_list_and_release(list
, "");
2424 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("elem//c"), &list
));
2425 expect_list_and_release(list
, "");
2426 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//elem[4]"), &list
));
2427 expect_list_and_release(list
, "");
2429 /* foo undeclared in document node */
2430 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
2431 /* undeclared in <root> node */
2432 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//foo:c"), &list
), E_FAIL
);
2433 /* undeclared in <elem> node */
2434 ole_expect(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//foo:c"), &list
), E_FAIL
);
2435 /* but this trick can be used */
2436 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//*[name()='foo:c']"), &list
));
2437 expect_list_and_release(list
, "E3.E4.E2.D1");
2439 /* it has to be declared in SelectionNamespaces */
2440 todo_wine
ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
2441 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
2443 /* now the namespace can be used */
2444 todo_wine
ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//test:c"), &list
));
2445 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
2446 todo_wine
ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//test:c"), &list
));
2447 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
2448 todo_wine
ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//test:c"), &list
));
2449 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
2450 todo_wine
ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_(".//test:x"), &list
));
2451 todo_wine
expect_list_and_release(list
, "E5.E1.E4.E1.E2.D1");
2453 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
2454 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
2455 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL
);
2457 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
2460 todo_wine
ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
2461 todo_wine
expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
2462 if (V_VT(&var
) == VT_BSTR
)
2463 expect_bstr_eq_and_free(V_BSTR(&var
), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
2465 /* extra attributes - same thing*/
2466 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
2467 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL
);
2468 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
2470 IXMLDOMNode_Release(rootNode
);
2471 IXMLDOMNode_Release(elem1Node
);
2472 IXMLDOMDocument_Release(doc
);
2476 static void test_cloneNode(void )
2478 IXMLDOMDocument
*doc
= NULL
;
2480 IXMLDOMNodeList
*pList
;
2481 IXMLDOMNamedNodeMap
*mapAttr
;
2482 LONG nLength
= 0, nLength1
= 0;
2483 LONG nAttrCnt
= 0, nAttrCnt1
= 0;
2485 IXMLDOMNode
*node_clone
;
2486 IXMLDOMNode
*node_first
;
2489 static const WCHAR szSearch
[] = { 'l', 'c', '/', 'p', 'r', 0 };
2491 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
2495 str
= SysAllocString( szComplete4
);
2496 ole_check(IXMLDOMDocument_loadXML(doc
, str
, &b
));
2497 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
2503 str
= SysAllocString( szSearch
);
2504 r
= IXMLDOMNode_selectSingleNode(doc
, str
, &node
);
2505 ok( r
== S_OK
, "ret %08x\n", r
);
2506 ok( node
!= NULL
, "node %p\n", node
);
2511 IXMLDOMDocument_Release(doc
);
2515 /* Check invalid parameter */
2516 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, NULL
);
2517 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2520 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, &node_clone
);
2521 ok( r
== S_OK
, "ret %08x\n", r
);
2522 ok( node_clone
!= NULL
, "node %p\n", node
);
2526 IXMLDOMDocument_Release(doc
);
2527 IXMLDOMNode_Release(node
);
2531 r
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
2532 ok( r
== S_OK
, "ret %08x\n", r
);
2535 IXMLDOMDocument
*doc2
;
2537 r
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
2538 ok( r
== S_OK
, "ret %08x\n", r
);
2540 IXMLDOMDocument_Release(doc2
);
2542 IXMLDOMNode_Release(node_first
);
2545 r
= IXMLDOMNode_get_childNodes(node
, &pList
);
2546 ok( r
== S_OK
, "ret %08x\n", r
);
2549 IXMLDOMNodeList_get_length(pList
, &nLength
);
2550 IXMLDOMNodeList_Release(pList
);
2553 r
= IXMLDOMNode_get_attributes(node
, &mapAttr
);
2554 ok( r
== S_OK
, "ret %08x\n", r
);
2557 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt
);
2558 IXMLDOMNamedNodeMap_Release(mapAttr
);
2561 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
2562 ok( r
== S_OK
, "ret %08x\n", r
);
2565 IXMLDOMNodeList_get_length(pList
, &nLength1
);
2566 IXMLDOMNodeList_Release(pList
);
2569 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
2570 ok( r
== S_OK
, "ret %08x\n", r
);
2573 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
2574 IXMLDOMNamedNodeMap_Release(mapAttr
);
2577 ok(nLength
== nLength1
, "wrong Child count (%d, %d)\n", nLength
, nLength1
);
2578 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%d, %d)\n", nAttrCnt
, nAttrCnt1
);
2579 IXMLDOMNode_Release(node_clone
);
2582 r
= IXMLDOMNode_cloneNode(node
, VARIANT_FALSE
, &node_clone
);
2583 ok( r
== S_OK
, "ret %08x\n", r
);
2584 ok( node_clone
!= NULL
, "node %p\n", node
);
2588 IXMLDOMDocument_Release(doc
);
2589 IXMLDOMNode_Release(node
);
2593 r
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
2594 ok( r
== S_FALSE
, "ret %08x\n", r
);
2597 IXMLDOMDocument
*doc2
;
2599 r
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
2600 ok( r
== S_OK
, "ret %08x\n", r
);
2602 IXMLDOMDocument_Release(doc2
);
2604 IXMLDOMNode_Release(node_first
);
2607 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
2608 ok( r
== S_OK
, "ret %08x\n", r
);
2611 IXMLDOMNodeList_get_length(pList
, &nLength1
);
2612 ok( nLength1
== 0, "Length should be 0 (%d)\n", nLength1
);
2613 IXMLDOMNodeList_Release(pList
);
2616 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
2617 ok( r
== S_OK
, "ret %08x\n", r
);
2620 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
2621 ok( nAttrCnt1
== 3, "Attribute count should be 3 (%d)\n", nAttrCnt1
);
2622 IXMLDOMNamedNodeMap_Release(mapAttr
);
2625 ok(nLength
!= nLength1
, "wrong Child count (%d, %d)\n", nLength
, nLength1
);
2626 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%d, %d)\n", nAttrCnt
, nAttrCnt1
);
2627 IXMLDOMNode_Release(node_clone
);
2630 IXMLDOMNode_Release(node
);
2631 IXMLDOMDocument_Release(doc
);
2634 static void test_xmlTypes(void)
2636 IXMLDOMDocument
*doc
= NULL
;
2637 IXMLDOMElement
*pRoot
;
2639 IXMLDOMComment
*pComment
;
2640 IXMLDOMElement
*pElement
;
2641 IXMLDOMAttribute
*pAttrubute
;
2642 IXMLDOMNamedNodeMap
*pAttribs
;
2643 IXMLDOMCDATASection
*pCDataSec
;
2644 IXMLDOMImplementation
*pIXMLDOMImplementation
= NULL
;
2645 IXMLDOMDocumentFragment
*pDocFrag
= NULL
;
2646 IXMLDOMEntityReference
*pEntityRef
= NULL
;
2648 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1; /* Used for testing Siblings */
2652 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
2656 hr
= IXMLDOMDocument_get_nextSibling(doc
, NULL
);
2657 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2659 hr
= IXMLDOMDocument_get_nextSibling(doc
, &pNextChild
);
2660 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2661 ok(pNextChild
== NULL
, "pDocChild not NULL\n");
2663 /* test previous Sibling */
2664 hr
= IXMLDOMDocument_get_previousSibling(doc
, NULL
);
2665 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2667 pNextChild
= (IXMLDOMNode
*)0x1;
2668 hr
= IXMLDOMDocument_get_previousSibling(doc
, &pNextChild
);
2669 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2670 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
2672 /* test get_attributes */
2673 hr
= IXMLDOMDocument_get_attributes( doc
, NULL
);
2674 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
2676 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
2677 hr
= IXMLDOMDocument_get_attributes( doc
, &pAttribs
);
2678 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2679 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
2681 /* test get_dataType */
2682 hr
= IXMLDOMDocument_get_dataType(doc
, &v
);
2683 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2684 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
2687 /* test nodeTypeString */
2688 hr
= IXMLDOMDocument_get_nodeTypeString(doc
, &str
);
2689 ok(hr
== S_OK
, "ret %08x\n", hr
);
2690 ok( !lstrcmpW( str
, _bstr_("document") ), "incorrect nodeTypeString string\n");
2693 /* test implementation */
2694 hr
= IXMLDOMDocument_get_implementation(doc
, NULL
);
2695 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2697 hr
= IXMLDOMDocument_get_implementation(doc
, &pIXMLDOMImplementation
);
2698 ok(hr
== S_OK
, "ret %08x\n", hr
);
2701 VARIANT_BOOL hasFeature
= VARIANT_TRUE
;
2702 BSTR sEmpty
= SysAllocStringLen(NULL
, 0);
2704 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, NULL
, sEmpty
, &hasFeature
);
2705 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2707 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, NULL
);
2708 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2710 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
2711 ok(hr
== S_OK
, "ret %08x\n", hr
);
2712 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
2714 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, &hasFeature
);
2715 ok(hr
== S_OK
, "ret %08x\n", hr
);
2716 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned true\n");
2718 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), NULL
, &hasFeature
);
2719 ok(hr
== S_OK
, "ret %08x\n", hr
);
2720 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned false\n");
2722 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
2723 ok(hr
== S_OK
, "ret %08x\n", hr
);
2724 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
2726 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), _bstr_("1.0"), &hasFeature
);
2727 ok(hr
== S_OK
, "ret %08x\n", hr
);
2728 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
2730 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("XML"), _bstr_("1.0"), &hasFeature
);
2731 ok(hr
== S_OK
, "ret %08x\n", hr
);
2732 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
2734 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature
);
2735 ok(hr
== S_OK
, "ret %08x\n", hr
);
2736 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
2738 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("SSS"), NULL
, &hasFeature
);
2739 ok(hr
== S_OK
, "ret %08x\n", hr
);
2740 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
2742 SysFreeString(sEmpty
);
2743 IXMLDOMImplementation_Release(pIXMLDOMImplementation
);
2748 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
2749 ok(hr
== S_OK
, "ret %08x\n", hr
);
2752 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
2753 ok(hr
== S_OK
, "ret %08x\n", hr
);
2757 hr
= IXMLDOMDocument_createComment(doc
, szComment
, &pComment
);
2758 ok(hr
== S_OK
, "ret %08x\n", hr
);
2761 /* test get_attributes */
2762 hr
= IXMLDOMComment_get_attributes( pComment
, NULL
);
2763 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
2765 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
2766 hr
= IXMLDOMComment_get_attributes( pComment
, &pAttribs
);
2767 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2768 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
2770 /* test nodeTypeString */
2771 hr
= IXMLDOMComment_get_nodeTypeString(pComment
, &str
);
2772 ok(hr
== S_OK
, "ret %08x\n", hr
);
2773 ok( !lstrcmpW( str
, _bstr_("comment") ), "incorrect nodeTypeString string\n");
2776 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pComment
, NULL
);
2777 ok(hr
== S_OK
, "ret %08x\n", hr
);
2779 hr
= IXMLDOMComment_get_nodeName(pComment
, &str
);
2780 ok(hr
== S_OK
, "ret %08x\n", hr
);
2781 ok( !lstrcmpW( str
, szCommentNodeText
), "incorrect comment node Name\n");
2784 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
2785 ok(hr
== S_OK
, "ret %08x\n", hr
);
2786 ok( !lstrcmpW( str
, szCommentXML
), "incorrect comment xml\n");
2789 hr
= IXMLDOMComment_get_dataType(pComment
, &v
);
2790 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2791 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
2794 /* put data Tests */
2795 hr
= IXMLDOMComment_put_data(pComment
, _bstr_("This &is a ; test <>\\"));
2796 ok(hr
== S_OK
, "ret %08x\n", hr
);
2798 /* get data Tests */
2799 hr
= IXMLDOMComment_get_data(pComment
, &str
);
2800 ok(hr
== S_OK
, "ret %08x\n", hr
);
2801 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
2804 /* get data Tests */
2805 hr
= IXMLDOMComment_get_nodeValue(pComment
, &v
);
2806 ok(hr
== S_OK
, "ret %08x\n", hr
);
2807 ok( V_VT(&v
) == VT_BSTR
, "incorrect dataType type\n");
2808 ok( !lstrcmpW( V_BSTR(&v
), _bstr_("This &is a ; test <>\\") ), "incorrect get_nodeValue string\n");
2811 /* Confirm XML text is good */
2812 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
2813 ok(hr
== S_OK
, "ret %08x\n", hr
);
2814 ok( !lstrcmpW( str
, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
2817 /* Confirm we get the put_data Text back */
2818 hr
= IXMLDOMComment_get_text(pComment
, &str
);
2819 ok(hr
== S_OK
, "ret %08x\n", hr
);
2820 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
2823 /* test length property */
2824 hr
= IXMLDOMComment_get_length(pComment
, &len
);
2825 ok(hr
== S_OK
, "ret %08x\n", hr
);
2826 ok(len
== 21, "expected 21 got %d\n", len
);
2828 /* test substringData */
2829 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, NULL
);
2830 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2832 /* test substringData - Invalid offset */
2833 str
= (BSTR
)&szElement
;
2834 hr
= IXMLDOMComment_substringData(pComment
, -1, 4, &str
);
2835 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2836 ok( str
== NULL
, "incorrect string\n");
2838 /* test substringData - Invalid offset */
2839 str
= (BSTR
)&szElement
;
2840 hr
= IXMLDOMComment_substringData(pComment
, 30, 0, &str
);
2841 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2842 ok( str
== NULL
, "incorrect string\n");
2844 /* test substringData - Invalid size */
2845 str
= (BSTR
)&szElement
;
2846 hr
= IXMLDOMComment_substringData(pComment
, 0, -1, &str
);
2847 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2848 ok( str
== NULL
, "incorrect string\n");
2850 /* test substringData - Invalid size */
2851 str
= (BSTR
)&szElement
;
2852 hr
= IXMLDOMComment_substringData(pComment
, 2, 0, &str
);
2853 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
2854 ok( str
== NULL
, "incorrect string\n");
2856 /* test substringData - Start of string */
2857 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, &str
);
2858 ok(hr
== S_OK
, "ret %08x\n", hr
);
2859 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
2862 /* test substringData - Middle of string */
2863 hr
= IXMLDOMComment_substringData(pComment
, 13, 4, &str
);
2864 ok(hr
== S_OK
, "ret %08x\n", hr
);
2865 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
2868 /* test substringData - End of string */
2869 hr
= IXMLDOMComment_substringData(pComment
, 20, 4, &str
);
2870 ok(hr
== S_OK
, "ret %08x\n", hr
);
2871 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
2874 /* test appendData */
2875 hr
= IXMLDOMComment_appendData(pComment
, NULL
);
2876 ok(hr
== S_OK
, "ret %08x\n", hr
);
2878 hr
= IXMLDOMComment_appendData(pComment
, _bstr_(""));
2879 ok(hr
== S_OK
, "ret %08x\n", hr
);
2881 hr
= IXMLDOMComment_appendData(pComment
, _bstr_("Append"));
2882 ok(hr
== S_OK
, "ret %08x\n", hr
);
2884 hr
= IXMLDOMComment_get_text(pComment
, &str
);
2885 ok(hr
== S_OK
, "ret %08x\n", hr
);
2886 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
2889 /* test insertData */
2890 str
= SysAllocStringLen(NULL
, 0);
2891 hr
= IXMLDOMComment_insertData(pComment
, -1, str
);
2892 ok(hr
== S_OK
, "ret %08x\n", hr
);
2894 hr
= IXMLDOMComment_insertData(pComment
, -1, NULL
);
2895 ok(hr
== S_OK
, "ret %08x\n", hr
);
2897 hr
= IXMLDOMComment_insertData(pComment
, 1000, str
);
2898 ok(hr
== S_OK
, "ret %08x\n", hr
);
2900 hr
= IXMLDOMComment_insertData(pComment
, 1000, NULL
);
2901 ok(hr
== S_OK
, "ret %08x\n", hr
);
2903 hr
= IXMLDOMComment_insertData(pComment
, 0, NULL
);
2904 ok(hr
== S_OK
, "ret %08x\n", hr
);
2906 hr
= IXMLDOMComment_insertData(pComment
, 0, str
);
2907 ok(hr
== S_OK
, "ret %08x\n", hr
);
2910 hr
= IXMLDOMComment_insertData(pComment
, -1, _bstr_("Inserting"));
2911 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2913 hr
= IXMLDOMComment_insertData(pComment
, 1000, _bstr_("Inserting"));
2914 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2916 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("Begin "));
2917 ok(hr
== S_OK
, "ret %08x\n", hr
);
2919 hr
= IXMLDOMComment_insertData(pComment
, 17, _bstr_("Middle"));
2920 ok(hr
== S_OK
, "ret %08x\n", hr
);
2922 hr
= IXMLDOMComment_insertData(pComment
, 39, _bstr_(" End"));
2923 ok(hr
== S_OK
, "ret %08x\n", hr
);
2925 hr
= IXMLDOMComment_get_text(pComment
, &str
);
2926 ok(hr
== S_OK
, "ret %08x\n", hr
);
2927 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
2931 /* invalid arguments */
2932 hr
= IXMLDOMComment_deleteData(pComment
, -1, 1);
2933 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2935 hr
= IXMLDOMComment_deleteData(pComment
, 0, 0);
2936 ok(hr
== S_OK
, "ret %08x\n", hr
);
2938 hr
= IXMLDOMComment_deleteData(pComment
, 0, -1);
2939 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2941 hr
= IXMLDOMComment_get_length(pComment
, &len
);
2942 ok(hr
== S_OK
, "ret %08x\n", hr
);
2943 ok(len
== 43, "expected 43 got %d\n", len
);
2945 hr
= IXMLDOMComment_deleteData(pComment
, len
, 1);
2946 ok(hr
== S_OK
, "ret %08x\n", hr
);
2948 hr
= IXMLDOMComment_deleteData(pComment
, len
+1, 1);
2949 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
2951 /* delete from start */
2952 hr
= IXMLDOMComment_deleteData(pComment
, 0, 5);
2953 ok(hr
== S_OK
, "ret %08x\n", hr
);
2955 hr
= IXMLDOMComment_get_length(pComment
, &len
);
2956 ok(hr
== S_OK
, "ret %08x\n", hr
);
2957 ok(len
== 38, "expected 38 got %d\n", len
);
2959 hr
= IXMLDOMComment_get_text(pComment
, &str
);
2960 ok(hr
== S_OK
, "ret %08x\n", hr
);
2961 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
2964 /* delete from end */
2965 hr
= IXMLDOMComment_deleteData(pComment
, 35, 3);
2966 ok(hr
== S_OK
, "ret %08x\n", hr
);
2968 hr
= IXMLDOMComment_get_length(pComment
, &len
);
2969 ok(hr
== S_OK
, "ret %08x\n", hr
);
2970 ok(len
== 35, "expected 35 got %d\n", len
);
2972 hr
= IXMLDOMComment_get_text(pComment
, &str
);
2973 ok(hr
== S_OK
, "ret %08x\n", hr
);
2974 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string\n");
2977 /* delete from inside */
2978 hr
= IXMLDOMComment_deleteData(pComment
, 1, 33);
2979 ok(hr
== S_OK
, "ret %08x\n", hr
);
2981 hr
= IXMLDOMComment_get_length(pComment
, &len
);
2982 ok(hr
== S_OK
, "ret %08x\n", hr
);
2983 ok(len
== 2, "expected 2 got %d\n", len
);
2985 hr
= IXMLDOMComment_get_text(pComment
, &str
);
2986 ok(hr
== S_OK
, "ret %08x\n", hr
);
2987 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string\n");
2990 /* delete whole data ... */
2991 hr
= IXMLDOMComment_get_length(pComment
, &len
);
2992 ok(hr
== S_OK
, "ret %08x\n", hr
);
2994 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
2995 ok(hr
== S_OK
, "ret %08x\n", hr
);
2996 /* ... and try again with empty string */
2997 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
2998 ok(hr
== S_OK
, "ret %08x\n", hr
);
3000 IXMLDOMComment_Release(pComment
);
3004 hr
= IXMLDOMDocument_createElement(doc
, szElement
, &pElement
);
3005 ok(hr
== S_OK
, "ret %08x\n", hr
);
3008 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3009 ok(hr
== S_OK
, "ret %08x\n", hr
);
3011 /* test nodeTypeString */
3012 hr
= IXMLDOMDocument_get_nodeTypeString(pElement
, &str
);
3013 ok(hr
== S_OK
, "ret %08x\n", hr
);
3014 ok( !lstrcmpW( str
, _bstr_("element") ), "incorrect nodeTypeString string\n");
3017 hr
= IXMLDOMElement_get_nodeName(pElement
, &str
);
3018 ok(hr
== S_OK
, "ret %08x\n", hr
);
3019 ok( !lstrcmpW( str
, szElement
), "incorrect element node Name\n");
3022 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3023 ok(hr
== S_OK
, "ret %08x\n", hr
);
3024 ok( !lstrcmpW( str
, szElementXML
), "incorrect element xml\n");
3027 hr
= IXMLDOMElement_get_dataType(pElement
, &v
);
3028 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3029 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3033 hr
= IXMLDOMDocument_createAttribute(doc
, szAttribute
, &pAttrubute
);
3034 ok(hr
== S_OK
, "ret %08x\n", hr
);
3037 IXMLDOMNode
*pNewChild
= (IXMLDOMNode
*)0x1;
3039 hr
= IXMLDOMAttribute_get_nextSibling(pAttrubute
, NULL
);
3040 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3042 pNextChild
= (IXMLDOMNode
*)0x1;
3043 hr
= IXMLDOMAttribute_get_nextSibling(pAttrubute
, &pNextChild
);
3044 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3045 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3047 /* test Previous Sibling*/
3048 hr
= IXMLDOMAttribute_get_previousSibling(pAttrubute
, NULL
);
3049 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3051 pNextChild
= (IXMLDOMNode
*)0x1;
3052 hr
= IXMLDOMAttribute_get_previousSibling(pAttrubute
, &pNextChild
);
3053 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3054 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3056 /* test get_attributes */
3057 hr
= IXMLDOMAttribute_get_attributes( pAttrubute
, NULL
);
3058 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
3060 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3061 hr
= IXMLDOMAttribute_get_attributes( pAttrubute
, &pAttribs
);
3062 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3063 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
3065 hr
= IXMLDOMElement_appendChild(pElement
, (IXMLDOMNode
*)pAttrubute
, &pNewChild
);
3066 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
3067 ok(pNewChild
== NULL
, "pNewChild not NULL\n");
3069 hr
= IXMLDOMElement_get_attributes(pElement
, &pAttribs
);
3070 ok(hr
== S_OK
, "ret %08x\n", hr
);
3073 hr
= IXMLDOMNamedNodeMap_setNamedItem(pAttribs
, (IXMLDOMNode
*)pAttrubute
, NULL
);
3074 ok(hr
== S_OK
, "ret %08x\n", hr
);
3076 IXMLDOMNamedNodeMap_Release(pAttribs
);
3079 hr
= IXMLDOMAttribute_get_nodeName(pAttrubute
, &str
);
3080 ok(hr
== S_OK
, "ret %08x\n", hr
);
3081 ok( !lstrcmpW( str
, szAttribute
), "incorrect attribute node Name\n");
3084 /* test nodeTypeString */
3085 hr
= IXMLDOMAttribute_get_nodeTypeString(pAttrubute
, &str
);
3086 ok(hr
== S_OK
, "ret %08x\n", hr
);
3087 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
3091 hr
= IXMLDOMAttribute_get_nodeName(pAttrubute
, &str
);
3092 ok(hr
== S_OK
, "ret %08x\n", hr
);
3093 ok( !lstrcmpW( str
, szAttribute
), "incorrect nodeName string\n");
3096 /* test name property */
3097 hr
= IXMLDOMAttribute_get_name(pAttrubute
, &str
);
3098 ok(hr
== S_OK
, "ret %08x\n", hr
);
3099 ok( !lstrcmpW( str
, szAttribute
), "incorrect name string\n");
3102 hr
= IXMLDOMAttribute_get_xml(pAttrubute
, &str
);
3103 ok(hr
== S_OK
, "ret %08x\n", hr
);
3104 ok( !lstrcmpW( str
, szAttributeXML
), "incorrect attribute xml\n");
3107 hr
= IXMLDOMAttribute_get_dataType(pAttrubute
, &v
);
3108 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3109 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3112 IXMLDOMAttribute_Release(pAttrubute
);
3114 /* Check Element again with the Add Attribute*/
3115 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3116 ok(hr
== S_OK
, "ret %08x\n", hr
);
3117 ok( !lstrcmpW( str
, szElementXML2
), "incorrect element xml\n");
3121 hr
= IXMLDOMElement_put_text(pElement
, _bstr_("TestingNode"));
3122 ok(hr
== S_OK
, "ret %08x\n", hr
);
3124 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3125 ok(hr
== S_OK
, "ret %08x\n", hr
);
3126 ok( !lstrcmpW( str
, szElementXML3
), "incorrect element xml\n");
3129 /* Test for reversible escaping */
3130 str
= SysAllocString( szStrangeChars
);
3131 hr
= IXMLDOMElement_put_text(pElement
, str
);
3132 ok(hr
== S_OK
, "ret %08x\n", hr
);
3133 SysFreeString( str
);
3135 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3136 ok(hr
== S_OK
, "ret %08x\n", hr
);
3137 ok( !lstrcmpW( str
, szElementXML4
), "incorrect element xml\n");
3140 hr
= IXMLDOMElement_get_text(pElement
, &str
);
3141 ok(hr
== S_OK
, "ret %08x\n", hr
);
3142 ok( !lstrcmpW( str
, szStrangeChars
), "incorrect element text\n");
3145 IXMLDOMElement_Release(pElement
);
3149 hr
= IXMLDOMDocument_createCDATASection(doc
, szCData
, NULL
);
3150 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3152 hr
= IXMLDOMDocument_createCDATASection(doc
, szCData
, &pCDataSec
);
3153 ok(hr
== S_OK
, "ret %08x\n", hr
);
3156 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1;
3161 hr
= IXMLDOMCDATASection_QueryInterface(pCDataSec
, &IID_IXMLDOMElement
, (LPVOID
*)&pElement
);
3162 ok(hr
== E_NOINTERFACE
, "ret %08x\n", hr
);
3164 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pCDataSec
, NULL
);
3165 ok(hr
== S_OK
, "ret %08x\n", hr
);
3167 /* get Attribute Tests */
3168 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, NULL
);
3169 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3171 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3172 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, &pAttribs
);
3173 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3174 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
3176 hr
= IXMLDOMCDATASection_get_nodeName(pCDataSec
, &str
);
3177 ok(hr
== S_OK
, "ret %08x\n", hr
);
3178 ok( !lstrcmpW( str
, szCDataNodeText
), "incorrect cdata node Name\n");
3181 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
3182 ok(hr
== S_OK
, "ret %08x\n", hr
);
3183 ok( !lstrcmpW( str
, szCDataXML
), "incorrect cdata xml\n");
3186 /* test lastChild */
3187 pNextChild
= (IXMLDOMNode
*)0x1;
3188 hr
= IXMLDOMCDATASection_get_lastChild(pCDataSec
, &pNextChild
);
3189 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3190 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3192 /* test get_dataType */
3193 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, NULL
);
3194 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3196 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, &v
);
3197 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3198 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3201 /* test nodeTypeString */
3202 hr
= IXMLDOMCDATASection_get_nodeTypeString(pCDataSec
, &str
);
3203 ok(hr
== S_OK
, "ret %08x\n", hr
);
3204 ok( !lstrcmpW( str
, _bstr_("cdatasection") ), "incorrect nodeTypeString string\n");
3207 /* put data Tests */
3208 hr
= IXMLDOMCDATASection_put_data(pCDataSec
, _bstr_("This &is a ; test <>\\"));
3209 ok(hr
== S_OK
, "ret %08x\n", hr
);
3211 /* Confirm XML text is good */
3212 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
3213 ok(hr
== S_OK
, "ret %08x\n", hr
);
3214 ok( !lstrcmpW( str
, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
3217 /* Confirm we get the put_data Text back */
3218 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3219 ok(hr
== S_OK
, "ret %08x\n", hr
);
3220 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3223 /* test length property */
3224 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
3225 ok(hr
== S_OK
, "ret %08x\n", hr
);
3226 ok(len
== 21, "expected 21 got %d\n", len
);
3228 /* test get nodeValue */
3229 hr
= IXMLDOMCDATASection_get_nodeValue(pCDataSec
, &var
);
3230 ok(hr
== S_OK
, "ret %08x\n", hr
);
3231 ok(V_VT(&var
) == VT_BSTR
, "got vt %04x\n", V_VT(&var
));
3232 ok( !lstrcmpW( V_BSTR(&var
), _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3236 hr
= IXMLDOMCDATASection_get_data(pCDataSec
, &str
);
3237 ok(hr
== S_OK
, "ret %08x\n", hr
);
3238 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3241 /* test substringData */
3242 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, NULL
);
3243 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3245 /* test substringData - Invalid offset */
3246 str
= (BSTR
)&szElement
;
3247 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, -1, 4, &str
);
3248 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3249 ok( str
== NULL
, "incorrect string\n");
3251 /* test substringData - Invalid offset */
3252 str
= (BSTR
)&szElement
;
3253 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 30, 0, &str
);
3254 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3255 ok( str
== NULL
, "incorrect string\n");
3257 /* test substringData - Invalid size */
3258 str
= (BSTR
)&szElement
;
3259 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, -1, &str
);
3260 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3261 ok( str
== NULL
, "incorrect string\n");
3263 /* test substringData - Invalid size */
3264 str
= (BSTR
)&szElement
;
3265 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 2, 0, &str
);
3266 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3267 ok( str
== NULL
, "incorrect string\n");
3269 /* test substringData - Start of string */
3270 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, &str
);
3271 ok(hr
== S_OK
, "ret %08x\n", hr
);
3272 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
3275 /* test substringData - Middle of string */
3276 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 13, 4, &str
);
3277 ok(hr
== S_OK
, "ret %08x\n", hr
);
3278 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
3281 /* test substringData - End of string */
3282 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 20, 4, &str
);
3283 ok(hr
== S_OK
, "ret %08x\n", hr
);
3284 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
3287 /* test appendData */
3288 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, NULL
);
3289 ok(hr
== S_OK
, "ret %08x\n", hr
);
3291 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_(""));
3292 ok(hr
== S_OK
, "ret %08x\n", hr
);
3294 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_("Append"));
3295 ok(hr
== S_OK
, "ret %08x\n", hr
);
3297 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3298 ok(hr
== S_OK
, "ret %08x\n", hr
);
3299 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
3302 /* test insertData */
3303 str
= SysAllocStringLen(NULL
, 0);
3304 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, str
);
3305 ok(hr
== S_OK
, "ret %08x\n", hr
);
3307 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, NULL
);
3308 ok(hr
== S_OK
, "ret %08x\n", hr
);
3310 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, str
);
3311 ok(hr
== S_OK
, "ret %08x\n", hr
);
3313 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, NULL
);
3314 ok(hr
== S_OK
, "ret %08x\n", hr
);
3316 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, NULL
);
3317 ok(hr
== S_OK
, "ret %08x\n", hr
);
3319 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, str
);
3320 ok(hr
== S_OK
, "ret %08x\n", hr
);
3323 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, _bstr_("Inserting"));
3324 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3326 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, _bstr_("Inserting"));
3327 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3329 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("Begin "));
3330 ok(hr
== S_OK
, "ret %08x\n", hr
);
3332 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 17, _bstr_("Middle"));
3333 ok(hr
== S_OK
, "ret %08x\n", hr
);
3335 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 39, _bstr_(" End"));
3336 ok(hr
== S_OK
, "ret %08x\n", hr
);
3338 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3339 ok(hr
== S_OK
, "ret %08x\n", hr
);
3340 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3343 IXMLDOMCDATASection_Release(pCDataSec
);
3346 /* Document Fragments */
3347 hr
= IXMLDOMDocument_createDocumentFragment(doc
, NULL
);
3348 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3350 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &pDocFrag
);
3351 ok(hr
== S_OK
, "ret %08x\n", hr
);
3354 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1;
3356 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pDocFrag
, NULL
);
3357 ok(hr
== S_OK
, "ret %08x\n", hr
);
3359 /* get Attribute Tests */
3360 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, NULL
);
3361 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3363 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3364 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, &pAttribs
);
3365 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3366 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
3368 hr
= IXMLDOMDocumentFragment_get_nodeName(pDocFrag
, &str
);
3369 ok(hr
== S_OK
, "ret %08x\n", hr
);
3370 ok( !lstrcmpW( str
, szDocFragmentText
), "incorrect docfragment node Name\n");
3373 /* test next Sibling*/
3374 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, NULL
);
3375 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3377 pNextChild
= (IXMLDOMNode
*)0x1;
3378 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, &pNextChild
);
3379 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3380 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3382 /* test Previous Sibling*/
3383 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, NULL
);
3384 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3386 pNextChild
= (IXMLDOMNode
*)0x1;
3387 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, &pNextChild
);
3388 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3389 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3391 /* test get_dataType */
3392 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, NULL
);
3393 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3395 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, &v
);
3396 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3397 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3400 /* test nodeTypeString */
3401 hr
= IXMLDOMDocumentFragment_get_nodeTypeString(pDocFrag
, &str
);
3402 ok(hr
== S_OK
, "ret %08x\n", hr
);
3403 ok( !lstrcmpW( str
, _bstr_("documentfragment") ), "incorrect nodeTypeString string\n");
3406 IXMLDOMDocumentFragment_Release(pDocFrag
);
3409 /* Entity References */
3410 hr
= IXMLDOMDocument_createEntityReference(doc
, szEntityRef
, NULL
);
3411 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3413 hr
= IXMLDOMDocument_createEntityReference(doc
, szEntityRef
, &pEntityRef
);
3414 ok(hr
== S_OK
, "ret %08x\n", hr
);
3417 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pEntityRef
, NULL
);
3418 ok(hr
== S_OK
, "ret %08x\n", hr
);
3420 /* get Attribute Tests */
3421 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, NULL
);
3422 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3424 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3425 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, &pAttribs
);
3426 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3427 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
3430 hr
= IXMLDOMEntityReference_get_dataType(pEntityRef
, &v
);
3431 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3432 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3435 /* test nodeTypeString */
3436 hr
= IXMLDOMEntityReference_get_nodeTypeString(pEntityRef
, &str
);
3437 ok(hr
== S_OK
, "ret %08x\n", hr
);
3438 ok( !lstrcmpW( str
, _bstr_("entityreference") ), "incorrect nodeTypeString string\n");
3442 hr
= IXMLDOMEntityReference_get_xml(pEntityRef
, &str
);
3443 ok(hr
== S_OK
, "ret %08x\n", hr
);
3444 ok( !lstrcmpW( str
, szEntityRefXML
), "incorrect xml string\n");
3447 IXMLDOMEntityReference_Release(pEntityRef
);
3450 IXMLDOMElement_Release( pRoot
);
3454 IXMLDOMDocument_Release(doc
);
3459 static void test_nodeTypeTests( void )
3461 IXMLDOMDocument
*doc
= NULL
;
3462 IXMLDOMElement
*pRoot
;
3463 IXMLDOMElement
*pElement
;
3466 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3470 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
3471 ok(hr
== S_OK
, "ret %08x\n", hr
);
3474 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
3475 ok(hr
== S_OK
, "ret %08x\n", hr
);
3478 hr
= IXMLDOMElement_put_dataType(pRoot
, NULL
);
3479 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3482 hr
= IXMLDOMElement_put_dataType(pRoot
, _bstr_("abcdefg") );
3483 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
3486 * The name passed into put_dataType is case-insensitive. So many of the names
3487 * have been changed to reflect this.
3490 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Boolean"), &pElement
);
3491 ok(hr
== S_OK
, "ret %08x\n", hr
);
3494 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3496 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Boolean") );
3497 ok(hr
== S_OK
, "ret %08x\n", hr
);
3499 IXMLDOMElement_Release(pElement
);
3503 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_String"), &pElement
);
3504 ok(hr
== S_OK
, "ret %08x\n", hr
);
3507 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3509 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("String") );
3510 ok(hr
== S_OK
, "ret %08x\n", hr
);
3512 IXMLDOMElement_Release(pElement
);
3516 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Number"), &pElement
);
3517 ok(hr
== S_OK
, "ret %08x\n", hr
);
3520 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3522 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("number") );
3523 ok(hr
== S_OK
, "ret %08x\n", hr
);
3525 IXMLDOMElement_Release(pElement
);
3529 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Int"), &pElement
);
3530 ok(hr
== S_OK
, "ret %08x\n", hr
);
3533 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3535 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("InT") );
3536 ok(hr
== S_OK
, "ret %08x\n", hr
);
3538 IXMLDOMElement_Release(pElement
);
3542 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Fixed"), &pElement
);
3543 ok(hr
== S_OK
, "ret %08x\n", hr
);
3546 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3548 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("fixed.14.4") );
3549 ok(hr
== S_OK
, "ret %08x\n", hr
);
3551 IXMLDOMElement_Release(pElement
);
3555 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime"), &pElement
);
3556 ok(hr
== S_OK
, "ret %08x\n", hr
);
3559 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3561 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime") );
3562 ok(hr
== S_OK
, "ret %08x\n", hr
);
3564 IXMLDOMElement_Release(pElement
);
3568 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime_tz"), &pElement
);
3569 ok(hr
== S_OK
, "ret %08x\n", hr
);
3572 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3574 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
3575 ok(hr
== S_OK
, "ret %08x\n", hr
);
3577 IXMLDOMElement_Release(pElement
);
3581 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Date"), &pElement
);
3582 ok(hr
== S_OK
, "ret %08x\n", hr
);
3585 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3587 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Date") );
3588 ok(hr
== S_OK
, "ret %08x\n", hr
);
3590 IXMLDOMElement_Release(pElement
);
3594 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time"), &pElement
);
3595 ok(hr
== S_OK
, "ret %08x\n", hr
);
3598 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3600 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time") );
3601 ok(hr
== S_OK
, "ret %08x\n", hr
);
3603 IXMLDOMElement_Release(pElement
);
3607 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time_TZ"), &pElement
);
3608 ok(hr
== S_OK
, "ret %08x\n", hr
);
3611 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3613 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time.tz") );
3614 ok(hr
== S_OK
, "ret %08x\n", hr
);
3616 IXMLDOMElement_Release(pElement
);
3620 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I1"), &pElement
);
3621 ok(hr
== S_OK
, "ret %08x\n", hr
);
3624 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3626 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I1") );
3627 ok(hr
== S_OK
, "ret %08x\n", hr
);
3629 IXMLDOMElement_Release(pElement
);
3633 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I2"), &pElement
);
3634 ok(hr
== S_OK
, "ret %08x\n", hr
);
3637 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3639 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I2") );
3640 ok(hr
== S_OK
, "ret %08x\n", hr
);
3642 IXMLDOMElement_Release(pElement
);
3646 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I4"), &pElement
);
3647 ok(hr
== S_OK
, "ret %08x\n", hr
);
3650 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3652 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I4") );
3653 ok(hr
== S_OK
, "ret %08x\n", hr
);
3655 IXMLDOMElement_Release(pElement
);
3659 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI1"), &pElement
);
3660 ok(hr
== S_OK
, "ret %08x\n", hr
);
3663 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3665 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI1") );
3666 ok(hr
== S_OK
, "ret %08x\n", hr
);
3668 IXMLDOMElement_Release(pElement
);
3672 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI2"), &pElement
);
3673 ok(hr
== S_OK
, "ret %08x\n", hr
);
3676 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3678 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI2") );
3679 ok(hr
== S_OK
, "ret %08x\n", hr
);
3681 IXMLDOMElement_Release(pElement
);
3685 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI4"), &pElement
);
3686 ok(hr
== S_OK
, "ret %08x\n", hr
);
3689 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3691 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI4") );
3692 ok(hr
== S_OK
, "ret %08x\n", hr
);
3694 IXMLDOMElement_Release(pElement
);
3698 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r4"), &pElement
);
3699 ok(hr
== S_OK
, "ret %08x\n", hr
);
3702 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3704 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r4") );
3705 ok(hr
== S_OK
, "ret %08x\n", hr
);
3707 IXMLDOMElement_Release(pElement
);
3711 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r8"), &pElement
);
3712 ok(hr
== S_OK
, "ret %08x\n", hr
);
3715 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3717 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r8") );
3718 ok(hr
== S_OK
, "ret %08x\n", hr
);
3720 IXMLDOMElement_Release(pElement
);
3724 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_float"), &pElement
);
3725 ok(hr
== S_OK
, "ret %08x\n", hr
);
3728 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3730 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("float") );
3731 ok(hr
== S_OK
, "ret %08x\n", hr
);
3733 IXMLDOMElement_Release(pElement
);
3737 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_uuid"), &pElement
);
3738 ok(hr
== S_OK
, "ret %08x\n", hr
);
3741 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3743 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UuId") );
3744 ok(hr
== S_OK
, "ret %08x\n", hr
);
3746 IXMLDOMElement_Release(pElement
);
3750 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_hex"), &pElement
);
3751 ok(hr
== S_OK
, "ret %08x\n", hr
);
3754 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3756 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.hex") );
3757 ok(hr
== S_OK
, "ret %08x\n", hr
);
3759 IXMLDOMElement_Release(pElement
);
3763 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_base64"), &pElement
);
3764 ok(hr
== S_OK
, "ret %08x\n", hr
);
3767 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3769 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.base64") );
3770 ok(hr
== S_OK
, "ret %08x\n", hr
);
3772 IXMLDOMElement_Release(pElement
);
3775 /* Check changing types */
3776 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Change"), &pElement
);
3777 ok(hr
== S_OK
, "ret %08x\n", hr
);
3780 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3782 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
3783 ok(hr
== S_OK
, "ret %08x\n", hr
);
3785 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("string") );
3786 ok(hr
== S_OK
, "ret %08x\n", hr
);
3788 IXMLDOMElement_Release(pElement
);
3791 IXMLDOMElement_Release(pRoot
);
3795 IXMLDOMDocument_Release(doc
);
3800 static void test_DocumentSaveToDocument(void)
3802 IXMLDOMDocument
*doc
= NULL
;
3803 IXMLDOMDocument
*doc2
= NULL
;
3804 IXMLDOMElement
*pRoot
;
3808 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3812 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc2
);
3815 IXMLDOMDocument_Release(doc
);
3819 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
3820 ok(hr
== S_OK
, "ret %08x\n", hr
);
3823 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
3824 ok(hr
== S_OK
, "ret %08x\n", hr
);
3831 V_VT(&vDoc
) = VT_UNKNOWN
;
3832 V_UNKNOWN(&vDoc
) = (IUnknown
*)doc2
;
3834 hr
= IXMLDOMDocument_save(doc
, vDoc
);
3835 ok(hr
== S_OK
, "ret %08x\n", hr
);
3837 hr
= IXMLDOMDocument_get_xml(doc
, &sOrig
);
3838 ok(hr
== S_OK
, "ret %08x\n", hr
);
3840 hr
= IXMLDOMDocument_get_xml(doc2
, &sNew
);
3841 ok(hr
== S_OK
, "ret %08x\n", hr
);
3843 ok( !lstrcmpW( sOrig
, sNew
), "New document is not the same as origial\n");
3845 SysFreeString(sOrig
);
3846 SysFreeString(sNew
);
3850 IXMLDOMDocument_Release(doc2
);
3851 IXMLDOMDocument_Release(doc
);
3854 static void test_DocumentSaveToFile(void)
3856 IXMLDOMDocument
*doc
= NULL
;
3857 IXMLDOMElement
*pRoot
;
3863 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3867 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
3868 ok(hr
== S_OK
, "ret %08x\n", hr
);
3871 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
3872 ok(hr
== S_OK
, "ret %08x\n", hr
);
3877 V_VT(&vFile
) = VT_BSTR
;
3878 V_BSTR(&vFile
) = _bstr_("test.xml");
3880 hr
= IXMLDOMDocument_save(doc
, vFile
);
3881 ok(hr
== S_OK
, "ret %08x\n", hr
);
3885 IXMLDOMElement_Release(pRoot
);
3886 IXMLDOMDocument_Release(doc
);
3888 file
= CreateFile("test.xml", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
3889 ok(file
!= INVALID_HANDLE_VALUE
, "Could not open file: %u\n", GetLastError());
3890 if(file
== INVALID_HANDLE_VALUE
)
3893 ReadFile(file
, buffer
, sizeof(buffer
), &read
, NULL
);
3894 ok(read
!= 0, "could not read file\n");
3895 ok(buffer
[0] != '<' || buffer
[1] != '?', "File contains processing instruction\n");
3898 DeleteFile("test.xml");
3901 static void test_testTransforms(void)
3903 IXMLDOMDocument
*doc
= NULL
;
3904 IXMLDOMDocument
*docSS
= NULL
;
3910 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3914 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&docSS
);
3917 IXMLDOMDocument_Release(doc
);
3921 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTransformXML
), &bSucc
);
3922 ok(hr
== S_OK
, "ret %08x\n", hr
);
3924 hr
= IXMLDOMDocument_loadXML(docSS
, _bstr_(szTransformSSXML
), &bSucc
);
3925 ok(hr
== S_OK
, "ret %08x\n", hr
);
3927 hr
= IXMLDOMDocument_QueryInterface(docSS
, &IID_IXMLDOMNode
, (LPVOID
*)&pNode
);
3928 ok(hr
== S_OK
, "ret %08x\n", hr
);
3933 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &bOut
);
3934 ok(hr
== S_OK
, "ret %08x\n", hr
);
3935 ok( compareIgnoreReturns( bOut
, _bstr_(szTransformOutput
)), "Stylesheet output not correct\n");
3936 SysFreeString(bOut
);
3938 IXMLDOMNode_Release(pNode
);
3941 IXMLDOMDocument_Release(docSS
);
3942 IXMLDOMDocument_Release(doc
);
3947 static void test_Namespaces(void)
3949 IXMLDOMDocument2
*doc
= NULL
;
3951 IXMLDOMNode
*pNode2
= NULL
;
3955 static const CHAR szNamespacesXML
[] =
3956 "<?xml version=\"1.0\"?>\n"
3957 "<root xmlns:WEB='http://www.winehq.org'>\n"
3958 "<WEB:Site version=\"1.0\" />\n"
3961 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3965 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szNamespacesXML
), &bSucc
);
3966 ok(hr
== S_OK
, "ret %08x\n", hr
);
3967 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
3969 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root"), &pNode
);
3970 ok(hr
== S_OK
, "ret %08x\n", hr
);
3973 hr
= IXMLDOMNode_get_firstChild( pNode
, &pNode2
);
3974 ok( hr
== S_OK
, "ret %08x\n", hr
);
3975 ok( pNode2
!= NULL
, "pNode2 == NULL\n");
3977 /* Test get_prefix */
3978 hr
= IXMLDOMNode_get_prefix(pNode2
, NULL
);
3979 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3980 /* NOTE: Need to test that arg2 gets cleared on Error. */
3982 hr
= IXMLDOMNode_get_prefix(pNode2
, &str
);
3983 ok( hr
== S_OK
, "ret %08x\n", hr
);
3984 ok( !lstrcmpW( str
, _bstr_("WEB")), "incorrect prefix string\n");
3987 /* Test get_namespaceURI */
3988 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, NULL
);
3989 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3990 /* NOTE: Need to test that arg2 gets cleared on Error. */
3992 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, &str
);
3993 ok( hr
== S_OK
, "ret %08x\n", hr
);
3994 ok( !lstrcmpW( str
, _bstr_("http://www.winehq.org")), "incorrect namespaceURI string\n");
3997 IXMLDOMNode_Release(pNode2
);
3998 IXMLDOMNode_Release(pNode
);
4001 IXMLDOMDocument2_Release(doc
);
4006 static void test_FormattingXML(void)
4008 IXMLDOMDocument2
*doc
= NULL
;
4009 IXMLDOMElement
*pElement
;
4013 static const CHAR szLinefeedXML
[] = "<?xml version=\"1.0\"?>\n<Root>\n\t<Sub val=\"A\" />\n</Root>";
4014 static const CHAR szLinefeedRootXML
[] = "<Root>\r\n\t<Sub val=\"A\"/>\r\n</Root>";
4016 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4020 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szLinefeedXML
), &bSucc
);
4021 ok(hr
== S_OK
, "ret %08x\n", hr
);
4022 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4024 if(bSucc
== VARIANT_TRUE
)
4026 hr
= IXMLDOMDocument2_get_documentElement(doc
, &pElement
);
4027 ok(hr
== S_OK
, "ret %08x\n", hr
);
4030 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
4031 ok(hr
== S_OK
, "ret %08x\n", hr
);
4032 ok( !lstrcmpW( str
, _bstr_(szLinefeedRootXML
) ), "incorrect element xml\n");
4035 IXMLDOMElement_Release(pElement
);
4039 IXMLDOMDocument2_Release(doc
);
4044 static void test_NodeTypeValue(void)
4046 IXMLDOMDocument2
*doc
= NULL
;
4052 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4056 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szTypeValueXML
), &bSucc
);
4057 ok(hr
== S_OK
, "ret %08x\n", hr
);
4058 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4059 if(bSucc
== VARIANT_TRUE
)
4061 hr
= IXMLDOMDocument2_get_nodeValue(doc
, NULL
);
4062 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4066 hr
= IXMLDOMDocument2_get_nodeValue(doc
, &v
);
4067 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4068 ok(V_VT(&v
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&v
));
4070 hr
= IXMLDOMDocument2_get_nodeTypedValue(doc
, NULL
);
4071 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4073 hr
= IXMLDOMDocument2_get_nodeTypedValue(doc
, &v
);
4074 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4076 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/string"), &pNode
);
4077 ok(hr
== S_OK
, "ret %08x\n", hr
);
4082 hr
= IXMLDOMNode_get_nodeValue(pNode
, &v
);
4083 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4084 ok(V_VT(&v
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&v
));
4086 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, NULL
);
4087 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4089 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4090 ok(hr
== S_OK
, "ret %08x\n", hr
);
4091 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4092 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("Wine") ), "incorrect value\n");
4095 IXMLDOMNode_Release(pNode
);
4098 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/string2"), &pNode
);
4099 ok(hr
== S_OK
, "ret %08x\n", hr
);
4102 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4103 ok(hr
== S_OK
, "ret %08x\n", hr
);
4104 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4105 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("String") ), "incorrect value\n");
4108 IXMLDOMNode_Release(pNode
);
4111 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/number"), &pNode
);
4112 ok(hr
== S_OK
, "ret %08x\n", hr
);
4115 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4116 ok(hr
== S_OK
, "ret %08x\n", hr
);
4117 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4118 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("12.44") ), "incorrect value\n");
4121 IXMLDOMNode_Release(pNode
);
4124 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/number2"), &pNode
);
4125 ok(hr
== S_OK
, "ret %08x\n", hr
);
4128 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4129 ok(hr
== S_OK
, "ret %08x\n", hr
);
4130 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4131 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("-3.71e3") ), "incorrect value\n");
4134 IXMLDOMNode_Release(pNode
);
4137 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/int"), &pNode
);
4138 ok(hr
== S_OK
, "ret %08x\n", hr
);
4141 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4142 ok(hr
== S_OK
, "ret %08x\n", hr
);
4143 ok(V_VT(&v
) == VT_I4
, "incorrect type\n");
4144 ok(V_I4(&v
) == -13, "incorrect value\n");
4147 IXMLDOMNode_Release(pNode
);
4150 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/fixed"), &pNode
);
4151 ok(hr
== S_OK
, "ret %08x\n", hr
);
4154 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4155 ok(hr
== S_OK
, "ret %08x\n", hr
);
4156 ok(V_VT(&v
) == VT_CY
, "incorrect type\n");
4159 IXMLDOMNode_Release(pNode
);
4162 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/bool"), &pNode
);
4163 ok(hr
== S_OK
, "ret %08x\n", hr
);
4166 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4167 ok(hr
== S_OK
, "ret %08x\n", hr
);
4168 ok(V_VT(&v
) == VT_BOOL
, "incorrect type\n");
4169 ok(V_BOOL(&v
) == VARIANT_TRUE
, "incorrect value\n");
4172 IXMLDOMNode_Release(pNode
);
4175 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/datetime"), &pNode
);
4176 ok(hr
== S_OK
, "ret %08x\n", hr
);
4179 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4180 ok(hr
== S_OK
, "ret %08x\n", hr
);
4181 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4182 double_eq(40135.13996527778, V_DATE(&v
));
4185 IXMLDOMNode_Release(pNode
);
4188 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/datetimetz"), &pNode
);
4189 ok(hr
== S_OK
, "ret %08x\n", hr
);
4192 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4193 ok(hr
== S_OK
, "ret %08x\n", hr
);
4194 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4195 double_eq(37813.59302083334, V_DATE(&v
));
4198 IXMLDOMNode_Release(pNode
);
4201 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/date"), &pNode
);
4202 ok(hr
== S_OK
, "ret %08x\n", hr
);
4205 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4206 ok(hr
== S_OK
, "ret %08x\n", hr
);
4207 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4208 double_eq(665413.0, V_DATE(&v
));
4211 IXMLDOMNode_Release(pNode
);
4214 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/time"), &pNode
);
4215 ok(hr
== S_OK
, "ret %08x\n", hr
);
4218 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4219 ok(hr
== S_OK
, "ret %08x\n", hr
);
4220 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4221 double_eq(0.5813888888888888, V_DATE(&v
));
4224 IXMLDOMNode_Release(pNode
);
4227 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/timetz"), &pNode
);
4228 ok(hr
== S_OK
, "ret %08x\n", hr
);
4231 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4232 ok(hr
== S_OK
, "ret %08x\n", hr
);
4233 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4234 double_eq(1.112511574074074, V_DATE(&v
));
4237 IXMLDOMNode_Release(pNode
);
4240 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/i1"), &pNode
);
4241 ok(hr
== S_OK
, "ret %08x\n", hr
);
4244 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4245 ok(hr
== S_OK
, "ret %08x\n", hr
);
4246 ok(V_VT(&v
) == VT_I1
, "incorrect type\n");
4247 ok(V_I1(&v
) == -13, "incorrect value\n");
4250 IXMLDOMNode_Release(pNode
);
4253 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/i2"), &pNode
);
4254 ok(hr
== S_OK
, "ret %08x\n", hr
);
4257 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4258 ok(hr
== S_OK
, "ret %08x\n", hr
);
4259 ok(V_VT(&v
) == VT_I2
, "incorrect type\n");
4260 ok(V_I2(&v
) == 31915, "incorrect value\n");
4263 IXMLDOMNode_Release(pNode
);
4266 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/i4"), &pNode
);
4267 ok(hr
== S_OK
, "ret %08x\n", hr
);
4270 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4271 ok(hr
== S_OK
, "ret %08x\n", hr
);
4272 ok(V_VT(&v
) == VT_I4
, "incorrect type\n");
4273 ok(V_I4(&v
) == -312232, "incorrect value\n");
4276 IXMLDOMNode_Release(pNode
);
4279 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/ui1"), &pNode
);
4280 ok(hr
== S_OK
, "ret %08x\n", hr
);
4283 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4284 ok(hr
== S_OK
, "ret %08x\n", hr
);
4285 ok(V_VT(&v
) == VT_UI1
, "incorrect type\n");
4286 ok(V_UI1(&v
) == 123, "incorrect value\n");
4289 IXMLDOMNode_Release(pNode
);
4292 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/ui2"), &pNode
);
4293 ok(hr
== S_OK
, "ret %08x\n", hr
);
4296 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4297 ok(hr
== S_OK
, "ret %08x\n", hr
);
4298 ok(V_VT(&v
) == VT_UI2
, "incorrect type\n");
4299 ok(V_UI2(&v
) == 48282, "incorrect value\n");
4302 IXMLDOMNode_Release(pNode
);
4305 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/ui4"), &pNode
);
4306 ok(hr
== S_OK
, "ret %08x\n", hr
);
4309 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4310 ok(hr
== S_OK
, "ret %08x\n", hr
);
4311 ok(V_VT(&v
) == VT_UI4
, "incorrect type\n");
4312 ok(V_UI4(&v
) == 949281, "incorrect value\n");
4315 IXMLDOMNode_Release(pNode
);
4318 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/r4"), &pNode
);
4319 ok(hr
== S_OK
, "ret %08x\n", hr
);
4322 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4323 ok(hr
== S_OK
, "ret %08x\n", hr
);
4324 ok(V_VT(&v
) == VT_R4
, "incorrect type\n");
4325 double_eq(213124.0, V_R4(&v
));
4328 IXMLDOMNode_Release(pNode
);
4331 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/r8"), &pNode
);
4332 ok(hr
== S_OK
, "ret %08x\n", hr
);
4335 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4336 ok(hr
== S_OK
, "ret %08x\n", hr
);
4337 ok(V_VT(&v
) == VT_R8
, "incorrect type\n");
4338 double_eq(0.412, V_R8(&v
));
4341 IXMLDOMNode_Release(pNode
);
4344 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/float"), &pNode
);
4345 ok(hr
== S_OK
, "ret %08x\n", hr
);
4348 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4349 ok(hr
== S_OK
, "ret %08x\n", hr
);
4350 ok(V_VT(&v
) == VT_R8
, "incorrect type\n");
4351 double_eq(41221.421, V_R8(&v
));
4354 IXMLDOMNode_Release(pNode
);
4357 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/uuid"), &pNode
);
4358 ok(hr
== S_OK
, "ret %08x\n", hr
);
4361 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4362 ok(hr
== S_OK
, "ret %08x\n", hr
);
4363 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4364 ok(!lstrcmpW(V_BSTR(&v
), _bstr_("333C7BC4-460F-11D0-BC04-0080C7055a83")), "incorrect value\n");
4367 IXMLDOMNode_Release(pNode
);
4370 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/binhex"), &pNode
);
4371 ok(hr
== S_OK
, "ret %08x\n", hr
);
4374 BYTE bytes
[] = {0xff,0xfc,0xa0,0x12,0x00,0x3c};
4376 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4377 ok(hr
== S_OK
, "ret %08x\n", hr
);
4378 ok(V_VT(&v
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
4379 ok(V_ARRAY(&v
)->rgsabound
[0].cElements
== 6, "incorrect array size\n");
4380 if(V_ARRAY(&v
)->rgsabound
[0].cElements
== 6)
4381 ok(!memcmp(bytes
, V_ARRAY(&v
)->pvData
, sizeof(bytes
)), "incorrect value\n");
4384 IXMLDOMNode_Release(pNode
);
4387 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/binbase64"), &pNode
);
4388 ok(hr
== S_OK
, "ret %08x\n", hr
);
4391 BYTE bytes
[] = {0x62,0x61,0x73,0x65,0x36,0x34,0x20,0x74,0x65,0x73,0x74};
4393 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4394 ok(hr
== S_OK
, "ret %08x\n", hr
);
4395 ok(V_VT(&v
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
4396 ok(V_ARRAY(&v
)->rgsabound
[0].cElements
== 11, "incorrect array size\n");
4397 if(V_ARRAY(&v
)->rgsabound
[0].cElements
== 11)
4398 ok(!memcmp(bytes
, V_ARRAY(&v
)->pvData
, sizeof(bytes
)), "incorrect value\n");
4401 IXMLDOMNode_Release(pNode
);
4405 IXMLDOMDocument2_Release(doc
);
4410 static void test_TransformWithLoadingLocalFile(void)
4412 IXMLDOMDocument2
*doc
= NULL
;
4413 IXMLDOMDocument2
*xsl
= NULL
;
4419 char lpPathBuffer
[MAX_PATH
];
4422 /* Create a Temp File. */
4423 GetTempPathA(MAX_PATH
, lpPathBuffer
);
4424 strcat(lpPathBuffer
, "customers.xml" );
4426 file
= CreateFile(lpPathBuffer
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
4427 ok(file
!= INVALID_HANDLE_VALUE
, "Could not create file: %u\n", GetLastError());
4428 if(file
== INVALID_HANDLE_VALUE
)
4431 WriteFile(file
, szBasicTransformXML
, strlen(szBasicTransformXML
), &dwWritten
, NULL
);
4434 /* Correct path to not include a escape character. */
4435 for(i
=0; i
< strlen(lpPathBuffer
); i
++)
4437 if(lpPathBuffer
[i
] == '\\')
4438 lpPathBuffer
[i
] = '/';
4441 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4445 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&xsl
);
4448 IXMLDOMDocument2_Release(doc
);
4452 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szTypeValueXML
), &bSucc
);
4453 ok(hr
== S_OK
, "ret %08x\n", hr
);
4454 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4455 if(bSucc
== VARIANT_TRUE
)
4458 BSTR sPart1
= _bstr_(szBasicTransformSSXMLPart1
);
4459 BSTR sPart2
= _bstr_(szBasicTransformSSXMLPart2
);
4460 BSTR sFileName
= _bstr_(lpPathBuffer
);
4461 int nLegnth
= lstrlenW(sPart1
) + lstrlenW(sPart2
) + lstrlenW(sFileName
) + 1;
4463 sXSL
= SysAllocStringLen(NULL
, nLegnth
);
4464 lstrcpyW(sXSL
, sPart1
);
4465 lstrcatW(sXSL
, sFileName
);
4466 lstrcatW(sXSL
, sPart2
);
4468 hr
= IXMLDOMDocument2_loadXML(xsl
, sXSL
, &bSucc
);
4469 ok(hr
== S_OK
, "ret %08x\n", hr
);
4470 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4471 if(bSucc
== VARIANT_TRUE
)
4475 hr
= IXMLDOMDocument_QueryInterface(xsl
, &IID_IXMLDOMNode
, (LPVOID
*)&pNode
);
4476 ok(hr
== S_OK
, "ret %08x\n", hr
);
4479 /* This will load the temp file via the XSL */
4480 hr
= IXMLDOMDocument2_transformNode(doc
, pNode
, &sResult
);
4481 ok(hr
== S_OK
, "ret %08x\n", hr
);
4484 ok( compareIgnoreReturns( sResult
, _bstr_(szBasicTransformOutput
)), "Stylesheet output not correct\n");
4485 SysFreeString(sResult
);
4488 IXMLDOMNode_Release(pNode
);
4492 SysFreeString(sXSL
);
4495 IXMLDOMDocument2_Release(doc
);
4496 IXMLDOMDocument2_Release(xsl
);
4498 DeleteFile(lpPathBuffer
);
4506 r
= CoInitialize( NULL
);
4507 ok( r
== S_OK
, "failed to init com\n");
4513 test_getElementsByTagName();
4515 test_get_childNodes();
4517 test_replaceChild();
4518 test_removeNamedItem();
4520 test_IXMLDOMDocument2();
4524 test_nodeTypeTests();
4525 test_DocumentSaveToDocument();
4526 test_DocumentSaveToFile();
4527 test_testTransforms();
4529 test_FormattingXML();
4530 test_NodeTypeValue();
4531 test_TransformWithLoadingLocalFile();