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
30 #include "msxml2did.h"
35 #include "wine/test.h"
39 DEFINE_GUID(IID_IObjectSafety
, 0xcb5bdc81, 0x93c1, 0x11cf, 0x8f,0x20, 0x00,0x80,0x5f,0x2c,0xd0,0x64);
41 static const WCHAR szEmpty
[] = { 0 };
42 static const WCHAR szIncomplete
[] = {
43 '<','?','x','m','l',' ',
44 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
46 static const WCHAR szComplete1
[] = {
47 '<','?','x','m','l',' ',
48 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
49 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
51 static const WCHAR szComplete2
[] = {
52 '<','?','x','m','l',' ',
53 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
54 '<','o','>','<','/','o','>','\n',0
56 static const WCHAR szComplete3
[] = {
57 '<','?','x','m','l',' ',
58 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
59 '<','a','>','<','/','a','>','\n',0
61 static const WCHAR szComplete4
[] = {
62 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
63 '<','l','c',' ','d','l','=','\'','s','t','r','1','\'','>','\n',
64 '<','b','s',' ','v','r','=','\'','s','t','r','2','\'',' ','s','z','=','\'','1','2','3','4','\'','>',
65 'f','n','1','.','t','x','t','\n',
66 '<','/','b','s','>','\n',
67 '<','p','r',' ','i','d','=','\'','s','t','r','3','\'',' ','v','r','=','\'','1','.','2','.','3','\'',' ',
68 'p','n','=','\'','w','i','n','e',' ','2','0','0','5','0','8','0','4','\'','>','\n',
69 'f','n','2','.','t','x','t','\n',
70 '<','/','p','r','>','\n',
71 '<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
75 '<','/','b','a','>','\n',
76 '<','/','f','o','>','\n',
77 '<','/','l','c','>','\n',0
79 static const WCHAR szComplete5
[] = {
80 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
81 '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','"',
82 ' ','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','"','>',
83 '<','S',':','s','c','o','p','e','>',
84 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
85 '<','/','S',':','s','c','o','p','e','>',
86 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
87 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
88 'c','o','m','p','u','t','e','r',
89 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
90 '<','/','S',':','s','e','a','r','c','h','>',0
93 static const WCHAR szComplete6
[] = {
94 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'',' ',
95 'e','n','c','o','d','i','n','g','=','\'','W','i','n','d','o','w','s','-','1','2','5','2','\'','?','>','\n',
96 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
99 static const CHAR szNonUnicodeXML
[] =
100 "<?xml version='1.0' encoding='Windows-1252'?>\n"
103 static const CHAR szExampleXML
[] =
104 "<?xml version='1.0' encoding='utf-8'?>\n"
105 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
110 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
111 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
112 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
120 " <c type=\"old\">C2 field</c>\n"
123 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
132 " <foo:c>C4 field</foo:c>\n"
136 static const CHAR szTransformXML
[] =
137 "<?xml version=\"1.0\"?>\n"
142 static const CHAR szTransformSSXML
[] =
143 "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n"
144 " <xsl:output method=\"html\"/>\n"
145 " <xsl:template match=\"/\">\n"
146 " <xsl:apply-templates select=\"greeting\"/>\n"
148 " <xsl:template match=\"greeting\">\n"
152 " <xsl:value-of select=\".\"/>\n"
159 static const CHAR szTransformOutput
[] =
162 "</h1></body></html>";
164 static const CHAR szTypeValueXML
[] =
165 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
166 "<root xmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n"
167 " <string>Wine</string>\n"
168 " <string2 dt:dt=\"string\">String</string2>\n"
169 " <number dt:dt=\"number\">12.44</number>\n"
170 " <number2 dt:dt=\"NUMbEr\">-3.71e3</number2>\n"
171 " <int dt:dt=\"int\">-13</int>\n"
172 " <fixed dt:dt=\"fixed.14.4\">7322.9371</fixed>\n"
173 " <bool dt:dt=\"boolean\">1</bool>\n"
174 " <datetime dt:dt=\"datetime\">2009-11-18T03:21:33.12</datetime>\n"
175 " <datetimetz dt:dt=\"datetime.tz\">2003-07-11T11:13:57+03:00</datetimetz>\n"
176 " <date dt:dt=\"date\">3721-11-01</date>\n"
177 " <time dt:dt=\"time\">13:57:12.31321</time>\n"
178 " <timetz dt:dt=\"time.tz\">23:21:01.13+03:21</timetz>\n"
179 " <i1 dt:dt=\"i1\">-13</i1>\n"
180 " <i2 dt:dt=\"i2\">31915</i2>\n"
181 " <i4 dt:dt=\"i4\">-312232</i4>\n"
182 " <ui1 dt:dt=\"ui1\">123</ui1>\n"
183 " <ui2 dt:dt=\"ui2\">48282</ui2>\n"
184 " <ui4 dt:dt=\"ui4\">949281</ui4>\n"
185 " <r4 dt:dt=\"r4\">213124.0</r4>\n"
186 " <r8 dt:dt=\"r8\">0.412</r8>\n"
187 " <float dt:dt=\"float\">41221.421</float>\n"
188 " <uuid dt:dt=\"uuid\">333C7BC4-460F-11D0-BC04-0080C7055a83</uuid>\n"
189 " <binhex dt:dt=\"bin.hex\">fffca012003c</binhex>\n"
190 " <binbase64 dt:dt=\"bin.base64\">YmFzZTY0IHRlc3Q=</binbase64>\n"
193 static const CHAR szBasicTransformSSXMLPart1
[] =
194 "<?xml version=\"1.0\"?>"
195 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >"
196 "<xsl:output method=\"html\"/>\n"
197 "<xsl:template match=\"/\">"
198 "<HTML><BODY><TABLE>"
199 " <xsl:apply-templates select='document(\"";
201 static const CHAR szBasicTransformSSXMLPart2
[] =
203 " <xsl:sort select=\"cost\"/><xsl:sort select=\"name\"/>"
204 " </xsl:apply-templates>"
205 "</TABLE></BODY></HTML>"
207 "<xsl:template match=\"bottle\">"
208 " <TR><xsl:apply-templates select=\"name\" /><xsl:apply-templates select=\"cost\" /></TR>"
210 "<xsl:template match=\"name\">"
211 " <TD><xsl:apply-templates /></TD>"
213 "<xsl:template match=\"cost\">"
214 " <TD><xsl:apply-templates /></TD>"
218 static const CHAR szBasicTransformXML
[] =
219 "<?xml version=\"1.0\"?><bottle><wine><name>Wine</name><cost>$25.00</cost></wine></bottle>";
221 static const CHAR szBasicTransformOutput
[] =
222 "<HTML><BODY><TABLE><TD>Wine</TD><TD>$25.00</TD></TABLE></BODY></HTML>";
224 static const WCHAR szNonExistentFile
[] = {
225 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
227 static const WCHAR szNonExistentAttribute
[] = {
228 'n','o','n','E','x','i','s','i','t','i','n','g','A','t','t','r','i','b','u','t','e',0
230 static const WCHAR szDocument
[] = {
231 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
234 static const WCHAR szOpen
[] = { 'o','p','e','n',0 };
235 static WCHAR szdl
[] = { 'd','l',0 };
236 static const WCHAR szvr
[] = { 'v','r',0 };
237 static const WCHAR szlc
[] = { 'l','c',0 };
238 static WCHAR szbs
[] = { 'b','s',0 };
239 static const WCHAR szstr1
[] = { 's','t','r','1',0 };
240 static const WCHAR szstr2
[] = { 's','t','r','2',0 };
241 static const WCHAR szstar
[] = { '*',0 };
242 static const WCHAR szfn1_txt
[] = {'f','n','1','.','t','x','t',0};
244 static WCHAR szComment
[] = {'A',' ','C','o','m','m','e','n','t',0 };
245 static WCHAR szCommentXML
[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
246 static WCHAR szCommentNodeText
[] = {'#','c','o','m','m','e','n','t',0 };
248 static WCHAR szElement
[] = {'E','l','e','T','e','s','t', 0 };
249 static WCHAR szElementXML
[] = {'<','E','l','e','T','e','s','t','/','>',0 };
250 static WCHAR szElementXML2
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
251 static WCHAR szElementXML3
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
252 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
253 static WCHAR szElementXML4
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
254 '&','a','m','p',';','x',' ',0x2103,'<','/','E','l','e','T','e','s','t','>',0 };
256 static WCHAR szAttribute
[] = {'A','t','t','r',0 };
257 static WCHAR szAttributeXML
[] = {'A','t','t','r','=','"','"',0 };
259 static WCHAR szCData
[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
260 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
261 static WCHAR szCDataXML
[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
262 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
264 static WCHAR szCDataNodeText
[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
265 static WCHAR szDocFragmentText
[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
267 static WCHAR szEntityRef
[] = {'e','n','t','i','t','y','r','e','f',0 };
268 static WCHAR szEntityRefXML
[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
269 static WCHAR szStrangeChars
[] = {'&','x',' ',0x2103, 0};
271 #define expect_bstr_eq_and_free(bstr, expect) { \
272 BSTR bstrExp = alloc_str_from_narrow(expect); \
273 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
274 SysFreeString(bstr); \
275 SysFreeString(bstrExp); \
278 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
280 #define ole_check(expr) { \
282 ok(r == S_OK, #expr " returned %x\n", r); \
285 #define ole_expect(expr, expect) { \
287 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
290 #define double_eq(x, y) ok((x)-(y)<=1e-14*(x) && (x)-(y)>=-1e-14*(x), "expected %.16g, got %.16g\n", x, y)
292 static BSTR
alloc_str_from_narrow(const char *str
)
294 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
295 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
296 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
300 BSTR alloced_bstrs
[256];
301 int alloced_bstrs_count
= 0;
303 static BSTR
_bstr_(const char *str
)
305 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
306 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
307 return alloced_bstrs
[alloced_bstrs_count
++];
310 static void free_bstrs(void)
313 for (i
= 0; i
< alloced_bstrs_count
; i
++)
314 SysFreeString(alloced_bstrs
[i
]);
315 alloced_bstrs_count
= 0;
318 static VARIANT
_variantbstr_(const char *str
)
322 V_BSTR(&v
) = _bstr_(str
);
326 static BOOL
compareIgnoreReturns(BSTR sLeft
, BSTR sRight
)
330 while (*sLeft
== '\r' || *sLeft
== '\n') sLeft
++;
331 while (*sRight
== '\r' || *sRight
== '\n') sRight
++;
332 if (*sLeft
!= *sRight
) return FALSE
;
333 if (!*sLeft
) return TRUE
;
339 static BOOL
compareIgnoreReturnsWhitespace(BSTR sLeft
, BSTR sRight
)
341 /* MSXML3 inserts whitespace where as libxml doesn't. */
344 while (*sLeft
== '\r' || *sLeft
== '\n' || *sLeft
== ' ') sLeft
++;
345 while (*sRight
== '\r' || *sRight
== '\n' || *sRight
== ' ') sRight
++;
346 if (*sLeft
!= *sRight
) return FALSE
;
347 if (!*sLeft
) return TRUE
;
353 static void get_str_for_type(DOMNodeType type
, char *buf
)
367 wsprintfA(buf
, "[%d]", type
);
371 #define test_disp(u) _test_disp(__LINE__,u)
372 static void _test_disp(unsigned line
, IUnknown
*unk
)
374 DISPID dispid
= DISPID_XMLDOM_NODELIST_RESET
;
382 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
383 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatch: %08x\n", hres
);
388 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
389 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
390 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
392 sName
= SysAllocString( szstar
);
393 hres
= IDispatchEx_DeleteMemberByName(dispex
, sName
, fdexNameCaseSensitive
);
394 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
395 SysFreeString( sName
);
397 hres
= IDispatchEx_DeleteMemberByDispID(dispex
, dispid
);
398 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
400 hres
= IDispatchEx_GetMemberProperties(dispex
, dispid
, grfdexPropCanAll
, &dwProps
);
401 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
402 ok(dwProps
== 0, "expected 0 got %d\n", dwProps
);
404 hres
= IDispatchEx_GetMemberName(dispex
, dispid
, &sName
);
405 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
407 SysFreeString(sName
);
409 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumDefault
, DISPID_XMLDOM_NODELIST_RESET
, &dispid
);
410 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
412 hres
= IDispatchEx_GetNameSpaceParent(dispex
, &pUnk
);
413 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
414 if(hres
== S_OK
&& pUnk
)
415 IUnknown_Release(pUnk
);
417 IDispatchEx_Release(dispex
);
420 static int get_node_position(IXMLDOMNode
*node
)
425 IXMLDOMNode_AddRef(node
);
428 IXMLDOMNode
*new_node
;
431 r
= IXMLDOMNode_get_previousSibling(node
, &new_node
);
432 ok(SUCCEEDED(r
), "get_previousSibling failed\n");
433 IXMLDOMNode_Release(node
);
439 static void node_to_string(IXMLDOMNode
*node
, char *buf
)
446 lstrcpyA(buf
, "(null)");
450 IXMLDOMNode_AddRef(node
);
453 IXMLDOMNode
*new_node
;
455 ole_check(IXMLDOMNode_get_nodeType(node
, &type
));
456 get_str_for_type(type
, buf
);
459 if (type
== NODE_ATTRIBUTE
)
462 ole_check(IXMLDOMNode_get_nodeName(node
, &bstr
));
464 wsprintfA(buf
, "%ws", bstr
);
469 r
= IXMLDOMNode_selectSingleNode(node
, _bstr_(".."), &new_node
);
473 int pos
= get_node_position(node
);
474 DOMNodeType parent_type
= NODE_INVALID
;
475 r
= IXMLDOMNode_get_parentNode(node
, &new_node
);
477 /* currently wine doesn't create a node for the <?xml ... ?>. To be able to test query
478 * results we "fix" it */
480 ole_check(IXMLDOMNode_get_nodeType(new_node
, &parent_type
));
481 if ((parent_type
== NODE_DOCUMENT
) && type
!= NODE_PROCESSING_INSTRUCTION
&& pos
==1)
483 todo_wine
ok(FALSE
, "The first child of the document node in MSXML is the <?xml ... ?> processing instruction\n");
486 wsprintf(buf
, "%d", pos
);
490 ok(SUCCEEDED(r
), "get_parentNode failed (%08x)\n", r
);
491 IXMLDOMNode_Release(node
);
500 static char *list_to_string(IXMLDOMNodeList
*list
)
502 static char buf
[4096];
509 lstrcpyA(buf
, "(null)");
512 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
513 for (i
= 0; i
< len
; i
++)
518 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
519 node_to_string(node
, pos
);
521 IXMLDOMNode_Release(node
);
527 #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); }
528 #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); }
530 static void test_domdoc( void )
533 IXMLDOMDocument
*doc
= NULL
;
534 IXMLDOMParseError
*error
;
535 IXMLDOMElement
*element
= NULL
;
537 IXMLDOMText
*nodetext
= NULL
;
538 IXMLDOMComment
*node_comment
= NULL
;
539 IXMLDOMAttribute
*node_attr
= NULL
;
540 IXMLDOMNode
*nodeChild
= NULL
;
541 IXMLDOMProcessingInstruction
*nodePI
= NULL
;
542 ISupportErrorInfo
*support_error
= NULL
;
550 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
551 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
552 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
556 test_disp((IUnknown
*)doc
);
560 /* crashes on native */
561 r
= IXMLDOMDocument_loadXML( doc
, (BSTR
)0x1, NULL
);
564 /* try some stupid things */
565 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
566 ok( r
== S_FALSE
, "loadXML succeeded\n");
569 r
= IXMLDOMDocument_loadXML( doc
, NULL
, &b
);
570 ok( r
== S_FALSE
, "loadXML succeeded\n");
571 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
573 /* try to load a document from a nonexistent file */
575 str
= SysAllocString( szNonExistentFile
);
577 V_VT(&var
) = VT_BSTR
;
580 r
= IXMLDOMDocument_load( doc
, var
, &b
);
581 ok( r
== S_FALSE
, "loadXML succeeded\n");
582 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
583 SysFreeString( str
);
585 /* try load an empty document */
587 str
= SysAllocString( szEmpty
);
588 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
589 ok( r
== S_FALSE
, "loadXML succeeded\n");
590 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
591 SysFreeString( str
);
593 r
= IXMLDOMDocument_get_async( doc
, &b
);
594 ok( r
== S_OK
, "get_async failed (%08x)\n", r
);
595 ok( b
== VARIANT_TRUE
, "Wrong default value\n");
597 /* check that there's no document element */
599 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
600 ok( r
== S_FALSE
, "should be no document element\n");
602 /* try finding a node */
604 str
= SysAllocString( szstr1
);
605 r
= IXMLDOMDocument_selectSingleNode( doc
, str
, &node
);
606 ok( r
== S_FALSE
, "ret %08x\n", r
);
607 SysFreeString( str
);
610 str
= SysAllocString( szIncomplete
);
611 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
612 ok( r
== S_FALSE
, "loadXML succeeded\n");
613 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
614 SysFreeString( str
);
616 /* check that there's no document element */
617 element
= (IXMLDOMElement
*)1;
618 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
619 ok( r
== S_FALSE
, "should be no document element\n");
620 ok( element
== NULL
, "Element should be NULL\n");
622 /* test for BSTR handling, pass broken BSTR */
623 memcpy(&buff
[2], szComplete1
, sizeof(szComplete1
));
624 /* just a big length */
625 *(DWORD
*)buff
= 0xf0f0;
627 r
= IXMLDOMDocument_loadXML( doc
, &buff
[2], &b
);
628 ok( r
== S_OK
, "loadXML failed\n");
629 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
631 /* loadXML ignores the encoding attribute and always expects Unicode */
633 str
= SysAllocString( szComplete6
);
634 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
635 ok( r
== S_OK
, "loadXML failed\n");
636 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
637 SysFreeString( str
);
639 /* try a BSTR containing a Windows-1252 document */
641 str
= SysAllocStringByteLen( szNonUnicodeXML
, sizeof(szNonUnicodeXML
) - 1 );
642 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
643 ok( r
== S_FALSE
, "loadXML succeeded\n");
644 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
645 SysFreeString( str
);
647 /* try to load something valid */
649 str
= SysAllocString( szComplete1
);
650 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
651 ok( r
== S_OK
, "loadXML failed\n");
652 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
653 SysFreeString( str
);
655 /* check if nodename is correct */
656 r
= IXMLDOMDocument_get_nodeName( doc
, NULL
);
657 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
659 /* content doesn't matter here */
661 r
= IXMLDOMDocument_get_nodeName( doc
, &str
);
662 ok ( r
== S_OK
, "get_nodeName wrong code\n");
663 ok ( str
!= NULL
, "str is null\n");
664 ok( !lstrcmpW( str
, szDocument
), "incorrect nodeName\n");
665 SysFreeString( str
);
668 r
= IXMLDOMDocument_put_text( doc
, _bstr_("Should Fail") );
669 ok( r
== E_FAIL
, "ret %08x\n", r
);
671 /* check that there's a document element */
673 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
674 ok( r
== S_OK
, "should be a document element\n");
677 IObjectIdentity
*ident
;
680 test_disp((IUnknown
*)element
);
682 r
= IXMLDOMElement_QueryInterface( element
, &IID_IObjectIdentity
, (LPVOID
*)&ident
);
683 ok( r
== E_NOINTERFACE
, "ret %08x\n", r
);
685 r
= IXMLDOMElement_get_tagName( element
, NULL
);
686 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
688 /* check if the tag is correct */
689 r
= IXMLDOMElement_get_tagName( element
, &tag
);
690 ok( r
== S_OK
, "couldn't get tag name\n");
691 ok( tag
!= NULL
, "tag was null\n");
692 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
693 SysFreeString( tag
);
695 /* figure out what happens if we try to reload the document */
696 str
= SysAllocString( szComplete2
);
697 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
698 ok( r
== S_OK
, "loadXML failed\n");
699 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
700 SysFreeString( str
);
702 /* check if the tag is still correct */
704 r
= IXMLDOMElement_get_tagName( element
, &tag
);
705 ok( r
== S_OK
, "couldn't get tag name\n");
706 ok( tag
!= NULL
, "tag was null\n");
707 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
708 SysFreeString( tag
);
710 IXMLDOMElement_Release( element
);
714 /* as soon as we call loadXML again, the document element will disappear */
716 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
717 ok( r
== S_FALSE
, "loadXML failed\n");
718 ok( b
== 2, "variant modified\n");
719 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
720 ok( r
== S_FALSE
, "should be no document element\n");
722 /* try to load something else simple and valid */
724 str
= SysAllocString( szComplete3
);
725 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
726 ok( r
== S_OK
, "loadXML failed\n");
727 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
728 SysFreeString( str
);
730 /* try something a little more complicated */
732 str
= SysAllocString( szComplete4
);
733 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
734 ok( r
== S_OK
, "loadXML failed\n");
735 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
736 SysFreeString( str
);
738 r
= IXMLDOMDocument_get_parseError( doc
, &error
);
739 ok( r
== S_OK
, "returns %08x\n", r
);
741 r
= IXMLDOMParseError_get_errorCode( error
, &code
);
742 ok( r
== S_FALSE
, "returns %08x\n", r
);
743 ok( code
== 0, "code %d\n", code
);
744 IXMLDOMParseError_Release( error
);
746 /* test createTextNode */
747 r
= IXMLDOMDocument_createTextNode(doc
, _bstr_(""), &nodetext
);
748 ok( r
== S_OK
, "returns %08x\n", r
);
749 IXMLDOMText_Release(nodetext
);
751 str
= SysAllocString( szOpen
);
752 r
= IXMLDOMDocument_createTextNode(doc
, str
, NULL
);
753 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
754 r
= IXMLDOMDocument_createTextNode(doc
, str
, &nodetext
);
755 ok( r
== S_OK
, "returns %08x\n", r
);
756 SysFreeString( str
);
759 IXMLDOMNamedNodeMap
*pAttribs
;
761 r
= IXMLDOMText_QueryInterface(nodetext
, &IID_IXMLDOMElement
, (LPVOID
*)&element
);
762 ok(r
== E_NOINTERFACE
, "ret %08x\n", r
);
764 /* Text Last Child Checks */
765 r
= IXMLDOMText_get_lastChild(nodetext
, NULL
);
766 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
768 nodeChild
= (IXMLDOMNode
*)0x1;
769 r
= IXMLDOMText_get_lastChild(nodetext
, &nodeChild
);
770 ok(r
== S_FALSE
, "ret %08x\n", r
);
771 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
773 /* test get_attributes */
774 r
= IXMLDOMText_get_attributes( nodetext
, NULL
);
775 ok( r
== E_INVALIDARG
, "get_attributes returned wrong code\n");
777 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
778 r
= IXMLDOMText_get_attributes( nodetext
, &pAttribs
);
779 ok(r
== S_FALSE
, "ret %08x\n", r
);
780 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
782 /* test get_dataType */
783 r
= IXMLDOMText_get_dataType(nodetext
, &var
);
784 ok(r
== S_FALSE
, "ret %08x\n", r
);
785 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
788 /* test length property */
789 r
= IXMLDOMText_get_length(nodetext
, NULL
);
790 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
792 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
793 ok(r
== S_OK
, "ret %08x\n", r
);
794 ok(nLength
== 4, "expected 4 got %d\n", nLength
);
796 /* test nodeTypeString */
797 r
= IXMLDOMText_get_nodeTypeString(nodetext
, &str
);
798 ok(r
== S_OK
, "ret %08x\n", r
);
799 ok( !lstrcmpW( str
, _bstr_("text") ), "incorrect nodeTypeString string\n");
803 r
= IXMLDOMText_put_data(nodetext
, _bstr_("This &is a ; test <>\\"));
804 ok(r
== S_OK
, "ret %08x\n", r
);
807 r
= IXMLDOMText_get_data(nodetext
, &str
);
808 ok(r
== S_OK
, "ret %08x\n", r
);
809 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
812 /* Confirm XML text is good */
813 r
= IXMLDOMText_get_xml(nodetext
, &str
);
814 ok(r
== S_OK
, "ret %08x\n", r
);
815 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
818 /* Confirm we get the put_data Text back */
819 r
= IXMLDOMText_get_text(nodetext
, &str
);
820 ok(r
== S_OK
, "ret %08x\n", r
);
821 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
824 /* test substringData */
825 r
= IXMLDOMText_substringData(nodetext
, 0, 4, NULL
);
826 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
828 /* test substringData - Invalid offset */
829 str
= (BSTR
)&szElement
;
830 r
= IXMLDOMText_substringData(nodetext
, -1, 4, &str
);
831 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
832 ok( str
== NULL
, "incorrect string\n");
834 /* test substringData - Invalid offset */
835 str
= (BSTR
)&szElement
;
836 r
= IXMLDOMText_substringData(nodetext
, 30, 0, &str
);
837 ok(r
== S_FALSE
, "ret %08x\n", r
);
838 ok( str
== NULL
, "incorrect string\n");
840 /* test substringData - Invalid size */
841 str
= (BSTR
)&szElement
;
842 r
= IXMLDOMText_substringData(nodetext
, 0, -1, &str
);
843 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
844 ok( str
== NULL
, "incorrect string\n");
846 /* test substringData - Invalid size */
847 str
= (BSTR
)&szElement
;
848 r
= IXMLDOMText_substringData(nodetext
, 2, 0, &str
);
849 ok(r
== S_FALSE
, "ret %08x\n", r
);
850 ok( str
== NULL
, "incorrect string\n");
852 /* test substringData - Start of string */
853 r
= IXMLDOMText_substringData(nodetext
, 0, 4, &str
);
854 ok(r
== S_OK
, "ret %08x\n", r
);
855 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
858 /* test substringData - Middle of string */
859 r
= IXMLDOMText_substringData(nodetext
, 13, 4, &str
);
860 ok(r
== S_OK
, "ret %08x\n", r
);
861 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
864 /* test substringData - End of string */
865 r
= IXMLDOMText_substringData(nodetext
, 20, 4, &str
);
866 ok(r
== S_OK
, "ret %08x\n", r
);
867 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
870 /* test appendData */
871 r
= IXMLDOMText_appendData(nodetext
, NULL
);
872 ok(r
== S_OK
, "ret %08x\n", r
);
874 r
= IXMLDOMText_appendData(nodetext
, _bstr_(""));
875 ok(r
== S_OK
, "ret %08x\n", r
);
877 r
= IXMLDOMText_appendData(nodetext
, _bstr_("Append"));
878 ok(r
== S_OK
, "ret %08x\n", r
);
880 r
= IXMLDOMText_get_text(nodetext
, &str
);
881 ok(r
== S_OK
, "ret %08x\n", r
);
882 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
885 /* test insertData */
886 str
= SysAllocStringLen(NULL
, 0);
887 r
= IXMLDOMText_insertData(nodetext
, -1, str
);
888 ok(r
== S_OK
, "ret %08x\n", r
);
890 r
= IXMLDOMText_insertData(nodetext
, -1, NULL
);
891 ok(r
== S_OK
, "ret %08x\n", r
);
893 r
= IXMLDOMText_insertData(nodetext
, 1000, str
);
894 ok(r
== S_OK
, "ret %08x\n", r
);
896 r
= IXMLDOMText_insertData(nodetext
, 1000, NULL
);
897 ok(r
== S_OK
, "ret %08x\n", r
);
899 r
= IXMLDOMText_insertData(nodetext
, 0, NULL
);
900 ok(r
== S_OK
, "ret %08x\n", r
);
902 r
= IXMLDOMText_insertData(nodetext
, 0, str
);
903 ok(r
== S_OK
, "ret %08x\n", r
);
906 r
= IXMLDOMText_insertData(nodetext
, -1, _bstr_("Inserting"));
907 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
909 r
= IXMLDOMText_insertData(nodetext
, 1000, _bstr_("Inserting"));
910 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
912 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("Begin "));
913 ok(r
== S_OK
, "ret %08x\n", r
);
915 r
= IXMLDOMText_insertData(nodetext
, 17, _bstr_("Middle"));
916 ok(r
== S_OK
, "ret %08x\n", r
);
918 r
= IXMLDOMText_insertData(nodetext
, 39, _bstr_(" End"));
919 ok(r
== S_OK
, "ret %08x\n", r
);
921 r
= IXMLDOMText_get_text(nodetext
, &str
);
922 ok(r
== S_OK
, "ret %08x\n", r
);
923 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
927 /* invalid arguments */
928 r
= IXMLDOMText_deleteData(nodetext
, -1, 1);
929 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
931 r
= IXMLDOMText_deleteData(nodetext
, 0, 0);
932 ok(r
== S_OK
, "ret %08x\n", r
);
934 r
= IXMLDOMText_deleteData(nodetext
, 0, -1);
935 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
937 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
938 ok(r
== S_OK
, "ret %08x\n", r
);
939 ok(nLength
== 43, "expected 43 got %d\n", nLength
);
941 r
= IXMLDOMText_deleteData(nodetext
, nLength
, 1);
942 ok(r
== S_OK
, "ret %08x\n", r
);
944 r
= IXMLDOMText_deleteData(nodetext
, nLength
+1, 1);
945 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
947 /* delete from start */
948 r
= IXMLDOMText_deleteData(nodetext
, 0, 5);
949 ok(r
== S_OK
, "ret %08x\n", r
);
951 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
952 ok(r
== S_OK
, "ret %08x\n", r
);
953 ok(nLength
== 38, "expected 38 got %d\n", nLength
);
955 r
= IXMLDOMText_get_text(nodetext
, &str
);
956 ok(r
== S_OK
, "ret %08x\n", r
);
957 /* whitespace preserving needs to be handled here */
958 todo_wine
ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
961 /* delete from end */
962 r
= IXMLDOMText_deleteData(nodetext
, 35, 3);
963 ok(r
== S_OK
, "ret %08x\n", r
);
965 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
966 ok(r
== S_OK
, "ret %08x\n", r
);
967 ok(nLength
== 35, "expected 35 got %d\n", nLength
);
969 r
= IXMLDOMText_get_text(nodetext
, &str
);
970 ok(r
== S_OK
, "ret %08x\n", r
);
971 todo_wine
ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append") ), "incorrect get_text string\n");
974 /* delete from inside */
975 r
= IXMLDOMText_deleteData(nodetext
, 1, 33);
976 ok(r
== S_OK
, "ret %08x\n", r
);
978 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
979 ok(r
== S_OK
, "ret %08x\n", r
);
980 ok(nLength
== 2, "expected 2 got %d\n", nLength
);
982 r
= IXMLDOMText_get_text(nodetext
, &str
);
983 ok(r
== S_OK
, "ret %08x\n", r
);
984 todo_wine
ok( !lstrcmpW( str
, _bstr_("") ), "incorrect get_text string\n");
987 /* delete whole data ... */
988 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
989 ok(r
== S_OK
, "ret %08x\n", r
);
991 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
992 ok(r
== S_OK
, "ret %08x\n", r
);
993 /* ... and try again with empty string */
994 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
995 ok(r
== S_OK
, "ret %08x\n", r
);
998 V_VT(&var
) = VT_BSTR
;
999 V_BSTR(&var
) = SysAllocString(szstr1
);
1000 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
1001 ok(r
== S_OK
, "ret %08x\n", r
);
1004 r
= IXMLDOMText_get_text(nodetext
, &str
);
1005 ok(r
== S_OK
, "ret %08x\n", r
);
1006 ok( !lstrcmpW( str
, szstr1
), "incorrect get_text string\n");
1012 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
1013 ok(r
== S_OK
, "ret %08x\n", r
);
1016 r
= IXMLDOMText_get_text(nodetext
, &str
);
1017 ok(r
== S_OK
, "ret %08x\n", r
);
1018 ok( !lstrcmpW( str
, _bstr_("99") ), "incorrect get_text string\n");
1021 /* ::replaceData() */
1022 V_VT(&var
) = VT_BSTR
;
1023 V_BSTR(&var
) = SysAllocString(szstr1
);
1024 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
1025 ok(r
== S_OK
, "ret %08x\n", r
);
1028 r
= IXMLDOMText_replaceData(nodetext
, 6, 0, NULL
);
1029 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1030 r
= IXMLDOMText_get_text(nodetext
, &str
);
1031 ok(r
== S_OK
, "ret %08x\n", r
);
1032 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
1035 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, NULL
);
1036 ok(r
== S_OK
, "ret %08x\n", r
);
1037 r
= IXMLDOMText_get_text(nodetext
, &str
);
1038 ok(r
== S_OK
, "ret %08x\n", r
);
1039 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
1042 /* NULL pointer means delete */
1043 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, NULL
);
1044 ok(r
== S_OK
, "ret %08x\n", r
);
1045 r
= IXMLDOMText_get_text(nodetext
, &str
);
1046 ok(r
== S_OK
, "ret %08x\n", r
);
1047 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string\n");
1050 /* empty string means delete */
1051 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_(""));
1052 ok(r
== S_OK
, "ret %08x\n", r
);
1053 r
= IXMLDOMText_get_text(nodetext
, &str
);
1054 ok(r
== S_OK
, "ret %08x\n", r
);
1055 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string\n");
1058 /* zero count means insert */
1059 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, _bstr_("a"));
1060 ok(r
== S_OK
, "ret %08x\n", r
);
1061 r
= IXMLDOMText_get_text(nodetext
, &str
);
1062 ok(r
== S_OK
, "ret %08x\n", r
);
1063 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string\n");
1066 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, NULL
);
1067 ok(r
== S_OK
, "ret %08x\n", r
);
1069 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("m"));
1070 ok(r
== S_OK
, "ret %08x\n", r
);
1071 r
= IXMLDOMText_get_text(nodetext
, &str
);
1072 ok(r
== S_OK
, "ret %08x\n", r
);
1073 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string\n");
1076 /* nonempty string, count greater than its length */
1077 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, _bstr_("a1.2"));
1078 ok(r
== S_OK
, "ret %08x\n", r
);
1079 r
= IXMLDOMText_get_text(nodetext
, &str
);
1080 ok(r
== S_OK
, "ret %08x\n", r
);
1081 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string\n");
1084 /* nonempty string, count less than its length */
1085 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_("wine"));
1086 ok(r
== S_OK
, "ret %08x\n", r
);
1087 r
= IXMLDOMText_get_text(nodetext
, &str
);
1088 ok(r
== S_OK
, "ret %08x\n", r
);
1089 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string\n");
1092 IXMLDOMText_Release( nodetext
);
1095 /* test Create Comment */
1096 r
= IXMLDOMDocument_createComment(doc
, NULL
, NULL
);
1097 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1098 node_comment
= (IXMLDOMComment
*)0x1;
1101 r
= IXMLDOMDocument_createComment(doc
, _bstr_(""), &node_comment
);
1102 ok( r
== S_OK
, "returns %08x\n", r
);
1104 r
= IXMLDOMComment_get_data(node_comment
, &str
);
1105 ok( r
== S_OK
, "returns %08x\n", r
);
1106 ok( str
&& SysStringLen(str
) == 0, "expected empty string data\n");
1107 IXMLDOMComment_Release(node_comment
);
1110 r
= IXMLDOMDocument_createComment(doc
, NULL
, &node_comment
);
1111 ok( r
== S_OK
, "returns %08x\n", r
);
1113 r
= IXMLDOMComment_get_data(node_comment
, &str
);
1114 ok( r
== S_OK
, "returns %08x\n", r
);
1115 ok( str
&& (SysStringLen(str
) == 0), "expected empty string data\n");
1116 IXMLDOMComment_Release(node_comment
);
1119 str
= SysAllocString(szComment
);
1120 r
= IXMLDOMDocument_createComment(doc
, str
, &node_comment
);
1122 ok( r
== S_OK
, "returns %08x\n", r
);
1125 /* Last Child Checks */
1126 r
= IXMLDOMComment_get_lastChild(node_comment
, NULL
);
1127 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1129 nodeChild
= (IXMLDOMNode
*)0x1;
1130 r
= IXMLDOMComment_get_lastChild(node_comment
, &nodeChild
);
1131 ok(r
== S_FALSE
, "ret %08x\n", r
);
1132 ok(nodeChild
== NULL
, "pLastChild not NULL\n");
1135 str
= (BSTR
)0xdeadbeef;
1136 IXMLDOMComment_get_baseName(node_comment
, &str
);
1137 ok(r
== S_FALSE
, "ret %08x\n", r
);
1138 ok(str
== NULL
, "Expected NULL\n");
1140 IXMLDOMComment_Release( node_comment
);
1143 /* test Create Attribute */
1144 str
= SysAllocString(szAttribute
);
1145 r
= IXMLDOMDocument_createAttribute(doc
, NULL
, NULL
);
1146 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1147 r
= IXMLDOMDocument_createAttribute(doc
, str
, &node_attr
);
1148 ok( r
== S_OK
, "returns %08x\n", r
);
1149 IXMLDOMText_Release( node_attr
);
1152 /* test Processing Instruction */
1153 str
= SysAllocStringLen(NULL
, 0);
1154 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, NULL
);
1155 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1156 r
= IXMLDOMDocument_createProcessingInstruction(doc
, NULL
, str
, &nodePI
);
1157 ok( r
== E_FAIL
, "returns %08x\n", r
);
1158 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, &nodePI
);
1159 ok( r
== E_FAIL
, "returns %08x\n", r
);
1162 r
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI
);
1163 ok( r
== S_OK
, "returns %08x\n", r
);
1166 /* Last Child Checks */
1167 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, NULL
);
1168 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1170 nodeChild
= (IXMLDOMNode
*)0x1;
1171 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, &nodeChild
);
1172 ok(r
== S_FALSE
, "ret %08x\n", r
);
1173 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
1175 r
= IXMLDOMProcessingInstruction_get_dataType(nodePI
, &var
);
1176 ok(r
== S_FALSE
, "ret %08x\n", r
);
1177 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
1181 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
1182 ok(r
== S_OK
, "ret %08x\n", r
);
1183 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1188 r
= IXMLDOMProcessingInstruction_get_baseName(nodePI
, &str
);
1189 ok(r
== S_OK
, "ret %08x\n", r
);
1190 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1194 r
= IXMLDOMProcessingInstruction_get_target(nodePI
, &str
);
1195 ok(r
== S_OK
, "ret %08x\n", r
);
1196 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect target string\n");
1199 /* test nodeTypeString */
1200 r
= IXMLDOMProcessingInstruction_get_nodeTypeString(nodePI
, &str
);
1201 ok(r
== S_OK
, "ret %08x\n", r
);
1202 ok( !lstrcmpW( str
, _bstr_("processinginstruction") ), "incorrect nodeTypeString string\n");
1205 /* test get_nodeValue */
1206 r
= IXMLDOMProcessingInstruction_get_nodeValue(nodePI
, &var
);
1207 ok(r
== S_OK
, "ret %08x\n", r
);
1208 ok( !lstrcmpW( V_BSTR(&var
), _bstr_("version=\"1.0\"") ), "incorrect data string\n");
1212 r
= IXMLDOMProcessingInstruction_get_data(nodePI
, &str
);
1213 ok(r
== S_OK
, "ret %08x\n", r
);
1214 ok( !lstrcmpW( str
, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
1218 r
= IXMLDOMProcessingInstruction_put_data(nodePI
, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
1219 ok(r
== E_FAIL
, "ret %08x\n", r
);
1222 V_VT(&var
) = VT_BSTR
;
1223 V_BSTR(&var
) = SysAllocString(szOpen
); /* Doesn't matter what the string is, cannot set an xml node. */
1224 r
= IXMLDOMProcessingInstruction_put_nodeValue(nodePI
, var
);
1225 ok(r
== E_FAIL
, "ret %08x\n", r
);
1228 /* test get nodeName */
1229 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
1230 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1231 ok(r
== S_OK
, "ret %08x\n", r
);
1234 IXMLDOMProcessingInstruction_Release(nodePI
);
1237 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_ISupportErrorInfo
, (LPVOID
*)&support_error
);
1238 ok( r
== S_OK
, "ret %08x\n", r
);
1241 r
= ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error
, &IID_IXMLDOMDocument
);
1242 todo_wine
ok( r
== S_OK
, "ret %08x\n", r
);
1243 ISupportErrorInfo_Release( support_error
);
1246 r
= IXMLDOMDocument_Release( doc
);
1247 ok( r
== 0, "document ref count incorrect\n");
1252 static void test_domnode( void )
1255 IXMLDOMDocument
*doc
= NULL
, *owner
= NULL
;
1256 IXMLDOMElement
*element
= NULL
;
1257 IXMLDOMNamedNodeMap
*map
= NULL
;
1258 IXMLDOMNode
*node
= NULL
, *next
= NULL
;
1259 IXMLDOMNodeList
*list
= NULL
;
1260 IXMLDOMAttribute
*attr
= NULL
;
1261 DOMNodeType type
= NODE_INVALID
;
1267 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1268 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1269 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
1274 str
= SysAllocString( szComplete4
);
1275 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1276 ok( r
== S_OK
, "loadXML failed\n");
1277 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1278 SysFreeString( str
);
1281 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
1282 ok( r
== S_OK
, "hasChildNoes bad return\n");
1283 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1285 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1286 ok( r
== S_OK
, "should be a document element\n");
1287 ok( element
!= NULL
, "should be an element\n");
1290 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
1292 r
= IXMLDOMNode_get_nodeValue( doc
, NULL
);
1293 ok(r
== E_INVALIDARG
, "get_nodeValue ret %08x\n", r
);
1295 r
= IXMLDOMNode_get_nodeValue( doc
, &var
);
1296 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
1297 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
1298 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
1303 r
= IXMLDOMNode_get_ownerDocument( element
, &owner
);
1304 ok( r
== S_OK
, "get_ownerDocument return code\n");
1305 ok( owner
!= doc
, "get_ownerDocument return\n");
1306 IXMLDOMDocument_Release(owner
);
1308 type
= NODE_INVALID
;
1309 r
= IXMLDOMNode_get_nodeType( element
, &type
);
1310 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1311 ok( type
== NODE_ELEMENT
, "node not an element\n");
1314 r
= IXMLDOMNode_get_baseName( element
, &str
);
1315 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1316 ok( lstrcmpW(str
,szlc
) == 0, "basename was wrong\n");
1319 /* check if nodename is correct */
1320 r
= IXMLDOMElement_get_nodeName( element
, NULL
);
1321 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1323 /* content doesn't matter here */
1325 r
= IXMLDOMElement_get_nodeName( element
, &str
);
1326 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1327 ok ( str
!= NULL
, "str is null\n");
1328 ok( !lstrcmpW( str
, szlc
), "incorrect nodeName\n");
1329 SysFreeString( str
);
1331 str
= SysAllocString( szNonExistentFile
);
1333 V_I4(&var
) = 0x1234;
1334 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1335 ok( r
== E_FAIL
, "getAttribute ret %08x\n", r
);
1336 ok( V_VT(&var
) == VT_NULL
|| V_VT(&var
) == VT_EMPTY
, "vt = %x\n", V_VT(&var
));
1339 r
= IXMLDOMElement_getAttributeNode( element
, str
, NULL
);
1340 ok( r
== E_FAIL
, "getAttributeNode ret %08x\n", r
);
1342 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
1343 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1344 ok( r
== E_FAIL
, "getAttributeNode ret %08x\n", r
);
1345 ok( attr
== NULL
, "getAttributeNode ret %p, expected NULL\n", attr
);
1346 SysFreeString( str
);
1348 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
1349 str
= SysAllocString( szNonExistentAttribute
);
1350 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1351 ok( r
== S_FALSE
, "getAttributeNode ret %08x\n", r
);
1352 ok( attr
== NULL
, "getAttributeNode ret %p, expected NULL\n", attr
);
1353 SysFreeString( str
);
1355 str
= SysAllocString( szdl
);
1357 V_I4(&var
) = 0x1234;
1358 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1359 ok( r
== S_OK
, "getAttribute ret %08x\n", r
);
1360 ok( V_VT(&var
) == VT_BSTR
, "vt = %x\n", V_VT(&var
));
1361 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "wrong attr value\n");
1362 VariantClear( &var
);
1364 r
= IXMLDOMElement_getAttribute( element
, NULL
, &var
);
1365 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1367 r
= IXMLDOMElement_getAttribute( element
, str
, NULL
);
1368 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1371 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1372 ok( r
== S_OK
, "GetAttributeNode ret %08x\n", r
);
1373 ok( attr
!= NULL
, "getAttributeNode returned NULL\n" );
1376 r
= IXMLDOMAttribute_get_parentNode( attr
, NULL
);
1377 ok( r
== E_INVALIDARG
, "Expected E_INVALIDARG, ret %08x\n", r
);
1379 /* attribute doesn't have a parent in msxml interpretation */
1380 node
= (IXMLDOMNode
*)0xdeadbeef;
1381 r
= IXMLDOMAttribute_get_parentNode( attr
, &node
);
1382 ok( r
== S_FALSE
, "Expected S_FALSE, ret %08x\n", r
);
1383 ok( node
== NULL
, "Expected NULL, got %p\n", node
);
1385 IXMLDOMAttribute_Release(attr
);
1388 SysFreeString( str
);
1390 r
= IXMLDOMElement_get_attributes( element
, &map
);
1391 ok( r
== S_OK
, "get_attributes returned wrong code\n");
1392 ok( map
!= NULL
, "should be attributes\n");
1395 r
= IXMLDOMNode_hasChildNodes( element
, &b
);
1396 ok( r
== S_OK
, "hasChildNoes bad return\n");
1397 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1400 ok( FALSE
, "no element\n");
1404 ISupportErrorInfo
*support_error
;
1405 r
= IXMLDOMNamedNodeMap_QueryInterface( map
, &IID_ISupportErrorInfo
, (LPVOID
*)&support_error
);
1406 ok( r
== S_OK
, "ret %08x\n", r
);
1408 r
= ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error
, &IID_IXMLDOMNamedNodeMap
);
1411 ok( r
== S_OK
, "ret %08x\n", r
);
1413 ISupportErrorInfo_Release( support_error
);
1415 str
= SysAllocString( szdl
);
1416 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
1417 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1418 ok( node
!= NULL
, "should be attributes\n");
1419 IXMLDOMNode_Release(node
);
1420 SysFreeString( str
);
1422 str
= SysAllocString( szdl
);
1423 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, NULL
);
1424 ok( r
== E_INVALIDARG
, "getNamedItem should return E_INVALIDARG\n");
1425 SysFreeString( str
);
1427 /* something that isn't in szComplete4 */
1428 str
= SysAllocString( szOpen
);
1429 node
= (IXMLDOMNode
*) 1;
1430 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
1431 ok( r
== S_FALSE
, "getNamedItem found a node that wasn't there\n");
1432 ok( node
== NULL
, "getNamedItem should have returned NULL\n");
1433 SysFreeString( str
);
1435 /* test indexed access of attributes */
1436 r
= IXMLDOMNamedNodeMap_get_length( map
, NULL
);
1437 ok ( r
== E_INVALIDARG
, "get_length should return E_INVALIDARG\n");
1439 r
= IXMLDOMNamedNodeMap_get_length( map
, &count
);
1440 ok ( r
== S_OK
, "get_length wrong code\n");
1441 ok ( count
== 1, "get_length != 1\n");
1444 r
= IXMLDOMNamedNodeMap_get_item( map
, -1, &node
);
1445 ok ( r
== S_FALSE
, "get_item (-1) wrong code\n");
1446 ok ( node
== NULL
, "there is no node\n");
1449 r
= IXMLDOMNamedNodeMap_get_item( map
, 1, &node
);
1450 ok ( r
== S_FALSE
, "get_item (1) wrong code\n");
1451 ok ( node
== NULL
, "there is no attribute\n");
1454 r
= IXMLDOMNamedNodeMap_get_item( map
, 0, &node
);
1455 ok ( r
== S_OK
, "get_item (0) wrong code\n");
1456 ok ( node
!= NULL
, "should be attribute\n");
1458 r
= IXMLDOMNode_get_nodeName( node
, NULL
);
1459 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1461 /* content doesn't matter here */
1463 r
= IXMLDOMNode_get_nodeName( node
, &str
);
1464 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1465 ok ( str
!= NULL
, "str is null\n");
1466 ok( !lstrcmpW( str
, szdl
), "incorrect node name\n");
1467 SysFreeString( str
);
1469 /* test sequential access of attributes */
1471 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1472 ok ( r
== S_OK
, "nextNode (first time) wrong code\n");
1473 ok ( node
!= NULL
, "nextNode, should be attribute\n");
1475 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1476 ok ( r
!= S_OK
, "nextNode (second time) wrong code\n");
1477 ok ( node
== NULL
, "nextNode, there is no attribute\n");
1479 r
= IXMLDOMNamedNodeMap_reset( map
);
1480 ok ( r
== S_OK
, "reset should return S_OK\n");
1482 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1483 ok ( r
== S_OK
, "nextNode (third time) wrong code\n");
1484 ok ( node
!= NULL
, "nextNode, should be attribute\n");
1487 ok( FALSE
, "no map\n");
1491 type
= NODE_INVALID
;
1492 r
= IXMLDOMNode_get_nodeType( node
, &type
);
1493 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1494 ok( type
== NODE_ATTRIBUTE
, "node not an attribute\n");
1497 r
= IXMLDOMNode_get_baseName( node
, NULL
);
1498 ok( r
== E_INVALIDARG
, "get_baseName returned wrong code\n");
1501 r
= IXMLDOMNode_get_baseName( node
, &str
);
1502 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1503 ok( lstrcmpW(str
,szdl
) == 0, "basename was wrong\n");
1504 SysFreeString( str
);
1506 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
1507 ok( r
== S_OK
, "returns %08x\n", r
);
1508 ok( V_VT(&var
) == VT_BSTR
, "vt %x\n", V_VT(&var
));
1509 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "nodeValue incorrect\n");
1512 r
= IXMLDOMNode_get_childNodes( node
, NULL
);
1513 ok( r
== E_INVALIDARG
, "get_childNodes returned wrong code\n");
1515 r
= IXMLDOMNode_get_childNodes( node
, &list
);
1516 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
1520 r
= IXMLDOMNodeList_nextNode( list
, &next
);
1521 ok( r
== S_OK
, "nextNode returned wrong code\n");
1524 ok( FALSE
, "no childlist\n");
1529 r
= IXMLDOMNode_hasChildNodes( next
, &b
);
1530 ok( r
== S_FALSE
, "hasChildNoes bad return\n");
1531 ok( b
== VARIANT_FALSE
, "hasChildNoes wrong result\n");
1533 type
= NODE_INVALID
;
1534 r
= IXMLDOMNode_get_nodeType( next
, &type
);
1535 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1536 ok( type
== NODE_TEXT
, "node not text\n");
1539 r
= IXMLDOMNode_get_baseName( next
, &str
);
1540 ok( r
== S_FALSE
, "get_baseName returned wrong code\n");
1541 ok( str
== NULL
, "basename was wrong\n");
1545 ok( FALSE
, "no next\n");
1548 IXMLDOMNode_Release( next
);
1551 IXMLDOMNodeList_Release( list
);
1554 IXMLDOMNode_Release( node
);
1557 ok( FALSE
, "no node\n");
1561 IXMLDOMNamedNodeMap_Release( map
);
1563 /* now traverse the tree from the root element */
1566 r
= IXMLDOMNode_get_childNodes( element
, &list
);
1567 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
1569 /* using get_item for child list doesn't advance the position */
1570 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
1571 expect_node(node
, "E2.E2.D1");
1572 IXMLDOMNode_Release(node
);
1573 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
1574 expect_node(node
, "E1.E2.D1");
1575 IXMLDOMNode_Release(node
);
1576 ole_check(IXMLDOMNodeList_reset(list
));
1578 IXMLDOMNodeList_AddRef(list
);
1579 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
1580 ole_check(IXMLDOMNodeList_reset(list
));
1582 node
= (void*)0xdeadbeef;
1583 str
= SysAllocString(szdl
);
1584 r
= IXMLDOMNode_selectSingleNode( element
, str
, &node
);
1586 ok( r
== S_FALSE
, "ret %08x\n", r
);
1587 ok( node
== NULL
, "node %p\n", node
);
1589 str
= SysAllocString(szbs
);
1590 r
= IXMLDOMNode_selectSingleNode( element
, str
, &node
);
1592 ok( r
== S_OK
, "ret %08x\n", r
);
1593 r
= IXMLDOMNode_Release( node
);
1594 ok( r
== 0, "ret %08x\n", r
);
1597 ok( FALSE
, "no element\n");
1601 r
= IXMLDOMNodeList_QueryInterface(list
, &IID_IDispatch
, NULL
);
1602 ok( r
== E_INVALIDARG
|| r
== E_POINTER
, "ret %08x\n", r
);
1604 r
= IXMLDOMNodeList_get_item(list
, 0, NULL
);
1605 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1607 r
= IXMLDOMNodeList_get_length(list
, NULL
);
1608 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1610 r
= IXMLDOMNodeList_get_length( list
, &count
);
1611 ok( r
== S_OK
, "get_length returns %08x\n", r
);
1612 ok( count
== 4, "get_length got %d\n", count
);
1614 r
= IXMLDOMNodeList_nextNode(list
, NULL
);
1615 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1617 r
= IXMLDOMNodeList_nextNode( list
, &node
);
1618 ok( r
== S_OK
, "nextNode returned wrong code\n");
1621 ok( FALSE
, "no list\n");
1625 type
= NODE_INVALID
;
1626 r
= IXMLDOMNode_get_nodeType( node
, &type
);
1627 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1628 ok( type
== NODE_ELEMENT
, "node not text\n");
1631 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
1632 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
1633 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
1634 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
1635 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
1637 r
= IXMLDOMNode_hasChildNodes( node
, NULL
);
1638 ok( r
== E_INVALIDARG
, "hasChildNoes bad return\n");
1641 r
= IXMLDOMNode_hasChildNodes( node
, &b
);
1642 ok( r
== S_OK
, "hasChildNoes bad return\n");
1643 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1646 r
= IXMLDOMNode_get_baseName( node
, &str
);
1647 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1648 ok( lstrcmpW(str
,szbs
) == 0, "basename was wrong\n");
1652 ok( FALSE
, "no node\n");
1655 IXMLDOMNode_Release( node
);
1657 IXMLDOMNodeList_Release( list
);
1659 IXMLDOMElement_Release( element
);
1662 str
= SysAllocString( szComplete5
);
1663 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1664 ok( r
== S_OK
, "loadXML failed\n");
1665 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1666 SysFreeString( str
);
1669 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
1670 ok( r
== S_OK
, "hasChildNoes bad return\n");
1671 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1673 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1674 ok( r
== S_OK
, "should be a document element\n");
1675 ok( element
!= NULL
, "should be an element\n");
1679 static const WCHAR szSSearch
[] = {'S',':','s','e','a','r','c','h',0};
1682 /* check if the tag is correct */
1683 r
= IXMLDOMElement_get_tagName( element
, &tag
);
1684 ok( r
== S_OK
, "couldn't get tag name\n");
1685 ok( tag
!= NULL
, "tag was null\n");
1686 ok( !lstrcmpW( tag
, szSSearch
), "incorrect tag name\n");
1687 SysFreeString( tag
);
1691 IXMLDOMElement_Release( element
);
1692 ok(IXMLDOMDocument_Release( doc
) == 0, "document is not destroyed\n");
1695 static void test_refs(void)
1700 IXMLDOMDocument
*doc
= NULL
;
1701 IXMLDOMElement
*element
= NULL
;
1702 IXMLDOMNode
*node
= NULL
, *node2
;
1703 IXMLDOMNodeList
*node_list
= NULL
;
1705 IUnknown
*unk
, *unk2
;
1707 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1708 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1709 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
1712 ref
= IXMLDOMDocument_Release(doc
);
1713 ok( ref
== 0, "ref %d\n", ref
);
1715 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1716 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1717 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
1721 str
= SysAllocString( szComplete4
);
1722 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1723 ok( r
== S_OK
, "loadXML failed\n");
1724 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1725 SysFreeString( str
);
1727 ref
= IXMLDOMDocument_AddRef( doc
);
1728 ok( ref
== 2, "ref %d\n", ref
);
1729 ref
= IXMLDOMDocument_AddRef( doc
);
1730 ok( ref
== 3, "ref %d\n", ref
);
1731 IXMLDOMDocument_Release( doc
);
1732 IXMLDOMDocument_Release( doc
);
1734 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1735 ok( r
== S_OK
, "should be a document element\n");
1736 ok( element
!= NULL
, "should be an element\n");
1738 ref
= IXMLDOMDocument_AddRef( doc
);
1739 ok( ref
== 2, "ref %d\n", ref
);
1740 IXMLDOMDocument_Release( doc
);
1742 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
1743 ok( r
== S_OK
, "rets %08x\n", r
);
1745 ref
= IXMLDOMNodeList_AddRef( node_list
);
1746 ok( ref
== 2, "ref %d\n", ref
);
1747 IXMLDOMNodeList_Release( node_list
);
1749 IXMLDOMNodeList_get_item( node_list
, 0, &node
);
1750 ok( r
== S_OK
, "rets %08x\n", r
);
1752 IXMLDOMNodeList_get_item( node_list
, 0, &node2
);
1753 ok( r
== S_OK
, "rets %08x\n", r
);
1755 ref
= IXMLDOMNode_AddRef( node
);
1756 ok( ref
== 2, "ref %d\n", ref
);
1757 IXMLDOMNode_Release( node
);
1759 ref
= IXMLDOMNode_Release( node
);
1760 ok( ref
== 0, "ref %d\n", ref
);
1761 ref
= IXMLDOMNode_Release( node2
);
1762 ok( ref
== 0, "ref %d\n", ref
);
1764 ref
= IXMLDOMNodeList_Release( node_list
);
1765 ok( ref
== 0, "ref %d\n", ref
);
1767 ok( node
!= node2
, "node %p node2 %p\n", node
, node2
);
1769 ref
= IXMLDOMDocument_Release( doc
);
1770 ok( ref
== 0, "ref %d\n", ref
);
1772 ref
= IXMLDOMElement_AddRef( element
);
1774 ok( ref
== 3, "ref %d\n", ref
);
1776 IXMLDOMElement_Release( element
);
1778 /* IUnknown must be unique however we obtain it */
1779 r
= IXMLDOMElement_QueryInterface( element
, &IID_IUnknown
, (LPVOID
*)&unk
);
1780 ok( r
== S_OK
, "rets %08x\n", r
);
1781 r
= IXMLDOMElement_QueryInterface( element
, &IID_IXMLDOMNode
, (LPVOID
*)&node
);
1782 ok( r
== S_OK
, "rets %08x\n", r
);
1783 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (LPVOID
*)&unk2
);
1784 ok( r
== S_OK
, "rets %08x\n", r
);
1785 ok( unk
== unk2
, "unk %p unk2 %p\n", unk
, unk2
);
1787 IUnknown_Release( unk2
);
1788 IUnknown_Release( unk
);
1789 IXMLDOMNode_Release( node
);
1791 IXMLDOMElement_Release( element
);
1795 static void test_create(void)
1797 static const WCHAR szOne
[] = {'1',0};
1798 static const WCHAR szOneGarbage
[] = {'1','G','a','r','b','a','g','e',0};
1802 IXMLDOMDocument
*doc
;
1803 IXMLDOMElement
*element
;
1804 IXMLDOMComment
*comment
;
1806 IXMLDOMCDATASection
*cdata
;
1807 IXMLDOMNode
*root
, *node
, *child
;
1808 IXMLDOMNamedNodeMap
*attr_map
;
1813 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1814 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1815 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
1819 /* types not supported for creation */
1821 V_I1(&var
) = NODE_DOCUMENT
;
1822 node
= (IXMLDOMNode
*)0x1;
1823 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1824 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1825 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1828 V_I1(&var
) = NODE_DOCUMENT_TYPE
;
1829 node
= (IXMLDOMNode
*)0x1;
1830 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1831 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1832 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1835 V_I1(&var
) = NODE_ENTITY
;
1836 node
= (IXMLDOMNode
*)0x1;
1837 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1838 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1839 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1842 V_I1(&var
) = NODE_NOTATION
;
1843 node
= (IXMLDOMNode
*)0x1;
1844 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1845 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1846 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1850 V_I1(&var
) = NODE_COMMENT
;
1852 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1853 ok( r
== S_OK
, "returns %08x\n", r
);
1854 ok( node
!= NULL
, "\n");
1856 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
1857 ok( r
== S_OK
, "returns %08x\n", r
);
1858 IXMLDOMNode_Release(node
);
1861 r
= IXMLDOMComment_get_data(comment
, &str
);
1862 ok( r
== S_OK
, "returns %08x\n", r
);
1863 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1864 IXMLDOMComment_Release(comment
);
1867 node
= (IXMLDOMNode
*)0x1;
1868 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
1869 ok( r
== S_OK
, "returns %08x\n", r
);
1871 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
1872 ok( r
== S_OK
, "returns %08x\n", r
);
1873 IXMLDOMNode_Release(node
);
1876 r
= IXMLDOMComment_get_data(comment
, &str
);
1877 ok( r
== S_OK
, "returns %08x\n", r
);
1878 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1879 IXMLDOMComment_Release(comment
);
1882 node
= (IXMLDOMNode
*)0x1;
1883 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
1884 ok( r
== S_OK
, "returns %08x\n", r
);
1886 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
1887 ok( r
== S_OK
, "returns %08x\n", r
);
1888 IXMLDOMNode_Release(node
);
1891 r
= IXMLDOMComment_get_data(comment
, &str
);
1892 ok( r
== S_OK
, "returns %08x\n", r
);
1893 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1894 IXMLDOMComment_Release(comment
);
1899 V_I1(&var
) = NODE_TEXT
;
1901 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1902 ok( r
== S_OK
, "returns %08x\n", r
);
1903 ok( node
!= NULL
, "\n");
1905 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
1906 ok( r
== S_OK
, "returns %08x\n", r
);
1907 IXMLDOMNode_Release(node
);
1910 r
= IXMLDOMText_get_data(text
, &str
);
1911 ok( r
== S_OK
, "returns %08x\n", r
);
1912 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1913 IXMLDOMText_Release(text
);
1916 node
= (IXMLDOMNode
*)0x1;
1917 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
1918 ok( r
== S_OK
, "returns %08x\n", r
);
1920 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
1921 ok( r
== S_OK
, "returns %08x\n", r
);
1922 IXMLDOMNode_Release(node
);
1925 r
= IXMLDOMText_get_data(text
, &str
);
1926 ok( r
== S_OK
, "returns %08x\n", r
);
1927 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1928 IXMLDOMText_Release(text
);
1931 node
= (IXMLDOMNode
*)0x1;
1932 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
1933 ok( r
== S_OK
, "returns %08x\n", r
);
1935 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
1936 ok( r
== S_OK
, "returns %08x\n", r
);
1937 IXMLDOMNode_Release(node
);
1940 r
= IXMLDOMText_get_data(text
, &str
);
1941 ok( r
== S_OK
, "returns %08x\n", r
);
1942 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1943 IXMLDOMText_Release(text
);
1946 /* NODE_CDATA_SECTION */
1948 V_I1(&var
) = NODE_CDATA_SECTION
;
1950 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1951 ok( r
== S_OK
, "returns %08x\n", r
);
1952 ok( node
!= NULL
, "\n");
1954 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
1955 ok( r
== S_OK
, "returns %08x\n", r
);
1956 IXMLDOMNode_Release(node
);
1959 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
1960 ok( r
== S_OK
, "returns %08x\n", r
);
1961 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1962 IXMLDOMCDATASection_Release(cdata
);
1965 node
= (IXMLDOMNode
*)0x1;
1966 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
1967 ok( r
== S_OK
, "returns %08x\n", r
);
1969 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
1970 ok( r
== S_OK
, "returns %08x\n", r
);
1971 IXMLDOMNode_Release(node
);
1974 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
1975 ok( r
== S_OK
, "returns %08x\n", r
);
1976 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1977 IXMLDOMCDATASection_Release(cdata
);
1980 node
= (IXMLDOMNode
*)0x1;
1981 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
1982 ok( r
== S_OK
, "returns %08x\n", r
);
1984 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
1985 ok( r
== S_OK
, "returns %08x\n", r
);
1986 IXMLDOMNode_Release(node
);
1989 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
1990 ok( r
== S_OK
, "returns %08x\n", r
);
1991 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1992 IXMLDOMCDATASection_Release(cdata
);
1995 /* NODE_ATTRIBUTE */
1997 V_I1(&var
) = NODE_ATTRIBUTE
;
1998 node
= (IXMLDOMNode
*)0x1;
1999 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2000 ok( r
== E_FAIL
, "returns %08x\n", r
);
2001 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2004 V_I1(&var
) = NODE_ATTRIBUTE
;
2005 node
= (IXMLDOMNode
*)0x1;
2006 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2007 ok( r
== E_FAIL
, "returns %08x\n", r
);
2008 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2011 V_I1(&var
) = NODE_ATTRIBUTE
;
2012 str
= SysAllocString( szlc
);
2013 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2014 ok( r
== S_OK
, "returns %08x\n", r
);
2015 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2018 /* a name is required for attribute, try a BSTR with first null wchar */
2020 V_I1(&var
) = NODE_ATTRIBUTE
;
2021 str
= SysAllocString( szstr1
);
2023 node
= (IXMLDOMNode
*)0x1;
2024 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2025 ok( r
== E_FAIL
, "returns %08x\n", r
);
2026 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2029 /* NODE_PROCESSING_INSTRUCTION */
2031 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
2032 node
= (IXMLDOMNode
*)0x1;
2033 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2034 ok( r
== E_FAIL
, "returns %08x\n", r
);
2035 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2038 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
2039 node
= (IXMLDOMNode
*)0x1;
2040 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2041 ok( r
== E_FAIL
, "returns %08x\n", r
);
2042 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2045 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
2046 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("pi"), NULL
, NULL
);
2047 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2049 /* NODE_ENTITY_REFERENCE */
2051 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
2052 node
= (IXMLDOMNode
*)0x1;
2053 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2054 ok( r
== E_FAIL
, "returns %08x\n", r
);
2055 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2058 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
2059 node
= (IXMLDOMNode
*)0x1;
2060 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2061 ok( r
== E_FAIL
, "returns %08x\n", r
);
2062 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2066 V_I1(&var
) = NODE_ELEMENT
;
2067 node
= (IXMLDOMNode
*)0x1;
2068 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2069 ok( r
== E_FAIL
, "returns %08x\n", r
);
2070 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2073 V_I1(&var
) = NODE_ELEMENT
;
2074 node
= (IXMLDOMNode
*)0x1;
2075 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2076 ok( r
== E_FAIL
, "returns %08x\n", r
);
2077 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2080 V_I1(&var
) = NODE_ELEMENT
;
2081 str
= SysAllocString( szlc
);
2082 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2083 ok( r
== S_OK
, "returns %08x\n", r
);
2084 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2087 V_I1(&var
) = NODE_ELEMENT
;
2088 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, NULL
);
2089 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2092 V_R4(&var
) = NODE_ELEMENT
;
2093 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2094 ok( r
== S_OK
, "returns %08x\n", r
);
2095 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2097 V_VT(&var
) = VT_BSTR
;
2098 V_BSTR(&var
) = SysAllocString( szOne
);
2099 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2100 ok( r
== S_OK
, "returns %08x\n", r
);
2101 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2104 V_VT(&var
) = VT_BSTR
;
2105 V_BSTR(&var
) = SysAllocString( szOneGarbage
);
2106 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2107 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2108 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2112 V_I4(&var
) = NODE_ELEMENT
;
2113 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2114 ok( r
== S_OK
, "returns %08x\n", r
);
2115 r
= IXMLDOMDocument_appendChild( doc
, node
, &root
);
2116 ok( r
== S_OK
, "returns %08x\n", r
);
2117 ok( node
== root
, "%p %p\n", node
, root
);
2119 ref
= IXMLDOMNode_AddRef( node
);
2120 ok(ref
== 3, "ref %d\n", ref
);
2121 IXMLDOMNode_Release( node
);
2123 ref
= IXMLDOMNode_Release( node
);
2124 ok(ref
== 1, "ref %d\n", ref
);
2125 SysFreeString( str
);
2128 V_I4(&var
) = NODE_ELEMENT
;
2129 str
= SysAllocString( szbs
);
2130 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2131 ok( r
== S_OK
, "returns %08x\n", r
);
2132 SysFreeString( str
);
2134 ref
= IXMLDOMNode_AddRef( node
);
2135 ok(ref
== 2, "ref = %d\n", ref
);
2136 IXMLDOMNode_Release( node
);
2138 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (LPVOID
*)&unk
);
2139 ok( r
== S_OK
, "returns %08x\n", r
);
2141 ref
= IXMLDOMNode_AddRef( unk
);
2142 ok(ref
== 3, "ref = %d\n", ref
);
2143 IXMLDOMNode_Release( unk
);
2145 V_VT(&var
) = VT_EMPTY
;
2146 r
= IXMLDOMNode_insertBefore( root
, (IXMLDOMNode
*)unk
, var
, &child
);
2147 ok( r
== S_OK
, "returns %08x\n", r
);
2148 ok( unk
== (IUnknown
*)child
, "%p %p\n", unk
, child
);
2149 IXMLDOMNode_Release( child
);
2150 IUnknown_Release( unk
);
2153 V_VT(&var
) = VT_NULL
;
2154 V_DISPATCH(&var
) = (IDispatch
*)node
;
2155 r
= IXMLDOMNode_insertBefore( root
, node
, var
, &child
);
2156 ok( r
== S_OK
, "returns %08x\n", r
);
2157 ok( node
== child
, "%p %p\n", node
, child
);
2158 IXMLDOMNode_Release( child
);
2161 V_VT(&var
) = VT_NULL
;
2162 V_DISPATCH(&var
) = (IDispatch
*)node
;
2163 r
= IXMLDOMNode_insertBefore( root
, node
, var
, NULL
);
2164 ok( r
== S_OK
, "returns %08x\n", r
);
2165 IXMLDOMNode_Release( node
);
2167 r
= IXMLDOMNode_QueryInterface( root
, &IID_IXMLDOMElement
, (LPVOID
*)&element
);
2168 ok( r
== S_OK
, "returns %08x\n", r
);
2170 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2171 ok( r
== S_OK
, "returns %08x\n", r
);
2172 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2173 ok( r
== S_OK
, "returns %08x\n", r
);
2174 ok( num
== 0, "num %d\n", num
);
2175 IXMLDOMNamedNodeMap_Release( attr_map
);
2177 V_VT(&var
) = VT_BSTR
;
2178 V_BSTR(&var
) = SysAllocString( szstr1
);
2179 name
= SysAllocString( szdl
);
2180 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2181 ok( r
== S_OK
, "returns %08x\n", r
);
2182 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2183 ok( r
== S_OK
, "returns %08x\n", r
);
2184 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2185 ok( r
== S_OK
, "returns %08x\n", r
);
2186 ok( num
== 1, "num %d\n", num
);
2187 IXMLDOMNamedNodeMap_Release( attr_map
);
2190 V_VT(&var
) = VT_BSTR
;
2191 V_BSTR(&var
) = SysAllocString( szstr2
);
2192 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2193 ok( r
== S_OK
, "returns %08x\n", r
);
2194 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2195 ok( r
== S_OK
, "returns %08x\n", r
);
2196 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2197 ok( r
== S_OK
, "returns %08x\n", r
);
2198 ok( num
== 1, "num %d\n", num
);
2199 IXMLDOMNamedNodeMap_Release( attr_map
);
2201 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
2202 ok( r
== S_OK
, "returns %08x\n", r
);
2203 ok( !lstrcmpW(V_BSTR(&var
), szstr2
), "wrong attr value\n");
2205 SysFreeString(name
);
2207 V_VT(&var
) = VT_BSTR
;
2208 V_BSTR(&var
) = SysAllocString( szstr1
);
2209 name
= SysAllocString( szlc
);
2210 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2211 ok( r
== S_OK
, "returns %08x\n", r
);
2212 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2213 ok( r
== S_OK
, "returns %08x\n", r
);
2214 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2215 ok( r
== S_OK
, "returns %08x\n", r
);
2216 ok( num
== 2, "num %d\n", num
);
2217 IXMLDOMNamedNodeMap_Release( attr_map
);
2219 SysFreeString(name
);
2223 name
= SysAllocString( szbs
);
2224 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2225 ok( r
== S_OK
, "returns %08x\n", r
);
2227 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
2228 ok( r
== S_OK
, "returns %08x\n", r
);
2229 ok( V_VT(&var
) == VT_BSTR
, "variant type %x\n", V_VT(&var
));
2231 SysFreeString(name
);
2233 /* Create an Attribute */
2235 V_I4(&var
) = NODE_ATTRIBUTE
;
2236 str
= SysAllocString( szAttribute
);
2237 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2238 ok( r
== S_OK
, "returns %08x\n", r
);
2239 ok( node
!= NULL
, "node was null\n");
2244 r
= IXMLDOMNode_get_nodeTypeString(node
, &str
);
2245 ok( r
== S_OK
, "returns %08x\n", r
);
2246 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
2248 IXMLDOMNode_Release( node
);
2251 IXMLDOMElement_Release( element
);
2252 IXMLDOMNode_Release( root
);
2253 IXMLDOMDocument_Release( doc
);
2256 static void test_getElementsByTagName(void)
2261 IXMLDOMDocument
*doc
;
2262 IXMLDOMNodeList
*node_list
;
2265 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2266 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2267 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
2271 str
= SysAllocString( szComplete4
);
2272 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2273 ok( r
== S_OK
, "loadXML failed\n");
2274 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2275 SysFreeString( str
);
2277 str
= SysAllocString( szstar
);
2278 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2279 ok( r
== S_OK
, "ret %08x\n", r
);
2280 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2281 ok( r
== S_OK
, "ret %08x\n", r
);
2282 ok( len
== 6, "len %d\n", len
);
2284 test_disp((IUnknown
*)node_list
);
2286 IXMLDOMNodeList_Release( node_list
);
2287 SysFreeString( str
);
2289 str
= SysAllocString( szbs
);
2290 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2291 ok( r
== S_OK
, "ret %08x\n", r
);
2292 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2293 ok( r
== S_OK
, "ret %08x\n", r
);
2294 ok( len
== 1, "len %d\n", len
);
2295 IXMLDOMNodeList_Release( node_list
);
2296 SysFreeString( str
);
2298 str
= SysAllocString( szdl
);
2299 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2300 ok( r
== S_OK
, "ret %08x\n", r
);
2301 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2302 ok( r
== S_OK
, "ret %08x\n", r
);
2303 ok( len
== 0, "len %d\n", len
);
2304 IXMLDOMNodeList_Release( node_list
);
2305 SysFreeString( str
);
2307 str
= SysAllocString( szstr1
);
2308 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2309 ok( r
== S_OK
, "ret %08x\n", r
);
2310 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2311 ok( r
== S_OK
, "ret %08x\n", r
);
2312 ok( len
== 0, "len %d\n", len
);
2313 IXMLDOMNodeList_Release( node_list
);
2314 SysFreeString( str
);
2316 IXMLDOMDocument_Release( doc
);
2319 static void test_get_text(void)
2324 IXMLDOMDocument
*doc
;
2325 IXMLDOMNode
*node
, *node2
, *node3
;
2326 IXMLDOMNode
*nodeRoot
;
2327 IXMLDOMNodeList
*node_list
;
2328 IXMLDOMNamedNodeMap
*node_map
;
2331 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2332 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2333 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
2337 str
= SysAllocString( szComplete4
);
2338 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2339 ok( r
== S_OK
, "loadXML failed\n");
2340 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2341 SysFreeString( str
);
2343 str
= SysAllocString( szbs
);
2344 r
= IXMLDOMDocument_getElementsByTagName( doc
, str
, &node_list
);
2345 ok( r
== S_OK
, "ret %08x\n", r
);
2348 /* Test to get all child node text. */
2349 r
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (LPVOID
*)&nodeRoot
);
2350 ok( r
== S_OK
, "ret %08x\n", r
);
2353 r
= IXMLDOMNode_get_text( nodeRoot
, &str
);
2354 ok( r
== S_OK
, "ret %08x\n", r
);
2355 ok( compareIgnoreReturnsWhitespace(str
, _bstr_("fn1.txt\n\n fn2.txt \n\nf1\n")), "wrong get_text\n");
2358 IXMLDOMNode_Release(nodeRoot
);
2362 /* this test crashes on win9x */
2363 r
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IDispatch
, NULL
);
2364 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2367 r
= IXMLDOMNodeList_get_length( node_list
, NULL
);
2368 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2370 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2371 ok( r
== S_OK
, "ret %08x\n", r
);
2372 ok( len
== 1, "expect 1 got %d\n", len
);
2374 r
= IXMLDOMNodeList_get_item( node_list
, 0, NULL
);
2375 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2377 r
= IXMLDOMNodeList_nextNode( node_list
, NULL
);
2378 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2380 r
= IXMLDOMNodeList_get_item( node_list
, 0, &node
);
2381 ok( r
== S_OK
, "ret %08x\n", r
);
2382 IXMLDOMNodeList_Release( node_list
);
2384 /* Invalid output parameter*/
2385 r
= IXMLDOMNode_get_text( node
, NULL
);
2386 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2388 r
= IXMLDOMNode_get_text( node
, &str
);
2389 ok( r
== S_OK
, "ret %08x\n", r
);
2390 ok( !memcmp(str
, szfn1_txt
, lstrlenW(szfn1_txt
) ), "wrong string\n" );
2393 r
= IXMLDOMNode_get_attributes( node
, &node_map
);
2394 ok( r
== S_OK
, "ret %08x\n", r
);
2396 str
= SysAllocString( szvr
);
2397 r
= IXMLDOMNamedNodeMap_getNamedItem( node_map
, str
, &node2
);
2398 ok( r
== S_OK
, "ret %08x\n", r
);
2401 r
= IXMLDOMNode_get_text( node2
, &str
);
2402 ok( r
== S_OK
, "ret %08x\n", r
);
2403 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
2406 r
= IXMLDOMNode_get_firstChild( node2
, &node3
);
2407 ok( r
== S_OK
, "ret %08x\n", r
);
2409 r
= IXMLDOMNode_get_text( node3
, &str
);
2410 ok( r
== S_OK
, "ret %08x\n", r
);
2411 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
2415 IXMLDOMNode_Release( node3
);
2416 IXMLDOMNode_Release( node2
);
2417 IXMLDOMNamedNodeMap_Release( node_map
);
2418 IXMLDOMNode_Release( node
);
2419 IXMLDOMDocument_Release( doc
);
2422 static void test_get_childNodes(void)
2427 IXMLDOMDocument
*doc
;
2428 IXMLDOMElement
*element
;
2429 IXMLDOMNode
*node
, *node2
;
2430 IXMLDOMNodeList
*node_list
, *node_list2
;
2433 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2434 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2435 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
2439 str
= SysAllocString( szComplete4
);
2440 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2441 ok( r
== S_OK
, "loadXML failed\n");
2442 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2443 SysFreeString( str
);
2445 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2446 ok( r
== S_OK
, "ret %08x\n", r
);
2448 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
2449 ok( r
== S_OK
, "ret %08x\n", r
);
2451 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2452 ok( r
== S_OK
, "ret %08x\n", r
);
2453 ok( len
== 4, "len %d\n", len
);
2455 r
= IXMLDOMNodeList_get_item( node_list
, 2, &node
);
2456 ok( r
== S_OK
, "ret %08x\n", r
);
2458 r
= IXMLDOMNode_get_childNodes( node
, &node_list2
);
2459 ok( r
== S_OK
, "ret %08x\n", r
);
2461 r
= IXMLDOMNodeList_get_length( node_list2
, &len
);
2462 ok( r
== S_OK
, "ret %08x\n", r
);
2463 ok( len
== 0, "len %d\n", len
);
2465 r
= IXMLDOMNodeList_get_item( node_list2
, 0, &node2
);
2466 ok( r
== S_FALSE
, "ret %08x\n", r
);
2468 IXMLDOMNodeList_Release( node_list2
);
2469 IXMLDOMNode_Release( node
);
2470 IXMLDOMNodeList_Release( node_list
);
2471 IXMLDOMElement_Release( element
);
2472 IXMLDOMDocument_Release( doc
);
2475 static void test_removeChild(void)
2480 IXMLDOMDocument
*doc
;
2481 IXMLDOMElement
*element
, *lc_element
;
2482 IXMLDOMNode
*fo_node
, *ba_node
, *removed_node
, *temp_node
, *lc_node
;
2483 IXMLDOMNodeList
*root_list
, *fo_list
;
2485 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2486 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2487 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
2491 str
= SysAllocString( szComplete4
);
2492 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2493 ok( r
== S_OK
, "loadXML failed\n");
2494 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2495 SysFreeString( str
);
2497 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2498 ok( r
== S_OK
, "ret %08x\n", r
);
2500 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
2501 ok( r
== S_OK
, "ret %08x\n", r
);
2503 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
2504 ok( r
== S_OK
, "ret %08x\n", r
);
2506 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
2507 ok( r
== S_OK
, "ret %08x\n", r
);
2509 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
2510 ok( r
== S_OK
, "ret %08x\n", r
);
2512 /* invalid parameter: NULL ptr */
2513 removed_node
= (void*)0xdeadbeef;
2514 r
= IXMLDOMElement_removeChild( element
, NULL
, &removed_node
);
2515 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2516 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
2518 /* ba_node is a descendant of element, but not a direct child. */
2519 removed_node
= (void*)0xdeadbeef;
2520 r
= IXMLDOMElement_removeChild( element
, ba_node
, &removed_node
);
2521 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2522 ok( removed_node
== NULL
, "%p\n", removed_node
);
2524 r
= IXMLDOMElement_removeChild( element
, fo_node
, &removed_node
);
2525 ok( r
== S_OK
, "ret %08x\n", r
);
2526 ok( fo_node
== removed_node
, "node %p node2 %p\n", fo_node
, removed_node
);
2528 /* try removing already removed child */
2529 temp_node
= (void*)0xdeadbeef;
2530 r
= IXMLDOMElement_removeChild( element
, fo_node
, &temp_node
);
2531 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2532 ok( temp_node
== NULL
, "%p\n", temp_node
);
2534 /* the removed node has no parent anymore */
2535 r
= IXMLDOMNode_get_parentNode( removed_node
, &temp_node
);
2536 ok( r
== S_FALSE
, "ret %08x\n", r
);
2537 ok( temp_node
== NULL
, "%p\n", temp_node
);
2539 IXMLDOMNode_Release( removed_node
);
2540 IXMLDOMNode_Release( ba_node
);
2541 IXMLDOMNodeList_Release( fo_list
);
2543 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
2544 ok( r
== S_OK
, "ret %08x\n", r
);
2546 r
= IXMLDOMElement_QueryInterface( lc_node
, &IID_IXMLDOMElement
, (LPVOID
*)&lc_element
);
2547 ok( r
== S_OK
, "ret %08x\n", r
);
2549 /* MS quirk: passing wrong interface pointer works, too */
2550 r
= IXMLDOMElement_removeChild( element
, (IXMLDOMNode
*)lc_element
, NULL
);
2551 ok( r
== S_OK
, "ret %08x\n", r
);
2553 r
= IXMLDOMNode_get_parentNode( lc_node
, &temp_node
);
2554 ok( r
== S_FALSE
, "ret %08x\n", r
);
2555 ok( temp_node
== NULL
, "%p\n", temp_node
);
2557 IXMLDOMNode_Release( lc_node
);
2558 IXMLDOMNodeList_Release( root_list
);
2559 IXMLDOMElement_Release( element
);
2560 IXMLDOMDocument_Release( doc
);
2563 static void test_replaceChild(void)
2568 IXMLDOMDocument
*doc
;
2569 IXMLDOMElement
*element
, *ba_element
;
2570 IXMLDOMNode
*fo_node
, *ba_node
, *lc_node
, *removed_node
, *temp_node
;
2571 IXMLDOMNodeList
*root_list
, *fo_list
;
2572 IUnknown
* unk1
, *unk2
;
2575 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2576 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2577 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
2581 str
= SysAllocString( szComplete4
);
2582 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2583 ok( r
== S_OK
, "loadXML failed\n");
2584 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2585 SysFreeString( str
);
2587 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2588 ok( r
== S_OK
, "ret %08x\n", r
);
2590 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
2591 ok( r
== S_OK
, "ret %08x\n", r
);
2593 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
2594 ok( r
== S_OK
, "ret %08x\n", r
);
2596 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
2597 ok( r
== S_OK
, "ret %08x\n", r
);
2599 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
2600 ok( r
== S_OK
, "ret %08x\n", r
);
2602 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
2603 ok( r
== S_OK
, "ret %08x\n", r
);
2605 IXMLDOMNodeList_Release( fo_list
);
2607 /* invalid parameter: NULL ptr for element to remove */
2608 removed_node
= (void*)0xdeadbeef;
2609 r
= IXMLDOMElement_replaceChild( element
, ba_node
, NULL
, &removed_node
);
2610 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2611 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
2613 /* invalid parameter: NULL for replacement element. (Sic!) */
2614 removed_node
= (void*)0xdeadbeef;
2615 r
= IXMLDOMElement_replaceChild( element
, NULL
, fo_node
, &removed_node
);
2616 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2617 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
2619 /* invalid parameter: OldNode is not a child */
2620 removed_node
= (void*)0xdeadbeef;
2621 r
= IXMLDOMElement_replaceChild( element
, lc_node
, ba_node
, &removed_node
);
2622 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2623 ok( removed_node
== NULL
, "%p\n", removed_node
);
2625 /* invalid parameter: would create loop */
2626 removed_node
= (void*)0xdeadbeef;
2627 r
= IXMLDOMNode_replaceChild( fo_node
, fo_node
, ba_node
, &removed_node
);
2628 ok( r
== E_FAIL
, "ret %08x\n", r
);
2629 ok( removed_node
== NULL
, "%p\n", removed_node
);
2631 r
= IXMLDOMElement_replaceChild( element
, ba_node
, fo_node
, NULL
);
2632 ok( r
== S_OK
, "ret %08x\n", r
);
2634 r
= IXMLDOMNodeList_get_item( root_list
, 3, &temp_node
);
2635 ok( r
== S_OK
, "ret %08x\n", r
);
2637 /* ba_node and temp_node refer to the same node, yet they
2638 are different interface pointers */
2639 ok( ba_node
!= temp_node
, "ba_node %p temp_node %p\n", ba_node
, temp_node
);
2640 r
= IXMLDOMNode_QueryInterface( temp_node
, &IID_IUnknown
, (void**)&unk1
);
2641 ok( r
== S_OK
, "ret %08x\n", r
);
2642 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IUnknown
, (void**)&unk2
);
2643 ok( r
== S_OK
, "ret %08x\n", r
);
2644 todo_wine
ok( unk1
== unk2
, "unk1 %p unk2 %p\n", unk1
, unk2
);
2646 IUnknown_Release( unk1
);
2647 IUnknown_Release( unk2
);
2649 /* ba_node should have been removed from below fo_node */
2650 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
2651 ok( r
== S_OK
, "ret %08x\n", r
);
2653 /* MS quirk: replaceChild also accepts elements instead of nodes */
2654 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IXMLDOMElement
, (void**)&ba_element
);
2655 ok( r
== S_OK
, "ret %08x\n", r
);
2657 r
= IXMLDOMElement_replaceChild( element
, ba_node
, (IXMLDOMNode
*)ba_element
, &removed_node
);
2658 ok( r
== S_OK
, "ret %08x\n", r
);
2660 r
= IXMLDOMNodeList_get_length( fo_list
, &len
);
2661 ok( r
== S_OK
, "ret %08x\n", r
);
2662 ok( len
== 0, "len %d\n", len
);
2664 IXMLDOMNodeList_Release( fo_list
);
2666 IXMLDOMNode_Release(ba_node
);
2667 IXMLDOMNode_Release(fo_node
);
2668 IXMLDOMNode_Release(temp_node
);
2669 IXMLDOMNodeList_Release( root_list
);
2670 IXMLDOMElement_Release( element
);
2671 IXMLDOMDocument_Release( doc
);
2674 static void test_removeNamedItem(void)
2676 IXMLDOMDocument
*doc
;
2677 IXMLDOMElement
*element
;
2678 IXMLDOMNode
*pr_node
, *removed_node
, *removed_node2
;
2679 IXMLDOMNodeList
*root_list
;
2680 IXMLDOMNamedNodeMap
* pr_attrs
;
2686 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2687 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2688 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
2692 str
= SysAllocString( szComplete4
);
2693 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2694 ok( r
== S_OK
, "loadXML failed\n");
2695 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2696 SysFreeString( str
);
2698 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2699 ok( r
== S_OK
, "ret %08x\n", r
);
2701 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
2702 ok( r
== S_OK
, "ret %08x\n", r
);
2704 r
= IXMLDOMNodeList_get_item( root_list
, 1, &pr_node
);
2705 ok( r
== S_OK
, "ret %08x\n", r
);
2707 r
= IXMLDOMNode_get_attributes( pr_node
, &pr_attrs
);
2708 ok( r
== S_OK
, "ret %08x\n", r
);
2710 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2711 ok( r
== S_OK
, "ret %08x\n", r
);
2712 ok( len
== 3, "length %d\n", len
);
2714 removed_node
= (void*)0xdeadbeef;
2715 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, NULL
, &removed_node
);
2716 ok ( r
== E_INVALIDARG
, "ret %08x\n", r
);
2717 ok ( removed_node
== (void*)0xdeadbeef, "removed_node == %p\n", removed_node
);
2719 removed_node
= (void*)0xdeadbeef;
2720 str
= SysAllocString(szvr
);
2721 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node
);
2722 ok ( r
== S_OK
, "ret %08x\n", r
);
2724 removed_node2
= (void*)0xdeadbeef;
2725 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node2
);
2726 ok ( r
== S_FALSE
, "ret %08x\n", r
);
2727 ok ( removed_node2
== NULL
, "removed_node == %p\n", removed_node2
);
2729 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2730 ok( r
== S_OK
, "ret %08x\n", r
);
2731 ok( len
== 2, "length %d\n", len
);
2733 r
= IXMLDOMNamedNodeMap_setNamedItem( pr_attrs
, removed_node
, NULL
);
2734 ok ( r
== S_OK
, "ret %08x\n", r
);
2735 IXMLDOMNode_Release(removed_node
);
2737 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2738 ok( r
== S_OK
, "ret %08x\n", r
);
2739 ok( len
== 3, "length %d\n", len
);
2741 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
2742 ok ( r
== S_OK
, "ret %08x\n", r
);
2744 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2745 ok( r
== S_OK
, "ret %08x\n", r
);
2746 ok( len
== 2, "length %d\n", len
);
2748 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
2749 ok ( r
== S_FALSE
, "ret %08x\n", r
);
2753 IXMLDOMNamedNodeMap_Release( pr_attrs
);
2754 IXMLDOMNode_Release( pr_node
);
2755 IXMLDOMNodeList_Release( root_list
);
2756 IXMLDOMElement_Release( element
);
2757 IXMLDOMDocument_Release( doc
);
2760 static void test_XMLHTTP(void)
2762 static const WCHAR wszBody
[] = {'m','o','d','e','=','T','e','s','t',0};
2763 static WCHAR wszPOST
[] = {'P','O','S','T',0};
2764 static WCHAR wszUrl
[] = {'h','t','t','p',':','/','/',
2765 'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
2766 'p','o','s','t','t','e','s','t','.','p','h','p',0};
2767 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
2768 IXMLHttpRequest
*pXMLHttpRequest
;
2769 BSTR bstrResponse
, str1
, str2
;
2773 HRESULT hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
,
2774 CLSCTX_INPROC_SERVER
, &IID_IXMLHttpRequest
,
2775 (void **)&pXMLHttpRequest
);
2778 win_skip("IXMLHTTPRequest is not available (0x%08x)\n", hr
);
2782 VariantInit(&dummy
);
2783 V_VT(&dummy
) = VT_ERROR
;
2784 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
2785 VariantInit(&varfalse
);
2786 V_VT(&varfalse
) = VT_BOOL
;
2787 V_BOOL(&varfalse
) = VARIANT_FALSE
;
2788 V_VT(&varbody
) = VT_BSTR
;
2789 V_BSTR(&varbody
) = SysAllocString(wszBody
);
2791 str1
= SysAllocString(wszPOST
);
2792 str2
= SysAllocString(wszUrl
);
2793 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, str1
, str2
, varfalse
, dummy
, dummy
);
2794 todo_wine
ok(hr
== S_OK
, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr
);
2795 SysFreeString(str1
);
2796 SysFreeString(str2
);
2798 hr
= IXMLHttpRequest_send(pXMLHttpRequest
, varbody
);
2799 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
2801 skip("No connection could be made with crossover.codeweavers.com\n");
2802 IXMLHttpRequest_Release(pXMLHttpRequest
);
2805 todo_wine
ok(hr
== S_OK
, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr
);
2806 VariantClear(&varbody
);
2808 hr
= IXMLHttpRequest_get_responseText(pXMLHttpRequest
, &bstrResponse
);
2809 todo_wine
ok(hr
== S_OK
, "IXMLHttpRequest_get_responseText should have succeeded instead of failing with 0x%08x\n", hr
);
2810 /* the server currently returns "FAILED" because the Content-Type header is
2811 * not what the server expects */
2814 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)), "bstrResponse differs from what was expected\n");
2815 SysFreeString(bstrResponse
);
2818 IXMLHttpRequest_Release(pXMLHttpRequest
);
2821 static void test_IXMLDOMDocument2(void)
2826 IXMLDOMDocument
*doc
;
2827 IXMLDOMDocument2
*doc2
;
2828 IDispatchEx
*dispex
;
2832 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2833 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2834 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
2838 str
= SysAllocString( szComplete4
);
2839 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2840 ok( r
== S_OK
, "loadXML failed\n");
2841 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2842 SysFreeString( str
);
2844 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IXMLDOMDocument2
, (void**)&doc2
);
2845 ok( r
== S_OK
, "ret %08x\n", r
);
2846 ok( doc
== (IXMLDOMDocument
*)doc2
, "interfaces differ\n");
2848 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IDispatchEx
, (void**)&dispex
);
2849 ok( r
== S_OK
, "ret %08x\n", r
);
2852 IDispatchEx_Release(dispex
);
2855 /* we will check if the variant got cleared */
2856 ref
= IXMLDOMDocument2_AddRef(doc2
);
2857 expect_eq(ref
, 3, int, "%d"); /* doc, doc2, AddRef*/
2858 V_VT(&var
) = VT_UNKNOWN
;
2859 V_UNKNOWN(&var
) = (IUnknown
*)doc2
;
2862 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("askldhfaklsdf"), &var
), E_FAIL
);
2863 expect_eq(V_VT(&var
), VT_UNKNOWN
, int, "%x");
2864 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), NULL
), E_INVALIDARG
);
2867 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
2868 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
2869 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
2872 /* the variant didn't get cleared*/
2873 expect_eq(IXMLDOMDocument2_Release(doc2
), 2, int, "%d");
2875 /* setProperty tests */
2876 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("askldhfaklsdf"), var
), E_FAIL
);
2877 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), var
), E_FAIL
);
2878 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL
);
2879 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
2880 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
2881 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
2883 /* contrary to what MSDN claims you can switch back from XPath to XSLPattern */
2884 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
2885 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
2886 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
2888 IXMLDOMDocument2_Release( doc2
);
2889 IXMLDOMDocument_Release( doc
);
2893 static void test_XPath(void)
2898 IXMLDOMDocument2
*doc
;
2899 IXMLDOMNode
*rootNode
;
2900 IXMLDOMNode
*elem1Node
;
2902 IXMLDOMNodeList
*list
;
2904 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2905 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
2906 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
2910 ole_check(IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &b
));
2911 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
2913 /* switch to XPath */
2914 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
2916 /* some simple queries*/
2917 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root"), &list
));
2918 ole_check(IXMLDOMNodeList_get_item(list
, 0, &rootNode
));
2919 ole_check(IXMLDOMNodeList_reset(list
));
2920 expect_list_and_release(list
, "E2.D1");
2921 if (rootNode
== NULL
)
2924 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//c"), &list
));
2925 expect_list_and_release(list
, "E3.E1.E2.D1 E3.E2.E2.D1");
2927 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//c[@type]"), &list
));
2928 expect_list_and_release(list
, "E3.E2.E2.D1");
2930 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem"), &list
));
2931 /* using get_item for query results advances the position */
2932 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
2933 expect_node(node
, "E2.E2.D1");
2934 IXMLDOMNode_Release(node
);
2935 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
2936 expect_node(node
, "E4.E2.D1");
2937 IXMLDOMNode_Release(node
);
2938 ole_check(IXMLDOMNodeList_reset(list
));
2939 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
2941 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("."), &list
));
2942 expect_list_and_release(list
, "E2.D1");
2944 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem[3]/preceding-sibling::*"), &list
));
2945 ole_check(IXMLDOMNodeList_get_item(list
, 0, &elem1Node
));
2946 ole_check(IXMLDOMNodeList_reset(list
));
2947 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
2949 /* select an attribute */
2950 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//@type"), &list
));
2951 expect_list_and_release(list
, "A'type'.E3.E2.E2.D1");
2953 /* would evaluate to a number */
2954 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("count(*)"), &list
), E_FAIL
);
2955 /* would evaluate to a boolean */
2956 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("position()>0"), &list
), E_FAIL
);
2957 /* would evaluate to a string */
2958 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("name()"), &list
), E_FAIL
);
2961 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("c"), &list
));
2962 expect_list_and_release(list
, "");
2963 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("elem//c"), &list
));
2964 expect_list_and_release(list
, "");
2965 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//elem[4]"), &list
));
2966 expect_list_and_release(list
, "");
2968 /* foo undeclared in document node */
2969 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
2970 /* undeclared in <root> node */
2971 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//foo:c"), &list
), E_FAIL
);
2972 /* undeclared in <elem> node */
2973 ole_expect(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//foo:c"), &list
), E_FAIL
);
2974 /* but this trick can be used */
2975 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//*[name()='foo:c']"), &list
));
2976 expect_list_and_release(list
, "E3.E4.E2.D1");
2978 /* it has to be declared in SelectionNamespaces */
2979 todo_wine
ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
2980 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
2982 /* now the namespace can be used */
2983 todo_wine
ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//test:c"), &list
));
2984 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
2985 todo_wine
ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//test:c"), &list
));
2986 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
2987 todo_wine
ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//test:c"), &list
));
2988 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
2989 todo_wine
ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_(".//test:x"), &list
));
2990 todo_wine
expect_list_and_release(list
, "E5.E1.E4.E1.E2.D1");
2992 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
2993 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
2994 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL
);
2996 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
2999 todo_wine
ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
3000 todo_wine
expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
3001 if (V_VT(&var
) == VT_BSTR
)
3002 expect_bstr_eq_and_free(V_BSTR(&var
), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
3004 /* extra attributes - same thing*/
3005 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
3006 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL
);
3007 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
3009 IXMLDOMNode_Release(rootNode
);
3010 IXMLDOMNode_Release(elem1Node
);
3011 IXMLDOMDocument_Release(doc
);
3015 static void test_cloneNode(void )
3017 IXMLDOMDocument
*doc
= NULL
;
3019 IXMLDOMNodeList
*pList
;
3020 IXMLDOMNamedNodeMap
*mapAttr
;
3021 LONG nLength
= 0, nLength1
= 0;
3022 LONG nAttrCnt
= 0, nAttrCnt1
= 0;
3024 IXMLDOMNode
*node_clone
;
3025 IXMLDOMNode
*node_first
;
3028 static const WCHAR szSearch
[] = { 'l', 'c', '/', 'p', 'r', 0 };
3030 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3031 ok( r
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", r
);
3035 str
= SysAllocString( szComplete4
);
3036 ole_check(IXMLDOMDocument_loadXML(doc
, str
, &b
));
3037 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
3043 str
= SysAllocString( szSearch
);
3044 r
= IXMLDOMNode_selectSingleNode(doc
, str
, &node
);
3045 ok( r
== S_OK
, "ret %08x\n", r
);
3046 ok( node
!= NULL
, "node %p\n", node
);
3051 IXMLDOMDocument_Release(doc
);
3055 /* Check invalid parameter */
3056 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, NULL
);
3057 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3060 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, &node_clone
);
3061 ok( r
== S_OK
, "ret %08x\n", r
);
3062 ok( node_clone
!= NULL
, "node %p\n", node
);
3066 IXMLDOMDocument_Release(doc
);
3067 IXMLDOMNode_Release(node
);
3071 r
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
3072 ok( r
== S_OK
, "ret %08x\n", r
);
3075 IXMLDOMDocument
*doc2
;
3077 r
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
3078 ok( r
== S_OK
, "ret %08x\n", r
);
3080 IXMLDOMDocument_Release(doc2
);
3082 IXMLDOMNode_Release(node_first
);
3085 r
= IXMLDOMNode_get_childNodes(node
, &pList
);
3086 ok( r
== S_OK
, "ret %08x\n", r
);
3089 IXMLDOMNodeList_get_length(pList
, &nLength
);
3090 IXMLDOMNodeList_Release(pList
);
3093 r
= IXMLDOMNode_get_attributes(node
, &mapAttr
);
3094 ok( r
== S_OK
, "ret %08x\n", r
);
3097 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt
);
3098 IXMLDOMNamedNodeMap_Release(mapAttr
);
3101 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
3102 ok( r
== S_OK
, "ret %08x\n", r
);
3105 IXMLDOMNodeList_get_length(pList
, &nLength1
);
3106 IXMLDOMNodeList_Release(pList
);
3109 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
3110 ok( r
== S_OK
, "ret %08x\n", r
);
3113 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
3114 IXMLDOMNamedNodeMap_Release(mapAttr
);
3117 ok(nLength
== nLength1
, "wrong Child count (%d, %d)\n", nLength
, nLength1
);
3118 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%d, %d)\n", nAttrCnt
, nAttrCnt1
);
3119 IXMLDOMNode_Release(node_clone
);
3122 r
= IXMLDOMNode_cloneNode(node
, VARIANT_FALSE
, &node_clone
);
3123 ok( r
== S_OK
, "ret %08x\n", r
);
3124 ok( node_clone
!= NULL
, "node %p\n", node
);
3128 IXMLDOMDocument_Release(doc
);
3129 IXMLDOMNode_Release(node
);
3133 r
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
3134 ok( r
== S_FALSE
, "ret %08x\n", r
);
3137 IXMLDOMDocument
*doc2
;
3139 r
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
3140 ok( r
== S_OK
, "ret %08x\n", r
);
3142 IXMLDOMDocument_Release(doc2
);
3144 IXMLDOMNode_Release(node_first
);
3147 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
3148 ok( r
== S_OK
, "ret %08x\n", r
);
3151 IXMLDOMNodeList_get_length(pList
, &nLength1
);
3152 ok( nLength1
== 0, "Length should be 0 (%d)\n", nLength1
);
3153 IXMLDOMNodeList_Release(pList
);
3156 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
3157 ok( r
== S_OK
, "ret %08x\n", r
);
3160 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
3161 ok( nAttrCnt1
== 3, "Attribute count should be 3 (%d)\n", nAttrCnt1
);
3162 IXMLDOMNamedNodeMap_Release(mapAttr
);
3165 ok(nLength
!= nLength1
, "wrong Child count (%d, %d)\n", nLength
, nLength1
);
3166 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%d, %d)\n", nAttrCnt
, nAttrCnt1
);
3167 IXMLDOMNode_Release(node_clone
);
3170 IXMLDOMNode_Release(node
);
3171 IXMLDOMDocument_Release(doc
);
3174 static void test_xmlTypes(void)
3176 IXMLDOMDocument
*doc
= NULL
;
3177 IXMLDOMElement
*pRoot
;
3179 IXMLDOMComment
*pComment
;
3180 IXMLDOMElement
*pElement
;
3181 IXMLDOMAttribute
*pAttribute
;
3182 IXMLDOMNamedNodeMap
*pAttribs
;
3183 IXMLDOMCDATASection
*pCDataSec
;
3184 IXMLDOMImplementation
*pIXMLDOMImplementation
= NULL
;
3185 IXMLDOMDocumentFragment
*pDocFrag
= NULL
;
3186 IXMLDOMEntityReference
*pEntityRef
= NULL
;
3188 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1; /* Used for testing Siblings */
3192 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3193 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
3197 hr
= IXMLDOMDocument_get_nextSibling(doc
, NULL
);
3198 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3200 hr
= IXMLDOMDocument_get_nextSibling(doc
, &pNextChild
);
3201 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3202 ok(pNextChild
== NULL
, "pDocChild not NULL\n");
3204 /* test previous Sibling */
3205 hr
= IXMLDOMDocument_get_previousSibling(doc
, NULL
);
3206 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3208 pNextChild
= (IXMLDOMNode
*)0x1;
3209 hr
= IXMLDOMDocument_get_previousSibling(doc
, &pNextChild
);
3210 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3211 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3213 /* test get_attributes */
3214 hr
= IXMLDOMDocument_get_attributes( doc
, NULL
);
3215 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
3217 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3218 hr
= IXMLDOMDocument_get_attributes( doc
, &pAttribs
);
3219 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3220 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
3222 /* test get_dataType */
3223 hr
= IXMLDOMDocument_get_dataType(doc
, &v
);
3224 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3225 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3228 /* test nodeTypeString */
3229 hr
= IXMLDOMDocument_get_nodeTypeString(doc
, &str
);
3230 ok(hr
== S_OK
, "ret %08x\n", hr
);
3231 ok( !lstrcmpW( str
, _bstr_("document") ), "incorrect nodeTypeString string\n");
3234 /* test implementation */
3235 hr
= IXMLDOMDocument_get_implementation(doc
, NULL
);
3236 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3238 hr
= IXMLDOMDocument_get_implementation(doc
, &pIXMLDOMImplementation
);
3239 ok(hr
== S_OK
, "ret %08x\n", hr
);
3242 VARIANT_BOOL hasFeature
= VARIANT_TRUE
;
3243 BSTR sEmpty
= SysAllocStringLen(NULL
, 0);
3245 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, NULL
, sEmpty
, &hasFeature
);
3246 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3248 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, NULL
);
3249 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3251 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
3252 ok(hr
== S_OK
, "ret %08x\n", hr
);
3253 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
3255 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, &hasFeature
);
3256 ok(hr
== S_OK
, "ret %08x\n", hr
);
3257 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned true\n");
3259 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), NULL
, &hasFeature
);
3260 ok(hr
== S_OK
, "ret %08x\n", hr
);
3261 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned false\n");
3263 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
3264 ok(hr
== S_OK
, "ret %08x\n", hr
);
3265 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
3267 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), _bstr_("1.0"), &hasFeature
);
3268 ok(hr
== S_OK
, "ret %08x\n", hr
);
3269 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
3271 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("XML"), _bstr_("1.0"), &hasFeature
);
3272 ok(hr
== S_OK
, "ret %08x\n", hr
);
3273 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
3275 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature
);
3276 ok(hr
== S_OK
, "ret %08x\n", hr
);
3277 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
3279 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("SSS"), NULL
, &hasFeature
);
3280 ok(hr
== S_OK
, "ret %08x\n", hr
);
3281 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
3283 SysFreeString(sEmpty
);
3284 IXMLDOMImplementation_Release(pIXMLDOMImplementation
);
3287 pRoot
= (IXMLDOMElement
*)0x1;
3288 hr
= IXMLDOMDocument_createElement(doc
, NULL
, &pRoot
);
3289 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3290 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
3292 pRoot
= (IXMLDOMElement
*)0x1;
3293 hr
= IXMLDOMDocument_createElement(doc
, _bstr_(""), &pRoot
);
3294 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
3295 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
3297 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
3298 ok(hr
== S_OK
, "ret %08x\n", hr
);
3301 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
3302 ok(hr
== S_OK
, "ret %08x\n", hr
);
3306 str
= SysAllocString(szComment
);
3307 hr
= IXMLDOMDocument_createComment(doc
, str
, &pComment
);
3309 ok(hr
== S_OK
, "ret %08x\n", hr
);
3312 /* test get_attributes */
3313 hr
= IXMLDOMComment_get_attributes( pComment
, NULL
);
3314 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
3316 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3317 hr
= IXMLDOMComment_get_attributes( pComment
, &pAttribs
);
3318 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3319 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
3321 /* test nodeTypeString */
3322 hr
= IXMLDOMComment_get_nodeTypeString(pComment
, &str
);
3323 ok(hr
== S_OK
, "ret %08x\n", hr
);
3324 ok( !lstrcmpW( str
, _bstr_("comment") ), "incorrect nodeTypeString string\n");
3327 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pComment
, NULL
);
3328 ok(hr
== S_OK
, "ret %08x\n", hr
);
3330 hr
= IXMLDOMComment_get_nodeName(pComment
, &str
);
3331 ok(hr
== S_OK
, "ret %08x\n", hr
);
3332 ok( !lstrcmpW( str
, szCommentNodeText
), "incorrect comment node Name\n");
3335 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
3336 ok(hr
== S_OK
, "ret %08x\n", hr
);
3337 ok( !lstrcmpW( str
, szCommentXML
), "incorrect comment xml\n");
3340 hr
= IXMLDOMComment_get_dataType(pComment
, &v
);
3341 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3342 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3345 /* put data Tests */
3346 hr
= IXMLDOMComment_put_data(pComment
, _bstr_("This &is a ; test <>\\"));
3347 ok(hr
== S_OK
, "ret %08x\n", hr
);
3349 /* get data Tests */
3350 hr
= IXMLDOMComment_get_data(pComment
, &str
);
3351 ok(hr
== S_OK
, "ret %08x\n", hr
);
3352 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
3355 /* get data Tests */
3356 hr
= IXMLDOMComment_get_nodeValue(pComment
, &v
);
3357 ok(hr
== S_OK
, "ret %08x\n", hr
);
3358 ok( V_VT(&v
) == VT_BSTR
, "incorrect dataType type\n");
3359 ok( !lstrcmpW( V_BSTR(&v
), _bstr_("This &is a ; test <>\\") ), "incorrect get_nodeValue string\n");
3362 /* Confirm XML text is good */
3363 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
3364 ok(hr
== S_OK
, "ret %08x\n", hr
);
3365 ok( !lstrcmpW( str
, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
3368 /* Confirm we get the put_data Text back */
3369 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3370 ok(hr
== S_OK
, "ret %08x\n", hr
);
3371 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
3374 /* test length property */
3375 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3376 ok(hr
== S_OK
, "ret %08x\n", hr
);
3377 ok(len
== 21, "expected 21 got %d\n", len
);
3379 /* test substringData */
3380 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, NULL
);
3381 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3383 /* test substringData - Invalid offset */
3384 str
= (BSTR
)&szElement
;
3385 hr
= IXMLDOMComment_substringData(pComment
, -1, 4, &str
);
3386 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3387 ok( str
== NULL
, "incorrect string\n");
3389 /* test substringData - Invalid offset */
3390 str
= (BSTR
)&szElement
;
3391 hr
= IXMLDOMComment_substringData(pComment
, 30, 0, &str
);
3392 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3393 ok( str
== NULL
, "incorrect string\n");
3395 /* test substringData - Invalid size */
3396 str
= (BSTR
)&szElement
;
3397 hr
= IXMLDOMComment_substringData(pComment
, 0, -1, &str
);
3398 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3399 ok( str
== NULL
, "incorrect string\n");
3401 /* test substringData - Invalid size */
3402 str
= (BSTR
)&szElement
;
3403 hr
= IXMLDOMComment_substringData(pComment
, 2, 0, &str
);
3404 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3405 ok( str
== NULL
, "incorrect string\n");
3407 /* test substringData - Start of string */
3408 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, &str
);
3409 ok(hr
== S_OK
, "ret %08x\n", hr
);
3410 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
3413 /* test substringData - Middle of string */
3414 hr
= IXMLDOMComment_substringData(pComment
, 13, 4, &str
);
3415 ok(hr
== S_OK
, "ret %08x\n", hr
);
3416 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
3419 /* test substringData - End of string */
3420 hr
= IXMLDOMComment_substringData(pComment
, 20, 4, &str
);
3421 ok(hr
== S_OK
, "ret %08x\n", hr
);
3422 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
3425 /* test appendData */
3426 hr
= IXMLDOMComment_appendData(pComment
, NULL
);
3427 ok(hr
== S_OK
, "ret %08x\n", hr
);
3429 hr
= IXMLDOMComment_appendData(pComment
, _bstr_(""));
3430 ok(hr
== S_OK
, "ret %08x\n", hr
);
3432 hr
= IXMLDOMComment_appendData(pComment
, _bstr_("Append"));
3433 ok(hr
== S_OK
, "ret %08x\n", hr
);
3435 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3436 ok(hr
== S_OK
, "ret %08x\n", hr
);
3437 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
3440 /* test insertData */
3441 str
= SysAllocStringLen(NULL
, 0);
3442 hr
= IXMLDOMComment_insertData(pComment
, -1, str
);
3443 ok(hr
== S_OK
, "ret %08x\n", hr
);
3445 hr
= IXMLDOMComment_insertData(pComment
, -1, NULL
);
3446 ok(hr
== S_OK
, "ret %08x\n", hr
);
3448 hr
= IXMLDOMComment_insertData(pComment
, 1000, str
);
3449 ok(hr
== S_OK
, "ret %08x\n", hr
);
3451 hr
= IXMLDOMComment_insertData(pComment
, 1000, NULL
);
3452 ok(hr
== S_OK
, "ret %08x\n", hr
);
3454 hr
= IXMLDOMComment_insertData(pComment
, 0, NULL
);
3455 ok(hr
== S_OK
, "ret %08x\n", hr
);
3457 hr
= IXMLDOMComment_insertData(pComment
, 0, str
);
3458 ok(hr
== S_OK
, "ret %08x\n", hr
);
3461 hr
= IXMLDOMComment_insertData(pComment
, -1, _bstr_("Inserting"));
3462 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3464 hr
= IXMLDOMComment_insertData(pComment
, 1000, _bstr_("Inserting"));
3465 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3467 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("Begin "));
3468 ok(hr
== S_OK
, "ret %08x\n", hr
);
3470 hr
= IXMLDOMComment_insertData(pComment
, 17, _bstr_("Middle"));
3471 ok(hr
== S_OK
, "ret %08x\n", hr
);
3473 hr
= IXMLDOMComment_insertData(pComment
, 39, _bstr_(" End"));
3474 ok(hr
== S_OK
, "ret %08x\n", hr
);
3476 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3477 ok(hr
== S_OK
, "ret %08x\n", hr
);
3478 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3482 /* invalid arguments */
3483 hr
= IXMLDOMComment_deleteData(pComment
, -1, 1);
3484 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3486 hr
= IXMLDOMComment_deleteData(pComment
, 0, 0);
3487 ok(hr
== S_OK
, "ret %08x\n", hr
);
3489 hr
= IXMLDOMComment_deleteData(pComment
, 0, -1);
3490 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3492 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3493 ok(hr
== S_OK
, "ret %08x\n", hr
);
3494 ok(len
== 43, "expected 43 got %d\n", len
);
3496 hr
= IXMLDOMComment_deleteData(pComment
, len
, 1);
3497 ok(hr
== S_OK
, "ret %08x\n", hr
);
3499 hr
= IXMLDOMComment_deleteData(pComment
, len
+1, 1);
3500 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3502 /* delete from start */
3503 hr
= IXMLDOMComment_deleteData(pComment
, 0, 5);
3504 ok(hr
== S_OK
, "ret %08x\n", hr
);
3506 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3507 ok(hr
== S_OK
, "ret %08x\n", hr
);
3508 ok(len
== 38, "expected 38 got %d\n", len
);
3510 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3511 ok(hr
== S_OK
, "ret %08x\n", hr
);
3512 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3515 /* delete from end */
3516 hr
= IXMLDOMComment_deleteData(pComment
, 35, 3);
3517 ok(hr
== S_OK
, "ret %08x\n", hr
);
3519 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3520 ok(hr
== S_OK
, "ret %08x\n", hr
);
3521 ok(len
== 35, "expected 35 got %d\n", len
);
3523 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3524 ok(hr
== S_OK
, "ret %08x\n", hr
);
3525 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string\n");
3528 /* delete from inside */
3529 hr
= IXMLDOMComment_deleteData(pComment
, 1, 33);
3530 ok(hr
== S_OK
, "ret %08x\n", hr
);
3532 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3533 ok(hr
== S_OK
, "ret %08x\n", hr
);
3534 ok(len
== 2, "expected 2 got %d\n", len
);
3536 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3537 ok(hr
== S_OK
, "ret %08x\n", hr
);
3538 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string\n");
3541 /* delete whole data ... */
3542 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3543 ok(hr
== S_OK
, "ret %08x\n", hr
);
3545 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
3546 ok(hr
== S_OK
, "ret %08x\n", hr
);
3547 /* ... and try again with empty string */
3548 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
3549 ok(hr
== S_OK
, "ret %08x\n", hr
);
3551 /* ::replaceData() */
3553 V_BSTR(&v
) = SysAllocString(szstr1
);
3554 hr
= IXMLDOMComment_put_nodeValue(pComment
, v
);
3555 ok(hr
== S_OK
, "ret %08x\n", hr
);
3558 hr
= IXMLDOMComment_replaceData(pComment
, 6, 0, NULL
);
3559 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3560 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3561 ok(hr
== S_OK
, "ret %08x\n", hr
);
3562 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
3565 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, NULL
);
3566 ok(hr
== S_OK
, "ret %08x\n", hr
);
3567 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3568 ok(hr
== S_OK
, "ret %08x\n", hr
);
3569 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
3572 /* NULL pointer means delete */
3573 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, NULL
);
3574 ok(hr
== S_OK
, "ret %08x\n", hr
);
3575 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3576 ok(hr
== S_OK
, "ret %08x\n", hr
);
3577 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string\n");
3580 /* empty string means delete */
3581 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_(""));
3582 ok(hr
== S_OK
, "ret %08x\n", hr
);
3583 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3584 ok(hr
== S_OK
, "ret %08x\n", hr
);
3585 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string\n");
3588 /* zero count means insert */
3589 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, _bstr_("a"));
3590 ok(hr
== S_OK
, "ret %08x\n", hr
);
3591 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3592 ok(hr
== S_OK
, "ret %08x\n", hr
);
3593 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string\n");
3596 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, NULL
);
3597 ok(hr
== S_OK
, "ret %08x\n", hr
);
3599 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("m"));
3600 ok(hr
== S_OK
, "ret %08x\n", hr
);
3601 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3602 ok(hr
== S_OK
, "ret %08x\n", hr
);
3603 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string\n");
3606 /* nonempty string, count greater than its length */
3607 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, _bstr_("a1.2"));
3608 ok(hr
== S_OK
, "ret %08x\n", hr
);
3609 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3610 ok(hr
== S_OK
, "ret %08x\n", hr
);
3611 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string\n");
3614 /* nonempty string, count less than its length */
3615 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_("wine"));
3616 ok(hr
== S_OK
, "ret %08x\n", hr
);
3617 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3618 ok(hr
== S_OK
, "ret %08x\n", hr
);
3619 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string\n");
3622 IXMLDOMComment_Release(pComment
);
3626 str
= SysAllocString(szElement
);
3627 hr
= IXMLDOMDocument_createElement(doc
, str
, &pElement
);
3629 ok(hr
== S_OK
, "ret %08x\n", hr
);
3632 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3633 ok(hr
== S_OK
, "ret %08x\n", hr
);
3635 /* test nodeTypeString */
3636 hr
= IXMLDOMDocument_get_nodeTypeString(pElement
, &str
);
3637 ok(hr
== S_OK
, "ret %08x\n", hr
);
3638 ok( !lstrcmpW( str
, _bstr_("element") ), "incorrect nodeTypeString string\n");
3641 hr
= IXMLDOMElement_get_nodeName(pElement
, &str
);
3642 ok(hr
== S_OK
, "ret %08x\n", hr
);
3643 ok( !lstrcmpW( str
, szElement
), "incorrect element node Name\n");
3646 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3647 ok(hr
== S_OK
, "ret %08x\n", hr
);
3648 ok( !lstrcmpW( str
, szElementXML
), "incorrect element xml\n");
3651 hr
= IXMLDOMElement_get_dataType(pElement
, &v
);
3652 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3653 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3657 pAttribute
= (IXMLDOMAttribute
*)0x1;
3658 hr
= IXMLDOMDocument_createAttribute(doc
, NULL
, &pAttribute
);
3659 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3660 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
3662 pAttribute
= (IXMLDOMAttribute
*)0x1;
3663 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_(""), &pAttribute
);
3664 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
3665 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
3667 str
= SysAllocString(szAttribute
);
3668 hr
= IXMLDOMDocument_createAttribute(doc
, str
, &pAttribute
);
3670 ok(hr
== S_OK
, "ret %08x\n", hr
);
3673 IXMLDOMNode
*pNewChild
= (IXMLDOMNode
*)0x1;
3675 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, NULL
);
3676 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3678 pNextChild
= (IXMLDOMNode
*)0x1;
3679 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, &pNextChild
);
3680 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3681 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3683 /* test Previous Sibling*/
3684 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, NULL
);
3685 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3687 pNextChild
= (IXMLDOMNode
*)0x1;
3688 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, &pNextChild
);
3689 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3690 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3692 /* test get_attributes */
3693 hr
= IXMLDOMAttribute_get_attributes( pAttribute
, NULL
);
3694 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
3696 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3697 hr
= IXMLDOMAttribute_get_attributes( pAttribute
, &pAttribs
);
3698 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3699 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
3701 hr
= IXMLDOMElement_appendChild(pElement
, (IXMLDOMNode
*)pAttribute
, &pNewChild
);
3702 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
3703 ok(pNewChild
== NULL
, "pNewChild not NULL\n");
3705 hr
= IXMLDOMElement_get_attributes(pElement
, &pAttribs
);
3706 ok(hr
== S_OK
, "ret %08x\n", hr
);
3709 hr
= IXMLDOMNamedNodeMap_setNamedItem(pAttribs
, (IXMLDOMNode
*)pAttribute
, NULL
);
3710 ok(hr
== S_OK
, "ret %08x\n", hr
);
3712 IXMLDOMNamedNodeMap_Release(pAttribs
);
3715 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
3716 ok(hr
== S_OK
, "ret %08x\n", hr
);
3717 ok( !lstrcmpW( str
, szAttribute
), "incorrect attribute node Name\n");
3720 /* test nodeTypeString */
3721 hr
= IXMLDOMAttribute_get_nodeTypeString(pAttribute
, &str
);
3722 ok(hr
== S_OK
, "ret %08x\n", hr
);
3723 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
3727 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
3728 ok(hr
== S_OK
, "ret %08x\n", hr
);
3729 ok( !lstrcmpW( str
, szAttribute
), "incorrect nodeName string\n");
3732 /* test name property */
3733 hr
= IXMLDOMAttribute_get_name(pAttribute
, &str
);
3734 ok(hr
== S_OK
, "ret %08x\n", hr
);
3735 ok( !lstrcmpW( str
, szAttribute
), "incorrect name string\n");
3738 hr
= IXMLDOMAttribute_get_xml(pAttribute
, &str
);
3739 ok(hr
== S_OK
, "ret %08x\n", hr
);
3740 ok( !lstrcmpW( str
, szAttributeXML
), "incorrect attribute xml\n");
3743 hr
= IXMLDOMAttribute_get_dataType(pAttribute
, &v
);
3744 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3745 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3748 IXMLDOMAttribute_Release(pAttribute
);
3750 /* Check Element again with the Add Attribute*/
3751 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3752 ok(hr
== S_OK
, "ret %08x\n", hr
);
3753 ok( !lstrcmpW( str
, szElementXML2
), "incorrect element xml\n");
3757 hr
= IXMLDOMElement_put_text(pElement
, _bstr_("TestingNode"));
3758 ok(hr
== S_OK
, "ret %08x\n", hr
);
3760 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3761 ok(hr
== S_OK
, "ret %08x\n", hr
);
3762 ok( !lstrcmpW( str
, szElementXML3
), "incorrect element xml\n");
3765 /* Test for reversible escaping */
3766 str
= SysAllocString( szStrangeChars
);
3767 hr
= IXMLDOMElement_put_text(pElement
, str
);
3768 ok(hr
== S_OK
, "ret %08x\n", hr
);
3769 SysFreeString( str
);
3771 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3772 ok(hr
== S_OK
, "ret %08x\n", hr
);
3773 ok( !lstrcmpW( str
, szElementXML4
), "incorrect element xml\n");
3776 hr
= IXMLDOMElement_get_text(pElement
, &str
);
3777 ok(hr
== S_OK
, "ret %08x\n", hr
);
3778 ok( !lstrcmpW( str
, szStrangeChars
), "incorrect element text\n");
3781 IXMLDOMElement_Release(pElement
);
3785 str
= SysAllocString(szCData
);
3786 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, NULL
);
3787 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3789 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, &pCDataSec
);
3791 ok(hr
== S_OK
, "ret %08x\n", hr
);
3794 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1;
3799 hr
= IXMLDOMCDATASection_QueryInterface(pCDataSec
, &IID_IXMLDOMElement
, (LPVOID
*)&pElement
);
3800 ok(hr
== E_NOINTERFACE
, "ret %08x\n", hr
);
3802 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pCDataSec
, NULL
);
3803 ok(hr
== S_OK
, "ret %08x\n", hr
);
3805 /* get Attribute Tests */
3806 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, NULL
);
3807 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3809 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3810 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, &pAttribs
);
3811 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3812 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
3814 hr
= IXMLDOMCDATASection_get_nodeName(pCDataSec
, &str
);
3815 ok(hr
== S_OK
, "ret %08x\n", hr
);
3816 ok( !lstrcmpW( str
, szCDataNodeText
), "incorrect cdata node Name\n");
3819 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
3820 ok(hr
== S_OK
, "ret %08x\n", hr
);
3821 ok( !lstrcmpW( str
, szCDataXML
), "incorrect cdata xml\n");
3824 /* test lastChild */
3825 pNextChild
= (IXMLDOMNode
*)0x1;
3826 hr
= IXMLDOMCDATASection_get_lastChild(pCDataSec
, &pNextChild
);
3827 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3828 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3830 /* test get_dataType */
3831 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, NULL
);
3832 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3834 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, &v
);
3835 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3836 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3839 /* test nodeTypeString */
3840 hr
= IXMLDOMCDATASection_get_nodeTypeString(pCDataSec
, &str
);
3841 ok(hr
== S_OK
, "ret %08x\n", hr
);
3842 ok( !lstrcmpW( str
, _bstr_("cdatasection") ), "incorrect nodeTypeString string\n");
3845 /* put data Tests */
3846 hr
= IXMLDOMCDATASection_put_data(pCDataSec
, _bstr_("This &is a ; test <>\\"));
3847 ok(hr
== S_OK
, "ret %08x\n", hr
);
3849 /* Confirm XML text is good */
3850 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
3851 ok(hr
== S_OK
, "ret %08x\n", hr
);
3852 ok( !lstrcmpW( str
, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
3855 /* Confirm we get the put_data Text back */
3856 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3857 ok(hr
== S_OK
, "ret %08x\n", hr
);
3858 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3861 /* test length property */
3862 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
3863 ok(hr
== S_OK
, "ret %08x\n", hr
);
3864 ok(len
== 21, "expected 21 got %d\n", len
);
3866 /* test get nodeValue */
3867 hr
= IXMLDOMCDATASection_get_nodeValue(pCDataSec
, &var
);
3868 ok(hr
== S_OK
, "ret %08x\n", hr
);
3869 ok(V_VT(&var
) == VT_BSTR
, "got vt %04x\n", V_VT(&var
));
3870 ok( !lstrcmpW( V_BSTR(&var
), _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3874 hr
= IXMLDOMCDATASection_get_data(pCDataSec
, &str
);
3875 ok(hr
== S_OK
, "ret %08x\n", hr
);
3876 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3879 /* test substringData */
3880 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, NULL
);
3881 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3883 /* test substringData - Invalid offset */
3884 str
= (BSTR
)&szElement
;
3885 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, -1, 4, &str
);
3886 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3887 ok( str
== NULL
, "incorrect string\n");
3889 /* test substringData - Invalid offset */
3890 str
= (BSTR
)&szElement
;
3891 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 30, 0, &str
);
3892 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3893 ok( str
== NULL
, "incorrect string\n");
3895 /* test substringData - Invalid size */
3896 str
= (BSTR
)&szElement
;
3897 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, -1, &str
);
3898 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3899 ok( str
== NULL
, "incorrect string\n");
3901 /* test substringData - Invalid size */
3902 str
= (BSTR
)&szElement
;
3903 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 2, 0, &str
);
3904 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3905 ok( str
== NULL
, "incorrect string\n");
3907 /* test substringData - Start of string */
3908 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, &str
);
3909 ok(hr
== S_OK
, "ret %08x\n", hr
);
3910 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
3913 /* test substringData - Middle of string */
3914 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 13, 4, &str
);
3915 ok(hr
== S_OK
, "ret %08x\n", hr
);
3916 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
3919 /* test substringData - End of string */
3920 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 20, 4, &str
);
3921 ok(hr
== S_OK
, "ret %08x\n", hr
);
3922 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
3925 /* test appendData */
3926 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, NULL
);
3927 ok(hr
== S_OK
, "ret %08x\n", hr
);
3929 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_(""));
3930 ok(hr
== S_OK
, "ret %08x\n", hr
);
3932 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_("Append"));
3933 ok(hr
== S_OK
, "ret %08x\n", hr
);
3935 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3936 ok(hr
== S_OK
, "ret %08x\n", hr
);
3937 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
3940 /* test insertData */
3941 str
= SysAllocStringLen(NULL
, 0);
3942 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, str
);
3943 ok(hr
== S_OK
, "ret %08x\n", hr
);
3945 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, NULL
);
3946 ok(hr
== S_OK
, "ret %08x\n", hr
);
3948 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, str
);
3949 ok(hr
== S_OK
, "ret %08x\n", hr
);
3951 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, NULL
);
3952 ok(hr
== S_OK
, "ret %08x\n", hr
);
3954 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, NULL
);
3955 ok(hr
== S_OK
, "ret %08x\n", hr
);
3957 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, str
);
3958 ok(hr
== S_OK
, "ret %08x\n", hr
);
3961 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, _bstr_("Inserting"));
3962 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3964 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, _bstr_("Inserting"));
3965 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3967 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("Begin "));
3968 ok(hr
== S_OK
, "ret %08x\n", hr
);
3970 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 17, _bstr_("Middle"));
3971 ok(hr
== S_OK
, "ret %08x\n", hr
);
3973 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 39, _bstr_(" End"));
3974 ok(hr
== S_OK
, "ret %08x\n", hr
);
3976 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3977 ok(hr
== S_OK
, "ret %08x\n", hr
);
3978 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3982 /* invalid arguments */
3983 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, -1, 1);
3984 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3986 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 0);
3987 ok(hr
== S_OK
, "ret %08x\n", hr
);
3989 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, -1);
3990 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3992 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
3993 ok(hr
== S_OK
, "ret %08x\n", hr
);
3994 ok(len
== 43, "expected 43 got %d\n", len
);
3996 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
, 1);
3997 ok(hr
== S_OK
, "ret %08x\n", hr
);
3999 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
+1, 1);
4000 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4002 /* delete from start */
4003 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 5);
4004 ok(hr
== S_OK
, "ret %08x\n", hr
);
4006 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
4007 ok(hr
== S_OK
, "ret %08x\n", hr
);
4008 ok(len
== 38, "expected 38 got %d\n", len
);
4010 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4011 ok(hr
== S_OK
, "ret %08x\n", hr
);
4012 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
4015 /* delete from end */
4016 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 35, 3);
4017 ok(hr
== S_OK
, "ret %08x\n", hr
);
4019 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
4020 ok(hr
== S_OK
, "ret %08x\n", hr
);
4021 ok(len
== 35, "expected 35 got %d\n", len
);
4023 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4024 ok(hr
== S_OK
, "ret %08x\n", hr
);
4025 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string\n");
4028 /* delete from inside */
4029 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 1, 33);
4030 ok(hr
== S_OK
, "ret %08x\n", hr
);
4032 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
4033 ok(hr
== S_OK
, "ret %08x\n", hr
);
4034 ok(len
== 2, "expected 2 got %d\n", len
);
4036 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4037 ok(hr
== S_OK
, "ret %08x\n", hr
);
4038 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string\n");
4041 /* delete whole data ... */
4042 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
4043 ok(hr
== S_OK
, "ret %08x\n", hr
);
4045 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
4046 ok(hr
== S_OK
, "ret %08x\n", hr
);
4048 /* ... and try again with empty string */
4049 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
4050 ok(hr
== S_OK
, "ret %08x\n", hr
);
4052 /* ::replaceData() */
4054 V_BSTR(&v
) = SysAllocString(szstr1
);
4055 hr
= IXMLDOMCDATASection_put_nodeValue(pCDataSec
, v
);
4056 ok(hr
== S_OK
, "ret %08x\n", hr
);
4059 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 6, 0, NULL
);
4060 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4061 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4062 ok(hr
== S_OK
, "ret %08x\n", hr
);
4063 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
4066 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, NULL
);
4067 ok(hr
== S_OK
, "ret %08x\n", hr
);
4068 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4069 ok(hr
== S_OK
, "ret %08x\n", hr
);
4070 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
4073 /* NULL pointer means delete */
4074 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, NULL
);
4075 ok(hr
== S_OK
, "ret %08x\n", hr
);
4076 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4077 ok(hr
== S_OK
, "ret %08x\n", hr
);
4078 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string\n");
4081 /* empty string means delete */
4082 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_(""));
4083 ok(hr
== S_OK
, "ret %08x\n", hr
);
4084 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4085 ok(hr
== S_OK
, "ret %08x\n", hr
);
4086 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string\n");
4089 /* zero count means insert */
4090 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, _bstr_("a"));
4091 ok(hr
== S_OK
, "ret %08x\n", hr
);
4092 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4093 ok(hr
== S_OK
, "ret %08x\n", hr
);
4094 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string\n");
4097 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, NULL
);
4098 ok(hr
== S_OK
, "ret %08x\n", hr
);
4100 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("m"));
4101 ok(hr
== S_OK
, "ret %08x\n", hr
);
4102 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4103 ok(hr
== S_OK
, "ret %08x\n", hr
);
4104 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string\n");
4107 /* nonempty string, count greater than its length */
4108 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, _bstr_("a1.2"));
4109 ok(hr
== S_OK
, "ret %08x\n", hr
);
4110 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4111 ok(hr
== S_OK
, "ret %08x\n", hr
);
4112 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string\n");
4115 /* nonempty string, count less than its length */
4116 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_("wine"));
4117 ok(hr
== S_OK
, "ret %08x\n", hr
);
4118 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4119 ok(hr
== S_OK
, "ret %08x\n", hr
);
4120 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string\n");
4123 IXMLDOMCDATASection_Release(pCDataSec
);
4126 /* Document Fragments */
4127 hr
= IXMLDOMDocument_createDocumentFragment(doc
, NULL
);
4128 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4130 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &pDocFrag
);
4131 ok(hr
== S_OK
, "ret %08x\n", hr
);
4136 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, NULL
);
4137 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4139 node
= (IXMLDOMNode
*)0x1;
4140 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, &node
);
4141 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4142 ok(node
== NULL
, "expected NULL, got %p\n", node
);
4144 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pDocFrag
, NULL
);
4145 ok(hr
== S_OK
, "ret %08x\n", hr
);
4147 /* get Attribute Tests */
4148 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, NULL
);
4149 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4151 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
4152 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, &pAttribs
);
4153 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4154 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
4156 hr
= IXMLDOMDocumentFragment_get_nodeName(pDocFrag
, &str
);
4157 ok(hr
== S_OK
, "ret %08x\n", hr
);
4158 ok( !lstrcmpW( str
, szDocFragmentText
), "incorrect docfragment node Name\n");
4161 /* test next Sibling*/
4162 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, NULL
);
4163 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4165 node
= (IXMLDOMNode
*)0x1;
4166 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, &node
);
4167 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4168 ok(node
== NULL
, "next sibling not NULL\n");
4170 /* test Previous Sibling*/
4171 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, NULL
);
4172 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4174 node
= (IXMLDOMNode
*)0x1;
4175 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, &node
);
4176 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4177 ok(node
== NULL
, "previous sibling not NULL\n");
4179 /* test get_dataType */
4180 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, NULL
);
4181 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4183 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, &v
);
4184 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4185 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
4188 /* test nodeTypeString */
4189 hr
= IXMLDOMDocumentFragment_get_nodeTypeString(pDocFrag
, &str
);
4190 ok(hr
== S_OK
, "ret %08x\n", hr
);
4191 ok( !lstrcmpW( str
, _bstr_("documentfragment") ), "incorrect nodeTypeString string\n");
4194 IXMLDOMDocumentFragment_Release(pDocFrag
);
4197 /* Entity References */
4198 hr
= IXMLDOMDocument_createEntityReference(doc
, NULL
, &pEntityRef
);
4199 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4200 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_(""), &pEntityRef
);
4201 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4203 str
= SysAllocString(szEntityRef
);
4204 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, NULL
);
4205 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4207 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, &pEntityRef
);
4209 ok(hr
== S_OK
, "ret %08x\n", hr
);
4212 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pEntityRef
, NULL
);
4213 ok(hr
== S_OK
, "ret %08x\n", hr
);
4215 /* get Attribute Tests */
4216 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, NULL
);
4217 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4219 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
4220 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, &pAttribs
);
4221 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4222 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
4225 hr
= IXMLDOMEntityReference_get_dataType(pEntityRef
, &v
);
4226 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4227 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
4230 /* test nodeTypeString */
4231 hr
= IXMLDOMEntityReference_get_nodeTypeString(pEntityRef
, &str
);
4232 ok(hr
== S_OK
, "ret %08x\n", hr
);
4233 ok( !lstrcmpW( str
, _bstr_("entityreference") ), "incorrect nodeTypeString string\n");
4237 hr
= IXMLDOMEntityReference_get_xml(pEntityRef
, &str
);
4238 ok(hr
== S_OK
, "ret %08x\n", hr
);
4239 ok( !lstrcmpW( str
, szEntityRefXML
), "incorrect xml string\n");
4242 IXMLDOMEntityReference_Release(pEntityRef
);
4245 IXMLDOMElement_Release( pRoot
);
4249 IXMLDOMDocument_Release(doc
);
4254 static void test_nodeTypeTests( void )
4256 IXMLDOMDocument
*doc
= NULL
;
4257 IXMLDOMElement
*pRoot
;
4258 IXMLDOMElement
*pElement
;
4261 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4262 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
4266 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), NULL
);
4267 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4269 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
4270 ok(hr
== S_OK
, "ret %08x\n", hr
);
4273 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
4274 ok(hr
== S_OK
, "ret %08x\n", hr
);
4277 hr
= IXMLDOMElement_put_dataType(pRoot
, NULL
);
4278 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4281 hr
= IXMLDOMElement_put_dataType(pRoot
, _bstr_("abcdefg") );
4282 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4285 * The name passed into put_dataType is case-insensitive. So many of the names
4286 * have been changed to reflect this.
4289 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Boolean"), &pElement
);
4290 ok(hr
== S_OK
, "ret %08x\n", hr
);
4293 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4295 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Boolean") );
4296 ok(hr
== S_OK
, "ret %08x\n", hr
);
4298 IXMLDOMElement_Release(pElement
);
4302 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_String"), &pElement
);
4303 ok(hr
== S_OK
, "ret %08x\n", hr
);
4306 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4308 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("String") );
4309 ok(hr
== S_OK
, "ret %08x\n", hr
);
4311 IXMLDOMElement_Release(pElement
);
4315 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Number"), &pElement
);
4316 ok(hr
== S_OK
, "ret %08x\n", hr
);
4319 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4321 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("number") );
4322 ok(hr
== S_OK
, "ret %08x\n", hr
);
4324 IXMLDOMElement_Release(pElement
);
4328 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Int"), &pElement
);
4329 ok(hr
== S_OK
, "ret %08x\n", hr
);
4332 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4334 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("InT") );
4335 ok(hr
== S_OK
, "ret %08x\n", hr
);
4337 IXMLDOMElement_Release(pElement
);
4341 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Fixed"), &pElement
);
4342 ok(hr
== S_OK
, "ret %08x\n", hr
);
4345 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4347 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("fixed.14.4") );
4348 ok(hr
== S_OK
, "ret %08x\n", hr
);
4350 IXMLDOMElement_Release(pElement
);
4354 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime"), &pElement
);
4355 ok(hr
== S_OK
, "ret %08x\n", hr
);
4358 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4360 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime") );
4361 ok(hr
== S_OK
, "ret %08x\n", hr
);
4363 IXMLDOMElement_Release(pElement
);
4367 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime_tz"), &pElement
);
4368 ok(hr
== S_OK
, "ret %08x\n", hr
);
4371 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4373 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
4374 ok(hr
== S_OK
, "ret %08x\n", hr
);
4376 IXMLDOMElement_Release(pElement
);
4380 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Date"), &pElement
);
4381 ok(hr
== S_OK
, "ret %08x\n", hr
);
4384 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4386 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Date") );
4387 ok(hr
== S_OK
, "ret %08x\n", hr
);
4389 IXMLDOMElement_Release(pElement
);
4393 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time"), &pElement
);
4394 ok(hr
== S_OK
, "ret %08x\n", hr
);
4397 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4399 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time") );
4400 ok(hr
== S_OK
, "ret %08x\n", hr
);
4402 IXMLDOMElement_Release(pElement
);
4406 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time_TZ"), &pElement
);
4407 ok(hr
== S_OK
, "ret %08x\n", hr
);
4410 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4412 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time.tz") );
4413 ok(hr
== S_OK
, "ret %08x\n", hr
);
4415 IXMLDOMElement_Release(pElement
);
4419 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I1"), &pElement
);
4420 ok(hr
== S_OK
, "ret %08x\n", hr
);
4423 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4425 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I1") );
4426 ok(hr
== S_OK
, "ret %08x\n", hr
);
4428 IXMLDOMElement_Release(pElement
);
4432 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I2"), &pElement
);
4433 ok(hr
== S_OK
, "ret %08x\n", hr
);
4436 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4438 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I2") );
4439 ok(hr
== S_OK
, "ret %08x\n", hr
);
4441 IXMLDOMElement_Release(pElement
);
4445 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I4"), &pElement
);
4446 ok(hr
== S_OK
, "ret %08x\n", hr
);
4449 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4451 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I4") );
4452 ok(hr
== S_OK
, "ret %08x\n", hr
);
4454 IXMLDOMElement_Release(pElement
);
4458 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI1"), &pElement
);
4459 ok(hr
== S_OK
, "ret %08x\n", hr
);
4462 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4464 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI1") );
4465 ok(hr
== S_OK
, "ret %08x\n", hr
);
4467 IXMLDOMElement_Release(pElement
);
4471 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI2"), &pElement
);
4472 ok(hr
== S_OK
, "ret %08x\n", hr
);
4475 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4477 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI2") );
4478 ok(hr
== S_OK
, "ret %08x\n", hr
);
4480 IXMLDOMElement_Release(pElement
);
4484 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI4"), &pElement
);
4485 ok(hr
== S_OK
, "ret %08x\n", hr
);
4488 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4490 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI4") );
4491 ok(hr
== S_OK
, "ret %08x\n", hr
);
4493 IXMLDOMElement_Release(pElement
);
4497 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r4"), &pElement
);
4498 ok(hr
== S_OK
, "ret %08x\n", hr
);
4501 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4503 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r4") );
4504 ok(hr
== S_OK
, "ret %08x\n", hr
);
4506 IXMLDOMElement_Release(pElement
);
4510 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r8"), &pElement
);
4511 ok(hr
== S_OK
, "ret %08x\n", hr
);
4514 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4516 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r8") );
4517 ok(hr
== S_OK
, "ret %08x\n", hr
);
4519 IXMLDOMElement_Release(pElement
);
4523 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_float"), &pElement
);
4524 ok(hr
== S_OK
, "ret %08x\n", hr
);
4527 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4529 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("float") );
4530 ok(hr
== S_OK
, "ret %08x\n", hr
);
4532 IXMLDOMElement_Release(pElement
);
4536 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_uuid"), &pElement
);
4537 ok(hr
== S_OK
, "ret %08x\n", hr
);
4540 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4542 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UuId") );
4543 ok(hr
== S_OK
, "ret %08x\n", hr
);
4545 IXMLDOMElement_Release(pElement
);
4549 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_hex"), &pElement
);
4550 ok(hr
== S_OK
, "ret %08x\n", hr
);
4553 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4555 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.hex") );
4556 ok(hr
== S_OK
, "ret %08x\n", hr
);
4558 IXMLDOMElement_Release(pElement
);
4562 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_base64"), &pElement
);
4563 ok(hr
== S_OK
, "ret %08x\n", hr
);
4566 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4568 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.base64") );
4569 ok(hr
== S_OK
, "ret %08x\n", hr
);
4571 IXMLDOMElement_Release(pElement
);
4574 /* Check changing types */
4575 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Change"), &pElement
);
4576 ok(hr
== S_OK
, "ret %08x\n", hr
);
4579 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4581 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
4582 ok(hr
== S_OK
, "ret %08x\n", hr
);
4584 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("string") );
4585 ok(hr
== S_OK
, "ret %08x\n", hr
);
4587 IXMLDOMElement_Release(pElement
);
4590 IXMLDOMElement_Release(pRoot
);
4594 IXMLDOMDocument_Release(doc
);
4599 static void test_DocumentSaveToDocument(void)
4601 IXMLDOMDocument
*doc
= NULL
;
4602 IXMLDOMDocument
*doc2
= NULL
;
4603 IXMLDOMElement
*pRoot
;
4607 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4608 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
4612 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc2
);
4613 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
4616 IXMLDOMDocument_Release(doc
);
4620 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
4621 ok(hr
== S_OK
, "ret %08x\n", hr
);
4624 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
4625 ok(hr
== S_OK
, "ret %08x\n", hr
);
4632 V_VT(&vDoc
) = VT_UNKNOWN
;
4633 V_UNKNOWN(&vDoc
) = (IUnknown
*)doc2
;
4635 hr
= IXMLDOMDocument_save(doc
, vDoc
);
4636 ok(hr
== S_OK
, "ret %08x\n", hr
);
4638 hr
= IXMLDOMDocument_get_xml(doc
, &sOrig
);
4639 ok(hr
== S_OK
, "ret %08x\n", hr
);
4641 hr
= IXMLDOMDocument_get_xml(doc2
, &sNew
);
4642 ok(hr
== S_OK
, "ret %08x\n", hr
);
4644 ok( !lstrcmpW( sOrig
, sNew
), "New document is not the same as origial\n");
4646 SysFreeString(sOrig
);
4647 SysFreeString(sNew
);
4651 IXMLDOMDocument_Release(doc2
);
4652 IXMLDOMDocument_Release(doc
);
4655 static void test_DocumentSaveToFile(void)
4657 IXMLDOMDocument
*doc
= NULL
;
4658 IXMLDOMElement
*pRoot
;
4664 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4665 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
4669 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
4670 ok(hr
== S_OK
, "ret %08x\n", hr
);
4673 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
4674 ok(hr
== S_OK
, "ret %08x\n", hr
);
4679 V_VT(&vFile
) = VT_BSTR
;
4680 V_BSTR(&vFile
) = _bstr_("test.xml");
4682 hr
= IXMLDOMDocument_save(doc
, vFile
);
4683 ok(hr
== S_OK
, "ret %08x\n", hr
);
4687 IXMLDOMElement_Release(pRoot
);
4688 IXMLDOMDocument_Release(doc
);
4690 file
= CreateFile("test.xml", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
4691 ok(file
!= INVALID_HANDLE_VALUE
, "Could not open file: %u\n", GetLastError());
4692 if(file
== INVALID_HANDLE_VALUE
)
4695 ReadFile(file
, buffer
, sizeof(buffer
), &read
, NULL
);
4696 ok(read
!= 0, "could not read file\n");
4697 ok(buffer
[0] != '<' || buffer
[1] != '?', "File contains processing instruction\n");
4700 DeleteFile("test.xml");
4703 static void test_testTransforms(void)
4705 IXMLDOMDocument
*doc
= NULL
;
4706 IXMLDOMDocument
*docSS
= NULL
;
4712 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4713 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
4717 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&docSS
);
4718 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
4721 IXMLDOMDocument_Release(doc
);
4725 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTransformXML
), &bSucc
);
4726 ok(hr
== S_OK
, "ret %08x\n", hr
);
4728 hr
= IXMLDOMDocument_loadXML(docSS
, _bstr_(szTransformSSXML
), &bSucc
);
4729 ok(hr
== S_OK
, "ret %08x\n", hr
);
4731 hr
= IXMLDOMDocument_QueryInterface(docSS
, &IID_IXMLDOMNode
, (LPVOID
*)&pNode
);
4732 ok(hr
== S_OK
, "ret %08x\n", hr
);
4737 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &bOut
);
4738 ok(hr
== S_OK
, "ret %08x\n", hr
);
4739 ok( compareIgnoreReturns( bOut
, _bstr_(szTransformOutput
)), "Stylesheet output not correct\n");
4740 SysFreeString(bOut
);
4742 IXMLDOMNode_Release(pNode
);
4745 IXMLDOMDocument_Release(docSS
);
4746 IXMLDOMDocument_Release(doc
);
4751 static void test_Namespaces(void)
4753 IXMLDOMDocument2
*doc
= NULL
;
4755 IXMLDOMNode
*pNode2
= NULL
;
4759 static const CHAR szNamespacesXML
[] =
4760 "<?xml version=\"1.0\"?>\n"
4761 "<root xmlns:WEB='http://www.winehq.org'>\n"
4762 "<WEB:Site version=\"1.0\" />\n"
4765 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4766 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
4770 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szNamespacesXML
), &bSucc
);
4771 ok(hr
== S_OK
, "ret %08x\n", hr
);
4772 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4774 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root"), &pNode
);
4775 ok(hr
== S_OK
, "ret %08x\n", hr
);
4778 hr
= IXMLDOMNode_get_firstChild( pNode
, &pNode2
);
4779 ok( hr
== S_OK
, "ret %08x\n", hr
);
4780 ok( pNode2
!= NULL
, "pNode2 == NULL\n");
4782 /* Test get_prefix */
4783 hr
= IXMLDOMNode_get_prefix(pNode2
, NULL
);
4784 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4785 /* NOTE: Need to test that arg2 gets cleared on Error. */
4787 hr
= IXMLDOMNode_get_prefix(pNode2
, &str
);
4788 ok( hr
== S_OK
, "ret %08x\n", hr
);
4789 ok( !lstrcmpW( str
, _bstr_("WEB")), "incorrect prefix string\n");
4792 /* Test get_namespaceURI */
4793 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, NULL
);
4794 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4795 /* NOTE: Need to test that arg2 gets cleared on Error. */
4797 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, &str
);
4798 ok( hr
== S_OK
, "ret %08x\n", hr
);
4799 ok( !lstrcmpW( str
, _bstr_("http://www.winehq.org")), "incorrect namespaceURI string\n");
4802 IXMLDOMNode_Release(pNode2
);
4803 IXMLDOMNode_Release(pNode
);
4806 IXMLDOMDocument2_Release(doc
);
4811 static void test_FormattingXML(void)
4813 IXMLDOMDocument2
*doc
= NULL
;
4814 IXMLDOMElement
*pElement
;
4818 static const CHAR szLinefeedXML
[] = "<?xml version=\"1.0\"?>\n<Root>\n\t<Sub val=\"A\" />\n</Root>";
4819 static const CHAR szLinefeedRootXML
[] = "<Root>\r\n\t<Sub val=\"A\"/>\r\n</Root>";
4821 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4822 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
4826 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szLinefeedXML
), &bSucc
);
4827 ok(hr
== S_OK
, "ret %08x\n", hr
);
4828 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4830 if(bSucc
== VARIANT_TRUE
)
4832 hr
= IXMLDOMDocument2_get_documentElement(doc
, &pElement
);
4833 ok(hr
== S_OK
, "ret %08x\n", hr
);
4836 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
4837 ok(hr
== S_OK
, "ret %08x\n", hr
);
4838 ok( !lstrcmpW( str
, _bstr_(szLinefeedRootXML
) ), "incorrect element xml\n");
4841 IXMLDOMElement_Release(pElement
);
4845 IXMLDOMDocument2_Release(doc
);
4850 static void test_NodeTypeValue(void)
4852 IXMLDOMDocument2
*doc
= NULL
;
4858 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4859 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
4863 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szTypeValueXML
), &bSucc
);
4864 ok(hr
== S_OK
, "ret %08x\n", hr
);
4865 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4866 if(bSucc
== VARIANT_TRUE
)
4868 hr
= IXMLDOMDocument2_get_nodeValue(doc
, NULL
);
4869 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4873 hr
= IXMLDOMDocument2_get_nodeValue(doc
, &v
);
4874 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4875 ok(V_VT(&v
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&v
));
4877 hr
= IXMLDOMDocument2_get_nodeTypedValue(doc
, NULL
);
4878 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4880 hr
= IXMLDOMDocument2_get_nodeTypedValue(doc
, &v
);
4881 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4883 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/string"), &pNode
);
4884 ok(hr
== S_OK
, "ret %08x\n", hr
);
4889 hr
= IXMLDOMNode_get_nodeValue(pNode
, &v
);
4890 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4891 ok(V_VT(&v
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&v
));
4893 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, NULL
);
4894 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4896 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4897 ok(hr
== S_OK
, "ret %08x\n", hr
);
4898 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4899 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("Wine") ), "incorrect value\n");
4902 IXMLDOMNode_Release(pNode
);
4905 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/string2"), &pNode
);
4906 ok(hr
== S_OK
, "ret %08x\n", hr
);
4909 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4910 ok(hr
== S_OK
, "ret %08x\n", hr
);
4911 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4912 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("String") ), "incorrect value\n");
4915 IXMLDOMNode_Release(pNode
);
4918 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/number"), &pNode
);
4919 ok(hr
== S_OK
, "ret %08x\n", hr
);
4922 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4923 ok(hr
== S_OK
, "ret %08x\n", hr
);
4924 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4925 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("12.44") ), "incorrect value\n");
4928 IXMLDOMNode_Release(pNode
);
4931 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/number2"), &pNode
);
4932 ok(hr
== S_OK
, "ret %08x\n", hr
);
4935 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4936 ok(hr
== S_OK
, "ret %08x\n", hr
);
4937 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4938 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("-3.71e3") ), "incorrect value\n");
4941 IXMLDOMNode_Release(pNode
);
4944 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/int"), &pNode
);
4945 ok(hr
== S_OK
, "ret %08x\n", hr
);
4948 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4949 ok(hr
== S_OK
, "ret %08x\n", hr
);
4950 ok(V_VT(&v
) == VT_I4
, "incorrect type\n");
4951 ok(V_I4(&v
) == -13, "incorrect value\n");
4954 IXMLDOMNode_Release(pNode
);
4957 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/fixed"), &pNode
);
4958 ok(hr
== S_OK
, "ret %08x\n", hr
);
4961 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4962 ok(hr
== S_OK
, "ret %08x\n", hr
);
4963 ok(V_VT(&v
) == VT_CY
, "incorrect type\n");
4966 IXMLDOMNode_Release(pNode
);
4969 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/bool"), &pNode
);
4970 ok(hr
== S_OK
, "ret %08x\n", hr
);
4973 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4974 ok(hr
== S_OK
, "ret %08x\n", hr
);
4975 ok(V_VT(&v
) == VT_BOOL
, "incorrect type\n");
4976 ok(V_BOOL(&v
) == VARIANT_TRUE
, "incorrect value\n");
4979 IXMLDOMNode_Release(pNode
);
4982 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/datetime"), &pNode
);
4983 ok(hr
== S_OK
, "ret %08x\n", hr
);
4986 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4987 ok(hr
== S_OK
, "ret %08x\n", hr
);
4988 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4989 double_eq(40135.13996527778, V_DATE(&v
));
4992 IXMLDOMNode_Release(pNode
);
4995 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/datetimetz"), &pNode
);
4996 ok(hr
== S_OK
, "ret %08x\n", hr
);
4999 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5000 ok(hr
== S_OK
, "ret %08x\n", hr
);
5001 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
5002 double_eq(37813.59302083334, V_DATE(&v
));
5005 IXMLDOMNode_Release(pNode
);
5008 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/date"), &pNode
);
5009 ok(hr
== S_OK
, "ret %08x\n", hr
);
5012 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5013 ok(hr
== S_OK
, "ret %08x\n", hr
);
5014 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
5015 double_eq(665413.0, V_DATE(&v
));
5018 IXMLDOMNode_Release(pNode
);
5021 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/time"), &pNode
);
5022 ok(hr
== S_OK
, "ret %08x\n", hr
);
5025 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5026 ok(hr
== S_OK
, "ret %08x\n", hr
);
5027 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
5028 double_eq(0.5813888888888888, V_DATE(&v
));
5031 IXMLDOMNode_Release(pNode
);
5034 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/timetz"), &pNode
);
5035 ok(hr
== S_OK
, "ret %08x\n", hr
);
5038 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5039 ok(hr
== S_OK
, "ret %08x\n", hr
);
5040 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
5041 double_eq(1.112511574074074, V_DATE(&v
));
5044 IXMLDOMNode_Release(pNode
);
5047 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/i1"), &pNode
);
5048 ok(hr
== S_OK
, "ret %08x\n", hr
);
5051 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5052 ok(hr
== S_OK
, "ret %08x\n", hr
);
5053 ok(V_VT(&v
) == VT_I1
, "incorrect type\n");
5054 ok(V_I1(&v
) == -13, "incorrect value\n");
5057 IXMLDOMNode_Release(pNode
);
5060 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/i2"), &pNode
);
5061 ok(hr
== S_OK
, "ret %08x\n", hr
);
5064 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5065 ok(hr
== S_OK
, "ret %08x\n", hr
);
5066 ok(V_VT(&v
) == VT_I2
, "incorrect type\n");
5067 ok(V_I2(&v
) == 31915, "incorrect value\n");
5070 IXMLDOMNode_Release(pNode
);
5073 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/i4"), &pNode
);
5074 ok(hr
== S_OK
, "ret %08x\n", hr
);
5077 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5078 ok(hr
== S_OK
, "ret %08x\n", hr
);
5079 ok(V_VT(&v
) == VT_I4
, "incorrect type\n");
5080 ok(V_I4(&v
) == -312232, "incorrect value\n");
5083 IXMLDOMNode_Release(pNode
);
5086 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/ui1"), &pNode
);
5087 ok(hr
== S_OK
, "ret %08x\n", hr
);
5090 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5091 ok(hr
== S_OK
, "ret %08x\n", hr
);
5092 ok(V_VT(&v
) == VT_UI1
, "incorrect type\n");
5093 ok(V_UI1(&v
) == 123, "incorrect value\n");
5096 IXMLDOMNode_Release(pNode
);
5099 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/ui2"), &pNode
);
5100 ok(hr
== S_OK
, "ret %08x\n", hr
);
5103 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5104 ok(hr
== S_OK
, "ret %08x\n", hr
);
5105 ok(V_VT(&v
) == VT_UI2
, "incorrect type\n");
5106 ok(V_UI2(&v
) == 48282, "incorrect value\n");
5109 IXMLDOMNode_Release(pNode
);
5112 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/ui4"), &pNode
);
5113 ok(hr
== S_OK
, "ret %08x\n", hr
);
5116 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5117 ok(hr
== S_OK
, "ret %08x\n", hr
);
5118 ok(V_VT(&v
) == VT_UI4
, "incorrect type\n");
5119 ok(V_UI4(&v
) == 949281, "incorrect value\n");
5122 IXMLDOMNode_Release(pNode
);
5125 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/r4"), &pNode
);
5126 ok(hr
== S_OK
, "ret %08x\n", hr
);
5129 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5130 ok(hr
== S_OK
, "ret %08x\n", hr
);
5131 ok(V_VT(&v
) == VT_R4
, "incorrect type\n");
5132 double_eq(213124.0, V_R4(&v
));
5135 IXMLDOMNode_Release(pNode
);
5138 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/r8"), &pNode
);
5139 ok(hr
== S_OK
, "ret %08x\n", hr
);
5142 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5143 ok(hr
== S_OK
, "ret %08x\n", hr
);
5144 ok(V_VT(&v
) == VT_R8
, "incorrect type\n");
5145 double_eq(0.412, V_R8(&v
));
5148 IXMLDOMNode_Release(pNode
);
5151 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/float"), &pNode
);
5152 ok(hr
== S_OK
, "ret %08x\n", hr
);
5155 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5156 ok(hr
== S_OK
, "ret %08x\n", hr
);
5157 ok(V_VT(&v
) == VT_R8
, "incorrect type\n");
5158 double_eq(41221.421, V_R8(&v
));
5161 IXMLDOMNode_Release(pNode
);
5164 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/uuid"), &pNode
);
5165 ok(hr
== S_OK
, "ret %08x\n", hr
);
5168 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5169 ok(hr
== S_OK
, "ret %08x\n", hr
);
5170 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
5171 ok(!lstrcmpW(V_BSTR(&v
), _bstr_("333C7BC4-460F-11D0-BC04-0080C7055a83")), "incorrect value\n");
5174 IXMLDOMNode_Release(pNode
);
5177 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/binhex"), &pNode
);
5178 ok(hr
== S_OK
, "ret %08x\n", hr
);
5181 BYTE bytes
[] = {0xff,0xfc,0xa0,0x12,0x00,0x3c};
5183 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5184 ok(hr
== S_OK
, "ret %08x\n", hr
);
5185 ok(V_VT(&v
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
5186 ok(V_ARRAY(&v
)->rgsabound
[0].cElements
== 6, "incorrect array size\n");
5187 if(V_ARRAY(&v
)->rgsabound
[0].cElements
== 6)
5188 ok(!memcmp(bytes
, V_ARRAY(&v
)->pvData
, sizeof(bytes
)), "incorrect value\n");
5191 IXMLDOMNode_Release(pNode
);
5194 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/binbase64"), &pNode
);
5195 ok(hr
== S_OK
, "ret %08x\n", hr
);
5198 BYTE bytes
[] = {0x62,0x61,0x73,0x65,0x36,0x34,0x20,0x74,0x65,0x73,0x74};
5200 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5201 ok(hr
== S_OK
, "ret %08x\n", hr
);
5202 ok(V_VT(&v
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
5203 ok(V_ARRAY(&v
)->rgsabound
[0].cElements
== 11, "incorrect array size\n");
5204 if(V_ARRAY(&v
)->rgsabound
[0].cElements
== 11)
5205 ok(!memcmp(bytes
, V_ARRAY(&v
)->pvData
, sizeof(bytes
)), "incorrect value\n");
5208 IXMLDOMNode_Release(pNode
);
5212 IXMLDOMDocument2_Release(doc
);
5217 static void test_TransformWithLoadingLocalFile(void)
5219 IXMLDOMDocument2
*doc
= NULL
;
5220 IXMLDOMDocument2
*xsl
= NULL
;
5226 char lpPathBuffer
[MAX_PATH
];
5229 /* Create a Temp File. */
5230 GetTempPathA(MAX_PATH
, lpPathBuffer
);
5231 strcat(lpPathBuffer
, "customers.xml" );
5233 file
= CreateFile(lpPathBuffer
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
5234 ok(file
!= INVALID_HANDLE_VALUE
, "Could not create file: %u\n", GetLastError());
5235 if(file
== INVALID_HANDLE_VALUE
)
5238 WriteFile(file
, szBasicTransformXML
, strlen(szBasicTransformXML
), &dwWritten
, NULL
);
5241 /* Correct path to not include a escape character. */
5242 for(i
=0; i
< strlen(lpPathBuffer
); i
++)
5244 if(lpPathBuffer
[i
] == '\\')
5245 lpPathBuffer
[i
] = '/';
5248 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
5249 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
5253 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&xsl
);
5254 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
5257 IXMLDOMDocument2_Release(doc
);
5261 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szTypeValueXML
), &bSucc
);
5262 ok(hr
== S_OK
, "ret %08x\n", hr
);
5263 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
5264 if(bSucc
== VARIANT_TRUE
)
5267 BSTR sPart1
= _bstr_(szBasicTransformSSXMLPart1
);
5268 BSTR sPart2
= _bstr_(szBasicTransformSSXMLPart2
);
5269 BSTR sFileName
= _bstr_(lpPathBuffer
);
5270 int nLegnth
= lstrlenW(sPart1
) + lstrlenW(sPart2
) + lstrlenW(sFileName
) + 1;
5272 sXSL
= SysAllocStringLen(NULL
, nLegnth
);
5273 lstrcpyW(sXSL
, sPart1
);
5274 lstrcatW(sXSL
, sFileName
);
5275 lstrcatW(sXSL
, sPart2
);
5277 hr
= IXMLDOMDocument2_loadXML(xsl
, sXSL
, &bSucc
);
5278 ok(hr
== S_OK
, "ret %08x\n", hr
);
5279 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
5280 if(bSucc
== VARIANT_TRUE
)
5284 hr
= IXMLDOMDocument_QueryInterface(xsl
, &IID_IXMLDOMNode
, (LPVOID
*)&pNode
);
5285 ok(hr
== S_OK
, "ret %08x\n", hr
);
5288 /* This will load the temp file via the XSL */
5289 hr
= IXMLDOMDocument2_transformNode(doc
, pNode
, &sResult
);
5290 ok(hr
== S_OK
, "ret %08x\n", hr
);
5293 ok( compareIgnoreReturns( sResult
, _bstr_(szBasicTransformOutput
)), "Stylesheet output not correct\n");
5294 SysFreeString(sResult
);
5297 IXMLDOMNode_Release(pNode
);
5301 SysFreeString(sXSL
);
5304 IXMLDOMDocument2_Release(doc
);
5305 IXMLDOMDocument2_Release(xsl
);
5307 DeleteFile(lpPathBuffer
);
5311 static void test_put_nodeValue(void)
5313 IXMLDOMDocument
*doc
;
5314 IXMLDOMEntityReference
*entityref
;
5319 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
5320 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
5324 /* test for unsupported types */
5326 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (void**)&node
);
5327 ok(hr
== S_OK
, "ret %08x\n", hr
);
5328 V_VT(&data
) = VT_BSTR
;
5329 V_BSTR(&data
) = _bstr_("one two three");
5330 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
5331 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5332 IXMLDOMNode_Release(node
);
5334 /* NODE_DOCUMENT_FRAGMENT */
5335 V_VT(&type
) = VT_I1
;
5336 V_I1(&type
) = NODE_DOCUMENT_FRAGMENT
;
5337 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
5338 ok(hr
== S_OK
, "ret %08x\n", hr
);
5339 V_VT(&data
) = VT_BSTR
;
5340 V_BSTR(&data
) = _bstr_("one two three");
5341 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
5342 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5343 IXMLDOMNode_Release(node
);
5346 V_VT(&type
) = VT_I1
;
5347 V_I1(&type
) = NODE_ELEMENT
;
5348 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
5349 ok(hr
== S_OK
, "ret %08x\n", hr
);
5350 V_VT(&data
) = VT_BSTR
;
5351 V_BSTR(&data
) = _bstr_("one two three");
5352 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
5353 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5354 IXMLDOMNode_Release(node
);
5356 /* NODE_ENTITY_REFERENCE */
5357 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_("ref"), &entityref
);
5358 ok(hr
== S_OK
, "ret %08x\n", hr
);
5360 V_VT(&data
) = VT_BSTR
;
5361 V_BSTR(&data
) = _bstr_("one two three");
5362 hr
= IXMLDOMEntityReference_put_nodeValue(entityref
, data
);
5363 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5365 hr
= IXMLDOMEntityReference_QueryInterface(entityref
, &IID_IXMLDOMNode
, (void**)&node
);
5366 ok(hr
== S_OK
, "ret %08x\n", hr
);
5367 V_VT(&data
) = VT_BSTR
;
5368 V_BSTR(&data
) = _bstr_("one two three");
5369 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
5370 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5371 IXMLDOMNode_Release(node
);
5372 IXMLDOMEntityReference_Release(entityref
);
5376 IXMLDOMDocument_Release(doc
);
5379 static void test_IObjectSafety_set(IObjectSafety
*safety
, HRESULT result
, HRESULT result2
, DWORD set
, DWORD mask
, DWORD expected
, DWORD expected2
)
5382 DWORD enabled
, supported
;
5384 trace("testing IObjectSafety: enable=%08x, mask=%08x\n", set
, mask
);
5386 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
, set
, mask
);
5387 if (result
== result2
)
5388 ok(hr
== result
, "SetInterfaceSafetyOptions: expected %08x, returned %08x\n", result
, hr
);
5390 ok(broken(hr
== result
) || hr
== result2
,
5391 "SetInterfaceSafetyOptions: expected %08x, got %08x\n", result2
, hr
);
5393 supported
= enabled
= 0xCAFECAFE;
5394 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5395 ok(hr
== S_OK
, "ret %08x\n", hr
);
5396 if (expected
== expected2
)
5397 ok(enabled
== expected
, "Expected %08x, got %08x\n", expected
, enabled
);
5399 ok(broken(enabled
== expected
) || enabled
== expected2
,
5400 "Expected %08x, got %08x\n", expected2
, enabled
);
5402 /* reset the safety options */
5404 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
5405 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_SECURITY_MANAGER
,
5407 ok(hr
== S_OK
, "ret %08x\n", hr
);
5409 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5410 ok(hr
== S_OK
, "ret %08x\n", hr
);
5411 ok(enabled
== 0, "Expected 0, got %08x\n", enabled
);
5414 static void test_document_IObjectSafety(void)
5416 IXMLDOMDocument
*doc
;
5417 IObjectSafety
*safety
;
5418 DWORD enabled
= 0, supported
= 0;
5421 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
5422 ok( hr
== S_OK
, "CoCreateInstance(CLSID_DOMDocument) should have succeeded instead of failing with 0x%08x\n", hr
);
5426 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IObjectSafety
, (void**)&safety
);
5427 ok(hr
== S_OK
, "ret %08x\n", hr
);
5430 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, NULL
, &enabled
);
5431 ok(hr
== E_POINTER
, "ret %08x\n", hr
);
5432 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, NULL
);
5433 ok(hr
== E_POINTER
, "ret %08x\n", hr
);
5435 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5436 ok(hr
== S_OK
, "ret %08x\n", hr
);
5437 ok(broken(supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
)) ||
5438 supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
5439 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), "
5440 "got %08x\n", supported
);
5441 ok(enabled
== 0, "Expected 0, got %08x\n", enabled
);
5443 /* set -- individual flags */
5445 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5446 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
5447 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
5449 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5450 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5451 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
);
5453 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5454 INTERFACE_USES_SECURITY_MANAGER
, INTERFACE_USES_SECURITY_MANAGER
,
5455 0, INTERFACE_USES_SECURITY_MANAGER
/* msxml3 SP8+ */);
5457 /* set INTERFACE_USES_DISPEX */
5459 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
5460 INTERFACE_USES_DISPEX
, INTERFACE_USES_DISPEX
,
5463 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
5464 INTERFACE_USES_DISPEX
, 0,
5467 test_IObjectSafety_set(safety
, S_OK
, S_OK
/* msxml3 SP8+ */,
5468 0, INTERFACE_USES_DISPEX
,
5471 /* set option masking */
5473 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5474 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5475 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
5476 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
5477 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
5479 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5480 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5481 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5482 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5483 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
5485 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5486 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5487 INTERFACE_USES_SECURITY_MANAGER
,
5491 /* set -- inheriting previous settings */
5493 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
5494 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
5495 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
5496 ok(hr
== S_OK
, "ret %08x\n", hr
);
5497 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5498 ok(hr
== S_OK
, "ret %08x\n", hr
);
5500 ok(broken(enabled
== INTERFACESAFE_FOR_UNTRUSTED_CALLER
) ||
5501 enabled
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
5502 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACE_USES_SECURITY_MANAGER), "
5503 "got %08x\n", enabled
);
5505 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
5506 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5507 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
5508 ok(hr
== S_OK
, "ret %08x\n", hr
);
5509 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5510 ok(hr
== S_OK
, "ret %08x\n", hr
);
5512 ok(broken(enabled
== INTERFACESAFE_FOR_UNTRUSTED_DATA
) ||
5513 enabled
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
) /* msxml3 SP8+ */,
5514 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA), "
5515 "got %08x\n", enabled
);
5517 IObjectSafety_Release(safety
);
5519 IXMLDOMDocument_Release(doc
);
5524 IXMLDOMDocument
*doc
;
5527 r
= CoInitialize( NULL
);
5528 ok( r
== S_OK
, "failed to init com\n");
5532 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
5533 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
5536 IXMLDOMDocument_Release(doc
);
5542 test_getElementsByTagName();
5544 test_get_childNodes();
5546 test_replaceChild();
5547 test_removeNamedItem();
5548 test_IXMLDOMDocument2();
5552 test_nodeTypeTests();
5553 test_DocumentSaveToDocument();
5554 test_DocumentSaveToFile();
5555 test_testTransforms();
5557 test_FormattingXML();
5558 test_NodeTypeValue();
5559 test_TransformWithLoadingLocalFile();
5560 test_put_nodeValue();
5561 test_document_IObjectSafety();
5564 win_skip("IXMLDOMDocument is not available (0x%08x)\n", r
);