4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2007-2008 Alistair Leslie-Hughes
6 * Copyright 2010 Adam Martinson for CodeWeavers
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "msxml2did.h"
36 #include "wine/test.h"
40 DEFINE_GUID(IID_IObjectSafety
, 0xcb5bdc81, 0x93c1, 0x11cf, 0x8f,0x20, 0x00,0x80,0x5f,0x2c,0xd0,0x64);
42 static int g_unexpectedcall
, g_expectedcall
;
46 const struct IDispatchVtbl
*lpVtbl
;
50 static inline dispevent
*impl_from_IDispatch( IDispatch
*iface
)
52 return (dispevent
*)((char*)iface
- FIELD_OFFSET(dispevent
, lpVtbl
));
55 static HRESULT WINAPI
dispevent_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppvObject
)
59 if ( IsEqualGUID( riid
, &IID_IDispatch
) ||
60 IsEqualGUID( riid
, &IID_IUnknown
) )
67 IDispatch_AddRef( iface
);
72 static ULONG WINAPI
dispevent_AddRef(IDispatch
*iface
)
74 dispevent
*This
= impl_from_IDispatch( iface
);
75 return InterlockedIncrement( &This
->ref
);
78 static ULONG WINAPI
dispevent_Release(IDispatch
*iface
)
80 dispevent
*This
= impl_from_IDispatch( iface
);
81 ULONG ref
= InterlockedDecrement( &This
->ref
);
84 HeapFree(GetProcessHeap(), 0, This
);
89 static HRESULT WINAPI
dispevent_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
96 static HRESULT WINAPI
dispevent_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
97 LCID lcid
, ITypeInfo
**ppTInfo
)
103 static HRESULT WINAPI
dispevent_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
104 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
110 static HRESULT WINAPI
dispevent_Invoke(IDispatch
*iface
, DISPID member
, REFIID riid
,
111 LCID lcid
, WORD flags
, DISPPARAMS
*params
, VARIANT
*result
,
112 EXCEPINFO
*excepInfo
, UINT
*argErr
)
114 ok(member
== 0, "expected 0 member, got %d\n", member
);
115 ok(lcid
== LOCALE_SYSTEM_DEFAULT
, "expected LOCALE_SYSTEM_DEFAULT, got lcid %x\n", lcid
);
116 ok(flags
== DISPATCH_METHOD
, "expected DISPATCH_METHOD, got %d\n", flags
);
118 ok(params
->cArgs
== 0, "got %d\n", params
->cArgs
);
119 ok(params
->cNamedArgs
== 0, "got %d\n", params
->cNamedArgs
);
120 ok(params
->rgvarg
== NULL
, "got %p\n", params
->rgvarg
);
121 ok(params
->rgdispidNamedArgs
== NULL
, "got %p\n", params
->rgdispidNamedArgs
);
123 ok(result
== NULL
, "got %p\n", result
);
124 ok(excepInfo
== NULL
, "got %p\n", excepInfo
);
125 ok(argErr
== NULL
, "got %p\n", argErr
);
131 static const IDispatchVtbl dispeventVtbl
=
133 dispevent_QueryInterface
,
136 dispevent_GetTypeInfoCount
,
137 dispevent_GetTypeInfo
,
138 dispevent_GetIDsOfNames
,
142 static IDispatch
* create_dispevent(void)
144 dispevent
*event
= HeapAlloc(GetProcessHeap(), 0, sizeof(*event
));
146 event
->lpVtbl
= &dispeventVtbl
;
149 return (IDispatch
*)&event
->lpVtbl
;
153 static const WCHAR szEmpty
[] = { 0 };
154 static const WCHAR szIncomplete
[] = {
155 '<','?','x','m','l',' ',
156 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
158 static const WCHAR szComplete1
[] = {
159 '<','?','x','m','l',' ',
160 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
161 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
163 static const WCHAR szComplete2
[] = {
164 '<','?','x','m','l',' ',
165 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
166 '<','o','>','<','/','o','>','\n',0
168 static const WCHAR szComplete3
[] = {
169 '<','?','x','m','l',' ',
170 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
171 '<','a','>','<','/','a','>','\n',0
173 static const WCHAR szComplete4
[] = {
174 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
175 '<','l','c',' ','d','l','=','\'','s','t','r','1','\'','>','\n',
176 '<','b','s',' ','v','r','=','\'','s','t','r','2','\'',' ','s','z','=','\'','1','2','3','4','\'','>',
177 'f','n','1','.','t','x','t','\n',
178 '<','/','b','s','>','\n',
179 '<','p','r',' ','i','d','=','\'','s','t','r','3','\'',' ','v','r','=','\'','1','.','2','.','3','\'',' ',
180 'p','n','=','\'','w','i','n','e',' ','2','0','0','5','0','8','0','4','\'','>','\n',
181 'f','n','2','.','t','x','t','\n',
182 '<','/','p','r','>','\n',
183 '<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
184 '<','f','o','>','\n',
185 '<','b','a','>','\n',
187 '<','/','b','a','>','\n',
188 '<','/','f','o','>','\n',
189 '<','/','l','c','>','\n',0
191 static const WCHAR szComplete5
[] = {
192 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
193 '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','"',
194 ' ','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','"','>',
195 '<','S',':','s','c','o','p','e','>',
196 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
197 '<','/','S',':','s','c','o','p','e','>',
198 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
199 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
200 'c','o','m','p','u','t','e','r',
201 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
202 '<','/','S',':','s','e','a','r','c','h','>',0
205 static const WCHAR szComplete6
[] = {
206 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'',' ',
207 'e','n','c','o','d','i','n','g','=','\'','W','i','n','d','o','w','s','-','1','2','5','2','\'','?','>','\n',
208 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
211 static const CHAR szNonUnicodeXML
[] =
212 "<?xml version='1.0' encoding='Windows-1252'?>\n"
215 static const CHAR szExampleXML
[] =
216 "<?xml version='1.0' encoding='utf-8'?>\n"
217 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
222 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
223 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
224 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
226 " <html xml:space='preserve' xmlns='http://www.w3.org/1999/xhtml'>\n"
227 " This is <strong>a</strong> <i>description</i> with preserved whitespace. <bar:x/>\n"
235 " <c type=\"old\">C2 field</c>\n"
238 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
247 " <foo:c>C4 field</foo:c>\n"
251 static const CHAR szNodeTypesXML
[] =
252 "<?xml version='1.0'?>"
253 "<!-- comment node 0 -->"
254 "<root id='0' depth='0'>"
255 " <!-- comment node 1 -->"
257 " <x id='1' depth='1'>"
258 " <?foo value='PI for x'?>"
259 " <!-- comment node 2 -->"
261 " <a id='3' depth='2'/>"
262 " <b id='4' depth='2'/>"
263 " <c id='5' depth='2'/>"
265 " <y id='2' depth='1'>"
266 " <?bar value='PI for y'?>"
267 " <!-- comment node 3 -->"
269 " <a id='6' depth='2'/>"
270 " <b id='7' depth='2'/>"
271 " <c id='8' depth='2'/>"
275 static const CHAR szTransformXML
[] =
276 "<?xml version=\"1.0\"?>\n"
281 static const CHAR szTransformSSXML
[] =
282 "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n"
283 " <xsl:output method=\"html\"/>\n"
284 " <xsl:template match=\"/\">\n"
285 " <xsl:apply-templates select=\"greeting\"/>\n"
287 " <xsl:template match=\"greeting\">\n"
291 " <xsl:value-of select=\".\"/>\n"
298 static const CHAR szTransformOutput
[] =
301 "</h1></body></html>";
303 static const CHAR szTypeValueXML
[] =
304 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
305 "<root xmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n"
306 " <string>Wine</string>\n"
307 " <string2 dt:dt=\"string\">String</string2>\n"
308 " <number dt:dt=\"number\">12.44</number>\n"
309 " <number2 dt:dt=\"NUMbEr\">-3.71e3</number2>\n"
310 " <int dt:dt=\"int\">-13</int>\n"
311 " <fixed dt:dt=\"fixed.14.4\">7322.9371</fixed>\n"
312 " <bool dt:dt=\"boolean\">1</bool>\n"
313 " <datetime dt:dt=\"datetime\">2009-11-18T03:21:33.12</datetime>\n"
314 " <datetimetz dt:dt=\"datetime.tz\">2003-07-11T11:13:57+03:00</datetimetz>\n"
315 " <date dt:dt=\"date\">3721-11-01</date>\n"
316 " <time dt:dt=\"time\">13:57:12.31321</time>\n"
317 " <timetz dt:dt=\"time.tz\">23:21:01.13+03:21</timetz>\n"
318 " <i1 dt:dt=\"i1\">-13</i1>\n"
319 " <i2 dt:dt=\"i2\">31915</i2>\n"
320 " <i4 dt:dt=\"i4\">-312232</i4>\n"
321 " <ui1 dt:dt=\"ui1\">123</ui1>\n"
322 " <ui2 dt:dt=\"ui2\">48282</ui2>\n"
323 " <ui4 dt:dt=\"ui4\">949281</ui4>\n"
324 " <r4 dt:dt=\"r4\">213124.0</r4>\n"
325 " <r8 dt:dt=\"r8\">0.412</r8>\n"
326 " <float dt:dt=\"float\">41221.421</float>\n"
327 " <uuid dt:dt=\"uuid\">333C7BC4-460F-11D0-BC04-0080C7055a83</uuid>\n"
328 " <binhex dt:dt=\"bin.hex\">fffca012003c</binhex>\n"
329 " <binbase64 dt:dt=\"bin.base64\">YmFzZTY0IHRlc3Q=</binbase64>\n"
332 static const CHAR szBasicTransformSSXMLPart1
[] =
333 "<?xml version=\"1.0\"?>"
334 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >"
335 "<xsl:output method=\"html\"/>\n"
336 "<xsl:template match=\"/\">"
337 "<HTML><BODY><TABLE>"
338 " <xsl:apply-templates select='document(\"";
340 static const CHAR szBasicTransformSSXMLPart2
[] =
342 " <xsl:sort select=\"cost\"/><xsl:sort select=\"name\"/>"
343 " </xsl:apply-templates>"
344 "</TABLE></BODY></HTML>"
346 "<xsl:template match=\"bottle\">"
347 " <TR><xsl:apply-templates select=\"name\" /><xsl:apply-templates select=\"cost\" /></TR>"
349 "<xsl:template match=\"name\">"
350 " <TD><xsl:apply-templates /></TD>"
352 "<xsl:template match=\"cost\">"
353 " <TD><xsl:apply-templates /></TD>"
357 static const CHAR szBasicTransformXML
[] =
358 "<?xml version=\"1.0\"?><bottle><wine><name>Wine</name><cost>$25.00</cost></wine></bottle>";
360 static const CHAR szBasicTransformOutput
[] =
361 "<HTML><BODY><TABLE><TD>Wine</TD><TD>$25.00</TD></TABLE></BODY></HTML>";
363 #define SZ_EMAIL_DTD \
365 " <!ELEMENT email (recipients,from,reply-to?,subject,body,attachment*)>"\
366 " <!ATTLIST email attachments IDREFS #REQUIRED>"\
367 " <!ATTLIST email sent (yes|no) \"no\">"\
368 " <!ELEMENT recipients (to+,cc*)>"\
369 " <!ELEMENT to (#PCDATA)>"\
370 " <!ATTLIST to name CDATA #IMPLIED>"\
371 " <!ELEMENT cc (#PCDATA)>"\
372 " <!ATTLIST cc name CDATA #IMPLIED>"\
373 " <!ELEMENT from (#PCDATA)>"\
374 " <!ATTLIST from name CDATA #IMPLIED>"\
375 " <!ELEMENT reply-to (#PCDATA)>"\
376 " <!ATTLIST reply-to name CDATA #IMPLIED>"\
377 " <!ELEMENT subject ANY>"\
378 " <!ELEMENT body ANY>"\
379 " <!ATTLIST body enc CDATA #FIXED \"UTF-8\">"\
380 " <!ELEMENT attachment (#PCDATA)>"\
381 " <!ATTLIST attachment id ID #REQUIRED>"\
384 static const CHAR szEmailXML
[] =
385 "<?xml version=\"1.0\"?>"
387 "<email attachments=\"patch1\">"
389 " <to>wine-patches@winehq.org</to>"
391 " <from name=\"Anonymous\">user@localhost</from>"
392 " <subject>msxml3/tests: DTD validation (try 87)</subject>"
394 " It no longer causes spontaneous combustion..."
396 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
399 static const CHAR szEmailXML_0D
[] =
400 "<?xml version=\"1.0\"?>"
402 "<email attachments=\"patch1\">"
404 " <to>wine-patches@winehq.org</to>"
406 " <from name=\"Anonymous\">user@localhost</from>"
407 " <subject>msxml3/tests: DTD validation (try 88)</subject>"
410 " XML_ELEMENT_UNDECLARED 0xC00CE00D"
412 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
415 static const CHAR szEmailXML_0E
[] =
416 "<?xml version=\"1.0\"?>"
418 "<email attachments=\"patch1\">"
420 " <to>wine-patches@winehq.org</to>"
422 " <from name=\"Anonymous\">user@localhost</from>"
423 " <subject>msxml3/tests: DTD validation (try 89)</subject>"
425 " XML_ELEMENT_ID_NOT_FOUND 0xC00CE00E"
427 " <attachment id=\"patch\">0001-msxml3-tests-DTD-validation.patch</attachment>"
430 static const CHAR szEmailXML_11
[] =
431 "<?xml version=\"1.0\"?>"
433 "<email attachments=\"patch1\">"
436 " <from name=\"Anonymous\">user@localhost</from>"
437 " <subject>msxml3/tests: DTD validation (try 90)</subject>"
439 " XML_EMPTY_NOT_ALLOWED 0xC00CE011"
441 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
444 static const CHAR szEmailXML_13
[] =
445 "<?xml version=\"1.0\"?>"
447 "<msg attachments=\"patch1\">"
449 " <to>wine-patches@winehq.org</to>"
451 " <from name=\"Anonymous\">user@localhost</from>"
452 " <subject>msxml3/tests: DTD validation (try 91)</subject>"
454 " XML_ROOT_NAME_MISMATCH 0xC00CE013"
456 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
459 static const CHAR szEmailXML_14
[] =
460 "<?xml version=\"1.0\"?>"
462 "<email attachments=\"patch1\">"
463 " <to>wine-patches@winehq.org</to>"
464 " <from name=\"Anonymous\">user@localhost</from>"
465 " <subject>msxml3/tests: DTD validation (try 92)</subject>"
467 " XML_INVALID_CONTENT 0xC00CE014"
469 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
472 static const CHAR szEmailXML_15
[] =
473 "<?xml version=\"1.0\"?>"
475 "<email attachments=\"patch1\" ip=\"127.0.0.1\">"
477 " <to>wine-patches@winehq.org</to>"
479 " <from name=\"Anonymous\">user@localhost</from>"
480 " <subject>msxml3/tests: DTD validation (try 93)</subject>"
482 " XML_ATTRIBUTE_NOT_DEFINED 0xC00CE015"
484 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
487 static const CHAR szEmailXML_16
[] =
488 "<?xml version=\"1.0\"?>"
490 "<email attachments=\"patch1\">"
492 " <to>wine-patches@winehq.org</to>"
494 " <from name=\"Anonymous\">user@localhost</from>"
495 " <subject>msxml3/tests: DTD validation (try 94)</subject>"
496 " <body enc=\"ASCII\">"
497 " XML_ATTRIBUTE_FIXED 0xC00CE016"
499 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
502 static const CHAR szEmailXML_17
[] =
503 "<?xml version=\"1.0\"?>"
505 "<email attachments=\"patch1\" sent=\"true\">"
507 " <to>wine-patches@winehq.org</to>"
509 " <from name=\"Anonymous\">user@localhost</from>"
510 " <subject>msxml3/tests: DTD validation (try 95)</subject>"
512 " XML_ATTRIBUTE_VALUE 0xC00CE017"
514 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
517 static const CHAR szEmailXML_18
[] =
518 "<?xml version=\"1.0\"?>"
520 "<email attachments=\"patch1\">"
523 " <to>wine-patches@winehq.org</to>"
525 " <from name=\"Anonymous\">user@localhost</from>"
526 " <subject>msxml3/tests: DTD validation (try 96)</subject>"
528 " XML_ILLEGAL_TEXT 0xC00CE018"
530 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
533 static const CHAR szEmailXML_20
[] =
534 "<?xml version=\"1.0\"?>"
538 " <to>wine-patches@winehq.org</to>"
540 " <from name=\"Anonymous\">user@localhost</from>"
541 " <subject>msxml3/tests: DTD validation (try 97)</subject>"
543 " XML_REQUIRED_ATTRIBUTE_MISSING 0xC00CE020"
545 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
548 static const CHAR szDatatypeXDR
[] =
549 "<Schema xmlns='urn:schemas-microsoft-com:xml-data'\n"
550 " xmlns:dt='urn:schemas-microsoft-com:datatypes'>\n"
551 " <ElementType name='base64Data' content='textOnly' dt:type='bin.base64'/>\n"
552 " <ElementType name='hexData' content='textOnly' dt:type='bin.hex'/>\n"
553 " <ElementType name='boolData' content='textOnly' dt:type='boolean'/>\n"
554 " <ElementType name='charData' content='textOnly' dt:type='char'/>\n"
555 " <ElementType name='dateData' content='textOnly' dt:type='date'/>\n"
556 " <ElementType name='dateTimeData' content='textOnly' dt:type='dateTime'/>\n"
557 " <ElementType name='dateTimeTzData' content='textOnly' dt:type='dateTime.tz'/>\n"
558 " <ElementType name='entityData' content='textOnly' dt:type='entity'/>\n"
559 " <ElementType name='entitiesData' content='textOnly' dt:type='entities'/>\n"
560 " <ElementType name='fixedData' content='textOnly' dt:type='fixed.14.4'/>\n"
561 " <ElementType name='floatData' content='textOnly' dt:type='float'/>\n"
562 " <ElementType name='i1Data' content='textOnly' dt:type='i1'/>\n"
563 " <ElementType name='i2Data' content='textOnly' dt:type='i2'/>\n"
564 " <ElementType name='i4Data' content='textOnly' dt:type='i4'/>\n"
565 " <ElementType name='i8Data' content='textOnly' dt:type='i8'/>\n"
566 " <ElementType name='intData' content='textOnly' dt:type='int'/>\n"
567 " <ElementType name='nmtokData' content='textOnly' dt:type='nmtoken'/>\n"
568 " <ElementType name='nmtoksData' content='textOnly' dt:type='nmtokens'/>\n"
569 " <ElementType name='numData' content='textOnly' dt:type='number'/>\n"
570 " <ElementType name='r4Data' content='textOnly' dt:type='r4'/>\n"
571 " <ElementType name='r8Data' content='textOnly' dt:type='r8'/>\n"
572 " <ElementType name='stringData' content='textOnly' dt:type='string'/>\n"
573 " <ElementType name='timeData' content='textOnly' dt:type='time'/>\n"
574 " <ElementType name='timeTzData' content='textOnly' dt:type='time.tz'/>\n"
575 " <ElementType name='u1Data' content='textOnly' dt:type='ui1'/>\n"
576 " <ElementType name='u2Data' content='textOnly' dt:type='ui2'/>\n"
577 " <ElementType name='u4Data' content='textOnly' dt:type='ui4'/>\n"
578 " <ElementType name='u8Data' content='textOnly' dt:type='ui8'/>\n"
579 " <ElementType name='uriData' content='textOnly' dt:type='uri'/>\n"
580 " <ElementType name='uuidData' content='textOnly' dt:type='uuid'/>\n"
582 " <ElementType name='Name' content='textOnly' dt:type='nmtoken'/>\n"
583 " <ElementType name='Value' content='eltOnly' order='many'>\n"
584 " <element type='base64Data'/>\n"
585 " <element type='hexData'/>\n"
586 " <element type='boolData'/>\n"
587 " <element type='charData'/>\n"
588 " <element type='dateData'/>\n"
589 " <element type='dateTimeData'/>\n"
590 " <element type='dateTimeTzData'/>\n"
591 " <element type='entityData'/>\n"
592 " <element type='entitiesData'/>\n"
593 " <element type='fixedData'/>\n"
594 " <element type='floatData'/>\n"
595 " <element type='i1Data'/>\n"
596 " <element type='i2Data'/>\n"
597 " <element type='i4Data'/>\n"
598 " <element type='i8Data'/>\n"
599 " <element type='intData'/>\n"
600 " <element type='nmtokData'/>\n"
601 " <element type='nmtoksData'/>\n"
602 " <element type='numData'/>\n"
603 " <element type='r4Data'/>\n"
604 " <element type='r8Data'/>\n"
605 " <element type='stringData'/>\n"
606 " <element type='timeData'/>\n"
607 " <element type='timeTzData'/>\n"
608 " <element type='u1Data'/>\n"
609 " <element type='u2Data'/>\n"
610 " <element type='u4Data'/>\n"
611 " <element type='u8Data'/>\n"
612 " <element type='uriData'/>\n"
613 " <element type='uuidData'/>\n"
615 " <ElementType name='Property' content='eltOnly' order='seq'>\n"
616 " <element type='Name'/>\n"
617 " <element type='Value'/>\n"
619 " <ElementType name='Properties' content='eltOnly'>\n"
620 " <element type='Property' minOccurs='0' maxOccurs='*'/>\n"
624 static const CHAR szDatatypeXML
[] =
625 "<?xml version='1.0'?>\n"
626 "<Properties xmlns='urn:x-schema:datatype-test-xdr'>\n"
628 " <Name>testBase64</Name>\n"
630 " <base64Data>+HugeNumber+</base64Data>\n"
634 " <Name>testHex</Name>\n"
636 " <hexData>deadbeef</hexData>\n"
640 " <Name>testBool</Name>\n"
642 " <boolData>1</boolData>\n"
646 " <Name>testChar</Name>\n"
648 " <charData>u</charData>\n"
652 " <Name>testDate</Name>\n"
654 " <dateData>1998-02-01</dateData>\n"
658 " <Name>testDateTime</Name>\n"
660 " <dateTimeData>1998-02-01T12:34:56</dateTimeData>\n"
664 " <Name>testDateTimeTz</Name>\n"
666 " <dateTimeTzData>1998-02-01T12:34:56-06:00</dateTimeTzData>\n"
670 " <Name>testFixed</Name>\n"
672 " <fixedData>3.1416</fixedData>\n"
676 " <Name>testFloat</Name>\n"
678 " <floatData>3.14159</floatData>\n"
682 " <Name>testI1</Name>\n"
684 " <i1Data>42</i1Data>\n"
688 " <Name>testI2</Name>\n"
690 " <i2Data>420</i2Data>\n"
694 " <Name>testI4</Name>\n"
696 " <i4Data>-420000000</i4Data>\n"
700 " <Name>testI8</Name>\n"
702 " <i8Data>-4200000000</i8Data>\n"
706 " <Name>testInt</Name>\n"
708 " <intData>42</intData>\n"
712 " <Name>testNmtoken</Name>\n"
714 " <nmtokData>tok1</nmtokData>\n"
718 " <Name>testNmtokens</Name>\n"
720 " <nmtoksData>tok1 tok2 tok3</nmtoksData>\n"
724 " <Name>testNumber</Name>\n"
726 " <numData>3.14159</numData>\n"
730 " <Name>testR4</Name>\n"
732 " <r4Data>3.14159265</r4Data>\n"
736 " <Name>testR8</Name>\n"
738 " <r8Data>3.14159265358979323846</r8Data>\n"
742 " <Name>testString</Name>\n"
744 " <stringData>foo bar</stringData>\n"
748 " <Name>testTime</Name>\n"
750 " <timeData>12:34:56</timeData>\n"
754 " <Name>testTimeTz</Name>\n"
756 " <timeTzData>12:34:56-06:00</timeTzData>\n"
760 " <Name>testU1</Name>\n"
762 " <u1Data>255</u1Data>\n"
766 " <Name>testU2</Name>\n"
768 " <u2Data>65535</u2Data>\n"
772 " <Name>testU4</Name>\n"
774 " <u4Data>4294967295</u4Data>\n"
778 " <Name>testU8</Name>\n"
780 " <u8Data>18446744073709551615</u8Data>\n"
784 " <Name>testURI</Name>\n"
786 " <uriData>urn:schemas-microsoft-com:datatypes</uriData>\n"
790 " <Name>testUUID</Name>\n"
792 " <uuidData>2933BF81-7B36-11D2-B20E-00C04F983E60</uuidData>\n"
797 static const WCHAR szNonExistentFile
[] = {
798 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
800 static const WCHAR szNonExistentAttribute
[] = {
801 'n','o','n','E','x','i','s','i','t','i','n','g','A','t','t','r','i','b','u','t','e',0
803 static const WCHAR szDocument
[] = {
804 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
807 static const WCHAR szOpen
[] = { 'o','p','e','n',0 };
808 static WCHAR szdl
[] = { 'd','l',0 };
809 static const WCHAR szvr
[] = { 'v','r',0 };
810 static const WCHAR szlc
[] = { 'l','c',0 };
811 static WCHAR szbs
[] = { 'b','s',0 };
812 static const WCHAR szstr1
[] = { 's','t','r','1',0 };
813 static const WCHAR szstr2
[] = { 's','t','r','2',0 };
814 static const WCHAR szstar
[] = { '*',0 };
815 static const WCHAR szfn1_txt
[] = {'f','n','1','.','t','x','t',0};
817 static WCHAR szComment
[] = {'A',' ','C','o','m','m','e','n','t',0 };
818 static WCHAR szCommentXML
[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
819 static WCHAR szCommentNodeText
[] = {'#','c','o','m','m','e','n','t',0 };
821 static WCHAR szElement
[] = {'E','l','e','T','e','s','t', 0 };
822 static WCHAR szElementXML
[] = {'<','E','l','e','T','e','s','t','/','>',0 };
823 static WCHAR szElementXML2
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
824 static WCHAR szElementXML3
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
825 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
826 static WCHAR szElementXML4
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
827 '&','a','m','p',';','x',' ',0x2103,'<','/','E','l','e','T','e','s','t','>',0 };
829 static WCHAR szAttribute
[] = {'A','t','t','r',0 };
830 static WCHAR szAttributeXML
[] = {'A','t','t','r','=','"','"',0 };
832 static WCHAR szCData
[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
833 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
834 static WCHAR szCDataXML
[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
835 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
837 static WCHAR szCDataNodeText
[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
838 static WCHAR szDocFragmentText
[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
840 static WCHAR szEntityRef
[] = {'e','n','t','i','t','y','r','e','f',0 };
841 static WCHAR szEntityRefXML
[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
842 static WCHAR szStrangeChars
[] = {'&','x',' ',0x2103, 0};
844 #define expect_bstr_eq_and_free(bstr, expect) { \
845 BSTR bstrExp = alloc_str_from_narrow(expect); \
846 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
847 SysFreeString(bstr); \
848 SysFreeString(bstrExp); \
851 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
853 #define ole_check(expr) { \
855 ok(r == S_OK, #expr " returned %x\n", r); \
858 #define ole_expect(expr, expect) { \
860 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
863 #define double_eq(x, y) ok((x)-(y)<=1e-14*(x) && (x)-(y)>=-1e-14*(x), "expected %.16g, got %.16g\n", x, y)
865 static void* _create_object(const GUID
*clsid
, const char *name
, const IID
*iid
, int line
)
870 hr
= CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
, iid
, &obj
);
872 win_skip_(__FILE__
,line
)("failed to create %s instance: 0x%08x\n", name
, hr
);
877 #define _create(cls) cls, #cls
879 #define create_document(iid) _create_object(&_create(CLSID_DOMDocument), iid, __LINE__)
881 #define create_document_version(v, iid) _create_object(&_create(CLSID_DOMDocument ## v), iid, __LINE__)
883 #define create_cache(iid) _create_object(&_create(CLSID_XMLSchemaCache), iid, __LINE__)
885 #define create_cache_version(v, iid) _create_object(&_create(CLSID_XMLSchemaCache ## v), iid, __LINE__)
887 static BSTR
alloc_str_from_narrow(const char *str
)
889 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
890 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
891 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
895 static BSTR alloced_bstrs
[256];
896 static int alloced_bstrs_count
;
898 static BSTR
_bstr_(const char *str
)
900 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
901 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
902 return alloced_bstrs
[alloced_bstrs_count
++];
905 static void free_bstrs(void)
908 for (i
= 0; i
< alloced_bstrs_count
; i
++)
909 SysFreeString(alloced_bstrs
[i
]);
910 alloced_bstrs_count
= 0;
913 static VARIANT
_variantbstr_(const char *str
)
917 V_BSTR(&v
) = _bstr_(str
);
921 static BOOL
compareIgnoreReturns(BSTR sLeft
, BSTR sRight
)
925 while (*sLeft
== '\r' || *sLeft
== '\n') sLeft
++;
926 while (*sRight
== '\r' || *sRight
== '\n') sRight
++;
927 if (*sLeft
!= *sRight
) return FALSE
;
928 if (!*sLeft
) return TRUE
;
934 static void get_str_for_type(DOMNodeType type
, char *buf
)
953 case NODE_PROCESSING_INSTRUCTION
:
957 wsprintfA(buf
, "[%d]", type
);
961 #define test_disp(u) _test_disp(__LINE__,u)
962 static void _test_disp(unsigned line
, IUnknown
*unk
)
964 DISPID dispid
= DISPID_XMLDOM_NODELIST_RESET
;
972 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
973 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatch: %08x\n", hres
);
978 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
979 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
980 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
982 sName
= SysAllocString( szstar
);
983 hres
= IDispatchEx_DeleteMemberByName(dispex
, sName
, fdexNameCaseSensitive
);
984 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
985 SysFreeString( sName
);
987 hres
= IDispatchEx_DeleteMemberByDispID(dispex
, dispid
);
988 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
990 hres
= IDispatchEx_GetMemberProperties(dispex
, dispid
, grfdexPropCanAll
, &dwProps
);
991 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
992 ok(dwProps
== 0, "expected 0 got %d\n", dwProps
);
994 hres
= IDispatchEx_GetMemberName(dispex
, dispid
, &sName
);
995 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
997 SysFreeString(sName
);
999 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumDefault
, DISPID_XMLDOM_NODELIST_RESET
, &dispid
);
1000 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
1002 hres
= IDispatchEx_GetNameSpaceParent(dispex
, &pUnk
);
1003 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
1004 if(hres
== S_OK
&& pUnk
)
1005 IUnknown_Release(pUnk
);
1007 IDispatchEx_Release(dispex
);
1010 static int get_node_position(IXMLDOMNode
*node
)
1015 IXMLDOMNode_AddRef(node
);
1018 IXMLDOMNode
*new_node
;
1021 r
= IXMLDOMNode_get_previousSibling(node
, &new_node
);
1022 ok(SUCCEEDED(r
), "get_previousSibling failed\n");
1023 IXMLDOMNode_Release(node
);
1025 } while (r
== S_OK
);
1029 static void node_to_string(IXMLDOMNode
*node
, char *buf
)
1036 lstrcpyA(buf
, "(null)");
1040 IXMLDOMNode_AddRef(node
);
1043 IXMLDOMNode
*new_node
;
1045 ole_check(IXMLDOMNode_get_nodeType(node
, &type
));
1046 get_str_for_type(type
, buf
);
1049 if (type
== NODE_ATTRIBUTE
)
1052 ole_check(IXMLDOMNode_get_nodeName(node
, &bstr
));
1054 wsprintfA(buf
, "%ws", bstr
);
1057 SysFreeString(bstr
);
1059 r
= IXMLDOMNode_selectSingleNode(node
, _bstr_(".."), &new_node
);
1063 r
= IXMLDOMNode_get_parentNode(node
, &new_node
);
1064 wsprintf(buf
, "%d", get_node_position(node
));
1068 ok(SUCCEEDED(r
), "get_parentNode failed (%08x)\n", r
);
1069 IXMLDOMNode_Release(node
);
1078 static char *list_to_string(IXMLDOMNodeList
*list
)
1080 static char buf
[4096];
1087 lstrcpyA(buf
, "(null)");
1090 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
1091 for (i
= 0; i
< len
; i
++)
1096 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
1097 node_to_string(node
, pos
);
1099 IXMLDOMNode_Release(node
);
1105 #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); }
1106 #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); }
1108 static void test_domdoc( void )
1111 IXMLDOMDocument
*doc
;
1112 IXMLDOMParseError
*error
;
1113 IXMLDOMElement
*element
= NULL
;
1115 IXMLDOMText
*nodetext
= NULL
;
1116 IXMLDOMComment
*node_comment
= NULL
;
1117 IXMLDOMAttribute
*node_attr
= NULL
;
1118 IXMLDOMNode
*nodeChild
= NULL
;
1119 IXMLDOMProcessingInstruction
*nodePI
= NULL
;
1120 ISupportErrorInfo
*support_error
= NULL
;
1128 doc
= create_document(&IID_IXMLDOMDocument
);
1131 test_disp((IUnknown
*)doc
);
1135 /* crashes on native */
1136 r
= IXMLDOMDocument_loadXML( doc
, (BSTR
)0x1, NULL
);
1139 /* try some stupid things */
1140 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
1141 ok( r
== S_FALSE
, "loadXML succeeded\n");
1144 r
= IXMLDOMDocument_loadXML( doc
, NULL
, &b
);
1145 ok( r
== S_FALSE
, "loadXML succeeded\n");
1146 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
1148 /* try to load a document from a nonexistent file */
1150 str
= SysAllocString( szNonExistentFile
);
1152 V_VT(&var
) = VT_BSTR
;
1155 r
= IXMLDOMDocument_load( doc
, var
, &b
);
1156 ok( r
== S_FALSE
, "loadXML succeeded\n");
1157 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
1158 SysFreeString( str
);
1160 /* try load an empty document */
1162 str
= SysAllocString( szEmpty
);
1163 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1164 ok( r
== S_FALSE
, "loadXML succeeded\n");
1165 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
1166 SysFreeString( str
);
1168 r
= IXMLDOMDocument_get_async( doc
, &b
);
1169 ok( r
== S_OK
, "get_async failed (%08x)\n", r
);
1170 ok( b
== VARIANT_TRUE
, "Wrong default value\n");
1172 /* check that there's no document element */
1174 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1175 ok( r
== S_FALSE
, "should be no document element\n");
1177 /* try finding a node */
1179 str
= SysAllocString( szstr1
);
1180 r
= IXMLDOMDocument_selectSingleNode( doc
, str
, &node
);
1181 ok( r
== S_FALSE
, "ret %08x\n", r
);
1182 SysFreeString( str
);
1185 str
= SysAllocString( szIncomplete
);
1186 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1187 ok( r
== S_FALSE
, "loadXML succeeded\n");
1188 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
1189 SysFreeString( str
);
1191 /* check that there's no document element */
1192 element
= (IXMLDOMElement
*)1;
1193 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1194 ok( r
== S_FALSE
, "should be no document element\n");
1195 ok( element
== NULL
, "Element should be NULL\n");
1197 /* test for BSTR handling, pass broken BSTR */
1198 memcpy(&buff
[2], szComplete1
, sizeof(szComplete1
));
1199 /* just a big length */
1200 *(DWORD
*)buff
= 0xf0f0;
1202 r
= IXMLDOMDocument_loadXML( doc
, &buff
[2], &b
);
1203 ok( r
== S_OK
, "loadXML failed\n");
1204 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1206 /* loadXML ignores the encoding attribute and always expects Unicode */
1208 str
= SysAllocString( szComplete6
);
1209 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1210 ok( r
== S_OK
, "loadXML failed\n");
1211 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1212 SysFreeString( str
);
1214 /* try a BSTR containing a Windows-1252 document */
1216 str
= SysAllocStringByteLen( szNonUnicodeXML
, sizeof(szNonUnicodeXML
) - 1 );
1217 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1218 ok( r
== S_FALSE
, "loadXML succeeded\n");
1219 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
1220 SysFreeString( str
);
1222 /* try to load something valid */
1224 str
= SysAllocString( szComplete1
);
1225 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1226 ok( r
== S_OK
, "loadXML failed\n");
1227 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1228 SysFreeString( str
);
1230 /* check if nodename is correct */
1231 r
= IXMLDOMDocument_get_nodeName( doc
, NULL
);
1232 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1234 str
= (BSTR
)0xdeadbeef;
1235 r
= IXMLDOMDocument_get_baseName( doc
, &str
);
1236 ok ( r
== S_FALSE
, "got 0x%08x\n", r
);
1237 ok (str
== NULL
, "got %p\n", str
);
1239 /* content doesn't matter here */
1241 r
= IXMLDOMDocument_get_nodeName( doc
, &str
);
1242 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1243 ok ( str
!= NULL
, "str is null\n");
1244 ok( !lstrcmpW( str
, szDocument
), "incorrect nodeName\n");
1245 SysFreeString( str
);
1248 r
= IXMLDOMDocument_put_text( doc
, _bstr_("Should Fail") );
1249 ok( r
== E_FAIL
, "ret %08x\n", r
);
1251 /* check that there's a document element */
1253 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1254 ok( r
== S_OK
, "should be a document element\n");
1257 IObjectIdentity
*ident
;
1260 test_disp((IUnknown
*)element
);
1262 r
= IXMLDOMElement_QueryInterface( element
, &IID_IObjectIdentity
, (void**)&ident
);
1263 ok( r
== E_NOINTERFACE
, "ret %08x\n", r
);
1265 r
= IXMLDOMElement_get_tagName( element
, NULL
);
1266 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
1268 /* check if the tag is correct */
1269 r
= IXMLDOMElement_get_tagName( element
, &tag
);
1270 ok( r
== S_OK
, "couldn't get tag name\n");
1271 ok( tag
!= NULL
, "tag was null\n");
1272 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
1273 SysFreeString( tag
);
1275 /* figure out what happens if we try to reload the document */
1276 str
= SysAllocString( szComplete2
);
1277 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1278 ok( r
== S_OK
, "loadXML failed\n");
1279 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1280 SysFreeString( str
);
1282 /* check if the tag is still correct */
1284 r
= IXMLDOMElement_get_tagName( element
, &tag
);
1285 ok( r
== S_OK
, "couldn't get tag name\n");
1286 ok( tag
!= NULL
, "tag was null\n");
1287 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
1288 SysFreeString( tag
);
1290 IXMLDOMElement_Release( element
);
1294 /* as soon as we call loadXML again, the document element will disappear */
1296 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
1297 ok( r
== S_FALSE
, "loadXML failed\n");
1298 ok( b
== 2, "variant modified\n");
1299 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1300 ok( r
== S_FALSE
, "should be no document element\n");
1302 /* try to load something else simple and valid */
1304 str
= SysAllocString( szComplete3
);
1305 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1306 ok( r
== S_OK
, "loadXML failed\n");
1307 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1308 SysFreeString( str
);
1310 /* try something a little more complicated */
1312 str
= SysAllocString( szComplete4
);
1313 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1314 ok( r
== S_OK
, "loadXML failed\n");
1315 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1316 SysFreeString( str
);
1318 r
= IXMLDOMDocument_get_parseError( doc
, &error
);
1319 ok( r
== S_OK
, "returns %08x\n", r
);
1321 r
= IXMLDOMParseError_get_errorCode( error
, &code
);
1322 ok( r
== S_FALSE
, "returns %08x\n", r
);
1323 ok( code
== 0, "code %d\n", code
);
1324 IXMLDOMParseError_Release( error
);
1326 /* test createTextNode */
1327 r
= IXMLDOMDocument_createTextNode(doc
, _bstr_(""), &nodetext
);
1328 ok( r
== S_OK
, "returns %08x\n", r
);
1329 IXMLDOMText_Release(nodetext
);
1331 str
= SysAllocString( szOpen
);
1332 r
= IXMLDOMDocument_createTextNode(doc
, str
, NULL
);
1333 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1334 r
= IXMLDOMDocument_createTextNode(doc
, str
, &nodetext
);
1335 ok( r
== S_OK
, "returns %08x\n", r
);
1336 SysFreeString( str
);
1339 IXMLDOMNamedNodeMap
*pAttribs
;
1341 r
= IXMLDOMText_QueryInterface(nodetext
, &IID_IXMLDOMElement
, (void**)&element
);
1342 ok(r
== E_NOINTERFACE
, "ret %08x\n", r
);
1344 /* Text Last Child Checks */
1345 r
= IXMLDOMText_get_lastChild(nodetext
, NULL
);
1346 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1348 nodeChild
= (IXMLDOMNode
*)0x1;
1349 r
= IXMLDOMText_get_lastChild(nodetext
, &nodeChild
);
1350 ok(r
== S_FALSE
, "ret %08x\n", r
);
1351 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
1353 /* test get_attributes */
1354 r
= IXMLDOMText_get_attributes( nodetext
, NULL
);
1355 ok( r
== E_INVALIDARG
, "get_attributes returned wrong code\n");
1357 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
1358 r
= IXMLDOMText_get_attributes( nodetext
, &pAttribs
);
1359 ok(r
== S_FALSE
, "ret %08x\n", r
);
1360 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
1362 /* test get_dataType */
1363 r
= IXMLDOMText_get_dataType(nodetext
, &var
);
1364 ok(r
== S_FALSE
, "ret %08x\n", r
);
1365 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
1368 /* test length property */
1369 r
= IXMLDOMText_get_length(nodetext
, NULL
);
1370 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1372 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1373 ok(r
== S_OK
, "ret %08x\n", r
);
1374 ok(nLength
== 4, "expected 4 got %d\n", nLength
);
1376 /* test nodeTypeString */
1377 r
= IXMLDOMText_get_nodeTypeString(nodetext
, &str
);
1378 ok(r
== S_OK
, "ret %08x\n", r
);
1379 ok( !lstrcmpW( str
, _bstr_("text") ), "incorrect nodeTypeString string\n");
1382 /* put data Tests */
1383 r
= IXMLDOMText_put_data(nodetext
, _bstr_("This &is a ; test <>\\"));
1384 ok(r
== S_OK
, "ret %08x\n", r
);
1386 /* get data Tests */
1387 r
= IXMLDOMText_get_data(nodetext
, &str
);
1388 ok(r
== S_OK
, "ret %08x\n", r
);
1389 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
1392 /* Confirm XML text is good */
1393 r
= IXMLDOMText_get_xml(nodetext
, &str
);
1394 ok(r
== S_OK
, "ret %08x\n", r
);
1395 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
1398 /* Confirm we get the put_data Text back */
1399 r
= IXMLDOMText_get_text(nodetext
, &str
);
1400 ok(r
== S_OK
, "ret %08x\n", r
);
1401 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
1404 /* test substringData */
1405 r
= IXMLDOMText_substringData(nodetext
, 0, 4, NULL
);
1406 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1408 /* test substringData - Invalid offset */
1409 str
= (BSTR
)&szElement
;
1410 r
= IXMLDOMText_substringData(nodetext
, -1, 4, &str
);
1411 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1412 ok( str
== NULL
, "incorrect string\n");
1414 /* test substringData - Invalid offset */
1415 str
= (BSTR
)&szElement
;
1416 r
= IXMLDOMText_substringData(nodetext
, 30, 0, &str
);
1417 ok(r
== S_FALSE
, "ret %08x\n", r
);
1418 ok( str
== NULL
, "incorrect string\n");
1420 /* test substringData - Invalid size */
1421 str
= (BSTR
)&szElement
;
1422 r
= IXMLDOMText_substringData(nodetext
, 0, -1, &str
);
1423 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1424 ok( str
== NULL
, "incorrect string\n");
1426 /* test substringData - Invalid size */
1427 str
= (BSTR
)&szElement
;
1428 r
= IXMLDOMText_substringData(nodetext
, 2, 0, &str
);
1429 ok(r
== S_FALSE
, "ret %08x\n", r
);
1430 ok( str
== NULL
, "incorrect string\n");
1432 /* test substringData - Start of string */
1433 r
= IXMLDOMText_substringData(nodetext
, 0, 4, &str
);
1434 ok(r
== S_OK
, "ret %08x\n", r
);
1435 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
1438 /* test substringData - Middle of string */
1439 r
= IXMLDOMText_substringData(nodetext
, 13, 4, &str
);
1440 ok(r
== S_OK
, "ret %08x\n", r
);
1441 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
1444 /* test substringData - End of string */
1445 r
= IXMLDOMText_substringData(nodetext
, 20, 4, &str
);
1446 ok(r
== S_OK
, "ret %08x\n", r
);
1447 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
1450 /* test appendData */
1451 r
= IXMLDOMText_appendData(nodetext
, NULL
);
1452 ok(r
== S_OK
, "ret %08x\n", r
);
1454 r
= IXMLDOMText_appendData(nodetext
, _bstr_(""));
1455 ok(r
== S_OK
, "ret %08x\n", r
);
1457 r
= IXMLDOMText_appendData(nodetext
, _bstr_("Append"));
1458 ok(r
== S_OK
, "ret %08x\n", r
);
1460 r
= IXMLDOMText_get_text(nodetext
, &str
);
1461 ok(r
== S_OK
, "ret %08x\n", r
);
1462 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1465 /* test insertData */
1466 str
= SysAllocStringLen(NULL
, 0);
1467 r
= IXMLDOMText_insertData(nodetext
, -1, str
);
1468 ok(r
== S_OK
, "ret %08x\n", r
);
1470 r
= IXMLDOMText_insertData(nodetext
, -1, NULL
);
1471 ok(r
== S_OK
, "ret %08x\n", r
);
1473 r
= IXMLDOMText_insertData(nodetext
, 1000, str
);
1474 ok(r
== S_OK
, "ret %08x\n", r
);
1476 r
= IXMLDOMText_insertData(nodetext
, 1000, NULL
);
1477 ok(r
== S_OK
, "ret %08x\n", r
);
1479 r
= IXMLDOMText_insertData(nodetext
, 0, NULL
);
1480 ok(r
== S_OK
, "ret %08x\n", r
);
1482 r
= IXMLDOMText_insertData(nodetext
, 0, str
);
1483 ok(r
== S_OK
, "ret %08x\n", r
);
1486 r
= IXMLDOMText_insertData(nodetext
, -1, _bstr_("Inserting"));
1487 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1489 r
= IXMLDOMText_insertData(nodetext
, 1000, _bstr_("Inserting"));
1490 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1492 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("Begin "));
1493 ok(r
== S_OK
, "ret %08x\n", r
);
1495 r
= IXMLDOMText_insertData(nodetext
, 17, _bstr_("Middle"));
1496 ok(r
== S_OK
, "ret %08x\n", r
);
1498 r
= IXMLDOMText_insertData(nodetext
, 39, _bstr_(" End"));
1499 ok(r
== S_OK
, "ret %08x\n", r
);
1501 r
= IXMLDOMText_get_text(nodetext
, &str
);
1502 ok(r
== S_OK
, "ret %08x\n", r
);
1503 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1507 /* invalid arguments */
1508 r
= IXMLDOMText_deleteData(nodetext
, -1, 1);
1509 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1511 r
= IXMLDOMText_deleteData(nodetext
, 0, 0);
1512 ok(r
== S_OK
, "ret %08x\n", r
);
1514 r
= IXMLDOMText_deleteData(nodetext
, 0, -1);
1515 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1517 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1518 ok(r
== S_OK
, "ret %08x\n", r
);
1519 ok(nLength
== 43, "expected 43 got %d\n", nLength
);
1521 r
= IXMLDOMText_deleteData(nodetext
, nLength
, 1);
1522 ok(r
== S_OK
, "ret %08x\n", r
);
1524 r
= IXMLDOMText_deleteData(nodetext
, nLength
+1, 1);
1525 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1527 /* delete from start */
1528 r
= IXMLDOMText_deleteData(nodetext
, 0, 5);
1529 ok(r
== S_OK
, "ret %08x\n", r
);
1531 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1532 ok(r
== S_OK
, "ret %08x\n", r
);
1533 ok(nLength
== 38, "expected 38 got %d\n", nLength
);
1535 r
= IXMLDOMText_get_text(nodetext
, &str
);
1536 ok(r
== S_OK
, "ret %08x\n", r
);
1537 ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1540 /* delete from end */
1541 r
= IXMLDOMText_deleteData(nodetext
, 35, 3);
1542 ok(r
== S_OK
, "ret %08x\n", r
);
1544 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1545 ok(r
== S_OK
, "ret %08x\n", r
);
1546 ok(nLength
== 35, "expected 35 got %d\n", nLength
);
1548 r
= IXMLDOMText_get_text(nodetext
, &str
);
1549 ok(r
== S_OK
, "ret %08x\n", r
);
1550 ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1553 /* delete from inside */
1554 r
= IXMLDOMText_deleteData(nodetext
, 1, 33);
1555 ok(r
== S_OK
, "ret %08x\n", r
);
1557 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1558 ok(r
== S_OK
, "ret %08x\n", r
);
1559 ok(nLength
== 2, "expected 2 got %d\n", nLength
);
1561 r
= IXMLDOMText_get_text(nodetext
, &str
);
1562 ok(r
== S_OK
, "ret %08x\n", r
);
1563 ok( !lstrcmpW( str
, _bstr_("") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1566 /* delete whole data ... */
1567 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1568 ok(r
== S_OK
, "ret %08x\n", r
);
1570 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
1571 ok(r
== S_OK
, "ret %08x\n", r
);
1572 /* ... and try again with empty string */
1573 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
1574 ok(r
== S_OK
, "ret %08x\n", r
);
1577 V_VT(&var
) = VT_BSTR
;
1578 V_BSTR(&var
) = SysAllocString(szstr1
);
1579 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
1580 ok(r
== S_OK
, "ret %08x\n", r
);
1583 r
= IXMLDOMText_get_text(nodetext
, &str
);
1584 ok(r
== S_OK
, "ret %08x\n", r
);
1585 ok( !lstrcmpW( str
, szstr1
), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1591 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
1592 ok(r
== S_OK
, "ret %08x\n", r
);
1595 r
= IXMLDOMText_get_text(nodetext
, &str
);
1596 ok(r
== S_OK
, "ret %08x\n", r
);
1597 ok( !lstrcmpW( str
, _bstr_("99") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1600 /* ::replaceData() */
1601 V_VT(&var
) = VT_BSTR
;
1602 V_BSTR(&var
) = SysAllocString(szstr1
);
1603 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
1604 ok(r
== S_OK
, "ret %08x\n", r
);
1607 r
= IXMLDOMText_replaceData(nodetext
, 6, 0, NULL
);
1608 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1609 r
= IXMLDOMText_get_text(nodetext
, &str
);
1610 ok(r
== S_OK
, "ret %08x\n", r
);
1611 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1614 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, NULL
);
1615 ok(r
== S_OK
, "ret %08x\n", r
);
1616 r
= IXMLDOMText_get_text(nodetext
, &str
);
1617 ok(r
== S_OK
, "ret %08x\n", r
);
1618 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1621 /* NULL pointer means delete */
1622 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, NULL
);
1623 ok(r
== S_OK
, "ret %08x\n", r
);
1624 r
= IXMLDOMText_get_text(nodetext
, &str
);
1625 ok(r
== S_OK
, "ret %08x\n", r
);
1626 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1629 /* empty string means delete */
1630 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_(""));
1631 ok(r
== S_OK
, "ret %08x\n", r
);
1632 r
= IXMLDOMText_get_text(nodetext
, &str
);
1633 ok(r
== S_OK
, "ret %08x\n", r
);
1634 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1637 /* zero count means insert */
1638 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, _bstr_("a"));
1639 ok(r
== S_OK
, "ret %08x\n", r
);
1640 r
= IXMLDOMText_get_text(nodetext
, &str
);
1641 ok(r
== S_OK
, "ret %08x\n", r
);
1642 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1645 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, NULL
);
1646 ok(r
== S_OK
, "ret %08x\n", r
);
1648 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("m"));
1649 ok(r
== S_OK
, "ret %08x\n", r
);
1650 r
= IXMLDOMText_get_text(nodetext
, &str
);
1651 ok(r
== S_OK
, "ret %08x\n", r
);
1652 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1655 /* nonempty string, count greater than its length */
1656 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, _bstr_("a1.2"));
1657 ok(r
== S_OK
, "ret %08x\n", r
);
1658 r
= IXMLDOMText_get_text(nodetext
, &str
);
1659 ok(r
== S_OK
, "ret %08x\n", r
);
1660 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1663 /* nonempty string, count less than its length */
1664 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_("wine"));
1665 ok(r
== S_OK
, "ret %08x\n", r
);
1666 r
= IXMLDOMText_get_text(nodetext
, &str
);
1667 ok(r
== S_OK
, "ret %08x\n", r
);
1668 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1671 IXMLDOMText_Release( nodetext
);
1674 /* test Create Comment */
1675 r
= IXMLDOMDocument_createComment(doc
, NULL
, NULL
);
1676 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1677 node_comment
= (IXMLDOMComment
*)0x1;
1680 r
= IXMLDOMDocument_createComment(doc
, _bstr_(""), &node_comment
);
1681 ok( r
== S_OK
, "returns %08x\n", r
);
1683 r
= IXMLDOMComment_get_data(node_comment
, &str
);
1684 ok( r
== S_OK
, "returns %08x\n", r
);
1685 ok( str
&& SysStringLen(str
) == 0, "expected empty string data\n");
1686 IXMLDOMComment_Release(node_comment
);
1689 r
= IXMLDOMDocument_createComment(doc
, NULL
, &node_comment
);
1690 ok( r
== S_OK
, "returns %08x\n", r
);
1692 r
= IXMLDOMComment_get_data(node_comment
, &str
);
1693 ok( r
== S_OK
, "returns %08x\n", r
);
1694 ok( str
&& (SysStringLen(str
) == 0), "expected empty string data\n");
1695 IXMLDOMComment_Release(node_comment
);
1698 str
= SysAllocString(szComment
);
1699 r
= IXMLDOMDocument_createComment(doc
, str
, &node_comment
);
1701 ok( r
== S_OK
, "returns %08x\n", r
);
1704 /* Last Child Checks */
1705 r
= IXMLDOMComment_get_lastChild(node_comment
, NULL
);
1706 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1708 nodeChild
= (IXMLDOMNode
*)0x1;
1709 r
= IXMLDOMComment_get_lastChild(node_comment
, &nodeChild
);
1710 ok(r
== S_FALSE
, "ret %08x\n", r
);
1711 ok(nodeChild
== NULL
, "pLastChild not NULL\n");
1714 str
= (BSTR
)0xdeadbeef;
1715 IXMLDOMComment_get_baseName(node_comment
, &str
);
1716 ok(r
== S_FALSE
, "ret %08x\n", r
);
1717 ok(str
== NULL
, "Expected NULL\n");
1719 IXMLDOMComment_Release( node_comment
);
1722 /* test Create Attribute */
1723 str
= SysAllocString(szAttribute
);
1724 r
= IXMLDOMDocument_createAttribute(doc
, NULL
, NULL
);
1725 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1726 r
= IXMLDOMDocument_createAttribute(doc
, str
, &node_attr
);
1727 ok( r
== S_OK
, "returns %08x\n", r
);
1728 IXMLDOMText_Release( node_attr
);
1731 /* test Processing Instruction */
1732 str
= SysAllocStringLen(NULL
, 0);
1733 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, NULL
);
1734 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1735 r
= IXMLDOMDocument_createProcessingInstruction(doc
, NULL
, str
, &nodePI
);
1736 ok( r
== E_FAIL
, "returns %08x\n", r
);
1737 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, &nodePI
);
1738 ok( r
== E_FAIL
, "returns %08x\n", r
);
1741 r
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI
);
1742 ok( r
== S_OK
, "returns %08x\n", r
);
1745 /* Last Child Checks */
1746 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, NULL
);
1747 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1749 nodeChild
= (IXMLDOMNode
*)0x1;
1750 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, &nodeChild
);
1751 ok(r
== S_FALSE
, "ret %08x\n", r
);
1752 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
1754 r
= IXMLDOMProcessingInstruction_get_dataType(nodePI
, &var
);
1755 ok(r
== S_FALSE
, "ret %08x\n", r
);
1756 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
1760 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
1761 ok(r
== S_OK
, "ret %08x\n", r
);
1762 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1767 r
= IXMLDOMProcessingInstruction_get_baseName(nodePI
, &str
);
1768 ok(r
== S_OK
, "ret %08x\n", r
);
1769 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1773 r
= IXMLDOMProcessingInstruction_get_target(nodePI
, &str
);
1774 ok(r
== S_OK
, "ret %08x\n", r
);
1775 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect target string\n");
1778 /* test nodeTypeString */
1779 r
= IXMLDOMProcessingInstruction_get_nodeTypeString(nodePI
, &str
);
1780 ok(r
== S_OK
, "ret %08x\n", r
);
1781 ok( !lstrcmpW( str
, _bstr_("processinginstruction") ), "incorrect nodeTypeString string\n");
1784 /* test get_nodeValue */
1785 r
= IXMLDOMProcessingInstruction_get_nodeValue(nodePI
, &var
);
1786 ok(r
== S_OK
, "ret %08x\n", r
);
1787 ok( !lstrcmpW( V_BSTR(&var
), _bstr_("version=\"1.0\"") ), "incorrect data string\n");
1791 r
= IXMLDOMProcessingInstruction_get_data(nodePI
, &str
);
1792 ok(r
== S_OK
, "ret %08x\n", r
);
1793 ok( !lstrcmpW( str
, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
1797 r
= IXMLDOMProcessingInstruction_put_data(nodePI
, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
1798 ok(r
== E_FAIL
, "ret %08x\n", r
);
1801 V_VT(&var
) = VT_BSTR
;
1802 V_BSTR(&var
) = SysAllocString(szOpen
); /* Doesn't matter what the string is, cannot set an xml node. */
1803 r
= IXMLDOMProcessingInstruction_put_nodeValue(nodePI
, var
);
1804 ok(r
== E_FAIL
, "ret %08x\n", r
);
1807 /* test get nodeName */
1808 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
1809 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1810 ok(r
== S_OK
, "ret %08x\n", r
);
1813 IXMLDOMProcessingInstruction_Release(nodePI
);
1816 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_ISupportErrorInfo
, (void**)&support_error
);
1817 ok( r
== S_OK
, "ret %08x\n", r
);
1820 r
= ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error
, &IID_IXMLDOMDocument
);
1821 todo_wine
ok( r
== S_OK
, "ret %08x\n", r
);
1822 ISupportErrorInfo_Release( support_error
);
1825 r
= IXMLDOMDocument_Release( doc
);
1826 ok( r
== 0, "document ref count incorrect\n");
1831 static void test_persiststreaminit(void)
1833 IXMLDOMDocument
*doc
;
1834 IPersistStreamInit
*streaminit
;
1837 doc
= create_document(&IID_IXMLDOMDocument
);
1840 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&streaminit
);
1841 ok( hr
== S_OK
, "failed with 0x%08x\n", hr
);
1843 hr
= IPersistStreamInit_InitNew(streaminit
);
1844 ok( hr
== S_OK
, "failed with 0x%08x\n", hr
);
1846 IXMLDOMDocument_Release(doc
);
1849 static void test_domnode( void )
1852 IXMLDOMDocument
*doc
, *owner
= NULL
;
1853 IXMLDOMElement
*element
= NULL
;
1854 IXMLDOMNamedNodeMap
*map
= NULL
;
1855 IXMLDOMNode
*node
= NULL
, *next
= NULL
;
1856 IXMLDOMNodeList
*list
= NULL
;
1857 IXMLDOMAttribute
*attr
= NULL
;
1858 DOMNodeType type
= NODE_INVALID
;
1864 doc
= create_document(&IID_IXMLDOMDocument
);
1868 str
= SysAllocString( szComplete4
);
1869 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1870 ok( r
== S_OK
, "loadXML failed\n");
1871 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1872 SysFreeString( str
);
1875 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
1876 ok( r
== S_OK
, "hasChildNoes bad return\n");
1877 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1879 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1880 ok( r
== S_OK
, "should be a document element\n");
1881 ok( element
!= NULL
, "should be an element\n");
1884 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
1886 r
= IXMLDOMNode_get_nodeValue( doc
, NULL
);
1887 ok(r
== E_INVALIDARG
, "get_nodeValue ret %08x\n", r
);
1889 r
= IXMLDOMNode_get_nodeValue( doc
, &var
);
1890 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
1891 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
1892 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
1897 r
= IXMLDOMNode_get_ownerDocument( element
, &owner
);
1898 ok( r
== S_OK
, "get_ownerDocument return code\n");
1899 ok( owner
!= doc
, "get_ownerDocument return\n");
1900 IXMLDOMDocument_Release(owner
);
1902 type
= NODE_INVALID
;
1903 r
= IXMLDOMNode_get_nodeType( element
, &type
);
1904 ok( r
== S_OK
, "got %08x\n", r
);
1905 ok( type
== NODE_ELEMENT
, "node not an element\n");
1908 r
= IXMLDOMNode_get_baseName( element
, &str
);
1909 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1910 ok( lstrcmpW(str
,szlc
) == 0, "basename was wrong\n");
1913 /* check if nodename is correct */
1914 r
= IXMLDOMElement_get_nodeName( element
, NULL
);
1915 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1917 /* content doesn't matter here */
1919 r
= IXMLDOMElement_get_nodeName( element
, &str
);
1920 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1921 ok ( str
!= NULL
, "str is null\n");
1922 ok( !lstrcmpW( str
, szlc
), "incorrect nodeName\n");
1923 SysFreeString( str
);
1925 str
= SysAllocString( szNonExistentFile
);
1927 V_I4(&var
) = 0x1234;
1928 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1929 ok( r
== E_FAIL
, "getAttribute ret %08x\n", r
);
1930 ok( V_VT(&var
) == VT_NULL
|| V_VT(&var
) == VT_EMPTY
, "vt = %x\n", V_VT(&var
));
1933 r
= IXMLDOMElement_getAttributeNode( element
, str
, NULL
);
1934 ok( r
== E_FAIL
, "getAttributeNode ret %08x\n", r
);
1936 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
1937 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1938 ok( r
== E_FAIL
, "getAttributeNode ret %08x\n", r
);
1939 ok( attr
== NULL
, "getAttributeNode ret %p, expected NULL\n", attr
);
1940 SysFreeString( str
);
1942 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
1943 str
= SysAllocString( szNonExistentAttribute
);
1944 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1945 ok( r
== S_FALSE
, "getAttributeNode ret %08x\n", r
);
1946 ok( attr
== NULL
, "getAttributeNode ret %p, expected NULL\n", attr
);
1947 SysFreeString( str
);
1949 str
= SysAllocString( szdl
);
1951 V_I4(&var
) = 0x1234;
1952 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1953 ok( r
== S_OK
, "getAttribute ret %08x\n", r
);
1954 ok( V_VT(&var
) == VT_BSTR
, "vt = %x\n", V_VT(&var
));
1955 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "wrong attr value\n");
1956 VariantClear( &var
);
1958 r
= IXMLDOMElement_getAttribute( element
, NULL
, &var
);
1959 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1961 r
= IXMLDOMElement_getAttribute( element
, str
, NULL
);
1962 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1965 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1966 ok( r
== S_OK
, "GetAttributeNode ret %08x\n", r
);
1967 ok( attr
!= NULL
, "getAttributeNode returned NULL\n" );
1970 r
= IXMLDOMAttribute_get_parentNode( attr
, NULL
);
1971 ok( r
== E_INVALIDARG
, "Expected E_INVALIDARG, ret %08x\n", r
);
1973 /* attribute doesn't have a parent in msxml interpretation */
1974 node
= (IXMLDOMNode
*)0xdeadbeef;
1975 r
= IXMLDOMAttribute_get_parentNode( attr
, &node
);
1976 ok( r
== S_FALSE
, "Expected S_FALSE, ret %08x\n", r
);
1977 ok( node
== NULL
, "Expected NULL, got %p\n", node
);
1979 IXMLDOMAttribute_Release(attr
);
1982 SysFreeString( str
);
1984 r
= IXMLDOMElement_get_attributes( element
, &map
);
1985 ok( r
== S_OK
, "get_attributes returned wrong code\n");
1986 ok( map
!= NULL
, "should be attributes\n");
1989 r
= IXMLDOMNode_hasChildNodes( element
, &b
);
1990 ok( r
== S_OK
, "hasChildNoes bad return\n");
1991 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1994 ok( FALSE
, "no element\n");
1998 ISupportErrorInfo
*support_error
;
1999 r
= IXMLDOMNamedNodeMap_QueryInterface( map
, &IID_ISupportErrorInfo
, (void**)&support_error
);
2000 ok( r
== S_OK
, "ret %08x\n", r
);
2002 r
= ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error
, &IID_IXMLDOMNamedNodeMap
);
2005 ok( r
== S_OK
, "ret %08x\n", r
);
2007 ISupportErrorInfo_Release( support_error
);
2009 str
= SysAllocString( szdl
);
2010 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
2011 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2012 ok( node
!= NULL
, "should be attributes\n");
2013 IXMLDOMNode_Release(node
);
2014 SysFreeString( str
);
2016 str
= SysAllocString( szdl
);
2017 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, NULL
);
2018 ok( r
== E_INVALIDARG
, "getNamedItem should return E_INVALIDARG\n");
2019 SysFreeString( str
);
2021 /* something that isn't in szComplete4 */
2022 str
= SysAllocString( szOpen
);
2023 node
= (IXMLDOMNode
*) 1;
2024 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
2025 ok( r
== S_FALSE
, "getNamedItem found a node that wasn't there\n");
2026 ok( node
== NULL
, "getNamedItem should have returned NULL\n");
2027 SysFreeString( str
);
2029 /* test indexed access of attributes */
2030 r
= IXMLDOMNamedNodeMap_get_length( map
, NULL
);
2031 ok ( r
== E_INVALIDARG
, "get_length should return E_INVALIDARG\n");
2033 r
= IXMLDOMNamedNodeMap_get_length( map
, &count
);
2034 ok ( r
== S_OK
, "get_length wrong code\n");
2035 ok ( count
== 1, "get_length != 1\n");
2038 r
= IXMLDOMNamedNodeMap_get_item( map
, -1, &node
);
2039 ok ( r
== S_FALSE
, "get_item (-1) wrong code\n");
2040 ok ( node
== NULL
, "there is no node\n");
2043 r
= IXMLDOMNamedNodeMap_get_item( map
, 1, &node
);
2044 ok ( r
== S_FALSE
, "get_item (1) wrong code\n");
2045 ok ( node
== NULL
, "there is no attribute\n");
2048 r
= IXMLDOMNamedNodeMap_get_item( map
, 0, &node
);
2049 ok ( r
== S_OK
, "get_item (0) wrong code\n");
2050 ok ( node
!= NULL
, "should be attribute\n");
2052 r
= IXMLDOMNode_get_nodeName( node
, NULL
);
2053 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
2055 /* content doesn't matter here */
2057 r
= IXMLDOMNode_get_nodeName( node
, &str
);
2058 ok ( r
== S_OK
, "get_nodeName wrong code\n");
2059 ok ( str
!= NULL
, "str is null\n");
2060 ok( !lstrcmpW( str
, szdl
), "incorrect node name\n");
2061 SysFreeString( str
);
2063 /* test sequential access of attributes */
2065 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
2066 ok ( r
== S_OK
, "nextNode (first time) wrong code\n");
2067 ok ( node
!= NULL
, "nextNode, should be attribute\n");
2069 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
2070 ok ( r
!= S_OK
, "nextNode (second time) wrong code\n");
2071 ok ( node
== NULL
, "nextNode, there is no attribute\n");
2073 r
= IXMLDOMNamedNodeMap_reset( map
);
2074 ok ( r
== S_OK
, "reset should return S_OK\n");
2076 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
2077 ok ( r
== S_OK
, "nextNode (third time) wrong code\n");
2078 ok ( node
!= NULL
, "nextNode, should be attribute\n");
2081 ok( FALSE
, "no map\n");
2085 type
= NODE_INVALID
;
2086 r
= IXMLDOMNode_get_nodeType( node
, &type
);
2087 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2088 ok( type
== NODE_ATTRIBUTE
, "node not an attribute\n");
2091 r
= IXMLDOMNode_get_baseName( node
, NULL
);
2092 ok( r
== E_INVALIDARG
, "get_baseName returned wrong code\n");
2095 r
= IXMLDOMNode_get_baseName( node
, &str
);
2096 ok( r
== S_OK
, "get_baseName returned wrong code\n");
2097 ok( lstrcmpW(str
,szdl
) == 0, "basename was wrong\n");
2098 SysFreeString( str
);
2100 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
2101 ok( r
== S_OK
, "returns %08x\n", r
);
2102 ok( V_VT(&var
) == VT_BSTR
, "vt %x\n", V_VT(&var
));
2103 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "nodeValue incorrect\n");
2106 r
= IXMLDOMNode_get_childNodes( node
, NULL
);
2107 ok( r
== E_INVALIDARG
, "get_childNodes returned wrong code\n");
2109 r
= IXMLDOMNode_get_childNodes( node
, &list
);
2110 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
2114 r
= IXMLDOMNodeList_nextNode( list
, &next
);
2115 ok( r
== S_OK
, "nextNode returned wrong code\n");
2118 ok( FALSE
, "no childlist\n");
2123 r
= IXMLDOMNode_hasChildNodes( next
, &b
);
2124 ok( r
== S_FALSE
, "hasChildNoes bad return\n");
2125 ok( b
== VARIANT_FALSE
, "hasChildNoes wrong result\n");
2127 type
= NODE_INVALID
;
2128 r
= IXMLDOMNode_get_nodeType( next
, &type
);
2129 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2130 ok( type
== NODE_TEXT
, "node not text\n");
2133 r
= IXMLDOMNode_get_baseName( next
, &str
);
2134 ok( r
== S_FALSE
, "get_baseName returned wrong code\n");
2135 ok( str
== NULL
, "basename was wrong\n");
2139 ok( FALSE
, "no next\n");
2142 IXMLDOMNode_Release( next
);
2145 IXMLDOMNodeList_Release( list
);
2148 IXMLDOMNode_Release( node
);
2151 ok( FALSE
, "no node\n");
2155 IXMLDOMNamedNodeMap_Release( map
);
2157 /* now traverse the tree from the root element */
2160 r
= IXMLDOMNode_get_childNodes( element
, &list
);
2161 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
2163 /* using get_item for child list doesn't advance the position */
2164 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
2165 expect_node(node
, "E2.E2.D1");
2166 IXMLDOMNode_Release(node
);
2167 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
2168 expect_node(node
, "E1.E2.D1");
2169 IXMLDOMNode_Release(node
);
2170 ole_check(IXMLDOMNodeList_reset(list
));
2172 IXMLDOMNodeList_AddRef(list
);
2173 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
2174 ole_check(IXMLDOMNodeList_reset(list
));
2176 node
= (void*)0xdeadbeef;
2177 str
= SysAllocString(szdl
);
2178 r
= IXMLDOMNode_selectSingleNode( element
, str
, &node
);
2180 ok( r
== S_FALSE
, "ret %08x\n", r
);
2181 ok( node
== NULL
, "node %p\n", node
);
2183 str
= SysAllocString(szbs
);
2184 r
= IXMLDOMNode_selectSingleNode( element
, str
, &node
);
2186 ok( r
== S_OK
, "ret %08x\n", r
);
2187 r
= IXMLDOMNode_Release( node
);
2188 ok( r
== 0, "ret %08x\n", r
);
2191 ok( FALSE
, "no element\n");
2195 r
= IXMLDOMNodeList_QueryInterface(list
, &IID_IDispatch
, NULL
);
2196 ok( r
== E_INVALIDARG
|| r
== E_POINTER
, "ret %08x\n", r
);
2198 r
= IXMLDOMNodeList_get_item(list
, 0, NULL
);
2199 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
2201 r
= IXMLDOMNodeList_get_length(list
, NULL
);
2202 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
2204 r
= IXMLDOMNodeList_get_length( list
, &count
);
2205 ok( r
== S_OK
, "get_length returns %08x\n", r
);
2206 ok( count
== 4, "get_length got %d\n", count
);
2208 r
= IXMLDOMNodeList_nextNode(list
, NULL
);
2209 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
2211 r
= IXMLDOMNodeList_nextNode( list
, &node
);
2212 ok( r
== S_OK
, "nextNode returned wrong code\n");
2215 ok( FALSE
, "no list\n");
2219 type
= NODE_INVALID
;
2220 r
= IXMLDOMNode_get_nodeType( node
, &type
);
2221 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2222 ok( type
== NODE_ELEMENT
, "node not text\n");
2225 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
2226 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
2227 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
2228 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
2229 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
2231 r
= IXMLDOMNode_hasChildNodes( node
, NULL
);
2232 ok( r
== E_INVALIDARG
, "hasChildNoes bad return\n");
2235 r
= IXMLDOMNode_hasChildNodes( node
, &b
);
2236 ok( r
== S_OK
, "hasChildNoes bad return\n");
2237 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
2240 r
= IXMLDOMNode_get_baseName( node
, &str
);
2241 ok( r
== S_OK
, "get_baseName returned wrong code\n");
2242 ok( lstrcmpW(str
,szbs
) == 0, "basename was wrong\n");
2246 ok( FALSE
, "no node\n");
2249 IXMLDOMNode_Release( node
);
2251 IXMLDOMNodeList_Release( list
);
2253 IXMLDOMElement_Release( element
);
2256 str
= SysAllocString( szComplete5
);
2257 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2258 ok( r
== S_OK
, "loadXML failed\n");
2259 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2260 SysFreeString( str
);
2263 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
2264 ok( r
== S_OK
, "hasChildNoes bad return\n");
2265 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
2267 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2268 ok( r
== S_OK
, "should be a document element\n");
2269 ok( element
!= NULL
, "should be an element\n");
2273 static const WCHAR szSSearch
[] = {'S',':','s','e','a','r','c','h',0};
2276 /* check if the tag is correct */
2277 r
= IXMLDOMElement_get_tagName( element
, &tag
);
2278 ok( r
== S_OK
, "couldn't get tag name\n");
2279 ok( tag
!= NULL
, "tag was null\n");
2280 ok( !lstrcmpW( tag
, szSSearch
), "incorrect tag name\n");
2281 SysFreeString( tag
);
2285 IXMLDOMElement_Release( element
);
2286 ok(IXMLDOMDocument_Release( doc
) == 0, "document is not destroyed\n");
2289 static void test_refs(void)
2294 IXMLDOMDocument
*doc
;
2295 IXMLDOMElement
*element
= NULL
;
2296 IXMLDOMNode
*node
= NULL
, *node2
;
2297 IXMLDOMNodeList
*node_list
= NULL
;
2299 IUnknown
*unk
, *unk2
;
2301 doc
= create_document(&IID_IXMLDOMDocument
);
2304 ref
= IXMLDOMDocument_Release(doc
);
2305 ok( ref
== 0, "ref %d\n", ref
);
2307 doc
= create_document(&IID_IXMLDOMDocument
);
2310 str
= SysAllocString( szComplete4
);
2311 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2312 ok( r
== S_OK
, "loadXML failed\n");
2313 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2314 SysFreeString( str
);
2316 ref
= IXMLDOMDocument_AddRef( doc
);
2317 ok( ref
== 2, "ref %d\n", ref
);
2318 ref
= IXMLDOMDocument_AddRef( doc
);
2319 ok( ref
== 3, "ref %d\n", ref
);
2320 IXMLDOMDocument_Release( doc
);
2321 IXMLDOMDocument_Release( doc
);
2323 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2324 ok( r
== S_OK
, "should be a document element\n");
2325 ok( element
!= NULL
, "should be an element\n");
2327 ref
= IXMLDOMDocument_AddRef( doc
);
2328 ok( ref
== 2, "ref %d\n", ref
);
2329 IXMLDOMDocument_Release( doc
);
2331 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
2332 ok( r
== S_OK
, "rets %08x\n", r
);
2334 ref
= IXMLDOMNodeList_AddRef( node_list
);
2335 ok( ref
== 2, "ref %d\n", ref
);
2336 IXMLDOMNodeList_Release( node_list
);
2338 IXMLDOMNodeList_get_item( node_list
, 0, &node
);
2339 ok( r
== S_OK
, "rets %08x\n", r
);
2341 IXMLDOMNodeList_get_item( node_list
, 0, &node2
);
2342 ok( r
== S_OK
, "rets %08x\n", r
);
2344 ref
= IXMLDOMNode_AddRef( node
);
2345 ok( ref
== 2, "ref %d\n", ref
);
2346 IXMLDOMNode_Release( node
);
2348 ref
= IXMLDOMNode_Release( node
);
2349 ok( ref
== 0, "ref %d\n", ref
);
2350 ref
= IXMLDOMNode_Release( node2
);
2351 ok( ref
== 0, "ref %d\n", ref
);
2353 ref
= IXMLDOMNodeList_Release( node_list
);
2354 ok( ref
== 0, "ref %d\n", ref
);
2356 ok( node
!= node2
, "node %p node2 %p\n", node
, node2
);
2358 ref
= IXMLDOMDocument_Release( doc
);
2359 ok( ref
== 0, "ref %d\n", ref
);
2361 ref
= IXMLDOMElement_AddRef( element
);
2363 ok( ref
== 3, "ref %d\n", ref
);
2365 IXMLDOMElement_Release( element
);
2367 /* IUnknown must be unique however we obtain it */
2368 r
= IXMLDOMElement_QueryInterface( element
, &IID_IUnknown
, (void**)&unk
);
2369 ok( r
== S_OK
, "rets %08x\n", r
);
2370 r
= IXMLDOMElement_QueryInterface( element
, &IID_IXMLDOMNode
, (void**)&node
);
2371 ok( r
== S_OK
, "rets %08x\n", r
);
2372 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (void**)&unk2
);
2373 ok( r
== S_OK
, "rets %08x\n", r
);
2374 ok( unk
== unk2
, "unk %p unk2 %p\n", unk
, unk2
);
2376 IUnknown_Release( unk2
);
2377 IUnknown_Release( unk
);
2378 IXMLDOMNode_Release( node
);
2380 IXMLDOMElement_Release( element
);
2384 static void test_create(void)
2386 static const WCHAR szOne
[] = {'1',0};
2387 static const WCHAR szOneGarbage
[] = {'1','G','a','r','b','a','g','e',0};
2391 IXMLDOMDocument
*doc
;
2392 IXMLDOMElement
*element
;
2393 IXMLDOMComment
*comment
;
2395 IXMLDOMCDATASection
*cdata
;
2396 IXMLDOMNode
*root
, *node
, *child
;
2397 IXMLDOMNamedNodeMap
*attr_map
;
2402 doc
= create_document(&IID_IXMLDOMDocument
);
2405 /* types not supported for creation */
2407 V_I1(&var
) = NODE_DOCUMENT
;
2408 node
= (IXMLDOMNode
*)0x1;
2409 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2410 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2411 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2414 V_I1(&var
) = NODE_DOCUMENT_TYPE
;
2415 node
= (IXMLDOMNode
*)0x1;
2416 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2417 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2418 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2421 V_I1(&var
) = NODE_ENTITY
;
2422 node
= (IXMLDOMNode
*)0x1;
2423 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2424 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2425 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2428 V_I1(&var
) = NODE_NOTATION
;
2429 node
= (IXMLDOMNode
*)0x1;
2430 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2431 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2432 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2436 V_I1(&var
) = NODE_COMMENT
;
2438 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2439 ok( r
== S_OK
, "returns %08x\n", r
);
2440 ok( node
!= NULL
, "\n");
2442 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
2443 ok( r
== S_OK
, "returns %08x\n", r
);
2444 IXMLDOMNode_Release(node
);
2447 r
= IXMLDOMComment_get_data(comment
, &str
);
2448 ok( r
== S_OK
, "returns %08x\n", r
);
2449 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2450 IXMLDOMComment_Release(comment
);
2453 node
= (IXMLDOMNode
*)0x1;
2454 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2455 ok( r
== S_OK
, "returns %08x\n", r
);
2457 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
2458 ok( r
== S_OK
, "returns %08x\n", r
);
2459 IXMLDOMNode_Release(node
);
2462 r
= IXMLDOMComment_get_data(comment
, &str
);
2463 ok( r
== S_OK
, "returns %08x\n", r
);
2464 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2465 IXMLDOMComment_Release(comment
);
2468 node
= (IXMLDOMNode
*)0x1;
2469 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
2470 ok( r
== S_OK
, "returns %08x\n", r
);
2472 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
2473 ok( r
== S_OK
, "returns %08x\n", r
);
2474 IXMLDOMNode_Release(node
);
2477 r
= IXMLDOMComment_get_data(comment
, &str
);
2478 ok( r
== S_OK
, "returns %08x\n", r
);
2479 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2480 IXMLDOMComment_Release(comment
);
2485 V_I1(&var
) = NODE_TEXT
;
2487 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2488 ok( r
== S_OK
, "returns %08x\n", r
);
2489 ok( node
!= NULL
, "\n");
2491 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
2492 ok( r
== S_OK
, "returns %08x\n", r
);
2493 IXMLDOMNode_Release(node
);
2496 r
= IXMLDOMText_get_data(text
, &str
);
2497 ok( r
== S_OK
, "returns %08x\n", r
);
2498 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2499 IXMLDOMText_Release(text
);
2502 node
= (IXMLDOMNode
*)0x1;
2503 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2504 ok( r
== S_OK
, "returns %08x\n", r
);
2506 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
2507 ok( r
== S_OK
, "returns %08x\n", r
);
2508 IXMLDOMNode_Release(node
);
2511 r
= IXMLDOMText_get_data(text
, &str
);
2512 ok( r
== S_OK
, "returns %08x\n", r
);
2513 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2514 IXMLDOMText_Release(text
);
2517 node
= (IXMLDOMNode
*)0x1;
2518 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
2519 ok( r
== S_OK
, "returns %08x\n", r
);
2521 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
2522 ok( r
== S_OK
, "returns %08x\n", r
);
2523 IXMLDOMNode_Release(node
);
2526 r
= IXMLDOMText_get_data(text
, &str
);
2527 ok( r
== S_OK
, "returns %08x\n", r
);
2528 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2529 IXMLDOMText_Release(text
);
2532 /* NODE_CDATA_SECTION */
2534 V_I1(&var
) = NODE_CDATA_SECTION
;
2536 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2537 ok( r
== S_OK
, "returns %08x\n", r
);
2538 ok( node
!= NULL
, "\n");
2540 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
2541 ok( r
== S_OK
, "returns %08x\n", r
);
2542 IXMLDOMNode_Release(node
);
2545 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
2546 ok( r
== S_OK
, "returns %08x\n", r
);
2547 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2548 IXMLDOMCDATASection_Release(cdata
);
2551 node
= (IXMLDOMNode
*)0x1;
2552 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2553 ok( r
== S_OK
, "returns %08x\n", r
);
2555 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
2556 ok( r
== S_OK
, "returns %08x\n", r
);
2557 IXMLDOMNode_Release(node
);
2560 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
2561 ok( r
== S_OK
, "returns %08x\n", r
);
2562 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2563 IXMLDOMCDATASection_Release(cdata
);
2566 node
= (IXMLDOMNode
*)0x1;
2567 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
2568 ok( r
== S_OK
, "returns %08x\n", r
);
2570 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
2571 ok( r
== S_OK
, "returns %08x\n", r
);
2572 IXMLDOMNode_Release(node
);
2575 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
2576 ok( r
== S_OK
, "returns %08x\n", r
);
2577 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2578 IXMLDOMCDATASection_Release(cdata
);
2581 /* NODE_ATTRIBUTE */
2583 V_I1(&var
) = NODE_ATTRIBUTE
;
2584 node
= (IXMLDOMNode
*)0x1;
2585 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2586 ok( r
== E_FAIL
, "returns %08x\n", r
);
2587 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2590 V_I1(&var
) = NODE_ATTRIBUTE
;
2591 node
= (IXMLDOMNode
*)0x1;
2592 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2593 ok( r
== E_FAIL
, "returns %08x\n", r
);
2594 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2597 V_I1(&var
) = NODE_ATTRIBUTE
;
2598 str
= SysAllocString( szlc
);
2599 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2600 ok( r
== S_OK
, "returns %08x\n", r
);
2601 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2604 /* a name is required for attribute, try a BSTR with first null wchar */
2606 V_I1(&var
) = NODE_ATTRIBUTE
;
2607 str
= SysAllocString( szstr1
);
2609 node
= (IXMLDOMNode
*)0x1;
2610 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2611 ok( r
== E_FAIL
, "returns %08x\n", r
);
2612 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2615 /* NODE_PROCESSING_INSTRUCTION */
2617 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
2618 node
= (IXMLDOMNode
*)0x1;
2619 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2620 ok( r
== E_FAIL
, "returns %08x\n", r
);
2621 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2624 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
2625 node
= (IXMLDOMNode
*)0x1;
2626 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2627 ok( r
== E_FAIL
, "returns %08x\n", r
);
2628 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2631 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
2632 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("pi"), NULL
, NULL
);
2633 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2635 /* NODE_ENTITY_REFERENCE */
2637 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
2638 node
= (IXMLDOMNode
*)0x1;
2639 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2640 ok( r
== E_FAIL
, "returns %08x\n", r
);
2641 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2644 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
2645 node
= (IXMLDOMNode
*)0x1;
2646 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2647 ok( r
== E_FAIL
, "returns %08x\n", r
);
2648 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2652 V_I1(&var
) = NODE_ELEMENT
;
2653 node
= (IXMLDOMNode
*)0x1;
2654 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2655 ok( r
== E_FAIL
, "returns %08x\n", r
);
2656 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2659 V_I1(&var
) = NODE_ELEMENT
;
2660 node
= (IXMLDOMNode
*)0x1;
2661 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2662 ok( r
== E_FAIL
, "returns %08x\n", r
);
2663 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2666 V_I1(&var
) = NODE_ELEMENT
;
2667 str
= SysAllocString( szlc
);
2668 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2669 ok( r
== S_OK
, "returns %08x\n", r
);
2670 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2673 V_I1(&var
) = NODE_ELEMENT
;
2674 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, NULL
);
2675 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2678 V_R4(&var
) = NODE_ELEMENT
;
2679 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2680 ok( r
== S_OK
, "returns %08x\n", r
);
2681 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2683 V_VT(&var
) = VT_BSTR
;
2684 V_BSTR(&var
) = SysAllocString( szOne
);
2685 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2686 ok( r
== S_OK
, "returns %08x\n", r
);
2687 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2690 V_VT(&var
) = VT_BSTR
;
2691 V_BSTR(&var
) = SysAllocString( szOneGarbage
);
2692 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2693 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2694 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2698 V_I4(&var
) = NODE_ELEMENT
;
2699 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2700 ok( r
== S_OK
, "returns %08x\n", r
);
2701 r
= IXMLDOMDocument_appendChild( doc
, node
, &root
);
2702 ok( r
== S_OK
, "returns %08x\n", r
);
2703 ok( node
== root
, "%p %p\n", node
, root
);
2705 ref
= IXMLDOMNode_AddRef( node
);
2706 ok(ref
== 3, "ref %d\n", ref
);
2707 IXMLDOMNode_Release( node
);
2709 ref
= IXMLDOMNode_Release( node
);
2710 ok(ref
== 1, "ref %d\n", ref
);
2711 SysFreeString( str
);
2714 V_I4(&var
) = NODE_ELEMENT
;
2715 str
= SysAllocString( szbs
);
2716 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2717 ok( r
== S_OK
, "returns %08x\n", r
);
2718 SysFreeString( str
);
2720 ref
= IXMLDOMNode_AddRef( node
);
2721 ok(ref
== 2, "ref = %d\n", ref
);
2722 IXMLDOMNode_Release( node
);
2724 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (void**)&unk
);
2725 ok( r
== S_OK
, "returns %08x\n", r
);
2727 ref
= IXMLDOMNode_AddRef( unk
);
2728 ok(ref
== 3, "ref = %d\n", ref
);
2729 IXMLDOMNode_Release( unk
);
2731 V_VT(&var
) = VT_EMPTY
;
2732 r
= IXMLDOMNode_insertBefore( root
, (IXMLDOMNode
*)unk
, var
, &child
);
2733 ok( r
== S_OK
, "returns %08x\n", r
);
2734 ok( unk
== (IUnknown
*)child
, "%p %p\n", unk
, child
);
2735 IXMLDOMNode_Release( child
);
2736 IUnknown_Release( unk
);
2739 V_VT(&var
) = VT_NULL
;
2740 V_DISPATCH(&var
) = (IDispatch
*)node
;
2741 r
= IXMLDOMNode_insertBefore( root
, node
, var
, &child
);
2742 ok( r
== S_OK
, "returns %08x\n", r
);
2743 ok( node
== child
, "%p %p\n", node
, child
);
2744 IXMLDOMNode_Release( child
);
2747 V_VT(&var
) = VT_NULL
;
2748 V_DISPATCH(&var
) = (IDispatch
*)node
;
2749 r
= IXMLDOMNode_insertBefore( root
, node
, var
, NULL
);
2750 ok( r
== S_OK
, "returns %08x\n", r
);
2751 IXMLDOMNode_Release( node
);
2753 r
= IXMLDOMNode_QueryInterface( root
, &IID_IXMLDOMElement
, (void**)&element
);
2754 ok( r
== S_OK
, "returns %08x\n", r
);
2756 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2757 ok( r
== S_OK
, "returns %08x\n", r
);
2758 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2759 ok( r
== S_OK
, "returns %08x\n", r
);
2760 ok( num
== 0, "num %d\n", num
);
2761 IXMLDOMNamedNodeMap_Release( attr_map
);
2763 V_VT(&var
) = VT_BSTR
;
2764 V_BSTR(&var
) = SysAllocString( szstr1
);
2765 name
= SysAllocString( szdl
);
2766 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2767 ok( r
== S_OK
, "returns %08x\n", r
);
2768 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2769 ok( r
== S_OK
, "returns %08x\n", r
);
2770 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2771 ok( r
== S_OK
, "returns %08x\n", r
);
2772 ok( num
== 1, "num %d\n", num
);
2773 IXMLDOMNamedNodeMap_Release( attr_map
);
2776 V_VT(&var
) = VT_BSTR
;
2777 V_BSTR(&var
) = SysAllocString( szstr2
);
2778 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2779 ok( r
== S_OK
, "returns %08x\n", r
);
2780 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2781 ok( r
== S_OK
, "returns %08x\n", r
);
2782 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2783 ok( r
== S_OK
, "returns %08x\n", r
);
2784 ok( num
== 1, "num %d\n", num
);
2785 IXMLDOMNamedNodeMap_Release( attr_map
);
2787 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
2788 ok( r
== S_OK
, "returns %08x\n", r
);
2789 ok( !lstrcmpW(V_BSTR(&var
), szstr2
), "wrong attr value\n");
2791 SysFreeString(name
);
2793 V_VT(&var
) = VT_BSTR
;
2794 V_BSTR(&var
) = SysAllocString( szstr1
);
2795 name
= SysAllocString( szlc
);
2796 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2797 ok( r
== S_OK
, "returns %08x\n", r
);
2798 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2799 ok( r
== S_OK
, "returns %08x\n", r
);
2800 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2801 ok( r
== S_OK
, "returns %08x\n", r
);
2802 ok( num
== 2, "num %d\n", num
);
2803 IXMLDOMNamedNodeMap_Release( attr_map
);
2805 SysFreeString(name
);
2809 name
= SysAllocString( szbs
);
2810 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2811 ok( r
== S_OK
, "returns %08x\n", r
);
2813 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
2814 ok( r
== S_OK
, "returns %08x\n", r
);
2815 ok( V_VT(&var
) == VT_BSTR
, "variant type %x\n", V_VT(&var
));
2817 SysFreeString(name
);
2819 /* Create an Attribute */
2821 V_I4(&var
) = NODE_ATTRIBUTE
;
2822 str
= SysAllocString( szAttribute
);
2823 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2824 ok( r
== S_OK
, "returns %08x\n", r
);
2825 ok( node
!= NULL
, "node was null\n");
2828 r
= IXMLDOMNode_get_nodeTypeString(node
, &str
);
2829 ok( r
== S_OK
, "returns %08x\n", r
);
2830 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
2832 IXMLDOMNode_Release( node
);
2834 IXMLDOMElement_Release( element
);
2835 IXMLDOMNode_Release( root
);
2836 IXMLDOMDocument_Release( doc
);
2839 static void test_getElementsByTagName(void)
2841 IXMLDOMNodeList
*node_list
;
2842 IXMLDOMDocument
*doc
;
2843 IXMLDOMElement
*elem
;
2850 doc
= create_document(&IID_IXMLDOMDocument
);
2853 str
= SysAllocString( szComplete4
);
2854 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2855 ok( r
== S_OK
, "loadXML failed\n");
2856 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2857 SysFreeString( str
);
2859 str
= SysAllocString( szstar
);
2861 /* null arguments cases */
2862 r
= IXMLDOMDocument_getElementsByTagName(doc
, NULL
, &node_list
);
2863 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2864 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, NULL
);
2865 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2867 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2868 ok( r
== S_OK
, "ret %08x\n", r
);
2869 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2870 ok( r
== S_OK
, "ret %08x\n", r
);
2871 ok( len
== 6, "len %d\n", len
);
2873 test_disp((IUnknown
*)node_list
);
2875 IXMLDOMNodeList_Release( node_list
);
2876 SysFreeString( str
);
2878 /* broken query BSTR */
2879 memcpy(&buff
[2], szstar
, sizeof(szstar
));
2880 /* just a big length */
2881 *(DWORD
*)buff
= 0xf0f0;
2882 r
= IXMLDOMDocument_getElementsByTagName(doc
, &buff
[2], &node_list
);
2883 ok( r
== S_OK
, "ret %08x\n", r
);
2884 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2885 ok( r
== S_OK
, "ret %08x\n", r
);
2886 ok( len
== 6, "len %d\n", len
);
2887 IXMLDOMNodeList_Release( node_list
);
2889 str
= SysAllocString( szbs
);
2890 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2891 ok( r
== S_OK
, "ret %08x\n", r
);
2892 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2893 ok( r
== S_OK
, "ret %08x\n", r
);
2894 ok( len
== 1, "len %d\n", len
);
2895 IXMLDOMNodeList_Release( node_list
);
2896 SysFreeString( str
);
2898 str
= SysAllocString( szdl
);
2899 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2900 ok( r
== S_OK
, "ret %08x\n", r
);
2901 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2902 ok( r
== S_OK
, "ret %08x\n", r
);
2903 ok( len
== 0, "len %d\n", len
);
2904 IXMLDOMNodeList_Release( node_list
);
2905 SysFreeString( str
);
2907 str
= SysAllocString( szstr1
);
2908 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2909 ok( r
== S_OK
, "ret %08x\n", r
);
2910 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2911 ok( r
== S_OK
, "ret %08x\n", r
);
2912 ok( len
== 0, "len %d\n", len
);
2913 IXMLDOMNodeList_Release( node_list
);
2914 SysFreeString( str
);
2916 /* test for element */
2917 r
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
2918 ok( r
== S_OK
, "ret %08x\n", r
);
2920 str
= SysAllocString( szstar
);
2922 /* null arguments cases */
2923 r
= IXMLDOMElement_getElementsByTagName(elem
, NULL
, &node_list
);
2924 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2925 r
= IXMLDOMElement_getElementsByTagName(elem
, str
, NULL
);
2926 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2928 r
= IXMLDOMElement_getElementsByTagName(elem
, str
, &node_list
);
2929 ok( r
== S_OK
, "ret %08x\n", r
);
2930 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2931 ok( r
== S_OK
, "ret %08x\n", r
);
2932 todo_wine
ok( len
== 5, "len %d\n", len
);
2934 IXMLDOMNodeList_Release( node_list
);
2935 SysFreeString( str
);
2937 /* broken query BSTR */
2938 memcpy(&buff
[2], szstar
, sizeof(szstar
));
2939 /* just a big length */
2940 *(DWORD
*)buff
= 0xf0f0;
2941 r
= IXMLDOMElement_getElementsByTagName(elem
, &buff
[2], &node_list
);
2942 ok( r
== S_OK
, "ret %08x\n", r
);
2943 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2944 ok( r
== S_OK
, "ret %08x\n", r
);
2945 todo_wine
ok( len
== 5, "len %d\n", len
);
2946 IXMLDOMNodeList_Release( node_list
);
2948 IXMLDOMElement_Release(elem
);
2950 IXMLDOMDocument_Release( doc
);
2953 static void test_get_text(void)
2958 IXMLDOMDocument
*doc
;
2959 IXMLDOMNode
*node
, *node2
, *node3
;
2960 IXMLDOMNode
*nodeRoot
;
2961 IXMLDOMNodeList
*node_list
;
2962 IXMLDOMNamedNodeMap
*node_map
;
2965 doc
= create_document(&IID_IXMLDOMDocument
);
2968 str
= SysAllocString( szComplete4
);
2969 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2970 ok( r
== S_OK
, "loadXML failed\n");
2971 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2972 SysFreeString( str
);
2974 str
= SysAllocString( szbs
);
2975 r
= IXMLDOMDocument_getElementsByTagName( doc
, str
, &node_list
);
2976 ok( r
== S_OK
, "ret %08x\n", r
);
2979 /* Test to get all child node text. */
2980 r
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (void**)&nodeRoot
);
2981 ok( r
== S_OK
, "ret %08x\n", r
);
2984 r
= IXMLDOMNode_get_text( nodeRoot
, &str
);
2985 ok( r
== S_OK
, "ret %08x\n", r
);
2986 ok( compareIgnoreReturns(str
, _bstr_("fn1.txt\n\n fn2.txt \n\nf1\n")), "wrong get_text: %s\n", wine_dbgstr_w(str
));
2989 IXMLDOMNode_Release(nodeRoot
);
2993 /* this test crashes on win9x */
2994 r
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IDispatch
, NULL
);
2995 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2998 r
= IXMLDOMNodeList_get_length( node_list
, NULL
);
2999 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3001 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3002 ok( r
== S_OK
, "ret %08x\n", r
);
3003 ok( len
== 1, "expect 1 got %d\n", len
);
3005 r
= IXMLDOMNodeList_get_item( node_list
, 0, NULL
);
3006 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3008 r
= IXMLDOMNodeList_nextNode( node_list
, NULL
);
3009 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3011 r
= IXMLDOMNodeList_get_item( node_list
, 0, &node
);
3012 ok( r
== S_OK
, "ret %08x\n", r
);
3013 IXMLDOMNodeList_Release( node_list
);
3015 /* Invalid output parameter*/
3016 r
= IXMLDOMNode_get_text( node
, NULL
);
3017 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3019 r
= IXMLDOMNode_get_text( node
, &str
);
3020 ok( r
== S_OK
, "ret %08x\n", r
);
3021 ok( !memcmp(str
, szfn1_txt
, lstrlenW(szfn1_txt
) ), "wrong string\n" );
3024 r
= IXMLDOMNode_get_attributes( node
, &node_map
);
3025 ok( r
== S_OK
, "ret %08x\n", r
);
3027 str
= SysAllocString( szvr
);
3028 r
= IXMLDOMNamedNodeMap_getNamedItem( node_map
, str
, &node2
);
3029 ok( r
== S_OK
, "ret %08x\n", r
);
3032 r
= IXMLDOMNode_get_text( node2
, &str
);
3033 ok( r
== S_OK
, "ret %08x\n", r
);
3034 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
3037 r
= IXMLDOMNode_get_firstChild( node2
, &node3
);
3038 ok( r
== S_OK
, "ret %08x\n", r
);
3040 r
= IXMLDOMNode_get_text( node3
, &str
);
3041 ok( r
== S_OK
, "ret %08x\n", r
);
3042 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
3046 IXMLDOMNode_Release( node3
);
3047 IXMLDOMNode_Release( node2
);
3048 IXMLDOMNamedNodeMap_Release( node_map
);
3049 IXMLDOMNode_Release( node
);
3050 IXMLDOMDocument_Release( doc
);
3053 static void test_get_childNodes(void)
3058 IXMLDOMDocument
*doc
;
3059 IXMLDOMElement
*element
;
3060 IXMLDOMNode
*node
, *node2
;
3061 IXMLDOMNodeList
*node_list
, *node_list2
;
3064 doc
= create_document(&IID_IXMLDOMDocument
);
3067 str
= SysAllocString( szComplete4
);
3068 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
3069 ok( r
== S_OK
, "loadXML failed\n");
3070 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3071 SysFreeString( str
);
3073 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
3074 ok( r
== S_OK
, "ret %08x\n", r
);
3076 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
3077 ok( r
== S_OK
, "ret %08x\n", r
);
3079 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3080 ok( r
== S_OK
, "ret %08x\n", r
);
3081 ok( len
== 4, "len %d\n", len
);
3083 r
= IXMLDOMNodeList_get_item( node_list
, 2, &node
);
3084 ok( r
== S_OK
, "ret %08x\n", r
);
3086 r
= IXMLDOMNode_get_childNodes( node
, &node_list2
);
3087 ok( r
== S_OK
, "ret %08x\n", r
);
3089 r
= IXMLDOMNodeList_get_length( node_list2
, &len
);
3090 ok( r
== S_OK
, "ret %08x\n", r
);
3091 ok( len
== 0, "len %d\n", len
);
3093 r
= IXMLDOMNodeList_get_item( node_list2
, 0, &node2
);
3094 ok( r
== S_FALSE
, "ret %08x\n", r
);
3096 IXMLDOMNodeList_Release( node_list2
);
3097 IXMLDOMNode_Release( node
);
3098 IXMLDOMNodeList_Release( node_list
);
3099 IXMLDOMElement_Release( element
);
3100 IXMLDOMDocument_Release( doc
);
3103 static void test_get_firstChild(void)
3105 static WCHAR xmlW
[] = {'x','m','l',0};
3106 IXMLDOMDocument
*doc
;
3112 doc
= create_document(&IID_IXMLDOMDocument
);
3115 str
= SysAllocString( szComplete4
);
3116 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
3117 ok( r
== S_OK
, "loadXML failed\n");
3118 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3119 SysFreeString( str
);
3121 r
= IXMLDOMDocument_get_firstChild( doc
, &node
);
3122 ok( r
== S_OK
, "ret %08x\n", r
);
3124 r
= IXMLDOMNode_get_nodeName( node
, &str
);
3125 ok( r
== S_OK
, "ret %08x\n", r
);
3127 ok(memcmp(str
, xmlW
, sizeof(xmlW
)) == 0, "expected \"xml\" node name\n");
3130 IXMLDOMNode_Release( node
);
3131 IXMLDOMDocument_Release( doc
);
3134 static void test_get_lastChild(void)
3136 static WCHAR lcW
[] = {'l','c',0};
3137 static WCHAR foW
[] = {'f','o',0};
3138 IXMLDOMDocument
*doc
;
3139 IXMLDOMNode
*node
, *child
;
3144 doc
= create_document(&IID_IXMLDOMDocument
);
3147 str
= SysAllocString( szComplete4
);
3148 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
3149 ok( r
== S_OK
, "loadXML failed\n");
3150 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3151 SysFreeString( str
);
3153 r
= IXMLDOMDocument_get_lastChild( doc
, &node
);
3154 ok( r
== S_OK
, "ret %08x\n", r
);
3156 r
= IXMLDOMNode_get_nodeName( node
, &str
);
3157 ok( r
== S_OK
, "ret %08x\n", r
);
3159 ok(memcmp(str
, lcW
, sizeof(lcW
)) == 0, "expected \"lc\" node name\n");
3162 r
= IXMLDOMNode_get_lastChild( node
, &child
);
3163 ok( r
== S_OK
, "ret %08x\n", r
);
3165 r
= IXMLDOMNode_get_nodeName( child
, &str
);
3166 ok( r
== S_OK
, "ret %08x\n", r
);
3168 ok(memcmp(str
, foW
, sizeof(foW
)) == 0, "expected \"fo\" node name\n");
3171 IXMLDOMNode_Release( child
);
3172 IXMLDOMNode_Release( node
);
3173 IXMLDOMDocument_Release( doc
);
3176 static void test_removeChild(void)
3181 IXMLDOMDocument
*doc
;
3182 IXMLDOMElement
*element
, *lc_element
;
3183 IXMLDOMNode
*fo_node
, *ba_node
, *removed_node
, *temp_node
, *lc_node
;
3184 IXMLDOMNodeList
*root_list
, *fo_list
;
3186 doc
= create_document(&IID_IXMLDOMDocument
);
3189 str
= SysAllocString( szComplete4
);
3190 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
3191 ok( r
== S_OK
, "loadXML failed\n");
3192 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3193 SysFreeString( str
);
3195 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
3196 ok( r
== S_OK
, "ret %08x\n", r
);
3198 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
3199 ok( r
== S_OK
, "ret %08x\n", r
);
3201 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
3202 ok( r
== S_OK
, "ret %08x\n", r
);
3204 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
3205 ok( r
== S_OK
, "ret %08x\n", r
);
3207 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
3208 ok( r
== S_OK
, "ret %08x\n", r
);
3210 /* invalid parameter: NULL ptr */
3211 removed_node
= (void*)0xdeadbeef;
3212 r
= IXMLDOMElement_removeChild( element
, NULL
, &removed_node
);
3213 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3214 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
3216 /* ba_node is a descendant of element, but not a direct child. */
3217 removed_node
= (void*)0xdeadbeef;
3218 r
= IXMLDOMElement_removeChild( element
, ba_node
, &removed_node
);
3219 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3220 ok( removed_node
== NULL
, "%p\n", removed_node
);
3222 r
= IXMLDOMElement_removeChild( element
, fo_node
, &removed_node
);
3223 ok( r
== S_OK
, "ret %08x\n", r
);
3224 ok( fo_node
== removed_node
, "node %p node2 %p\n", fo_node
, removed_node
);
3226 /* try removing already removed child */
3227 temp_node
= (void*)0xdeadbeef;
3228 r
= IXMLDOMElement_removeChild( element
, fo_node
, &temp_node
);
3229 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3230 ok( temp_node
== NULL
, "%p\n", temp_node
);
3232 /* the removed node has no parent anymore */
3233 r
= IXMLDOMNode_get_parentNode( removed_node
, &temp_node
);
3234 ok( r
== S_FALSE
, "ret %08x\n", r
);
3235 ok( temp_node
== NULL
, "%p\n", temp_node
);
3237 IXMLDOMNode_Release( removed_node
);
3238 IXMLDOMNode_Release( ba_node
);
3239 IXMLDOMNodeList_Release( fo_list
);
3241 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
3242 ok( r
== S_OK
, "ret %08x\n", r
);
3244 r
= IXMLDOMElement_QueryInterface( lc_node
, &IID_IXMLDOMElement
, (void**)&lc_element
);
3245 ok( r
== S_OK
, "ret %08x\n", r
);
3247 /* MS quirk: passing wrong interface pointer works, too */
3248 r
= IXMLDOMElement_removeChild( element
, (IXMLDOMNode
*)lc_element
, NULL
);
3249 ok( r
== S_OK
, "ret %08x\n", r
);
3251 r
= IXMLDOMNode_get_parentNode( lc_node
, &temp_node
);
3252 ok( r
== S_FALSE
, "ret %08x\n", r
);
3253 ok( temp_node
== NULL
, "%p\n", temp_node
);
3255 IXMLDOMNode_Release( lc_node
);
3256 IXMLDOMNodeList_Release( root_list
);
3257 IXMLDOMElement_Release( element
);
3258 IXMLDOMDocument_Release( doc
);
3261 static void test_replaceChild(void)
3266 IXMLDOMDocument
*doc
;
3267 IXMLDOMElement
*element
, *ba_element
;
3268 IXMLDOMNode
*fo_node
, *ba_node
, *lc_node
, *removed_node
, *temp_node
;
3269 IXMLDOMNodeList
*root_list
, *fo_list
;
3270 IUnknown
* unk1
, *unk2
;
3273 doc
= create_document(&IID_IXMLDOMDocument
);
3276 str
= SysAllocString( szComplete4
);
3277 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
3278 ok( r
== S_OK
, "loadXML failed\n");
3279 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3280 SysFreeString( str
);
3282 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
3283 ok( r
== S_OK
, "ret %08x\n", r
);
3285 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
3286 ok( r
== S_OK
, "ret %08x\n", r
);
3288 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
3289 ok( r
== S_OK
, "ret %08x\n", r
);
3291 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
3292 ok( r
== S_OK
, "ret %08x\n", r
);
3294 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
3295 ok( r
== S_OK
, "ret %08x\n", r
);
3297 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
3298 ok( r
== S_OK
, "ret %08x\n", r
);
3300 IXMLDOMNodeList_Release( fo_list
);
3302 /* invalid parameter: NULL ptr for element to remove */
3303 removed_node
= (void*)0xdeadbeef;
3304 r
= IXMLDOMElement_replaceChild( element
, ba_node
, NULL
, &removed_node
);
3305 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3306 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
3308 /* invalid parameter: NULL for replacement element. (Sic!) */
3309 removed_node
= (void*)0xdeadbeef;
3310 r
= IXMLDOMElement_replaceChild( element
, NULL
, fo_node
, &removed_node
);
3311 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3312 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
3314 /* invalid parameter: OldNode is not a child */
3315 removed_node
= (void*)0xdeadbeef;
3316 r
= IXMLDOMElement_replaceChild( element
, lc_node
, ba_node
, &removed_node
);
3317 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3318 ok( removed_node
== NULL
, "%p\n", removed_node
);
3320 /* invalid parameter: would create loop */
3321 removed_node
= (void*)0xdeadbeef;
3322 r
= IXMLDOMNode_replaceChild( fo_node
, fo_node
, ba_node
, &removed_node
);
3323 ok( r
== E_FAIL
, "ret %08x\n", r
);
3324 ok( removed_node
== NULL
, "%p\n", removed_node
);
3326 r
= IXMLDOMElement_replaceChild( element
, ba_node
, fo_node
, NULL
);
3327 ok( r
== S_OK
, "ret %08x\n", r
);
3329 r
= IXMLDOMNodeList_get_item( root_list
, 3, &temp_node
);
3330 ok( r
== S_OK
, "ret %08x\n", r
);
3332 /* ba_node and temp_node refer to the same node, yet they
3333 are different interface pointers */
3334 ok( ba_node
!= temp_node
, "ba_node %p temp_node %p\n", ba_node
, temp_node
);
3335 r
= IXMLDOMNode_QueryInterface( temp_node
, &IID_IUnknown
, (void**)&unk1
);
3336 ok( r
== S_OK
, "ret %08x\n", r
);
3337 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IUnknown
, (void**)&unk2
);
3338 ok( r
== S_OK
, "ret %08x\n", r
);
3339 todo_wine
ok( unk1
== unk2
, "unk1 %p unk2 %p\n", unk1
, unk2
);
3341 IUnknown_Release( unk1
);
3342 IUnknown_Release( unk2
);
3344 /* ba_node should have been removed from below fo_node */
3345 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
3346 ok( r
== S_OK
, "ret %08x\n", r
);
3348 /* MS quirk: replaceChild also accepts elements instead of nodes */
3349 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IXMLDOMElement
, (void**)&ba_element
);
3350 ok( r
== S_OK
, "ret %08x\n", r
);
3352 r
= IXMLDOMElement_replaceChild( element
, ba_node
, (IXMLDOMNode
*)ba_element
, &removed_node
);
3353 ok( r
== S_OK
, "ret %08x\n", r
);
3355 r
= IXMLDOMNodeList_get_length( fo_list
, &len
);
3356 ok( r
== S_OK
, "ret %08x\n", r
);
3357 ok( len
== 0, "len %d\n", len
);
3359 IXMLDOMNodeList_Release( fo_list
);
3361 IXMLDOMNode_Release(ba_node
);
3362 IXMLDOMNode_Release(fo_node
);
3363 IXMLDOMNode_Release(temp_node
);
3364 IXMLDOMNodeList_Release( root_list
);
3365 IXMLDOMElement_Release( element
);
3366 IXMLDOMDocument_Release( doc
);
3369 static void test_removeNamedItem(void)
3371 IXMLDOMDocument
*doc
;
3372 IXMLDOMElement
*element
;
3373 IXMLDOMNode
*pr_node
, *removed_node
, *removed_node2
;
3374 IXMLDOMNodeList
*root_list
;
3375 IXMLDOMNamedNodeMap
* pr_attrs
;
3381 doc
= create_document(&IID_IXMLDOMDocument
);
3384 str
= SysAllocString( szComplete4
);
3385 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
3386 ok( r
== S_OK
, "loadXML failed\n");
3387 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3388 SysFreeString( str
);
3390 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
3391 ok( r
== S_OK
, "ret %08x\n", r
);
3393 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
3394 ok( r
== S_OK
, "ret %08x\n", r
);
3396 r
= IXMLDOMNodeList_get_item( root_list
, 1, &pr_node
);
3397 ok( r
== S_OK
, "ret %08x\n", r
);
3399 r
= IXMLDOMNode_get_attributes( pr_node
, &pr_attrs
);
3400 ok( r
== S_OK
, "ret %08x\n", r
);
3402 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
3403 ok( r
== S_OK
, "ret %08x\n", r
);
3404 ok( len
== 3, "length %d\n", len
);
3406 removed_node
= (void*)0xdeadbeef;
3407 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, NULL
, &removed_node
);
3408 ok ( r
== E_INVALIDARG
, "ret %08x\n", r
);
3409 ok ( removed_node
== (void*)0xdeadbeef, "got %p\n", removed_node
);
3411 removed_node
= (void*)0xdeadbeef;
3412 str
= SysAllocString(szvr
);
3413 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node
);
3414 ok ( r
== S_OK
, "ret %08x\n", r
);
3416 removed_node2
= (void*)0xdeadbeef;
3417 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node2
);
3418 ok ( r
== S_FALSE
, "ret %08x\n", r
);
3419 ok ( removed_node2
== NULL
, "got %p\n", removed_node2
);
3421 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
3422 ok( r
== S_OK
, "ret %08x\n", r
);
3423 ok( len
== 2, "length %d\n", len
);
3425 r
= IXMLDOMNamedNodeMap_setNamedItem( pr_attrs
, removed_node
, NULL
);
3426 ok ( r
== S_OK
, "ret %08x\n", r
);
3427 IXMLDOMNode_Release(removed_node
);
3429 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
3430 ok( r
== S_OK
, "ret %08x\n", r
);
3431 ok( len
== 3, "length %d\n", len
);
3433 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
3434 ok ( r
== S_OK
, "ret %08x\n", r
);
3436 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
3437 ok( r
== S_OK
, "ret %08x\n", r
);
3438 ok( len
== 2, "length %d\n", len
);
3440 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
3441 ok ( r
== S_FALSE
, "ret %08x\n", r
);
3445 IXMLDOMNamedNodeMap_Release( pr_attrs
);
3446 IXMLDOMNode_Release( pr_node
);
3447 IXMLDOMNodeList_Release( root_list
);
3448 IXMLDOMElement_Release( element
);
3449 IXMLDOMDocument_Release( doc
);
3452 static void test_XMLHTTP(void)
3454 static const WCHAR wszBody
[] = {'m','o','d','e','=','T','e','s','t',0};
3455 static const WCHAR wszPOST
[] = {'P','O','S','T',0};
3456 static const WCHAR wszUrl
[] = {'h','t','t','p',':','/','/',
3457 'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
3458 'p','o','s','t','t','e','s','t','.','p','h','p',0};
3459 static const WCHAR xmltestW
[] = {'h','t','t','p',':','/','/',
3460 'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
3461 'x','m','l','t','e','s','t','.','x','m','l',0};
3462 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
3463 static const CHAR xmltestbodyA
[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
3465 IXMLHttpRequest
*pXMLHttpRequest
;
3466 BSTR bstrResponse
, method
, url
;
3470 LONG state
, status
, ref
, bound
;
3473 HRESULT hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
,
3474 CLSCTX_INPROC_SERVER
, &IID_IXMLHttpRequest
,
3475 (void **)&pXMLHttpRequest
);
3478 win_skip("IXMLHTTPRequest is not available (0x%08x)\n", hr
);
3482 VariantInit(&dummy
);
3483 V_VT(&dummy
) = VT_ERROR
;
3484 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
3485 VariantInit(&async
);
3486 V_VT(&async
) = VT_BOOL
;
3487 V_BOOL(&async
) = VARIANT_FALSE
;
3488 V_VT(&varbody
) = VT_BSTR
;
3489 V_BSTR(&varbody
) = SysAllocString(wszBody
);
3491 method
= SysAllocString(wszPOST
);
3492 url
= SysAllocString(wszUrl
);
3496 /* crashes on win98 */
3497 hr
= IXMLHttpRequest_put_onreadystatechange(pXMLHttpRequest
, NULL
);
3498 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3501 hr
= IXMLHttpRequest_abort(pXMLHttpRequest
);
3502 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3504 /* send before open */
3505 hr
= IXMLHttpRequest_send(pXMLHttpRequest
, dummy
);
3506 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win9x, win2k */, "got 0x%08x\n", hr
);
3508 /* initial status code */
3509 hr
= IXMLHttpRequest_get_status(pXMLHttpRequest
, NULL
);
3510 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3512 status
= 0xdeadbeef;
3513 hr
= IXMLHttpRequest_get_status(pXMLHttpRequest
, &status
);
3514 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win9x, win2k */, "got 0x%08x\n", hr
);
3515 ok(status
== 0xdeadbeef, "got %d\n", status
);
3517 /* invalid parameters */
3518 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, NULL
, NULL
, async
, dummy
, dummy
);
3519 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3521 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, method
, NULL
, async
, dummy
, dummy
);
3522 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3524 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, NULL
, url
, async
, dummy
, dummy
);
3525 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3527 hr
= IXMLHttpRequest_setRequestHeader(pXMLHttpRequest
, NULL
, NULL
);
3528 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3530 hr
= IXMLHttpRequest_setRequestHeader(pXMLHttpRequest
, _bstr_("header1"), NULL
);
3531 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win9x, win2k */, "got 0x%08x\n", hr
);
3533 hr
= IXMLHttpRequest_setRequestHeader(pXMLHttpRequest
, NULL
, _bstr_("value1"));
3534 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3536 hr
= IXMLHttpRequest_setRequestHeader(pXMLHttpRequest
, _bstr_("header1"), _bstr_("value1"));
3537 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win9x, win2k */, "got 0x%08x\n", hr
);
3539 hr
= IXMLHttpRequest_get_readyState(pXMLHttpRequest
, NULL
);
3540 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3543 hr
= IXMLHttpRequest_get_readyState(pXMLHttpRequest
, &state
);
3544 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3545 ok(state
== READYSTATE_UNINITIALIZED
, "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
3547 event
= create_dispevent();
3548 ref
= IDispatch_AddRef(event
);
3549 ok(ref
== 2, "got %d\n", ref
);
3550 IDispatch_Release(event
);
3552 hr
= IXMLHttpRequest_put_onreadystatechange(pXMLHttpRequest
, event
);
3553 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3555 ref
= IDispatch_AddRef(event
);
3556 ok(ref
== 3, "got %d\n", ref
);
3557 IDispatch_Release(event
);
3559 g_unexpectedcall
= g_expectedcall
= 0;
3561 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, method
, url
, async
, dummy
, dummy
);
3562 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3564 ok(g_unexpectedcall
== 0, "unexpected disp event call\n");
3565 ok(g_expectedcall
== 1 || broken(g_expectedcall
== 0) /* win2k */, "no expected disp event call\n");
3567 /* status code after ::open() */
3568 status
= 0xdeadbeef;
3569 hr
= IXMLHttpRequest_get_status(pXMLHttpRequest
, &status
);
3570 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win9x, win2k */, "got 0x%08x\n", hr
);
3571 ok(status
== 0xdeadbeef, "got %d\n", status
);
3574 hr
= IXMLHttpRequest_get_readyState(pXMLHttpRequest
, &state
);
3575 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3576 ok(state
== READYSTATE_LOADING
, "got %d, expected READYSTATE_LOADING\n", state
);
3578 hr
= IXMLHttpRequest_abort(pXMLHttpRequest
);
3579 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3582 hr
= IXMLHttpRequest_get_readyState(pXMLHttpRequest
, &state
);
3583 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3584 ok(state
== READYSTATE_UNINITIALIZED
|| broken(state
== READYSTATE_LOADING
) /* win98, win2k */,
3585 "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
3587 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, method
, url
, async
, dummy
, dummy
);
3588 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3590 hr
= IXMLHttpRequest_setRequestHeader(pXMLHttpRequest
, _bstr_("header1"), _bstr_("value1"));
3591 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3593 hr
= IXMLHttpRequest_setRequestHeader(pXMLHttpRequest
, NULL
, _bstr_("value1"));
3594 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3596 hr
= IXMLHttpRequest_setRequestHeader(pXMLHttpRequest
, _bstr_(""), _bstr_("value1"));
3597 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3599 SysFreeString(method
);
3602 hr
= IXMLHttpRequest_send(pXMLHttpRequest
, varbody
);
3603 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
3605 skip("No connection could be made with crossover.codeweavers.com\n");
3606 IXMLHttpRequest_Release(pXMLHttpRequest
);
3609 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3611 /* status code after ::send() */
3612 status
= 0xdeadbeef;
3613 hr
= IXMLHttpRequest_get_status(pXMLHttpRequest
, &status
);
3614 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3615 ok(status
== 200, "got %d\n", status
);
3617 /* another ::send() after completed request */
3618 hr
= IXMLHttpRequest_send(pXMLHttpRequest
, varbody
);
3619 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win9x, win2k */, "got 0x%08x\n", hr
);
3621 VariantClear(&varbody
);
3623 hr
= IXMLHttpRequest_get_responseText(pXMLHttpRequest
, &bstrResponse
);
3624 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3625 /* the server currently returns "FAILED" because the Content-Type header is
3626 * not what the server expects */
3629 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)),
3630 "expected %s, got %s\n", wine_dbgstr_w(wszExpectedResponse
), wine_dbgstr_w(bstrResponse
));
3631 SysFreeString(bstrResponse
);
3635 url
= SysAllocString(xmltestW
);
3637 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, _bstr_("GET"), url
, async
, dummy
, dummy
);
3638 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3640 V_VT(&varbody
) = VT_EMPTY
;
3642 hr
= IXMLHttpRequest_send(pXMLHttpRequest
, varbody
);
3643 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
3645 skip("No connection could be made with crossover.codeweavers.com\n");
3646 IXMLHttpRequest_Release(pXMLHttpRequest
);
3649 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3651 hr
= IXMLHttpRequest_get_responseText(pXMLHttpRequest
, NULL
);
3652 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3654 hr
= IXMLHttpRequest_get_responseText(pXMLHttpRequest
, &bstrResponse
);
3655 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3658 ok(!memcmp(bstrResponse
, _bstr_(xmltestbodyA
), sizeof(xmltestbodyA
)*sizeof(WCHAR
)),
3659 "expected %s, got %s\n", xmltestbodyA
, wine_dbgstr_w(bstrResponse
));
3660 SysFreeString(bstrResponse
);
3663 hr
= IXMLHttpRequest_get_responseBody(pXMLHttpRequest
, NULL
);
3664 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
3666 V_VT(&varbody
) = VT_EMPTY
;
3667 hr
= IXMLHttpRequest_get_responseBody(pXMLHttpRequest
, &varbody
);
3668 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3669 ok(V_VT(&varbody
) == (VT_ARRAY
|VT_UI1
), "got type %d, expected %d\n", V_VT(&varbody
), VT_ARRAY
|VT_UI1
);
3670 ok(SafeArrayGetDim(V_ARRAY(&varbody
)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody
)));
3673 hr
= SafeArrayGetLBound(V_ARRAY(&varbody
), 1, &bound
);
3674 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3675 ok(bound
== 0, "got %d, expected zero bound\n", bound
);
3677 hr
= SafeArrayAccessData(V_ARRAY(&varbody
), &ptr
);
3678 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
3679 ok(memcmp(ptr
, xmltestbodyA
, sizeof(xmltestbodyA
)-1) == 0, "got wrond body data\n");
3680 SafeArrayUnaccessData(V_ARRAY(&varbody
));
3682 VariantClear(&varbody
);
3686 IDispatch_Release(event
);
3687 IXMLHttpRequest_Release(pXMLHttpRequest
);
3691 static void test_IXMLDOMDocument2(void)
3693 static const WCHAR emptyW
[] = {0};
3694 IXMLDOMDocument2
*doc2
, *dtddoc2
;
3695 IXMLDOMDocument
*doc
;
3696 IXMLDOMParseError
* err
;
3697 IDispatchEx
*dispex
;
3704 doc
= create_document(&IID_IXMLDOMDocument
);
3707 dtddoc2
= create_document(&IID_IXMLDOMDocument2
);
3710 IXMLDOMDocument_Release(doc
);
3714 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IXMLDOMDocument2
, (void**)&doc2
);
3715 ok( r
== S_OK
, "ret %08x\n", r
);
3716 ok( doc
== (IXMLDOMDocument
*)doc2
, "interfaces differ\n");
3718 ole_expect(IXMLDOMDocument2_get_readyState(doc2
, NULL
), E_INVALIDARG
);
3719 ole_check(IXMLDOMDocument2_get_readyState(doc2
, &res
));
3720 ok(res
== READYSTATE_COMPLETE
, "expected READYSTATE_COMPLETE (4), got %i\n", res
);
3723 ole_expect(IXMLDOMDocument2_validate(doc2
, NULL
), S_FALSE
);
3724 ole_expect(IXMLDOMDocument2_validate(doc2
, &err
), S_FALSE
);
3725 ok(err
!= NULL
, "expected a pointer\n");
3729 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3731 ok(res
== E_XML_NOTWF
, "got %08x\n", res
);
3732 IXMLDOMParseError_Release(err
);
3735 str
= SysAllocString( szComplete4
);
3736 r
= IXMLDOMDocument_loadXML( doc2
, str
, &b
);
3737 ok( r
== S_OK
, "loadXML failed\n");
3738 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3739 SysFreeString( str
);
3741 ole_check(IXMLDOMDocument2_get_readyState(doc
, &res
));
3742 ok(res
== READYSTATE_COMPLETE
, "expected READYSTATE_COMPLETE (4), got %i\n", res
);
3745 ole_expect(IXMLDOMDocument2_validate(doc2
, &err
), S_FALSE
);
3746 ok(err
!= NULL
, "expected a pointer\n");
3750 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3752 ok(res
== E_XML_NODTD
, "got %08x\n", res
);
3753 IXMLDOMParseError_Release(err
);
3756 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IDispatchEx
, (void**)&dispex
);
3757 ok( r
== S_OK
, "ret %08x\n", r
);
3760 IDispatchEx_Release(dispex
);
3763 /* we will check if the variant got cleared */
3764 ref
= IXMLDOMDocument2_AddRef(doc2
);
3765 expect_eq(ref
, 3, int, "%d"); /* doc, doc2, AddRef*/
3766 V_VT(&var
) = VT_UNKNOWN
;
3767 V_UNKNOWN(&var
) = (IUnknown
*)doc2
;
3770 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("askldhfaklsdf"), &var
), E_FAIL
);
3771 expect_eq(V_VT(&var
), VT_UNKNOWN
, int, "%x");
3772 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), NULL
), E_INVALIDARG
);
3775 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
3776 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
3777 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
3780 /* the variant didn't get cleared*/
3781 expect_eq(IXMLDOMDocument2_Release(doc2
), 2, int, "%d");
3783 /* setProperty tests */
3784 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("askldhfaklsdf"), var
), E_FAIL
);
3785 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), var
), E_FAIL
);
3786 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL
);
3787 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
3788 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
3789 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
3791 V_VT(&var
) = VT_BSTR
;
3792 V_BSTR(&var
) = SysAllocString(emptyW
);
3793 r
= IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionNamespaces"), var
);
3794 ok(r
== S_OK
, "got 0x%08x\n", r
);
3799 r
= IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionNamespaces"), var
);
3800 ok(r
== E_FAIL
, "got 0x%08x\n", r
);
3802 /* contrary to what MSDN claims you can switch back from XPath to XSLPattern */
3803 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
3804 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
3805 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
3807 IXMLDOMDocument2_Release( doc2
);
3808 IXMLDOMDocument_Release( doc
);
3810 /* DTD validation */
3811 ole_check(IXMLDOMDocument2_put_validateOnParse(dtddoc2
, VARIANT_FALSE
));
3812 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML
), &b
));
3813 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3815 ole_check(IXMLDOMDocument2_validate(dtddoc2
, &err
));
3816 ok(err
!= NULL
, "expected pointer\n");
3820 ole_expect(IXMLDOMParseError_get_errorCode(err
, &res
), S_FALSE
);
3821 ok(res
== 0, "got %08x\n", res
);
3822 IXMLDOMParseError_Release(err
);
3825 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_0D
), &b
));
3826 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3828 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3829 ok(err
!= NULL
, "expected pointer\n");
3833 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3834 /* XML_ELEMENT_UNDECLARED */
3835 todo_wine
ok(res
== 0xC00CE00D, "got %08x\n", res
);
3836 IXMLDOMParseError_Release(err
);
3839 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_0E
), &b
));
3840 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3842 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3843 ok(err
!= NULL
, "expected pointer\n");
3847 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3848 /* XML_ELEMENT_ID_NOT_FOUND */
3849 todo_wine
ok(res
== 0xC00CE00E, "got %08x\n", res
);
3850 IXMLDOMParseError_Release(err
);
3853 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_11
), &b
));
3854 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3856 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3857 ok(err
!= NULL
, "expected pointer\n");
3861 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3862 /* XML_EMPTY_NOT_ALLOWED */
3863 todo_wine
ok(res
== 0xC00CE011, "got %08x\n", res
);
3864 IXMLDOMParseError_Release(err
);
3867 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_13
), &b
));
3868 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3870 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3871 ok(err
!= NULL
, "expected pointer\n");
3875 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3876 /* XML_ROOT_NAME_MISMATCH */
3877 todo_wine
ok(res
== 0xC00CE013, "got %08x\n", res
);
3878 IXMLDOMParseError_Release(err
);
3881 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_14
), &b
));
3882 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3884 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3885 ok(err
!= NULL
, "expected pointer\n");
3889 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3890 /* XML_INVALID_CONTENT */
3891 todo_wine
ok(res
== 0xC00CE014, "got %08x\n", res
);
3892 IXMLDOMParseError_Release(err
);
3895 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_15
), &b
));
3896 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3898 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3899 ok(err
!= NULL
, "expected pointer\n");
3903 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3904 /* XML_ATTRIBUTE_NOT_DEFINED */
3905 todo_wine
ok(res
== 0xC00CE015, "got %08x\n", res
);
3906 IXMLDOMParseError_Release(err
);
3909 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_16
), &b
));
3910 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3912 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3913 ok(err
!= NULL
, "expected pointer\n");
3917 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3918 /* XML_ATTRIBUTE_FIXED */
3919 todo_wine
ok(res
== 0xC00CE016, "got %08x\n", res
);
3920 IXMLDOMParseError_Release(err
);
3923 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_17
), &b
));
3924 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3926 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3927 ok(err
!= NULL
, "expected pointer\n");
3931 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3932 /* XML_ATTRIBUTE_VALUE */
3933 todo_wine
ok(res
== 0xC00CE017, "got %08x\n", res
);
3934 IXMLDOMParseError_Release(err
);
3937 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_18
), &b
));
3938 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3940 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3941 ok(err
!= NULL
, "expected pointer\n");
3945 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3946 /* XML_ILLEGAL_TEXT */
3947 todo_wine
ok(res
== 0xC00CE018, "got %08x\n", res
);
3948 IXMLDOMParseError_Release(err
);
3951 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_20
), &b
));
3952 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3954 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3955 ok(err
!= NULL
, "expected pointer\n");
3959 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3960 /* XML_REQUIRED_ATTRIBUTE_MISSING */
3961 todo_wine
ok(res
== 0xC00CE020, "got %08x\n", res
);
3962 IXMLDOMParseError_Release(err
);
3965 IXMLDOMDocument2_Release( dtddoc2
);
3969 #define helper_ole_check(expr) { \
3971 ok_(__FILE__, line)(r == S_OK, "=> %i: " #expr " returned %08x\n", __LINE__, r); \
3974 #define helper_expect_list_and_release(list, expstr) { \
3975 char *str = list_to_string(list); \
3976 ok_(__FILE__, line)(strcmp(str, expstr)==0, "=> %i: Invalid node list: %s, expected %s\n", __LINE__, str, expstr); \
3977 if (list) IXMLDOMNodeList_Release(list); \
3980 #define helper_expect_bstr_and_release(bstr, str) { \
3981 ok_(__FILE__, line)(lstrcmpW(bstr, _bstr_(str)) == 0, \
3982 "=> %i: got %s\n", __LINE__, wine_dbgstr_w(bstr)); \
3983 SysFreeString(bstr); \
3986 #define check_ws_ignored(doc, str) _check_ws_ignored(__LINE__, doc, str)
3987 static inline void _check_ws_ignored(int line
, IXMLDOMDocument2
* doc
, char const* str
)
3989 IXMLDOMNode
*node1
, *node2
;
3990 IXMLDOMNodeList
*list
;
3993 helper_ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//*[local-name()='html']"), &list
));
3994 helper_ole_check(IXMLDOMNodeList_get_item(list
, 0, &node1
));
3995 helper_ole_check(IXMLDOMNodeList_get_item(list
, 1, &node2
));
3996 helper_ole_check(IXMLDOMNodeList_reset(list
));
3997 helper_expect_list_and_release(list
, "E1.E4.E1.E2.D1 E2.E4.E1.E2.D1");
3999 helper_ole_check(IXMLDOMNode_get_childNodes(node1
, &list
));
4000 helper_expect_list_and_release(list
, "T1.E1.E4.E1.E2.D1 E2.E1.E4.E1.E2.D1 E3.E1.E4.E1.E2.D1 T4.E1.E4.E1.E2.D1 E5.E1.E4.E1.E2.D1");
4001 helper_ole_check(IXMLDOMNode_get_text(node1
, &bstr
));
4004 helper_expect_bstr_and_release(bstr
, str
);
4008 helper_expect_bstr_and_release(bstr
, "This is a description.");
4010 IXMLDOMNode_Release(node1
);
4012 helper_ole_check(IXMLDOMNode_get_childNodes(node2
, &list
));
4013 helper_expect_list_and_release(list
, "T1.E2.E4.E1.E2.D1 E2.E2.E4.E1.E2.D1 T3.E2.E4.E1.E2.D1 E4.E2.E4.E1.E2.D1 T5.E2.E4.E1.E2.D1 E6.E2.E4.E1.E2.D1 T7.E2.E4.E1.E2.D1");
4014 helper_ole_check(IXMLDOMNode_get_text(node2
, &bstr
));
4015 helper_expect_bstr_and_release(bstr
, "\n This is a description with preserved whitespace. \n ");
4016 IXMLDOMNode_Release(node2
);
4019 #define check_ws_preserved(doc, str) _check_ws_preserved(__LINE__, doc, str)
4020 static inline void _check_ws_preserved(int line
, IXMLDOMDocument2
* doc
, char const* str
)
4022 IXMLDOMNode
*node1
, *node2
;
4023 IXMLDOMNodeList
*list
;
4026 helper_ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//*[local-name()='html']"), &list
));
4027 helper_ole_check(IXMLDOMNodeList_get_item(list
, 0, &node1
));
4028 helper_ole_check(IXMLDOMNodeList_get_item(list
, 1, &node2
));
4029 helper_ole_check(IXMLDOMNodeList_reset(list
));
4030 helper_expect_list_and_release(list
, "E2.E8.E2.E2.D1 E4.E8.E2.E2.D1");
4032 helper_ole_check(IXMLDOMNode_get_childNodes(node1
, &list
));
4033 helper_expect_list_and_release(list
, "T1.E2.E8.E2.E2.D1 E2.E2.E8.E2.E2.D1 T3.E2.E8.E2.E2.D1 E4.E2.E8.E2.E2.D1 T5.E2.E8.E2.E2.D1 E6.E2.E8.E2.E2.D1 T7.E2.E8.E2.E2.D1");
4034 helper_ole_check(IXMLDOMNode_get_text(node1
, &bstr
));
4037 helper_expect_bstr_and_release(bstr
, str
);
4041 helper_expect_bstr_and_release(bstr
, "\n This is a description. \n ");
4043 IXMLDOMNode_Release(node1
);
4045 helper_ole_check(IXMLDOMNode_get_childNodes(node2
, &list
));
4046 helper_expect_list_and_release(list
, "T1.E4.E8.E2.E2.D1 E2.E4.E8.E2.E2.D1 T3.E4.E8.E2.E2.D1 E4.E4.E8.E2.E2.D1 T5.E4.E8.E2.E2.D1 E6.E4.E8.E2.E2.D1 T7.E4.E8.E2.E2.D1");
4047 helper_ole_check(IXMLDOMNode_get_text(node2
, &bstr
));
4048 helper_expect_bstr_and_release(bstr
, "\n This is a description with preserved whitespace. \n ");
4049 IXMLDOMNode_Release(node2
);
4052 static void test_whitespace(void)
4055 IXMLDOMDocument2
*doc1
, *doc2
, *doc3
, *doc4
;
4057 doc1
= create_document(&IID_IXMLDOMDocument2
);
4058 doc2
= create_document(&IID_IXMLDOMDocument2
);
4059 if (!doc1
|| !doc2
) return;
4061 ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc2
, VARIANT_TRUE
));
4062 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc1
, &b
));
4063 ok(b
== VARIANT_FALSE
, "expected false\n");
4064 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc2
, &b
));
4065 ok(b
== VARIANT_TRUE
, "expected true\n");
4067 ole_check(IXMLDOMDocument2_loadXML(doc1
, _bstr_(szExampleXML
), &b
));
4068 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4069 ole_check(IXMLDOMDocument2_loadXML(doc2
, _bstr_(szExampleXML
), &b
));
4070 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4072 /* switch to XPath */
4073 ole_check(IXMLDOMDocument2_setProperty(doc1
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
4074 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
4076 check_ws_ignored(doc1
, NULL
);
4077 check_ws_preserved(doc2
, NULL
);
4079 /* new instances copy the property */
4080 ole_check(IXMLDOMDocument2_QueryInterface(doc1
, &IID_IXMLDOMDocument2
, (void**) &doc3
));
4081 ole_check(IXMLDOMDocument2_QueryInterface(doc2
, &IID_IXMLDOMDocument2
, (void**) &doc4
));
4083 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc3
, &b
));
4084 ok(b
== VARIANT_FALSE
, "expected false\n");
4085 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc4
, &b
));
4086 ok(b
== VARIANT_TRUE
, "expected true\n");
4088 check_ws_ignored(doc3
, NULL
);
4089 check_ws_preserved(doc4
, NULL
);
4091 /* setting after loading xml affects trimming of leading/trailing ws only */
4092 ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc1
, VARIANT_TRUE
));
4093 ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc2
, VARIANT_FALSE
));
4095 /* the trailing "\n " isn't there, because it was ws-only node */
4096 check_ws_ignored(doc1
, "\n This is a description. ");
4097 check_ws_preserved(doc2
, "This is a description.");
4099 /* it takes effect on reload */
4100 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc1
, &b
));
4101 ok(b
== VARIANT_TRUE
, "expected true\n");
4102 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc2
, &b
));
4103 ok(b
== VARIANT_FALSE
, "expected false\n");
4105 ole_check(IXMLDOMDocument2_loadXML(doc1
, _bstr_(szExampleXML
), &b
));
4106 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4107 ole_check(IXMLDOMDocument2_loadXML(doc2
, _bstr_(szExampleXML
), &b
));
4108 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4110 check_ws_preserved(doc1
, NULL
);
4111 check_ws_ignored(doc2
, NULL
);
4113 /* other instances follow suit */
4114 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc3
, &b
));
4115 ok(b
== VARIANT_TRUE
, "expected true\n");
4116 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc4
, &b
));
4117 ok(b
== VARIANT_FALSE
, "expected false\n");
4119 check_ws_preserved(doc3
, NULL
);
4120 check_ws_ignored(doc4
, NULL
);
4122 IXMLDOMDocument_Release(doc1
);
4123 IXMLDOMDocument_Release(doc2
);
4124 IXMLDOMDocument_Release(doc3
);
4125 IXMLDOMDocument_Release(doc4
);
4129 static void test_XPath(void)
4133 IXMLDOMDocument2
*doc
;
4134 IXMLDOMNode
*rootNode
;
4135 IXMLDOMNode
*elem1Node
;
4137 IXMLDOMNodeList
*list
;
4139 doc
= create_document(&IID_IXMLDOMDocument2
);
4142 ole_check(IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &b
));
4143 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4145 /* switch to XPath */
4146 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
4148 /* some simple queries*/
4149 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root"), &list
));
4150 ole_check(IXMLDOMNodeList_get_item(list
, 0, &rootNode
));
4151 ole_check(IXMLDOMNodeList_reset(list
));
4152 expect_list_and_release(list
, "E2.D1");
4153 if (rootNode
== NULL
)
4156 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//c"), &list
));
4157 expect_list_and_release(list
, "E3.E1.E2.D1 E3.E2.E2.D1");
4159 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//c[@type]"), &list
));
4160 expect_list_and_release(list
, "E3.E2.E2.D1");
4162 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem"), &list
));
4163 /* using get_item for query results advances the position */
4164 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
4165 expect_node(node
, "E2.E2.D1");
4166 IXMLDOMNode_Release(node
);
4167 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
4168 expect_node(node
, "E4.E2.D1");
4169 IXMLDOMNode_Release(node
);
4170 ole_check(IXMLDOMNodeList_reset(list
));
4171 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
4173 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("."), &list
));
4174 expect_list_and_release(list
, "E2.D1");
4176 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem[3]/preceding-sibling::*"), &list
));
4177 ole_check(IXMLDOMNodeList_get_item(list
, 0, &elem1Node
));
4178 ole_check(IXMLDOMNodeList_reset(list
));
4179 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
4181 /* select an attribute */
4182 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//@type"), &list
));
4183 expect_list_and_release(list
, "A'type'.E3.E2.E2.D1");
4185 /* would evaluate to a number */
4186 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("count(*)"), &list
), E_FAIL
);
4187 /* would evaluate to a boolean */
4188 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("position()>0"), &list
), E_FAIL
);
4189 /* would evaluate to a string */
4190 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("name()"), &list
), E_FAIL
);
4193 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("c"), &list
));
4194 expect_list_and_release(list
, "");
4195 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("elem//c"), &list
));
4196 expect_list_and_release(list
, "");
4197 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//elem[4]"), &list
));
4198 expect_list_and_release(list
, "");
4199 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//elem[0]"), &list
));
4200 expect_list_and_release(list
, "");
4202 /* foo undeclared in document node */
4203 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
4204 /* undeclared in <root> node */
4205 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//foo:c"), &list
), E_FAIL
);
4206 /* undeclared in <elem> node */
4207 ole_expect(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//foo:c"), &list
), E_FAIL
);
4208 /* but this trick can be used */
4209 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//*[name()='foo:c']"), &list
));
4210 expect_list_and_release(list
, "E3.E4.E2.D1");
4212 /* it has to be declared in SelectionNamespaces */
4213 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
4214 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
4216 /* now the namespace can be used */
4217 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//test:c"), &list
));
4218 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
4219 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//test:c"), &list
));
4220 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
4221 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//test:c"), &list
));
4222 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
4223 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_(".//test:x"), &list
));
4224 expect_list_and_release(list
, "E5.E1.E4.E1.E2.D1 E6.E2.E4.E1.E2.D1");
4226 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
4227 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
4228 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL
);
4230 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
4233 ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
4234 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
4235 if (V_VT(&var
) == VT_BSTR
)
4236 expect_bstr_eq_and_free(V_BSTR(&var
), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
4238 /* extra attributes - same thing*/
4239 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
4240 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL
);
4241 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
4243 IXMLDOMNode_Release(rootNode
);
4244 IXMLDOMNode_Release(elem1Node
);
4245 IXMLDOMDocument_Release(doc
);
4249 static void test_cloneNode(void )
4251 IXMLDOMDocument
*doc
;
4253 IXMLDOMNodeList
*pList
;
4254 IXMLDOMNamedNodeMap
*mapAttr
;
4255 LONG nLength
= 0, nLength1
= 0;
4256 LONG nAttrCnt
= 0, nAttrCnt1
= 0;
4258 IXMLDOMNode
*node_clone
;
4259 IXMLDOMNode
*node_first
;
4262 static const WCHAR szSearch
[] = { 'l', 'c', '/', 'p', 'r', 0 };
4264 doc
= create_document(&IID_IXMLDOMDocument
);
4267 str
= SysAllocString( szComplete4
);
4268 ole_check(IXMLDOMDocument_loadXML(doc
, str
, &b
));
4269 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4275 str
= SysAllocString( szSearch
);
4276 r
= IXMLDOMNode_selectSingleNode(doc
, str
, &node
);
4277 ok( r
== S_OK
, "ret %08x\n", r
);
4278 ok( node
!= NULL
, "node %p\n", node
);
4283 IXMLDOMDocument_Release(doc
);
4287 /* Check invalid parameter */
4288 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, NULL
);
4289 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4292 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, &node_clone
);
4293 ok( r
== S_OK
, "ret %08x\n", r
);
4294 ok( node_clone
!= NULL
, "node %p\n", node
);
4298 IXMLDOMDocument_Release(doc
);
4299 IXMLDOMNode_Release(node
);
4303 r
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
4304 ok( r
== S_OK
, "ret %08x\n", r
);
4307 IXMLDOMDocument
*doc2
;
4309 r
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
4310 ok( r
== S_OK
, "ret %08x\n", r
);
4312 IXMLDOMDocument_Release(doc2
);
4314 IXMLDOMNode_Release(node_first
);
4317 r
= IXMLDOMNode_get_childNodes(node
, &pList
);
4318 ok( r
== S_OK
, "ret %08x\n", r
);
4321 IXMLDOMNodeList_get_length(pList
, &nLength
);
4322 IXMLDOMNodeList_Release(pList
);
4325 r
= IXMLDOMNode_get_attributes(node
, &mapAttr
);
4326 ok( r
== S_OK
, "ret %08x\n", r
);
4329 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt
);
4330 IXMLDOMNamedNodeMap_Release(mapAttr
);
4333 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
4334 ok( r
== S_OK
, "ret %08x\n", r
);
4337 IXMLDOMNodeList_get_length(pList
, &nLength1
);
4338 IXMLDOMNodeList_Release(pList
);
4341 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
4342 ok( r
== S_OK
, "ret %08x\n", r
);
4345 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
4346 IXMLDOMNamedNodeMap_Release(mapAttr
);
4349 ok(nLength
== nLength1
, "wrong Child count (%d, %d)\n", nLength
, nLength1
);
4350 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%d, %d)\n", nAttrCnt
, nAttrCnt1
);
4351 IXMLDOMNode_Release(node_clone
);
4354 r
= IXMLDOMNode_cloneNode(node
, VARIANT_FALSE
, &node_clone
);
4355 ok( r
== S_OK
, "ret %08x\n", r
);
4356 ok( node_clone
!= NULL
, "node %p\n", node
);
4360 IXMLDOMDocument_Release(doc
);
4361 IXMLDOMNode_Release(node
);
4365 r
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
4366 ok( r
== S_FALSE
, "ret %08x\n", r
);
4369 IXMLDOMDocument
*doc2
;
4371 r
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
4372 ok( r
== S_OK
, "ret %08x\n", r
);
4374 IXMLDOMDocument_Release(doc2
);
4376 IXMLDOMNode_Release(node_first
);
4379 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
4380 ok( r
== S_OK
, "ret %08x\n", r
);
4383 IXMLDOMNodeList_get_length(pList
, &nLength1
);
4384 ok( nLength1
== 0, "Length should be 0 (%d)\n", nLength1
);
4385 IXMLDOMNodeList_Release(pList
);
4388 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
4389 ok( r
== S_OK
, "ret %08x\n", r
);
4392 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
4393 ok( nAttrCnt1
== 3, "Attribute count should be 3 (%d)\n", nAttrCnt1
);
4394 IXMLDOMNamedNodeMap_Release(mapAttr
);
4397 ok(nLength
!= nLength1
, "wrong Child count (%d, %d)\n", nLength
, nLength1
);
4398 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%d, %d)\n", nAttrCnt
, nAttrCnt1
);
4399 IXMLDOMNode_Release(node_clone
);
4402 IXMLDOMNode_Release(node
);
4403 IXMLDOMDocument_Release(doc
);
4406 static void test_xmlTypes(void)
4408 IXMLDOMDocument
*doc
;
4409 IXMLDOMElement
*pRoot
;
4411 IXMLDOMComment
*pComment
;
4412 IXMLDOMElement
*pElement
;
4413 IXMLDOMAttribute
*pAttribute
;
4414 IXMLDOMNamedNodeMap
*pAttribs
;
4415 IXMLDOMCDATASection
*pCDataSec
;
4416 IXMLDOMImplementation
*pIXMLDOMImplementation
= NULL
;
4417 IXMLDOMDocumentFragment
*pDocFrag
= NULL
;
4418 IXMLDOMEntityReference
*pEntityRef
= NULL
;
4420 IXMLDOMNode
*pNextChild
;
4424 doc
= create_document(&IID_IXMLDOMDocument
);
4427 pNextChild
= (void*)0xdeadbeef;
4428 hr
= IXMLDOMDocument_get_nextSibling(doc
, NULL
);
4429 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4431 pNextChild
= (void*)0xdeadbeef;
4432 hr
= IXMLDOMDocument_get_nextSibling(doc
, &pNextChild
);
4433 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4434 ok(pNextChild
== NULL
, "pDocChild not NULL\n");
4436 /* test previous Sibling */
4437 hr
= IXMLDOMDocument_get_previousSibling(doc
, NULL
);
4438 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4440 pNextChild
= (void*)0xdeadbeef;
4441 hr
= IXMLDOMDocument_get_previousSibling(doc
, &pNextChild
);
4442 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4443 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
4445 /* test get_attributes */
4446 hr
= IXMLDOMDocument_get_attributes( doc
, NULL
);
4447 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
4449 pAttribs
= (void*)0xdeadbeef;
4450 hr
= IXMLDOMDocument_get_attributes( doc
, &pAttribs
);
4451 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4452 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
4454 /* test get_dataType */
4455 V_VT(&v
) = VT_EMPTY
;
4456 hr
= IXMLDOMDocument_get_dataType(doc
, &v
);
4457 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4458 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
4461 /* test nodeTypeString */
4463 hr
= IXMLDOMDocument_get_nodeTypeString(doc
, &str
);
4464 ok(hr
== S_OK
, "ret %08x\n", hr
);
4465 ok( !lstrcmpW( str
, _bstr_("document") ), "incorrect nodeTypeString string\n");
4468 /* test implementation */
4469 hr
= IXMLDOMDocument_get_implementation(doc
, NULL
);
4470 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4472 hr
= IXMLDOMDocument_get_implementation(doc
, &pIXMLDOMImplementation
);
4473 ok(hr
== S_OK
, "ret %08x\n", hr
);
4476 VARIANT_BOOL hasFeature
= VARIANT_TRUE
;
4477 BSTR sEmpty
= SysAllocStringLen(NULL
, 0);
4479 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, NULL
, sEmpty
, &hasFeature
);
4480 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4482 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, NULL
);
4483 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4485 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
4486 ok(hr
== S_OK
, "ret %08x\n", hr
);
4487 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
4489 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, &hasFeature
);
4490 ok(hr
== S_OK
, "ret %08x\n", hr
);
4491 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned true\n");
4493 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), NULL
, &hasFeature
);
4494 ok(hr
== S_OK
, "ret %08x\n", hr
);
4495 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned false\n");
4497 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
4498 ok(hr
== S_OK
, "ret %08x\n", hr
);
4499 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
4501 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), _bstr_("1.0"), &hasFeature
);
4502 ok(hr
== S_OK
, "ret %08x\n", hr
);
4503 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
4505 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("XML"), _bstr_("1.0"), &hasFeature
);
4506 ok(hr
== S_OK
, "ret %08x\n", hr
);
4507 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
4509 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature
);
4510 ok(hr
== S_OK
, "ret %08x\n", hr
);
4511 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
4513 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("SSS"), NULL
, &hasFeature
);
4514 ok(hr
== S_OK
, "ret %08x\n", hr
);
4515 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
4517 SysFreeString(sEmpty
);
4518 IXMLDOMImplementation_Release(pIXMLDOMImplementation
);
4521 pRoot
= (IXMLDOMElement
*)0x1;
4522 hr
= IXMLDOMDocument_createElement(doc
, NULL
, &pRoot
);
4523 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4524 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
4526 pRoot
= (IXMLDOMElement
*)0x1;
4527 hr
= IXMLDOMDocument_createElement(doc
, _bstr_(""), &pRoot
);
4528 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4529 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
4531 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
4532 ok(hr
== S_OK
, "ret %08x\n", hr
);
4535 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
4536 ok(hr
== S_OK
, "ret %08x\n", hr
);
4540 str
= SysAllocString(szComment
);
4541 hr
= IXMLDOMDocument_createComment(doc
, str
, &pComment
);
4543 ok(hr
== S_OK
, "ret %08x\n", hr
);
4546 /* test get_attributes */
4547 hr
= IXMLDOMComment_get_attributes( pComment
, NULL
);
4548 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
4550 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
4551 hr
= IXMLDOMComment_get_attributes( pComment
, &pAttribs
);
4552 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4553 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
4555 /* test nodeTypeString */
4556 hr
= IXMLDOMComment_get_nodeTypeString(pComment
, &str
);
4557 ok(hr
== S_OK
, "ret %08x\n", hr
);
4558 ok( !lstrcmpW( str
, _bstr_("comment") ), "incorrect nodeTypeString string\n");
4561 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pComment
, NULL
);
4562 ok(hr
== S_OK
, "ret %08x\n", hr
);
4564 hr
= IXMLDOMComment_get_nodeName(pComment
, &str
);
4565 ok(hr
== S_OK
, "ret %08x\n", hr
);
4566 ok( !lstrcmpW( str
, szCommentNodeText
), "incorrect comment node Name\n");
4569 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
4570 ok(hr
== S_OK
, "ret %08x\n", hr
);
4571 ok( !lstrcmpW( str
, szCommentXML
), "incorrect comment xml\n");
4574 hr
= IXMLDOMComment_get_dataType(pComment
, &v
);
4575 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4576 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
4579 /* put data Tests */
4580 hr
= IXMLDOMComment_put_data(pComment
, _bstr_("This &is a ; test <>\\"));
4581 ok(hr
== S_OK
, "ret %08x\n", hr
);
4583 /* get data Tests */
4584 hr
= IXMLDOMComment_get_data(pComment
, &str
);
4585 ok(hr
== S_OK
, "ret %08x\n", hr
);
4586 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
4589 /* get data Tests */
4590 hr
= IXMLDOMComment_get_nodeValue(pComment
, &v
);
4591 ok(hr
== S_OK
, "ret %08x\n", hr
);
4592 ok( V_VT(&v
) == VT_BSTR
, "incorrect dataType type\n");
4593 ok( !lstrcmpW( V_BSTR(&v
), _bstr_("This &is a ; test <>\\") ), "incorrect get_nodeValue string\n");
4596 /* Confirm XML text is good */
4597 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
4598 ok(hr
== S_OK
, "ret %08x\n", hr
);
4599 ok( !lstrcmpW( str
, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
4602 /* Confirm we get the put_data Text back */
4603 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4604 ok(hr
== S_OK
, "ret %08x\n", hr
);
4605 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
4608 /* test length property */
4609 hr
= IXMLDOMComment_get_length(pComment
, &len
);
4610 ok(hr
== S_OK
, "ret %08x\n", hr
);
4611 ok(len
== 21, "expected 21 got %d\n", len
);
4613 /* test substringData */
4614 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, NULL
);
4615 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4617 /* test substringData - Invalid offset */
4618 str
= (BSTR
)&szElement
;
4619 hr
= IXMLDOMComment_substringData(pComment
, -1, 4, &str
);
4620 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4621 ok( str
== NULL
, "incorrect string\n");
4623 /* test substringData - Invalid offset */
4624 str
= (BSTR
)&szElement
;
4625 hr
= IXMLDOMComment_substringData(pComment
, 30, 0, &str
);
4626 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4627 ok( str
== NULL
, "incorrect string\n");
4629 /* test substringData - Invalid size */
4630 str
= (BSTR
)&szElement
;
4631 hr
= IXMLDOMComment_substringData(pComment
, 0, -1, &str
);
4632 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4633 ok( str
== NULL
, "incorrect string\n");
4635 /* test substringData - Invalid size */
4636 str
= (BSTR
)&szElement
;
4637 hr
= IXMLDOMComment_substringData(pComment
, 2, 0, &str
);
4638 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4639 ok( str
== NULL
, "incorrect string\n");
4641 /* test substringData - Start of string */
4642 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, &str
);
4643 ok(hr
== S_OK
, "ret %08x\n", hr
);
4644 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
4647 /* test substringData - Middle of string */
4648 hr
= IXMLDOMComment_substringData(pComment
, 13, 4, &str
);
4649 ok(hr
== S_OK
, "ret %08x\n", hr
);
4650 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
4653 /* test substringData - End of string */
4654 hr
= IXMLDOMComment_substringData(pComment
, 20, 4, &str
);
4655 ok(hr
== S_OK
, "ret %08x\n", hr
);
4656 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
4659 /* test appendData */
4660 hr
= IXMLDOMComment_appendData(pComment
, NULL
);
4661 ok(hr
== S_OK
, "ret %08x\n", hr
);
4663 hr
= IXMLDOMComment_appendData(pComment
, _bstr_(""));
4664 ok(hr
== S_OK
, "ret %08x\n", hr
);
4666 hr
= IXMLDOMComment_appendData(pComment
, _bstr_("Append"));
4667 ok(hr
== S_OK
, "ret %08x\n", hr
);
4669 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4670 ok(hr
== S_OK
, "ret %08x\n", hr
);
4671 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4674 /* test insertData */
4675 str
= SysAllocStringLen(NULL
, 0);
4676 hr
= IXMLDOMComment_insertData(pComment
, -1, str
);
4677 ok(hr
== S_OK
, "ret %08x\n", hr
);
4679 hr
= IXMLDOMComment_insertData(pComment
, -1, NULL
);
4680 ok(hr
== S_OK
, "ret %08x\n", hr
);
4682 hr
= IXMLDOMComment_insertData(pComment
, 1000, str
);
4683 ok(hr
== S_OK
, "ret %08x\n", hr
);
4685 hr
= IXMLDOMComment_insertData(pComment
, 1000, NULL
);
4686 ok(hr
== S_OK
, "ret %08x\n", hr
);
4688 hr
= IXMLDOMComment_insertData(pComment
, 0, NULL
);
4689 ok(hr
== S_OK
, "ret %08x\n", hr
);
4691 hr
= IXMLDOMComment_insertData(pComment
, 0, str
);
4692 ok(hr
== S_OK
, "ret %08x\n", hr
);
4695 hr
= IXMLDOMComment_insertData(pComment
, -1, _bstr_("Inserting"));
4696 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4698 hr
= IXMLDOMComment_insertData(pComment
, 1000, _bstr_("Inserting"));
4699 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4701 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("Begin "));
4702 ok(hr
== S_OK
, "ret %08x\n", hr
);
4704 hr
= IXMLDOMComment_insertData(pComment
, 17, _bstr_("Middle"));
4705 ok(hr
== S_OK
, "ret %08x\n", hr
);
4707 hr
= IXMLDOMComment_insertData(pComment
, 39, _bstr_(" End"));
4708 ok(hr
== S_OK
, "ret %08x\n", hr
);
4710 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4711 ok(hr
== S_OK
, "ret %08x\n", hr
);
4712 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4716 /* invalid arguments */
4717 hr
= IXMLDOMComment_deleteData(pComment
, -1, 1);
4718 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4720 hr
= IXMLDOMComment_deleteData(pComment
, 0, 0);
4721 ok(hr
== S_OK
, "ret %08x\n", hr
);
4723 hr
= IXMLDOMComment_deleteData(pComment
, 0, -1);
4724 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4726 hr
= IXMLDOMComment_get_length(pComment
, &len
);
4727 ok(hr
== S_OK
, "ret %08x\n", hr
);
4728 ok(len
== 43, "expected 43 got %d\n", len
);
4730 hr
= IXMLDOMComment_deleteData(pComment
, len
, 1);
4731 ok(hr
== S_OK
, "ret %08x\n", hr
);
4733 hr
= IXMLDOMComment_deleteData(pComment
, len
+1, 1);
4734 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4736 /* delete from start */
4737 hr
= IXMLDOMComment_deleteData(pComment
, 0, 5);
4738 ok(hr
== S_OK
, "ret %08x\n", hr
);
4740 hr
= IXMLDOMComment_get_length(pComment
, &len
);
4741 ok(hr
== S_OK
, "ret %08x\n", hr
);
4742 ok(len
== 38, "expected 38 got %d\n", len
);
4744 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4745 ok(hr
== S_OK
, "ret %08x\n", hr
);
4746 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4749 /* delete from end */
4750 hr
= IXMLDOMComment_deleteData(pComment
, 35, 3);
4751 ok(hr
== S_OK
, "ret %08x\n", hr
);
4753 hr
= IXMLDOMComment_get_length(pComment
, &len
);
4754 ok(hr
== S_OK
, "ret %08x\n", hr
);
4755 ok(len
== 35, "expected 35 got %d\n", len
);
4757 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4758 ok(hr
== S_OK
, "ret %08x\n", hr
);
4759 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4762 /* delete from inside */
4763 hr
= IXMLDOMComment_deleteData(pComment
, 1, 33);
4764 ok(hr
== S_OK
, "ret %08x\n", hr
);
4766 hr
= IXMLDOMComment_get_length(pComment
, &len
);
4767 ok(hr
== S_OK
, "ret %08x\n", hr
);
4768 ok(len
== 2, "expected 2 got %d\n", len
);
4770 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4771 ok(hr
== S_OK
, "ret %08x\n", hr
);
4772 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4775 /* delete whole data ... */
4776 hr
= IXMLDOMComment_get_length(pComment
, &len
);
4777 ok(hr
== S_OK
, "ret %08x\n", hr
);
4779 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
4780 ok(hr
== S_OK
, "ret %08x\n", hr
);
4781 /* ... and try again with empty string */
4782 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
4783 ok(hr
== S_OK
, "ret %08x\n", hr
);
4785 /* ::replaceData() */
4787 V_BSTR(&v
) = SysAllocString(szstr1
);
4788 hr
= IXMLDOMComment_put_nodeValue(pComment
, v
);
4789 ok(hr
== S_OK
, "ret %08x\n", hr
);
4792 hr
= IXMLDOMComment_replaceData(pComment
, 6, 0, NULL
);
4793 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4794 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4795 ok(hr
== S_OK
, "ret %08x\n", hr
);
4796 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4799 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, NULL
);
4800 ok(hr
== S_OK
, "ret %08x\n", hr
);
4801 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4802 ok(hr
== S_OK
, "ret %08x\n", hr
);
4803 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4806 /* NULL pointer means delete */
4807 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, NULL
);
4808 ok(hr
== S_OK
, "ret %08x\n", hr
);
4809 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4810 ok(hr
== S_OK
, "ret %08x\n", hr
);
4811 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4814 /* empty string means delete */
4815 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_(""));
4816 ok(hr
== S_OK
, "ret %08x\n", hr
);
4817 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4818 ok(hr
== S_OK
, "ret %08x\n", hr
);
4819 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4822 /* zero count means insert */
4823 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, _bstr_("a"));
4824 ok(hr
== S_OK
, "ret %08x\n", hr
);
4825 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4826 ok(hr
== S_OK
, "ret %08x\n", hr
);
4827 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4830 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, NULL
);
4831 ok(hr
== S_OK
, "ret %08x\n", hr
);
4833 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("m"));
4834 ok(hr
== S_OK
, "ret %08x\n", hr
);
4835 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4836 ok(hr
== S_OK
, "ret %08x\n", hr
);
4837 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4840 /* nonempty string, count greater than its length */
4841 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, _bstr_("a1.2"));
4842 ok(hr
== S_OK
, "ret %08x\n", hr
);
4843 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4844 ok(hr
== S_OK
, "ret %08x\n", hr
);
4845 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4848 /* nonempty string, count less than its length */
4849 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_("wine"));
4850 ok(hr
== S_OK
, "ret %08x\n", hr
);
4851 hr
= IXMLDOMComment_get_text(pComment
, &str
);
4852 ok(hr
== S_OK
, "ret %08x\n", hr
);
4853 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
4856 IXMLDOMComment_Release(pComment
);
4860 str
= SysAllocString(szElement
);
4861 hr
= IXMLDOMDocument_createElement(doc
, str
, &pElement
);
4863 ok(hr
== S_OK
, "ret %08x\n", hr
);
4866 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4867 ok(hr
== S_OK
, "ret %08x\n", hr
);
4869 /* test nodeTypeString */
4870 hr
= IXMLDOMDocument_get_nodeTypeString(pElement
, &str
);
4871 ok(hr
== S_OK
, "ret %08x\n", hr
);
4872 ok( !lstrcmpW( str
, _bstr_("element") ), "incorrect nodeTypeString string\n");
4875 hr
= IXMLDOMElement_get_nodeName(pElement
, &str
);
4876 ok(hr
== S_OK
, "ret %08x\n", hr
);
4877 ok( !lstrcmpW( str
, szElement
), "incorrect element node Name\n");
4880 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
4881 ok(hr
== S_OK
, "ret %08x\n", hr
);
4882 ok( !lstrcmpW( str
, szElementXML
), "incorrect element xml\n");
4885 hr
= IXMLDOMElement_get_dataType(pElement
, &v
);
4886 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4887 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
4891 pAttribute
= (IXMLDOMAttribute
*)0x1;
4892 hr
= IXMLDOMDocument_createAttribute(doc
, NULL
, &pAttribute
);
4893 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4894 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
4896 pAttribute
= (IXMLDOMAttribute
*)0x1;
4897 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_(""), &pAttribute
);
4898 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4899 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
4901 str
= SysAllocString(szAttribute
);
4902 hr
= IXMLDOMDocument_createAttribute(doc
, str
, &pAttribute
);
4904 ok(hr
== S_OK
, "ret %08x\n", hr
);
4907 IXMLDOMNode
*pNewChild
= (IXMLDOMNode
*)0x1;
4909 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, NULL
);
4910 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4912 pNextChild
= (IXMLDOMNode
*)0x1;
4913 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, &pNextChild
);
4914 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4915 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
4917 /* test Previous Sibling*/
4918 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, NULL
);
4919 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4921 pNextChild
= (IXMLDOMNode
*)0x1;
4922 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, &pNextChild
);
4923 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4924 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
4926 /* test get_attributes */
4927 hr
= IXMLDOMAttribute_get_attributes( pAttribute
, NULL
);
4928 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
4930 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
4931 hr
= IXMLDOMAttribute_get_attributes( pAttribute
, &pAttribs
);
4932 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4933 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
4935 hr
= IXMLDOMElement_appendChild(pElement
, (IXMLDOMNode
*)pAttribute
, &pNewChild
);
4936 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4937 ok(pNewChild
== NULL
, "pNewChild not NULL\n");
4939 hr
= IXMLDOMElement_get_attributes(pElement
, &pAttribs
);
4940 ok(hr
== S_OK
, "ret %08x\n", hr
);
4943 hr
= IXMLDOMNamedNodeMap_setNamedItem(pAttribs
, (IXMLDOMNode
*)pAttribute
, NULL
);
4944 ok(hr
== S_OK
, "ret %08x\n", hr
);
4946 IXMLDOMNamedNodeMap_Release(pAttribs
);
4949 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
4950 ok(hr
== S_OK
, "ret %08x\n", hr
);
4951 ok( !lstrcmpW( str
, szAttribute
), "incorrect attribute node Name\n");
4954 /* test nodeTypeString */
4955 hr
= IXMLDOMAttribute_get_nodeTypeString(pAttribute
, &str
);
4956 ok(hr
== S_OK
, "ret %08x\n", hr
);
4957 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
4961 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
4962 ok(hr
== S_OK
, "ret %08x\n", hr
);
4963 ok( !lstrcmpW( str
, szAttribute
), "incorrect nodeName string\n");
4966 /* test name property */
4967 hr
= IXMLDOMAttribute_get_name(pAttribute
, &str
);
4968 ok(hr
== S_OK
, "ret %08x\n", hr
);
4969 ok( !lstrcmpW( str
, szAttribute
), "incorrect name string\n");
4972 hr
= IXMLDOMAttribute_get_xml(pAttribute
, &str
);
4973 ok(hr
== S_OK
, "ret %08x\n", hr
);
4974 ok( !lstrcmpW( str
, szAttributeXML
), "incorrect attribute xml\n");
4977 hr
= IXMLDOMAttribute_get_dataType(pAttribute
, &v
);
4978 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4979 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
4982 IXMLDOMAttribute_Release(pAttribute
);
4984 /* Check Element again with the Add Attribute*/
4985 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
4986 ok(hr
== S_OK
, "ret %08x\n", hr
);
4987 ok( !lstrcmpW( str
, szElementXML2
), "incorrect element xml\n");
4991 hr
= IXMLDOMElement_put_text(pElement
, _bstr_("TestingNode"));
4992 ok(hr
== S_OK
, "ret %08x\n", hr
);
4994 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
4995 ok(hr
== S_OK
, "ret %08x\n", hr
);
4996 ok( !lstrcmpW( str
, szElementXML3
), "incorrect element xml\n");
4999 /* Test for reversible escaping */
5000 str
= SysAllocString( szStrangeChars
);
5001 hr
= IXMLDOMElement_put_text(pElement
, str
);
5002 ok(hr
== S_OK
, "ret %08x\n", hr
);
5003 SysFreeString( str
);
5005 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
5006 ok(hr
== S_OK
, "ret %08x\n", hr
);
5007 ok( !lstrcmpW( str
, szElementXML4
), "incorrect element xml\n");
5010 hr
= IXMLDOMElement_get_text(pElement
, &str
);
5011 ok(hr
== S_OK
, "ret %08x\n", hr
);
5012 ok( !lstrcmpW( str
, szStrangeChars
), "incorrect element text\n");
5015 IXMLDOMElement_Release(pElement
);
5019 str
= SysAllocString(szCData
);
5020 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, NULL
);
5021 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5023 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, &pCDataSec
);
5025 ok(hr
== S_OK
, "ret %08x\n", hr
);
5028 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1;
5033 hr
= IXMLDOMCDATASection_QueryInterface(pCDataSec
, &IID_IXMLDOMElement
, (void**)&pElement
);
5034 ok(hr
== E_NOINTERFACE
, "ret %08x\n", hr
);
5036 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pCDataSec
, NULL
);
5037 ok(hr
== S_OK
, "ret %08x\n", hr
);
5039 /* get Attribute Tests */
5040 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, NULL
);
5041 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5043 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
5044 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, &pAttribs
);
5045 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5046 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
5048 hr
= IXMLDOMCDATASection_get_nodeName(pCDataSec
, &str
);
5049 ok(hr
== S_OK
, "ret %08x\n", hr
);
5050 ok( !lstrcmpW( str
, szCDataNodeText
), "incorrect cdata node Name\n");
5053 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
5054 ok(hr
== S_OK
, "ret %08x\n", hr
);
5055 ok( !lstrcmpW( str
, szCDataXML
), "incorrect cdata xml\n");
5058 /* test lastChild */
5059 pNextChild
= (IXMLDOMNode
*)0x1;
5060 hr
= IXMLDOMCDATASection_get_lastChild(pCDataSec
, &pNextChild
);
5061 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5062 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
5064 /* test get_dataType */
5065 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, NULL
);
5066 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5068 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, &v
);
5069 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5070 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
5073 /* test nodeTypeString */
5074 hr
= IXMLDOMCDATASection_get_nodeTypeString(pCDataSec
, &str
);
5075 ok(hr
== S_OK
, "ret %08x\n", hr
);
5076 ok( !lstrcmpW( str
, _bstr_("cdatasection") ), "incorrect nodeTypeString string\n");
5079 /* put data Tests */
5080 hr
= IXMLDOMCDATASection_put_data(pCDataSec
, _bstr_("This &is a ; test <>\\"));
5081 ok(hr
== S_OK
, "ret %08x\n", hr
);
5083 /* Confirm XML text is good */
5084 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
5085 ok(hr
== S_OK
, "ret %08x\n", hr
);
5086 ok( !lstrcmpW( str
, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
5089 /* Confirm we get the put_data Text back */
5090 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5091 ok(hr
== S_OK
, "ret %08x\n", hr
);
5092 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
5095 /* test length property */
5096 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5097 ok(hr
== S_OK
, "ret %08x\n", hr
);
5098 ok(len
== 21, "expected 21 got %d\n", len
);
5100 /* test get nodeValue */
5101 hr
= IXMLDOMCDATASection_get_nodeValue(pCDataSec
, &var
);
5102 ok(hr
== S_OK
, "ret %08x\n", hr
);
5103 ok(V_VT(&var
) == VT_BSTR
, "got vt %04x\n", V_VT(&var
));
5104 ok( !lstrcmpW( V_BSTR(&var
), _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
5108 hr
= IXMLDOMCDATASection_get_data(pCDataSec
, &str
);
5109 ok(hr
== S_OK
, "ret %08x\n", hr
);
5110 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
5113 /* test substringData */
5114 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, NULL
);
5115 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5117 /* test substringData - Invalid offset */
5118 str
= (BSTR
)&szElement
;
5119 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, -1, 4, &str
);
5120 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5121 ok( str
== NULL
, "incorrect string\n");
5123 /* test substringData - Invalid offset */
5124 str
= (BSTR
)&szElement
;
5125 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 30, 0, &str
);
5126 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5127 ok( str
== NULL
, "incorrect string\n");
5129 /* test substringData - Invalid size */
5130 str
= (BSTR
)&szElement
;
5131 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, -1, &str
);
5132 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5133 ok( str
== NULL
, "incorrect string\n");
5135 /* test substringData - Invalid size */
5136 str
= (BSTR
)&szElement
;
5137 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 2, 0, &str
);
5138 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5139 ok( str
== NULL
, "incorrect string\n");
5141 /* test substringData - Start of string */
5142 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, &str
);
5143 ok(hr
== S_OK
, "ret %08x\n", hr
);
5144 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
5147 /* test substringData - Middle of string */
5148 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 13, 4, &str
);
5149 ok(hr
== S_OK
, "ret %08x\n", hr
);
5150 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
5153 /* test substringData - End of string */
5154 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 20, 4, &str
);
5155 ok(hr
== S_OK
, "ret %08x\n", hr
);
5156 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
5159 /* test appendData */
5160 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, NULL
);
5161 ok(hr
== S_OK
, "ret %08x\n", hr
);
5163 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_(""));
5164 ok(hr
== S_OK
, "ret %08x\n", hr
);
5166 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_("Append"));
5167 ok(hr
== S_OK
, "ret %08x\n", hr
);
5169 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5170 ok(hr
== S_OK
, "ret %08x\n", hr
);
5171 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5174 /* test insertData */
5175 str
= SysAllocStringLen(NULL
, 0);
5176 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, str
);
5177 ok(hr
== S_OK
, "ret %08x\n", hr
);
5179 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, NULL
);
5180 ok(hr
== S_OK
, "ret %08x\n", hr
);
5182 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, str
);
5183 ok(hr
== S_OK
, "ret %08x\n", hr
);
5185 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, NULL
);
5186 ok(hr
== S_OK
, "ret %08x\n", hr
);
5188 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, NULL
);
5189 ok(hr
== S_OK
, "ret %08x\n", hr
);
5191 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, str
);
5192 ok(hr
== S_OK
, "ret %08x\n", hr
);
5195 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, _bstr_("Inserting"));
5196 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5198 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, _bstr_("Inserting"));
5199 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5201 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("Begin "));
5202 ok(hr
== S_OK
, "ret %08x\n", hr
);
5204 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 17, _bstr_("Middle"));
5205 ok(hr
== S_OK
, "ret %08x\n", hr
);
5207 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 39, _bstr_(" End"));
5208 ok(hr
== S_OK
, "ret %08x\n", hr
);
5210 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5211 ok(hr
== S_OK
, "ret %08x\n", hr
);
5212 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5216 /* invalid arguments */
5217 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, -1, 1);
5218 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5220 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 0);
5221 ok(hr
== S_OK
, "ret %08x\n", hr
);
5223 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, -1);
5224 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5226 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5227 ok(hr
== S_OK
, "ret %08x\n", hr
);
5228 ok(len
== 43, "expected 43 got %d\n", len
);
5230 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
, 1);
5231 ok(hr
== S_OK
, "ret %08x\n", hr
);
5233 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
+1, 1);
5234 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5236 /* delete from start */
5237 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 5);
5238 ok(hr
== S_OK
, "ret %08x\n", hr
);
5240 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5241 ok(hr
== S_OK
, "ret %08x\n", hr
);
5242 ok(len
== 38, "expected 38 got %d\n", len
);
5244 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5245 ok(hr
== S_OK
, "ret %08x\n", hr
);
5246 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5249 /* delete from end */
5250 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 35, 3);
5251 ok(hr
== S_OK
, "ret %08x\n", hr
);
5253 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5254 ok(hr
== S_OK
, "ret %08x\n", hr
);
5255 ok(len
== 35, "expected 35 got %d\n", len
);
5257 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5258 ok(hr
== S_OK
, "ret %08x\n", hr
);
5259 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5262 /* delete from inside */
5263 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 1, 33);
5264 ok(hr
== S_OK
, "ret %08x\n", hr
);
5266 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5267 ok(hr
== S_OK
, "ret %08x\n", hr
);
5268 ok(len
== 2, "expected 2 got %d\n", len
);
5270 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5271 ok(hr
== S_OK
, "ret %08x\n", hr
);
5272 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5275 /* delete whole data ... */
5276 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5277 ok(hr
== S_OK
, "ret %08x\n", hr
);
5279 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
5280 ok(hr
== S_OK
, "ret %08x\n", hr
);
5282 /* ... and try again with empty string */
5283 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
5284 ok(hr
== S_OK
, "ret %08x\n", hr
);
5286 /* ::replaceData() */
5288 V_BSTR(&v
) = SysAllocString(szstr1
);
5289 hr
= IXMLDOMCDATASection_put_nodeValue(pCDataSec
, v
);
5290 ok(hr
== S_OK
, "ret %08x\n", hr
);
5293 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 6, 0, NULL
);
5294 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5295 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5296 ok(hr
== S_OK
, "ret %08x\n", hr
);
5297 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5300 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, NULL
);
5301 ok(hr
== S_OK
, "ret %08x\n", hr
);
5302 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5303 ok(hr
== S_OK
, "ret %08x\n", hr
);
5304 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5307 /* NULL pointer means delete */
5308 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, NULL
);
5309 ok(hr
== S_OK
, "ret %08x\n", hr
);
5310 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5311 ok(hr
== S_OK
, "ret %08x\n", hr
);
5312 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5315 /* empty string means delete */
5316 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_(""));
5317 ok(hr
== S_OK
, "ret %08x\n", hr
);
5318 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5319 ok(hr
== S_OK
, "ret %08x\n", hr
);
5320 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5323 /* zero count means insert */
5324 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, _bstr_("a"));
5325 ok(hr
== S_OK
, "ret %08x\n", hr
);
5326 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5327 ok(hr
== S_OK
, "ret %08x\n", hr
);
5328 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5331 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, NULL
);
5332 ok(hr
== S_OK
, "ret %08x\n", hr
);
5334 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("m"));
5335 ok(hr
== S_OK
, "ret %08x\n", hr
);
5336 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5337 ok(hr
== S_OK
, "ret %08x\n", hr
);
5338 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5341 /* nonempty string, count greater than its length */
5342 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, _bstr_("a1.2"));
5343 ok(hr
== S_OK
, "ret %08x\n", hr
);
5344 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5345 ok(hr
== S_OK
, "ret %08x\n", hr
);
5346 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5349 /* nonempty string, count less than its length */
5350 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_("wine"));
5351 ok(hr
== S_OK
, "ret %08x\n", hr
);
5352 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5353 ok(hr
== S_OK
, "ret %08x\n", hr
);
5354 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5357 IXMLDOMCDATASection_Release(pCDataSec
);
5360 /* Document Fragments */
5361 hr
= IXMLDOMDocument_createDocumentFragment(doc
, NULL
);
5362 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5364 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &pDocFrag
);
5365 ok(hr
== S_OK
, "ret %08x\n", hr
);
5370 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, NULL
);
5371 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5373 node
= (IXMLDOMNode
*)0x1;
5374 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, &node
);
5375 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5376 ok(node
== NULL
, "expected NULL, got %p\n", node
);
5378 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pDocFrag
, NULL
);
5379 ok(hr
== S_OK
, "ret %08x\n", hr
);
5381 /* get Attribute Tests */
5382 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, NULL
);
5383 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5385 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
5386 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, &pAttribs
);
5387 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5388 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
5390 hr
= IXMLDOMDocumentFragment_get_nodeName(pDocFrag
, &str
);
5391 ok(hr
== S_OK
, "ret %08x\n", hr
);
5392 ok( !lstrcmpW( str
, szDocFragmentText
), "incorrect docfragment node Name\n");
5395 /* test next Sibling*/
5396 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, NULL
);
5397 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5399 node
= (IXMLDOMNode
*)0x1;
5400 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, &node
);
5401 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5402 ok(node
== NULL
, "next sibling not NULL\n");
5404 /* test Previous Sibling*/
5405 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, NULL
);
5406 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5408 node
= (IXMLDOMNode
*)0x1;
5409 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, &node
);
5410 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5411 ok(node
== NULL
, "previous sibling not NULL\n");
5413 /* test get_dataType */
5414 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, NULL
);
5415 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5417 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, &v
);
5418 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5419 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
5422 /* test nodeTypeString */
5423 hr
= IXMLDOMDocumentFragment_get_nodeTypeString(pDocFrag
, &str
);
5424 ok(hr
== S_OK
, "ret %08x\n", hr
);
5425 ok( !lstrcmpW( str
, _bstr_("documentfragment") ), "incorrect nodeTypeString string\n");
5428 IXMLDOMDocumentFragment_Release(pDocFrag
);
5431 /* Entity References */
5432 hr
= IXMLDOMDocument_createEntityReference(doc
, NULL
, &pEntityRef
);
5433 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5434 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_(""), &pEntityRef
);
5435 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5437 str
= SysAllocString(szEntityRef
);
5438 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, NULL
);
5439 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5441 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, &pEntityRef
);
5443 ok(hr
== S_OK
, "ret %08x\n", hr
);
5446 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pEntityRef
, NULL
);
5447 ok(hr
== S_OK
, "ret %08x\n", hr
);
5449 /* get Attribute Tests */
5450 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, NULL
);
5451 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5453 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
5454 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, &pAttribs
);
5455 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5456 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
5459 hr
= IXMLDOMEntityReference_get_dataType(pEntityRef
, &v
);
5460 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5461 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
5464 /* test nodeTypeString */
5465 hr
= IXMLDOMEntityReference_get_nodeTypeString(pEntityRef
, &str
);
5466 ok(hr
== S_OK
, "ret %08x\n", hr
);
5467 ok( !lstrcmpW( str
, _bstr_("entityreference") ), "incorrect nodeTypeString string\n");
5471 hr
= IXMLDOMEntityReference_get_xml(pEntityRef
, &str
);
5472 ok(hr
== S_OK
, "ret %08x\n", hr
);
5473 ok( !lstrcmpW( str
, szEntityRefXML
), "incorrect xml string\n");
5476 IXMLDOMEntityReference_Release(pEntityRef
);
5479 IXMLDOMElement_Release( pRoot
);
5483 IXMLDOMDocument_Release(doc
);
5488 static void test_nodeTypeTests( void )
5490 IXMLDOMDocument
*doc
= NULL
;
5491 IXMLDOMElement
*pRoot
;
5492 IXMLDOMElement
*pElement
;
5495 doc
= create_document(&IID_IXMLDOMDocument
);
5498 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), NULL
);
5499 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5501 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
5502 ok(hr
== S_OK
, "ret %08x\n", hr
);
5505 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
5506 ok(hr
== S_OK
, "ret %08x\n", hr
);
5509 hr
= IXMLDOMElement_put_dataType(pRoot
, NULL
);
5510 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5513 hr
= IXMLDOMElement_put_dataType(pRoot
, _bstr_("abcdefg") );
5514 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5517 * The name passed into put_dataType is case-insensitive. So many of the names
5518 * have been changed to reflect this.
5521 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Boolean"), &pElement
);
5522 ok(hr
== S_OK
, "ret %08x\n", hr
);
5525 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5527 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Boolean") );
5528 ok(hr
== S_OK
, "ret %08x\n", hr
);
5530 IXMLDOMElement_Release(pElement
);
5534 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_String"), &pElement
);
5535 ok(hr
== S_OK
, "ret %08x\n", hr
);
5538 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5540 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("String") );
5541 ok(hr
== S_OK
, "ret %08x\n", hr
);
5543 IXMLDOMElement_Release(pElement
);
5547 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Number"), &pElement
);
5548 ok(hr
== S_OK
, "ret %08x\n", hr
);
5551 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5553 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("number") );
5554 ok(hr
== S_OK
, "ret %08x\n", hr
);
5556 IXMLDOMElement_Release(pElement
);
5560 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Int"), &pElement
);
5561 ok(hr
== S_OK
, "ret %08x\n", hr
);
5564 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5566 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("InT") );
5567 ok(hr
== S_OK
, "ret %08x\n", hr
);
5569 IXMLDOMElement_Release(pElement
);
5573 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Fixed"), &pElement
);
5574 ok(hr
== S_OK
, "ret %08x\n", hr
);
5577 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5579 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("fixed.14.4") );
5580 ok(hr
== S_OK
, "ret %08x\n", hr
);
5582 IXMLDOMElement_Release(pElement
);
5586 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime"), &pElement
);
5587 ok(hr
== S_OK
, "ret %08x\n", hr
);
5590 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5592 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime") );
5593 ok(hr
== S_OK
, "ret %08x\n", hr
);
5595 IXMLDOMElement_Release(pElement
);
5599 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime_tz"), &pElement
);
5600 ok(hr
== S_OK
, "ret %08x\n", hr
);
5603 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5605 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
5606 ok(hr
== S_OK
, "ret %08x\n", hr
);
5608 IXMLDOMElement_Release(pElement
);
5612 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Date"), &pElement
);
5613 ok(hr
== S_OK
, "ret %08x\n", hr
);
5616 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5618 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Date") );
5619 ok(hr
== S_OK
, "ret %08x\n", hr
);
5621 IXMLDOMElement_Release(pElement
);
5625 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time"), &pElement
);
5626 ok(hr
== S_OK
, "ret %08x\n", hr
);
5629 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5631 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time") );
5632 ok(hr
== S_OK
, "ret %08x\n", hr
);
5634 IXMLDOMElement_Release(pElement
);
5638 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time_TZ"), &pElement
);
5639 ok(hr
== S_OK
, "ret %08x\n", hr
);
5642 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5644 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time.tz") );
5645 ok(hr
== S_OK
, "ret %08x\n", hr
);
5647 IXMLDOMElement_Release(pElement
);
5651 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I1"), &pElement
);
5652 ok(hr
== S_OK
, "ret %08x\n", hr
);
5655 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5657 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I1") );
5658 ok(hr
== S_OK
, "ret %08x\n", hr
);
5660 IXMLDOMElement_Release(pElement
);
5664 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I2"), &pElement
);
5665 ok(hr
== S_OK
, "ret %08x\n", hr
);
5668 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5670 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I2") );
5671 ok(hr
== S_OK
, "ret %08x\n", hr
);
5673 IXMLDOMElement_Release(pElement
);
5677 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I4"), &pElement
);
5678 ok(hr
== S_OK
, "ret %08x\n", hr
);
5681 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5683 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I4") );
5684 ok(hr
== S_OK
, "ret %08x\n", hr
);
5686 IXMLDOMElement_Release(pElement
);
5690 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI1"), &pElement
);
5691 ok(hr
== S_OK
, "ret %08x\n", hr
);
5694 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5696 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI1") );
5697 ok(hr
== S_OK
, "ret %08x\n", hr
);
5699 IXMLDOMElement_Release(pElement
);
5703 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI2"), &pElement
);
5704 ok(hr
== S_OK
, "ret %08x\n", hr
);
5707 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5709 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI2") );
5710 ok(hr
== S_OK
, "ret %08x\n", hr
);
5712 IXMLDOMElement_Release(pElement
);
5716 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI4"), &pElement
);
5717 ok(hr
== S_OK
, "ret %08x\n", hr
);
5720 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5722 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI4") );
5723 ok(hr
== S_OK
, "ret %08x\n", hr
);
5725 IXMLDOMElement_Release(pElement
);
5729 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r4"), &pElement
);
5730 ok(hr
== S_OK
, "ret %08x\n", hr
);
5733 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5735 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r4") );
5736 ok(hr
== S_OK
, "ret %08x\n", hr
);
5738 IXMLDOMElement_Release(pElement
);
5742 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r8"), &pElement
);
5743 ok(hr
== S_OK
, "ret %08x\n", hr
);
5746 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5748 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r8") );
5749 ok(hr
== S_OK
, "ret %08x\n", hr
);
5751 IXMLDOMElement_Release(pElement
);
5755 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_float"), &pElement
);
5756 ok(hr
== S_OK
, "ret %08x\n", hr
);
5759 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5761 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("float") );
5762 ok(hr
== S_OK
, "ret %08x\n", hr
);
5764 IXMLDOMElement_Release(pElement
);
5768 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_uuid"), &pElement
);
5769 ok(hr
== S_OK
, "ret %08x\n", hr
);
5772 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5774 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UuId") );
5775 ok(hr
== S_OK
, "ret %08x\n", hr
);
5777 IXMLDOMElement_Release(pElement
);
5781 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_hex"), &pElement
);
5782 ok(hr
== S_OK
, "ret %08x\n", hr
);
5785 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5787 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.hex") );
5788 ok(hr
== S_OK
, "ret %08x\n", hr
);
5790 IXMLDOMElement_Release(pElement
);
5794 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_base64"), &pElement
);
5795 ok(hr
== S_OK
, "ret %08x\n", hr
);
5798 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5800 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.base64") );
5801 ok(hr
== S_OK
, "ret %08x\n", hr
);
5803 IXMLDOMElement_Release(pElement
);
5806 /* Check changing types */
5807 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Change"), &pElement
);
5808 ok(hr
== S_OK
, "ret %08x\n", hr
);
5811 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5813 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
5814 ok(hr
== S_OK
, "ret %08x\n", hr
);
5816 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("string") );
5817 ok(hr
== S_OK
, "ret %08x\n", hr
);
5819 IXMLDOMElement_Release(pElement
);
5822 IXMLDOMElement_Release(pRoot
);
5826 IXMLDOMDocument_Release(doc
);
5831 static void test_DocumentSaveToDocument(void)
5833 IXMLDOMDocument
*doc
, *doc2
;
5834 IXMLDOMElement
*pRoot
;
5837 doc
= create_document(&IID_IXMLDOMDocument
);
5840 doc2
= create_document(&IID_IXMLDOMDocument
);
5843 IXMLDOMDocument_Release(doc
);
5847 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
5848 ok(hr
== S_OK
, "ret %08x\n", hr
);
5851 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
5852 ok(hr
== S_OK
, "ret %08x\n", hr
);
5859 V_VT(&vDoc
) = VT_UNKNOWN
;
5860 V_UNKNOWN(&vDoc
) = (IUnknown
*)doc2
;
5862 hr
= IXMLDOMDocument_save(doc
, vDoc
);
5863 ok(hr
== S_OK
, "ret %08x\n", hr
);
5865 hr
= IXMLDOMDocument_get_xml(doc
, &sOrig
);
5866 ok(hr
== S_OK
, "ret %08x\n", hr
);
5868 hr
= IXMLDOMDocument_get_xml(doc2
, &sNew
);
5869 ok(hr
== S_OK
, "ret %08x\n", hr
);
5871 ok( !lstrcmpW( sOrig
, sNew
), "New document is not the same as origial\n");
5873 SysFreeString(sOrig
);
5874 SysFreeString(sNew
);
5878 IXMLDOMDocument_Release(doc2
);
5879 IXMLDOMDocument_Release(doc
);
5882 static void test_DocumentSaveToFile(void)
5884 IXMLDOMDocument
*doc
;
5885 IXMLDOMElement
*pRoot
;
5891 doc
= create_document(&IID_IXMLDOMDocument
);
5894 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
5895 ok(hr
== S_OK
, "ret %08x\n", hr
);
5898 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
5899 ok(hr
== S_OK
, "ret %08x\n", hr
);
5904 V_VT(&vFile
) = VT_BSTR
;
5905 V_BSTR(&vFile
) = _bstr_("test.xml");
5907 hr
= IXMLDOMDocument_save(doc
, vFile
);
5908 ok(hr
== S_OK
, "ret %08x\n", hr
);
5912 IXMLDOMElement_Release(pRoot
);
5913 IXMLDOMDocument_Release(doc
);
5915 file
= CreateFile("test.xml", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
5916 ok(file
!= INVALID_HANDLE_VALUE
, "Could not open file: %u\n", GetLastError());
5917 if(file
== INVALID_HANDLE_VALUE
)
5920 ReadFile(file
, buffer
, sizeof(buffer
), &read
, NULL
);
5921 ok(read
!= 0, "could not read file\n");
5922 ok(buffer
[0] != '<' || buffer
[1] != '?', "File contains processing instruction\n");
5925 DeleteFile("test.xml");
5928 static void test_testTransforms(void)
5930 IXMLDOMDocument
*doc
, *docSS
;
5936 doc
= create_document(&IID_IXMLDOMDocument
);
5939 docSS
= create_document(&IID_IXMLDOMDocument
);
5942 IXMLDOMDocument_Release(doc
);
5946 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTransformXML
), &bSucc
);
5947 ok(hr
== S_OK
, "ret %08x\n", hr
);
5949 hr
= IXMLDOMDocument_loadXML(docSS
, _bstr_(szTransformSSXML
), &bSucc
);
5950 ok(hr
== S_OK
, "ret %08x\n", hr
);
5952 hr
= IXMLDOMDocument_QueryInterface(docSS
, &IID_IXMLDOMNode
, (void**)&pNode
);
5953 ok(hr
== S_OK
, "ret %08x\n", hr
);
5958 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &bOut
);
5959 ok(hr
== S_OK
, "ret %08x\n", hr
);
5960 ok( compareIgnoreReturns( bOut
, _bstr_(szTransformOutput
)), "Stylesheet output not correct\n");
5961 SysFreeString(bOut
);
5963 IXMLDOMNode_Release(pNode
);
5966 IXMLDOMDocument_Release(docSS
);
5967 IXMLDOMDocument_Release(doc
);
5972 static void test_Namespaces(void)
5974 IXMLDOMDocument
*doc
;
5976 IXMLDOMNode
*pNode2
= NULL
;
5980 static const CHAR szNamespacesXML
[] =
5981 "<?xml version=\"1.0\"?>\n"
5982 "<root xmlns:WEB='http://www.winehq.org'>\n"
5983 "<WEB:Site version=\"1.0\" />\n"
5986 doc
= create_document(&IID_IXMLDOMDocument
);
5989 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szNamespacesXML
), &bSucc
);
5990 ok(hr
== S_OK
, "ret %08x\n", hr
);
5991 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
5993 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root"), &pNode
);
5994 ok(hr
== S_OK
, "ret %08x\n", hr
);
5997 hr
= IXMLDOMNode_get_firstChild( pNode
, &pNode2
);
5998 ok( hr
== S_OK
, "ret %08x\n", hr
);
5999 ok( pNode2
!= NULL
, "pNode2 == NULL\n");
6001 /* Test get_prefix */
6002 hr
= IXMLDOMNode_get_prefix(pNode2
, NULL
);
6003 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6004 /* NOTE: Need to test that arg2 gets cleared on Error. */
6006 hr
= IXMLDOMNode_get_prefix(pNode2
, &str
);
6007 ok( hr
== S_OK
, "ret %08x\n", hr
);
6008 ok( !lstrcmpW( str
, _bstr_("WEB")), "incorrect prefix string\n");
6011 /* Test get_namespaceURI */
6012 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, NULL
);
6013 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6014 /* NOTE: Need to test that arg2 gets cleared on Error. */
6016 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, &str
);
6017 ok( hr
== S_OK
, "ret %08x\n", hr
);
6018 ok( !lstrcmpW( str
, _bstr_("http://www.winehq.org")), "incorrect namespaceURI string\n");
6021 IXMLDOMNode_Release(pNode2
);
6022 IXMLDOMNode_Release(pNode
);
6025 IXMLDOMDocument_Release(doc
);
6030 static void test_FormattingXML(void)
6032 IXMLDOMDocument
*doc
;
6033 IXMLDOMElement
*pElement
;
6037 static const CHAR szLinefeedXML
[] = "<?xml version=\"1.0\"?>\n<Root>\n\t<Sub val=\"A\" />\n</Root>";
6038 static const CHAR szLinefeedRootXML
[] = "<Root>\r\n\t<Sub val=\"A\"/>\r\n</Root>";
6040 doc
= create_document(&IID_IXMLDOMDocument
);
6043 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szLinefeedXML
), &bSucc
);
6044 ok(hr
== S_OK
, "ret %08x\n", hr
);
6045 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
6047 if(bSucc
== VARIANT_TRUE
)
6049 hr
= IXMLDOMDocument_get_documentElement(doc
, &pElement
);
6050 ok(hr
== S_OK
, "ret %08x\n", hr
);
6053 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
6054 ok(hr
== S_OK
, "ret %08x\n", hr
);
6055 ok( !lstrcmpW( str
, _bstr_(szLinefeedRootXML
) ), "incorrect element xml\n");
6058 IXMLDOMElement_Release(pElement
);
6062 IXMLDOMDocument_Release(doc
);
6067 typedef struct _nodetypedvalue_t
{
6070 const char *value
; /* value in string format */
6073 static const nodetypedvalue_t get_nodetypedvalue
[] = {
6074 { "root/string", VT_BSTR
, "Wine" },
6075 { "root/string2", VT_BSTR
, "String" },
6076 { "root/number", VT_BSTR
, "12.44" },
6077 { "root/number2", VT_BSTR
, "-3.71e3" },
6078 { "root/int", VT_I4
, "-13" },
6079 { "root/fixed", VT_CY
, "7322.9371" },
6080 { "root/bool", VT_BOOL
, "-1" },
6081 { "root/datetime", VT_DATE
, "40135.14" },
6082 { "root/datetimetz",VT_DATE
, "37813.59" },
6083 { "root/date", VT_DATE
, "665413" },
6084 { "root/time", VT_DATE
, "0.5813889" },
6085 { "root/timetz", VT_DATE
, "1.112512" },
6086 { "root/i1", VT_I1
, "-13" },
6087 { "root/i2", VT_I2
, "31915" },
6088 { "root/i4", VT_I4
, "-312232" },
6089 { "root/ui1", VT_UI1
, "123" },
6090 { "root/ui2", VT_UI2
, "48282" },
6091 { "root/ui4", VT_UI4
, "949281" },
6092 { "root/r4", VT_R4
, "213124" },
6093 { "root/r8", VT_R8
, "0.412" },
6094 { "root/float", VT_R8
, "41221.421" },
6095 { "root/uuid", VT_BSTR
, "333C7BC4-460F-11D0-BC04-0080C7055a83" },
6099 static void test_nodeTypedValue(void)
6101 const nodetypedvalue_t
*entry
= get_nodetypedvalue
;
6102 IXMLDOMDocument
*doc
;
6108 doc
= create_document(&IID_IXMLDOMDocument
);
6112 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTypeValueXML
), &b
);
6113 ok(hr
== S_OK
, "ret %08x\n", hr
);
6114 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
6116 hr
= IXMLDOMDocument_get_nodeValue(doc
, NULL
);
6117 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6119 V_VT(&value
) = VT_BSTR
;
6120 V_BSTR(&value
) = NULL
;
6121 hr
= IXMLDOMDocument_get_nodeValue(doc
, &value
);
6122 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6123 ok(V_VT(&value
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&value
));
6125 hr
= IXMLDOMDocument_get_nodeTypedValue(doc
, NULL
);
6126 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6128 hr
= IXMLDOMDocument_get_nodeTypedValue(doc
, &value
);
6129 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6131 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root/string"), &node
);
6132 ok(hr
== S_OK
, "ret %08x\n", hr
);
6134 V_VT(&value
) = VT_BSTR
;
6135 V_BSTR(&value
) = NULL
;
6136 hr
= IXMLDOMNode_get_nodeValue(node
, &value
);
6137 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6138 ok(V_VT(&value
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&value
));
6140 hr
= IXMLDOMNode_get_nodeTypedValue(node
, NULL
);
6141 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6143 IXMLDOMNode_Release(node
);
6145 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root/binhex"), &node
);
6146 ok(hr
== S_OK
, "ret %08x\n", hr
);
6148 BYTE bytes
[] = {0xff,0xfc,0xa0,0x12,0x00,0x3c};
6150 hr
= IXMLDOMNode_get_nodeTypedValue(node
, &value
);
6151 ok(hr
== S_OK
, "ret %08x\n", hr
);
6152 ok(V_VT(&value
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
6153 ok(V_ARRAY(&value
)->rgsabound
[0].cElements
== 6, "incorrect array size\n");
6154 if(V_ARRAY(&value
)->rgsabound
[0].cElements
== 6)
6155 ok(!memcmp(bytes
, V_ARRAY(&value
)->pvData
, sizeof(bytes
)), "incorrect value\n");
6156 VariantClear(&value
);
6157 IXMLDOMNode_Release(node
);
6160 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root/binbase64"), &node
);
6161 ok(hr
== S_OK
, "ret %08x\n", hr
);
6163 BYTE bytes
[] = {0x62,0x61,0x73,0x65,0x36,0x34,0x20,0x74,0x65,0x73,0x74};
6165 hr
= IXMLDOMNode_get_nodeTypedValue(node
, &value
);
6166 ok(hr
== S_OK
, "ret %08x\n", hr
);
6167 ok(V_VT(&value
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
6168 ok(V_ARRAY(&value
)->rgsabound
[0].cElements
== 11, "incorrect array size\n");
6169 if(V_ARRAY(&value
)->rgsabound
[0].cElements
== 11)
6170 ok(!memcmp(bytes
, V_ARRAY(&value
)->pvData
, sizeof(bytes
)), "incorrect value\n");
6171 VariantClear(&value
);
6172 IXMLDOMNode_Release(node
);
6177 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_(entry
->name
), &node
);
6178 ok(hr
== S_OK
, "ret %08x\n", hr
);
6180 hr
= IXMLDOMNode_get_nodeTypedValue(node
, &value
);
6181 ok(hr
== S_OK
, "ret %08x\n", hr
);
6182 ok(V_VT(&value
) == entry
->type
, "incorrect type, expected %d, got %d\n", entry
->type
, V_VT(&value
));
6184 if (entry
->type
!= VT_BSTR
)
6186 if (entry
->type
== VT_DATE
||
6187 entry
->type
== VT_R8
||
6188 entry
->type
== VT_CY
)
6190 if (entry
->type
== VT_DATE
)
6192 hr
= VariantChangeType(&value
, &value
, 0, VT_R4
);
6193 ok(hr
== S_OK
, "ret %08x\n", hr
);
6195 hr
= VariantChangeTypeEx(&value
, &value
,
6196 MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_DEFAULT
), SORT_DEFAULT
),
6197 VARIANT_NOUSEROVERRIDE
, VT_BSTR
);
6198 ok(hr
== S_OK
, "ret %08x\n", hr
);
6202 hr
= VariantChangeType(&value
, &value
, 0, VT_BSTR
);
6203 ok(hr
== S_OK
, "ret %08x\n", hr
);
6206 ok(lstrcmpW( V_BSTR(&value
), _bstr_(entry
->value
)) == 0,
6207 "expected %s, got %s\n", entry
->value
, wine_dbgstr_w(V_BSTR(&value
)));
6210 ok(lstrcmpW( V_BSTR(&value
), _bstr_(entry
->value
)) == 0,
6211 "expected %s, got %s\n", entry
->value
, wine_dbgstr_w(V_BSTR(&value
)));
6213 VariantClear( &value
);
6214 IXMLDOMNode_Release(node
);
6219 IXMLDOMDocument_Release(doc
);
6223 static void test_TransformWithLoadingLocalFile(void)
6225 IXMLDOMDocument
*doc
;
6226 IXMLDOMDocument
*xsl
;
6232 char lpPathBuffer
[MAX_PATH
];
6235 /* Create a Temp File. */
6236 GetTempPathA(MAX_PATH
, lpPathBuffer
);
6237 strcat(lpPathBuffer
, "customers.xml" );
6239 file
= CreateFile(lpPathBuffer
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
6240 ok(file
!= INVALID_HANDLE_VALUE
, "Could not create file: %u\n", GetLastError());
6241 if(file
== INVALID_HANDLE_VALUE
)
6244 WriteFile(file
, szBasicTransformXML
, strlen(szBasicTransformXML
), &dwWritten
, NULL
);
6247 /* Correct path to not include a escape character. */
6248 for(i
=0; i
< strlen(lpPathBuffer
); i
++)
6250 if(lpPathBuffer
[i
] == '\\')
6251 lpPathBuffer
[i
] = '/';
6254 doc
= create_document(&IID_IXMLDOMDocument
);
6257 xsl
= create_document(&IID_IXMLDOMDocument
);
6260 IXMLDOMDocument2_Release(doc
);
6264 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTypeValueXML
), &bSucc
);
6265 ok(hr
== S_OK
, "ret %08x\n", hr
);
6266 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
6267 if(bSucc
== VARIANT_TRUE
)
6270 BSTR sPart1
= _bstr_(szBasicTransformSSXMLPart1
);
6271 BSTR sPart2
= _bstr_(szBasicTransformSSXMLPart2
);
6272 BSTR sFileName
= _bstr_(lpPathBuffer
);
6273 int nLegnth
= lstrlenW(sPart1
) + lstrlenW(sPart2
) + lstrlenW(sFileName
) + 1;
6275 sXSL
= SysAllocStringLen(NULL
, nLegnth
);
6276 lstrcpyW(sXSL
, sPart1
);
6277 lstrcatW(sXSL
, sFileName
);
6278 lstrcatW(sXSL
, sPart2
);
6280 hr
= IXMLDOMDocument_loadXML(xsl
, sXSL
, &bSucc
);
6281 ok(hr
== S_OK
, "ret %08x\n", hr
);
6282 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
6283 if(bSucc
== VARIANT_TRUE
)
6287 hr
= IXMLDOMDocument_QueryInterface(xsl
, &IID_IXMLDOMNode
, (void**)&pNode
);
6288 ok(hr
== S_OK
, "ret %08x\n", hr
);
6291 /* This will load the temp file via the XSL */
6292 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &sResult
);
6293 ok(hr
== S_OK
, "ret %08x\n", hr
);
6296 ok( compareIgnoreReturns( sResult
, _bstr_(szBasicTransformOutput
)), "Stylesheet output not correct\n");
6297 SysFreeString(sResult
);
6300 IXMLDOMNode_Release(pNode
);
6304 SysFreeString(sXSL
);
6307 IXMLDOMDocument_Release(doc
);
6308 IXMLDOMDocument_Release(xsl
);
6310 DeleteFile(lpPathBuffer
);
6314 static void test_put_nodeValue(void)
6316 static const WCHAR jeevesW
[] = {'J','e','e','v','e','s',' ','&',' ','W','o','o','s','t','e','r',0};
6317 IXMLDOMDocument
*doc
;
6319 IXMLDOMEntityReference
*entityref
;
6320 IXMLDOMAttribute
*attr
;
6325 doc
= create_document(&IID_IXMLDOMDocument
);
6328 /* test for unsupported types */
6330 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (void**)&node
);
6331 ok(hr
== S_OK
, "ret %08x\n", hr
);
6332 V_VT(&data
) = VT_BSTR
;
6333 V_BSTR(&data
) = _bstr_("one two three");
6334 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
6335 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6336 IXMLDOMNode_Release(node
);
6338 /* NODE_DOCUMENT_FRAGMENT */
6339 V_VT(&type
) = VT_I1
;
6340 V_I1(&type
) = NODE_DOCUMENT_FRAGMENT
;
6341 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
6342 ok(hr
== S_OK
, "ret %08x\n", hr
);
6343 V_VT(&data
) = VT_BSTR
;
6344 V_BSTR(&data
) = _bstr_("one two three");
6345 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
6346 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6347 IXMLDOMNode_Release(node
);
6350 V_VT(&type
) = VT_I1
;
6351 V_I1(&type
) = NODE_ELEMENT
;
6352 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
6353 ok(hr
== S_OK
, "ret %08x\n", hr
);
6354 V_VT(&data
) = VT_BSTR
;
6355 V_BSTR(&data
) = _bstr_("one two three");
6356 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
6357 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6358 IXMLDOMNode_Release(node
);
6360 /* NODE_ENTITY_REFERENCE */
6361 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_("ref"), &entityref
);
6362 ok(hr
== S_OK
, "ret %08x\n", hr
);
6364 V_VT(&data
) = VT_BSTR
;
6365 V_BSTR(&data
) = _bstr_("one two three");
6366 hr
= IXMLDOMEntityReference_put_nodeValue(entityref
, data
);
6367 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6369 hr
= IXMLDOMEntityReference_QueryInterface(entityref
, &IID_IXMLDOMNode
, (void**)&node
);
6370 ok(hr
== S_OK
, "ret %08x\n", hr
);
6371 V_VT(&data
) = VT_BSTR
;
6372 V_BSTR(&data
) = _bstr_("one two three");
6373 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
6374 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6375 IXMLDOMNode_Release(node
);
6376 IXMLDOMEntityReference_Release(entityref
);
6378 /* supported types */
6379 hr
= IXMLDOMDocument_createTextNode(doc
, _bstr_(""), &text
);
6380 ok(hr
== S_OK
, "ret %08x\n", hr
);
6381 V_VT(&data
) = VT_BSTR
;
6382 V_BSTR(&data
) = _bstr_("Jeeves & Wooster");
6383 hr
= IXMLDOMText_put_nodeValue(text
, data
);
6384 ok(hr
== S_OK
, "ret %08x\n", hr
);
6385 IXMLDOMText_Release(text
);
6387 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("attr"), &attr
);
6388 ok(hr
== S_OK
, "ret %08x\n", hr
);
6389 V_VT(&data
) = VT_BSTR
;
6390 V_BSTR(&data
) = _bstr_("Jeeves & Wooster");
6391 hr
= IXMLDOMAttribute_put_nodeValue(attr
, data
);
6392 ok(hr
== S_OK
, "ret %08x\n", hr
);
6393 hr
= IXMLDOMAttribute_get_nodeValue(attr
, &data
);
6394 ok(hr
== S_OK
, "ret %08x\n", hr
);
6395 ok(memcmp(V_BSTR(&data
), jeevesW
, sizeof(jeevesW
)) == 0, "got %s\n",
6396 wine_dbgstr_w(V_BSTR(&data
)));
6397 VariantClear(&data
);
6398 IXMLDOMAttribute_Release(attr
);
6402 IXMLDOMDocument_Release(doc
);
6405 static void test_IObjectSafety_set(IObjectSafety
*safety
, HRESULT result
, HRESULT result2
, DWORD set
, DWORD mask
, DWORD expected
, DWORD expected2
)
6407 DWORD enabled
, supported
;
6410 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
, set
, mask
);
6411 if (result
== result2
)
6412 ok(hr
== result
, "SetInterfaceSafetyOptions: expected %08x, returned %08x\n", result
, hr
);
6414 ok(broken(hr
== result
) || hr
== result2
,
6415 "SetInterfaceSafetyOptions: expected %08x, got %08x\n", result2
, hr
);
6417 supported
= enabled
= 0xCAFECAFE;
6418 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
6419 ok(hr
== S_OK
, "ret %08x\n", hr
);
6420 if (expected
== expected2
)
6421 ok(enabled
== expected
, "Expected %08x, got %08x\n", expected
, enabled
);
6423 ok(broken(enabled
== expected
) || enabled
== expected2
,
6424 "Expected %08x, got %08x\n", expected2
, enabled
);
6426 /* reset the safety options */
6428 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
6429 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_SECURITY_MANAGER
,
6431 ok(hr
== S_OK
, "ret %08x\n", hr
);
6433 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
6434 ok(hr
== S_OK
, "ret %08x\n", hr
);
6435 ok(enabled
== 0, "Expected 0, got %08x\n", enabled
);
6438 static void test_document_IObjectSafety(void)
6440 IXMLDOMDocument
*doc
;
6441 IObjectSafety
*safety
;
6442 DWORD enabled
= 0, supported
= 0;
6445 doc
= create_document(&IID_IXMLDOMDocument
);
6448 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IObjectSafety
, (void**)&safety
);
6449 ok(hr
== S_OK
, "ret %08x\n", hr
);
6452 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, NULL
, &enabled
);
6453 ok(hr
== E_POINTER
, "ret %08x\n", hr
);
6454 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, NULL
);
6455 ok(hr
== E_POINTER
, "ret %08x\n", hr
);
6457 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
6458 ok(hr
== S_OK
, "ret %08x\n", hr
);
6459 ok(broken(supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
)) ||
6460 supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
6461 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), "
6462 "got %08x\n", supported
);
6463 ok(enabled
== 0, "Expected 0, got %08x\n", enabled
);
6465 /* set -- individual flags */
6467 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
6468 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
6469 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
6471 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
6472 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
,
6473 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
);
6475 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
6476 INTERFACE_USES_SECURITY_MANAGER
, INTERFACE_USES_SECURITY_MANAGER
,
6477 0, INTERFACE_USES_SECURITY_MANAGER
/* msxml3 SP8+ */);
6479 /* set INTERFACE_USES_DISPEX */
6481 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
6482 INTERFACE_USES_DISPEX
, INTERFACE_USES_DISPEX
,
6485 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
6486 INTERFACE_USES_DISPEX
, 0,
6489 test_IObjectSafety_set(safety
, S_OK
, S_OK
/* msxml3 SP8+ */,
6490 0, INTERFACE_USES_DISPEX
,
6493 /* set option masking */
6495 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
6496 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
6497 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
6498 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
6499 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
6501 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
6502 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
6503 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
6504 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
6505 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
6507 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
6508 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
6509 INTERFACE_USES_SECURITY_MANAGER
,
6513 /* set -- inheriting previous settings */
6515 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
6516 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
6517 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
6518 ok(hr
== S_OK
, "ret %08x\n", hr
);
6519 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
6520 ok(hr
== S_OK
, "ret %08x\n", hr
);
6522 ok(broken(enabled
== INTERFACESAFE_FOR_UNTRUSTED_CALLER
) ||
6523 enabled
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
6524 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACE_USES_SECURITY_MANAGER), "
6525 "got %08x\n", enabled
);
6527 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
6528 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
6529 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
6530 ok(hr
== S_OK
, "ret %08x\n", hr
);
6531 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
6532 ok(hr
== S_OK
, "ret %08x\n", hr
);
6534 ok(broken(enabled
== INTERFACESAFE_FOR_UNTRUSTED_DATA
) ||
6535 enabled
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
) /* msxml3 SP8+ */,
6536 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA), "
6537 "got %08x\n", enabled
);
6539 IObjectSafety_Release(safety
);
6541 IXMLDOMDocument_Release(doc
);
6544 typedef struct _property_test_t
{
6547 const char *property
;
6551 static const property_test_t properties_test_data
[] = {
6552 { &CLSID_DOMDocument
, "CLSID_DOMDocument" , "SelectionLanguage", "XSLPattern" },
6553 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2" , "SelectionLanguage", "XSLPattern" },
6554 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30", "SelectionLanguage", "XSLPattern" },
6555 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40", "SelectionLanguage", "XPath" },
6556 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60", "SelectionLanguage", "XPath" },
6560 static void test_default_properties(void)
6562 const property_test_t
*entry
= properties_test_data
;
6563 IXMLDOMDocument2
*doc
;
6569 hr
= CoCreateInstance(entry
->guid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (void**)&doc
);
6572 win_skip("can't create %s instance\n", entry
->clsid
);
6577 hr
= IXMLDOMDocument2_getProperty(doc
, _bstr_(entry
->property
), &var
);
6578 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6579 ok(lstrcmpW(V_BSTR(&var
), _bstr_(entry
->value
)) == 0, "expected %s, for %s\n",
6580 entry
->value
, entry
->clsid
);
6583 IXMLDOMDocument2_Release(doc
);
6589 static void test_XSLPattern(void)
6591 IXMLDOMDocument2
*doc
;
6592 IXMLDOMNodeList
*list
;
6596 doc
= create_document(&IID_IXMLDOMDocument2
);
6599 ole_check(IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
));
6600 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
6602 /* switch to XSLPattern */
6603 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
6605 /* XPath doesn't select elements with non-null default namespace with unqualified selectors, XSLPattern does */
6606 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//elem/c"), &list
));
6608 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6609 /* should select <elem><c> and <elem xmlns='...'><c> but not <elem><foo:c> */
6610 ok(len
== 3, "expected 3 entries in list, got %d\n", len
);
6611 IXMLDOMNodeList_Release(list
);
6613 /* for XSLPattern start index is 0, for XPath it's 1 */
6614 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[0]"), &list
));
6616 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6617 ok(len
!= 0, "expected filled list\n");
6619 expect_list_and_release(list
, "E1.E2.D1");
6622 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index()=1]"), &list
));
6624 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6625 ok(len
!= 0, "expected filled list\n");
6627 expect_list_and_release(list
, "E2.E2.D1");
6630 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() $eq$ 1]"), &list
));
6632 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6633 ok(len
!= 0, "expected filled list\n");
6635 expect_list_and_release(list
, "E2.E2.D1");
6638 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[end()]"), &list
));
6640 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6641 ok(len
!= 0, "expected filled list\n");
6643 expect_list_and_release(list
, "E4.E2.D1");
6646 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[$not$ end()]"), &list
));
6648 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6649 ok(len
!= 0, "expected filled list\n");
6651 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
6654 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() != 0]"), &list
));
6656 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6657 ok(len
!= 0, "expected filled list\n");
6659 expect_list_and_release(list
, "E2.E2.D1 E3.E2.D1 E4.E2.D1");
6660 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() $ne$ 0]"), &list
));
6662 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6663 ok(len
!= 0, "expected filled list\n");
6665 expect_list_and_release(list
, "E2.E2.D1 E3.E2.D1 E4.E2.D1");
6668 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() < 2]"), &list
));
6670 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6671 ok(len
!= 0, "expected filled list\n");
6673 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1");
6674 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() $lt$ 2]"), &list
));
6676 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6677 ok(len
!= 0, "expected filled list\n");
6679 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1");
6682 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() <= 1]"), &list
));
6684 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6685 ok(len
!= 0, "expected filled list\n");
6687 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1");
6688 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() $le$ 1]"), &list
));
6690 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6691 ok(len
!= 0, "expected filled list\n");
6693 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1");
6696 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() > 1]"), &list
));
6698 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6699 ok(len
!= 0, "expected filled list\n");
6701 expect_list_and_release(list
, "E3.E2.D1 E4.E2.D1");
6702 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() $gt$ 1]"), &list
));
6704 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6705 ok(len
!= 0, "expected filled list\n");
6707 expect_list_and_release(list
, "E3.E2.D1 E4.E2.D1");
6710 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() >= 2]"), &list
));
6712 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6713 ok(len
!= 0, "expected filled list\n");
6715 expect_list_and_release(list
, "E3.E2.D1 E4.E2.D1");
6716 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index() $ge$ 2]"), &list
));
6718 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6719 ok(len
!= 0, "expected filled list\n");
6721 expect_list_and_release(list
, "E3.E2.D1 E4.E2.D1");
6724 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[a $ieq$ 'a2 field']"), &list
));
6726 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6727 ok(len
!= 0, "expected filled list\n");
6729 expect_list_and_release(list
, "E2.E2.D1");
6732 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[a $ine$ 'a2 field']"), &list
));
6734 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6735 ok(len
!= 0, "expected filled list\n");
6737 expect_list_and_release(list
, "E1.E2.D1 E3.E2.D1 E4.E2.D1");
6740 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[a $ilt$ 'a3 field']"), &list
));
6742 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6743 ok(len
!= 0, "expected filled list\n");
6745 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1");
6748 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[a $ile$ 'a2 field']"), &list
));
6750 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6751 ok(len
!= 0, "expected filled list\n");
6753 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1");
6756 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[a $igt$ 'a2 field']"), &list
));
6758 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6759 ok(len
!= 0, "expected filled list\n");
6761 expect_list_and_release(list
, "E3.E2.D1 E4.E2.D1");
6764 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[a $ige$ 'a3 field']"), &list
));
6766 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6767 ok(len
!= 0, "expected filled list\n");
6769 expect_list_and_release(list
, "E3.E2.D1 E4.E2.D1");
6772 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[$any$ *='B2 field']"), &list
));
6774 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6775 ok(len
!= 0, "expected filled list\n");
6777 expect_list_and_release(list
, "E2.E2.D1");
6780 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[$all$ *!='B2 field']"), &list
));
6782 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6783 ok(len
!= 0, "expected filled list\n");
6785 expect_list_and_release(list
, "E1.E2.D1 E3.E2.D1 E4.E2.D1");
6788 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index()=0 or end()]"), &list
));
6790 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6791 ok(len
!= 0, "expected filled list\n");
6793 expect_list_and_release(list
, "E1.E2.D1 E4.E2.D1");
6794 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index()=0 $or$ end()]"), &list
));
6796 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6797 ok(len
!= 0, "expected filled list\n");
6799 expect_list_and_release(list
, "E1.E2.D1 E4.E2.D1");
6800 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index()=0 || end()]"), &list
));
6802 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6803 ok(len
!= 0, "expected filled list\n");
6805 expect_list_and_release(list
, "E1.E2.D1 E4.E2.D1");
6808 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index()>0 and $not$ end()]"), &list
));
6810 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6811 ok(len
!= 0, "expected filled list\n");
6813 expect_list_and_release(list
, "E2.E2.D1 E3.E2.D1");
6814 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index()>0 $and$ $not$ end()]"), &list
));
6816 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6817 ok(len
!= 0, "expected filled list\n");
6819 expect_list_and_release(list
, "E2.E2.D1 E3.E2.D1");
6820 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[index()>0 && $not$ end()]"), &list
));
6822 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6823 ok(len
!= 0, "expected filled list\n");
6825 expect_list_and_release(list
, "E2.E2.D1 E3.E2.D1");
6827 /* namespace handling */
6828 /* no registered namespaces */
6829 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("")));
6832 /* prefixes don't need to be registered, you may use them as they are in the doc */
6833 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//bar:x"), &list
));
6835 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6836 ok(len
!= 0, "expected filled list\n");
6838 expect_list_and_release(list
, "E5.E1.E4.E1.E2.D1 E6.E2.E4.E1.E2.D1");
6840 /* prefixes must be explicitly specified in the name */
6841 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//foo:elem"), &list
));
6843 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6844 ok(len
== 0, "expected empty list\n");
6846 IXMLDOMNodeList_Release(list
);
6848 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//foo:c"), &list
));
6850 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6851 ok(len
!= 0, "expected filled list\n");
6853 expect_list_and_release(list
, "E3.E4.E2.D1");
6855 /* explicitly register prefix foo */
6856 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
6858 /* now we get the same behavior as XPath */
6859 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//foo:c"), &list
));
6861 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6862 ok(len
!= 0, "expected filled list\n");
6864 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
6866 /* set prefix foo to some nonexistent namespace */
6867 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("xmlns:foo='urn:nonexistent-foo'")));
6869 /* the registered prefix takes precedence */
6870 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//foo:c"), &list
));
6872 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6873 ok(len
== 0, "expected empty list\n");
6875 IXMLDOMNodeList_Release(list
);
6877 IXMLDOMDocument2_Release(doc
);
6879 doc
= create_document(&IID_IXMLDOMDocument2
);
6882 ole_check(IXMLDOMDocument2_loadXML(doc
, _bstr_(szNodeTypesXML
), &b
));
6883 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
6887 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("attribute()"), &list
));
6889 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6890 ok(len
== 0, "expected empty list\n");
6892 IXMLDOMNodeList_Release(list
);
6894 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("attribute('depth')"), &list
));
6896 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6897 ok(len
== 0, "expected empty list\n");
6899 IXMLDOMNodeList_Release(list
);
6901 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root/attribute('depth')"), &list
));
6903 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6904 ok(len
!= 0, "expected filled list\n");
6906 expect_list_and_release(list
, "A'depth'.E3.D1");
6908 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//x/attribute()"), &list
));
6910 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6911 ok(len
!= 0, "expected filled list\n");
6913 expect_list_and_release(list
, "A'id'.E3.E3.D1 A'depth'.E3.E3.D1");
6916 ole_expect(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//x//attribute(id)"), &list
), E_FAIL
);
6918 IXMLDOMNodeList_Release(list
);
6919 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//x//attribute('id')"), &list
));
6921 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6922 ok(len
!= 0, "expected filled list\n");
6924 expect_list_and_release(list
, "A'id'.E3.E3.D1 A'id'.E4.E3.E3.D1 A'id'.E5.E3.E3.D1 A'id'.E6.E3.E3.D1");
6927 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("comment()"), &list
));
6929 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6930 ok(len
!= 0, "expected filled list\n");
6932 expect_list_and_release(list
, "C2.D1");
6934 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//comment()"), &list
));
6936 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6937 ok(len
!= 0, "expected filled list\n");
6939 expect_list_and_release(list
, "C2.D1 C1.E3.D1 C2.E3.E3.D1 C2.E4.E3.D1");
6942 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("element()"), &list
));
6944 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6945 ok(len
!= 0, "expected filled list\n");
6947 expect_list_and_release(list
, "E3.D1");
6949 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root/y/element()"), &list
));
6951 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6952 ok(len
!= 0, "expected filled list\n");
6954 expect_list_and_release(list
, "E4.E4.E3.D1 E5.E4.E3.D1 E6.E4.E3.D1");
6957 ole_expect(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//element(a)"), &list
), E_FAIL
);
6959 IXMLDOMNodeList_Release(list
);
6960 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//element('a')"), &list
));
6962 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6963 ok(len
!= 0, "expected filled list\n");
6965 expect_list_and_release(list
, "E4.E3.E3.D1 E4.E4.E3.D1");
6968 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("node()"), &list
));
6970 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6971 ok(len
!= 0, "expected filled list\n");
6973 expect_list_and_release(list
, "P1.D1 C2.D1 E3.D1");
6975 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//x/node()"), &list
));
6977 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6978 ok(len
!= 0, "expected filled list\n");
6980 expect_list_and_release(list
, "P1.E3.E3.D1 C2.E3.E3.D1 T3.E3.E3.D1 E4.E3.E3.D1 E5.E3.E3.D1 E6.E3.E3.D1");
6983 /* XML_ELEMENT_NODE */
6984 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//x/node()[nodeType()=1]"), &list
));
6986 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6987 ok(len
!= 0, "expected filled list\n");
6989 expect_list_and_release(list
, "E4.E3.E3.D1 E5.E3.E3.D1 E6.E3.E3.D1");
6991 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//x/node()[nodeType()=3]"), &list
));
6993 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
6994 ok(len
!= 0, "expected filled list\n");
6996 expect_list_and_release(list
, "T3.E3.E3.D1");
6998 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//x/node()[nodeType()=7]"), &list
));
7000 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
7001 ok(len
!= 0, "expected filled list\n");
7003 expect_list_and_release(list
, "P1.E3.E3.D1");
7004 /* XML_COMMENT_NODE */
7005 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//x/node()[nodeType()=8]"), &list
));
7007 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
7008 ok(len
!= 0, "expected filled list\n");
7010 expect_list_and_release(list
, "C2.E3.E3.D1");
7013 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("pi()"), &list
));
7017 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
7018 ok(len
!= 0, "expected filled list\n");
7020 expect_list_and_release(list
, "P1.D1");
7023 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//y/pi()"), &list
));
7025 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
7026 ok(len
!= 0, "expected filled list\n");
7028 expect_list_and_release(list
, "P1.E4.E3.D1");
7031 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root/textnode()"), &list
));
7033 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
7034 ok(len
!= 0, "expected filled list\n");
7036 expect_list_and_release(list
, "T2.E3.D1");
7038 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root/element()/textnode()"), &list
));
7040 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
7041 ok(len
!= 0, "expected filled list\n");
7043 expect_list_and_release(list
, "T3.E3.E3.D1 T3.E4.E3.D1");
7045 IXMLDOMDocument2_Release(doc
);
7049 static void test_splitText(void)
7051 IXMLDOMCDATASection
*cdata
;
7052 IXMLDOMElement
*root
;
7053 IXMLDOMDocument
*doc
;
7054 IXMLDOMText
*text
, *text2
;
7057 VARIANT_BOOL success
;
7061 doc
= create_document(&IID_IXMLDOMDocument
);
7064 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_("<root></root>"), &success
);
7065 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7067 hr
= IXMLDOMDocument_get_documentElement(doc
, &root
);
7068 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7070 hr
= IXMLDOMDocument_createCDATASection(doc
, _bstr_("beautiful plumage"), &cdata
);
7071 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7073 V_VT(&var
) = VT_EMPTY
;
7074 hr
= IXMLDOMElement_appendChild(root
, (IXMLDOMNode
*)cdata
, NULL
);
7075 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7078 hr
= IXMLDOMCDATASection_get_length(cdata
, &length
);
7079 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7080 ok(length
> 0, "got %d\n", length
);
7082 hr
= IXMLDOMCDATASection_splitText(cdata
, 0, NULL
);
7083 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7085 text
= (void*)0xdeadbeef;
7086 /* negative offset */
7087 hr
= IXMLDOMCDATASection_splitText(cdata
, -1, &text
);
7088 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7089 ok(text
== (void*)0xdeadbeef, "got %p\n", text
);
7091 text
= (void*)0xdeadbeef;
7092 /* offset outside data */
7093 hr
= IXMLDOMCDATASection_splitText(cdata
, length
+ 1, &text
);
7094 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7095 ok(text
== 0, "got %p\n", text
);
7097 text
= (void*)0xdeadbeef;
7098 /* offset outside data */
7099 hr
= IXMLDOMCDATASection_splitText(cdata
, length
, &text
);
7100 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7101 ok(text
== 0, "got %p\n", text
);
7103 /* no empty node created */
7104 node
= (void*)0xdeadbeef;
7105 hr
= IXMLDOMCDATASection_get_nextSibling(cdata
, &node
);
7106 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7107 ok(node
== 0, "got %p\n", text
);
7109 hr
= IXMLDOMCDATASection_splitText(cdata
, 10, &text
);
7110 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7113 hr
= IXMLDOMText_get_length(text
, &length
);
7114 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7115 ok(length
== 7, "got %d\n", length
);
7117 hr
= IXMLDOMCDATASection_get_nextSibling(cdata
, &node
);
7118 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7119 IXMLDOMNode_Release(node
);
7121 /* split new text node */
7122 hr
= IXMLDOMText_get_length(text
, &length
);
7123 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7125 node
= (void*)0xdeadbeef;
7126 hr
= IXMLDOMText_get_nextSibling(text
, &node
);
7127 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7128 ok(node
== 0, "got %p\n", text
);
7130 hr
= IXMLDOMText_splitText(text
, 0, NULL
);
7131 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7133 text2
= (void*)0xdeadbeef;
7134 /* negative offset */
7135 hr
= IXMLDOMText_splitText(text
, -1, &text2
);
7136 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7137 ok(text2
== (void*)0xdeadbeef, "got %p\n", text2
);
7139 text2
= (void*)0xdeadbeef;
7140 /* offset outside data */
7141 hr
= IXMLDOMText_splitText(text
, length
+ 1, &text2
);
7142 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7143 ok(text2
== 0, "got %p\n", text2
);
7145 text2
= (void*)0xdeadbeef;
7146 /* offset outside data */
7147 hr
= IXMLDOMText_splitText(text
, length
, &text2
);
7148 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7149 ok(text2
== 0, "got %p\n", text
);
7152 hr
= IXMLDOMText_splitText(text
, 4, &text2
);
7153 todo_wine
ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7154 if (text2
) IXMLDOMText_Release(text2
);
7157 hr
= IXMLDOMText_get_nextSibling(text
, &node
);
7158 todo_wine
ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7159 if (node
) IXMLDOMNode_Release(node
);
7161 IXMLDOMText_Release(text
);
7162 IXMLDOMElement_Release(root
);
7163 IXMLDOMCDATASection_Release(cdata
);
7167 static void test_getQualifiedItem(void)
7169 IXMLDOMDocument
*doc
;
7170 IXMLDOMElement
*element
;
7171 IXMLDOMNode
*pr_node
, *node
;
7172 IXMLDOMNodeList
*root_list
;
7173 IXMLDOMNamedNodeMap
*map
;
7179 doc
= create_document(&IID_IXMLDOMDocument
);
7182 str
= SysAllocString( szComplete4
);
7183 hr
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
7184 ok( hr
== S_OK
, "loadXML failed\n");
7185 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7186 SysFreeString( str
);
7188 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
7189 ok( hr
== S_OK
, "ret %08x\n", hr
);
7191 hr
= IXMLDOMElement_get_childNodes(element
, &root_list
);
7192 ok( hr
== S_OK
, "ret %08x\n", hr
);
7194 hr
= IXMLDOMNodeList_get_item(root_list
, 1, &pr_node
);
7195 ok( hr
== S_OK
, "ret %08x\n", hr
);
7196 IXMLDOMNodeList_Release(root_list
);
7198 hr
= IXMLDOMNode_get_attributes(pr_node
, &map
);
7199 ok( hr
== S_OK
, "ret %08x\n", hr
);
7200 IXMLDOMNode_Release(pr_node
);
7202 hr
= IXMLDOMNamedNodeMap_get_length(map
, &len
);
7203 ok( hr
== S_OK
, "ret %08x\n", hr
);
7204 ok( len
== 3, "length %d\n", len
);
7206 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, NULL
, NULL
, NULL
);
7207 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7209 node
= (void*)0xdeadbeef;
7210 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, NULL
, NULL
, &node
);
7211 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7212 ok( node
== (void*)0xdeadbeef, "got %p\n", node
);
7214 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, _bstr_("id"), NULL
, NULL
);
7215 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7217 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, _bstr_("id"), NULL
, &node
);
7218 ok( hr
== S_OK
, "ret %08x\n", hr
);
7219 IXMLDOMNode_Release(node
);
7221 IXMLDOMNamedNodeMap_Release( map
);
7222 IXMLDOMElement_Release( element
);
7223 IXMLDOMDocument_Release( doc
);
7227 static void test_removeQualifiedItem(void)
7229 IXMLDOMDocument
*doc
;
7230 IXMLDOMElement
*element
;
7231 IXMLDOMNode
*pr_node
, *node
;
7232 IXMLDOMNodeList
*root_list
;
7233 IXMLDOMNamedNodeMap
*map
;
7239 doc
= create_document(&IID_IXMLDOMDocument
);
7242 str
= SysAllocString( szComplete4
);
7243 hr
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
7244 ok( hr
== S_OK
, "loadXML failed\n");
7245 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7246 SysFreeString( str
);
7248 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
7249 ok( hr
== S_OK
, "ret %08x\n", hr
);
7251 hr
= IXMLDOMElement_get_childNodes(element
, &root_list
);
7252 ok( hr
== S_OK
, "ret %08x\n", hr
);
7254 hr
= IXMLDOMNodeList_get_item(root_list
, 1, &pr_node
);
7255 ok( hr
== S_OK
, "ret %08x\n", hr
);
7256 IXMLDOMNodeList_Release(root_list
);
7258 hr
= IXMLDOMNode_get_attributes(pr_node
, &map
);
7259 ok( hr
== S_OK
, "ret %08x\n", hr
);
7260 IXMLDOMNode_Release(pr_node
);
7262 hr
= IXMLDOMNamedNodeMap_get_length(map
, &len
);
7263 ok( hr
== S_OK
, "ret %08x\n", hr
);
7264 ok( len
== 3, "length %d\n", len
);
7266 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, NULL
, NULL
, NULL
);
7267 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7269 node
= (void*)0xdeadbeef;
7270 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, NULL
, NULL
, &node
);
7271 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7272 ok( node
== (void*)0xdeadbeef, "got %p\n", node
);
7274 /* out pointer is optional */
7275 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, _bstr_("id"), NULL
, NULL
);
7276 ok( hr
== S_OK
, "ret %08x\n", hr
);
7278 /* already removed */
7279 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, _bstr_("id"), NULL
, NULL
);
7280 ok( hr
== S_FALSE
, "ret %08x\n", hr
);
7282 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, _bstr_("vr"), NULL
, &node
);
7283 ok( hr
== S_OK
, "ret %08x\n", hr
);
7284 IXMLDOMNode_Release(node
);
7286 IXMLDOMNamedNodeMap_Release( map
);
7287 IXMLDOMElement_Release( element
);
7288 IXMLDOMDocument_Release( doc
);
7292 static void test_get_ownerDocument(void)
7294 IXMLDOMDocument
*doc1
, *doc2
, *doc3
;
7295 IXMLDOMDocument2
*doc
, *doc_owner
;
7302 doc
= create_document(&IID_IXMLDOMDocument2
);
7305 str
= SysAllocString( szComplete4
);
7306 hr
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
7307 ok( hr
== S_OK
, "loadXML failed\n");
7308 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7309 SysFreeString( str
);
7311 hr
= IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionLanguage"), &var
);
7312 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7313 ok( lstrcmpW(V_BSTR(&var
), _bstr_("XSLPattern")) == 0, "expected XSLPattern\n");
7316 /* set to XPath and check that new instances use it */
7317 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath"));
7318 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7320 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("xmlns:wi=\'www.winehq.org\'"));
7321 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7323 hr
= IXMLDOMDocument2_get_firstChild(doc
, &node
);
7324 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7326 hr
= IXMLDOMNode_get_ownerDocument(node
, &doc1
);
7327 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7329 hr
= IXMLDOMDocument_QueryInterface(doc1
, &IID_IXMLDOMDocument2
, (void**)&doc_owner
);
7330 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7331 ok( doc_owner
!= doc
, "got %p, doc %p\n", doc_owner
, doc
);
7332 hr
= IXMLDOMDocument2_getProperty(doc_owner
, _bstr_("SelectionNamespaces"), &var
);
7333 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7334 ok( lstrcmpW(V_BSTR(&var
), _bstr_("xmlns:wi=\'www.winehq.org\'")) == 0, "expected previously set value\n");
7337 hr
= IXMLDOMDocument2_getProperty(doc_owner
, _bstr_("SelectionLanguage"), &var
);
7338 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7339 ok( lstrcmpW(V_BSTR(&var
), _bstr_("XPath")) == 0, "expected XPath\n");
7341 IXMLDOMDocument2_Release(doc_owner
);
7343 hr
= IXMLDOMNode_get_ownerDocument(node
, &doc2
);
7344 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7345 IXMLDOMNode_Release(node
);
7347 ok(doc1
!= doc2
, "got %p, expected %p. original %p\n", doc2
, doc1
, doc
);
7350 str
= SysAllocString( szComplete4
);
7351 hr
= IXMLDOMDocument2_loadXML( doc
, str
, &b
);
7352 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7353 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7354 SysFreeString( str
);
7356 /* properties retained even after reload */
7357 hr
= IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
);
7358 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7359 ok( lstrcmpW(V_BSTR(&var
), _bstr_("xmlns:wi=\'www.winehq.org\'")) == 0, "expected previously set value\n");
7362 hr
= IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionLanguage"), &var
);
7363 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7364 ok( lstrcmpW(V_BSTR(&var
), _bstr_("XPath")) == 0, "expected XPath\n");
7367 hr
= IXMLDOMDocument2_get_firstChild(doc
, &node
);
7368 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7370 hr
= IXMLDOMNode_get_ownerDocument(node
, &doc3
);
7371 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7372 IXMLDOMNode_Release(node
);
7374 hr
= IXMLDOMDocument_QueryInterface(doc3
, &IID_IXMLDOMDocument2
, (void**)&doc_owner
);
7375 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7376 ok(doc3
!= doc1
&& doc3
!= doc2
&& doc_owner
!= doc
, "got %p, (%p, %p, %p)\n", doc3
, doc
, doc1
, doc2
);
7378 IXMLDOMDocument_Release(doc1
);
7379 IXMLDOMDocument_Release(doc2
);
7380 IXMLDOMDocument_Release(doc3
);
7381 IXMLDOMDocument2_Release(doc
);
7385 static void test_setAttributeNode(void)
7387 IXMLDOMDocument
*doc
, *doc2
;
7388 IXMLDOMElement
*elem
;
7389 IXMLDOMAttribute
*attr
, *attr2
, *ret_attr
;
7394 doc
= create_document(&IID_IXMLDOMDocument
);
7397 str
= SysAllocString( szComplete4
);
7398 hr
= IXMLDOMDocument2_loadXML( doc
, str
, &b
);
7399 ok( hr
== S_OK
, "loadXML failed\n");
7400 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7401 SysFreeString( str
);
7403 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
7404 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7406 ret_attr
= (void*)0xdeadbeef;
7407 hr
= IXMLDOMElement_setAttributeNode(elem
, NULL
, &ret_attr
);
7408 ok( hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7409 ok( ret_attr
== (void*)0xdeadbeef, "got %p\n", ret_attr
);
7411 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("attr"), &attr
);
7412 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7414 ret_attr
= (void*)0xdeadbeef;
7415 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
7416 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7417 ok( ret_attr
== NULL
, "got %p\n", ret_attr
);
7420 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("attr"), &attr2
);
7421 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7422 IXMLDOMAttribute_Release(attr2
);
7424 /* try to add it another time */
7425 ret_attr
= (void*)0xdeadbeef;
7426 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
7427 todo_wine
ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
7428 todo_wine
ok( ret_attr
== (void*)0xdeadbeef, "got %p\n", ret_attr
);
7430 IXMLDOMElement_Release(elem
);
7432 /* initialy used element is released, attribute still 'has' a container */
7433 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
7434 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7435 ret_attr
= (void*)0xdeadbeef;
7436 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
7437 todo_wine
ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
7438 todo_wine
ok( ret_attr
== (void*)0xdeadbeef, "got %p\n", ret_attr
);
7439 IXMLDOMElement_Release(elem
);
7441 /* add attribute already attached to another document */
7442 doc2
= create_document(&IID_IXMLDOMDocument
);
7444 str
= SysAllocString( szComplete4
);
7445 hr
= IXMLDOMDocument_loadXML( doc2
, str
, &b
);
7446 ok( hr
== S_OK
, "loadXML failed\n");
7447 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7448 SysFreeString( str
);
7450 hr
= IXMLDOMDocument_get_documentElement(doc2
, &elem
);
7451 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7452 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, NULL
);
7453 todo_wine
ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
7454 IXMLDOMElement_Release(elem
);
7456 IXMLDOMDocument_Release(doc2
);
7458 IXMLDOMAttribute_Release(attr
);
7459 IXMLDOMDocument_Release(doc
);
7463 static void test_get_dataType(void)
7465 IXMLDOMDocument2
*doc
, *schema
;
7466 IXMLDOMSchemaCollection
* cache
;
7468 IXMLDOMParseError
* err
;
7476 doc
= create_document(&IID_IXMLDOMDocument2
);
7477 schema
= create_document(&IID_IXMLDOMDocument2
);
7478 cache
= create_cache(&IID_IXMLDOMSchemaCollection
);
7480 if (!doc
|| !schema
|| !cache
)
7482 if (doc
) IXMLDOMDocument2_Release(doc
);
7483 if (schema
) IXMLDOMDocument2_Release(schema
);
7484 if (cache
) IXMLDOMSchemaCollection_Release(cache
);
7489 ole_check(IXMLDOMDocument2_loadXML(doc
, _bstr_(szDatatypeXML
), &b
));
7490 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
7492 ole_check(IXMLDOMDocument2_loadXML(schema
, _bstr_(szDatatypeXDR
), &b
));
7493 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
7496 ole_expect(IXMLDOMDocument2_validate(doc
, &err
), S_FALSE
);
7497 ok(err
!= NULL
, "domdoc_validate() should always set err\n");
7498 ole_check(IXMLDOMParseError_get_errorCode(err
, &l
));
7499 ok(l
== E_XML_NODTD
, "got %08x\n", l
);
7500 IXMLDOMParseError_Release(err
);
7502 /* check data types without the schema */
7504 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testBase64']/Value/base64Data"), &node
));
7505 ok(node
!= NULL
, "expected node\n");
7506 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7507 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7508 if (V_VT(&v
) == VT_BSTR
)
7509 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7511 IXMLDOMNode_Release(node
);
7514 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testHex']/Value/hexData"), &node
));
7515 ok(node
!= NULL
, "expected node\n");
7516 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7517 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7518 if (V_VT(&v
) == VT_BSTR
)
7519 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7521 IXMLDOMNode_Release(node
);
7524 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testBool']/Value/boolData"), &node
));
7525 ok(node
!= NULL
, "expected node\n");
7526 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7527 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7528 if (V_VT(&v
) == VT_BSTR
)
7529 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7531 IXMLDOMNode_Release(node
);
7534 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testChar']/Value/charData"), &node
));
7535 ok(node
!= NULL
, "expected node\n");
7536 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7537 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7538 if (V_VT(&v
) == VT_BSTR
)
7539 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7541 IXMLDOMNode_Release(node
);
7544 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testDate']/Value/dateData"), &node
));
7545 ok(node
!= NULL
, "expected node\n");
7546 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7547 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7548 if (V_VT(&v
) == VT_BSTR
)
7549 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7551 IXMLDOMNode_Release(node
);
7554 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testDateTime']/Value/dateTimeData"), &node
));
7555 ok(node
!= NULL
, "expected node\n");
7556 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7557 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7558 if (V_VT(&v
) == VT_BSTR
)
7559 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7561 IXMLDOMNode_Release(node
);
7564 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testDateTimeTz']/Value/dateTimeTzData"), &node
));
7565 ok(node
!= NULL
, "expected node\n");
7566 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7567 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7568 if (V_VT(&v
) == VT_BSTR
)
7569 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7571 IXMLDOMNode_Release(node
);
7574 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testFixed']/Value/fixedData"), &node
));
7575 ok(node
!= NULL
, "expected node\n");
7576 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7577 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7578 if (V_VT(&v
) == VT_BSTR
)
7579 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7581 IXMLDOMNode_Release(node
);
7584 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testFloat']/Value/floatData"), &node
));
7585 ok(node
!= NULL
, "expected node\n");
7586 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7587 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7588 if (V_VT(&v
) == VT_BSTR
)
7589 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7591 IXMLDOMNode_Release(node
);
7594 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testI1']/Value/i1Data"), &node
));
7595 ok(node
!= NULL
, "expected node\n");
7596 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7597 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7598 if (V_VT(&v
) == VT_BSTR
)
7599 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7601 IXMLDOMNode_Release(node
);
7604 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testI2']/Value/i2Data"), &node
));
7605 ok(node
!= NULL
, "expected node\n");
7606 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7607 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7608 if (V_VT(&v
) == VT_BSTR
)
7609 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7611 IXMLDOMNode_Release(node
);
7614 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testI4']/Value/i4Data"), &node
));
7615 ok(node
!= NULL
, "expected node\n");
7616 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7617 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7618 if (V_VT(&v
) == VT_BSTR
)
7619 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7621 IXMLDOMNode_Release(node
);
7624 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testI8']/Value/i8Data"), &node
));
7625 ok(node
!= NULL
, "expected node\n");
7626 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7627 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7628 if (V_VT(&v
) == VT_BSTR
)
7629 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7631 IXMLDOMNode_Release(node
);
7634 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testInt']/Value/intData"), &node
));
7635 ok(node
!= NULL
, "expected node\n");
7636 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7637 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7638 if (V_VT(&v
) == VT_BSTR
)
7639 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7641 IXMLDOMNode_Release(node
);
7644 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testNmtoken']/Value/nmtokData"), &node
));
7645 ok(node
!= NULL
, "expected node\n");
7646 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7647 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7648 if (V_VT(&v
) == VT_BSTR
)
7649 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7651 IXMLDOMNode_Release(node
);
7654 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testNmtokens']/Value/nmtoksData"), &node
));
7655 ok(node
!= NULL
, "expected node\n");
7656 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7657 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7658 if (V_VT(&v
) == VT_BSTR
)
7659 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7661 IXMLDOMNode_Release(node
);
7664 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testNumber']/Value/numData"), &node
));
7665 ok(node
!= NULL
, "expected node\n");
7666 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7667 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7668 if (V_VT(&v
) == VT_BSTR
)
7669 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7671 IXMLDOMNode_Release(node
);
7674 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testR4']/Value/r4Data"), &node
));
7675 ok(node
!= NULL
, "expected node\n");
7676 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7677 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7678 if (V_VT(&v
) == VT_BSTR
)
7679 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7681 IXMLDOMNode_Release(node
);
7684 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testR8']/Value/r8Data"), &node
));
7685 ok(node
!= NULL
, "expected node\n");
7686 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7687 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7688 if (V_VT(&v
) == VT_BSTR
)
7689 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7691 IXMLDOMNode_Release(node
);
7694 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testString']/Value/stringData"), &node
));
7695 ok(node
!= NULL
, "expected node\n");
7696 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7697 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7698 if (V_VT(&v
) == VT_BSTR
)
7699 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7701 IXMLDOMNode_Release(node
);
7704 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testTime']/Value/timeData"), &node
));
7705 ok(node
!= NULL
, "expected node\n");
7706 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7707 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7708 if (V_VT(&v
) == VT_BSTR
)
7709 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7711 IXMLDOMNode_Release(node
);
7714 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testTimeTz']/Value/timeTzData"), &node
));
7715 ok(node
!= NULL
, "expected node\n");
7716 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7717 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7718 if (V_VT(&v
) == VT_BSTR
)
7719 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7721 IXMLDOMNode_Release(node
);
7724 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testU1']/Value/u1Data"), &node
));
7725 ok(node
!= NULL
, "expected node\n");
7726 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7727 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7728 if (V_VT(&v
) == VT_BSTR
)
7729 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7731 IXMLDOMNode_Release(node
);
7734 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testU2']/Value/u2Data"), &node
));
7735 ok(node
!= NULL
, "expected node\n");
7736 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7737 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7738 if (V_VT(&v
) == VT_BSTR
)
7739 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7741 IXMLDOMNode_Release(node
);
7744 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testU4']/Value/u4Data"), &node
));
7745 ok(node
!= NULL
, "expected node\n");
7746 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7747 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7748 if (V_VT(&v
) == VT_BSTR
)
7749 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7751 IXMLDOMNode_Release(node
);
7754 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testU8']/Value/u8Data"), &node
));
7755 ok(node
!= NULL
, "expected node\n");
7756 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7757 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7758 if (V_VT(&v
) == VT_BSTR
)
7759 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7761 IXMLDOMNode_Release(node
);
7764 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testURI']/Value/uriData"), &node
));
7765 ok(node
!= NULL
, "expected node\n");
7766 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7767 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7768 if (V_VT(&v
) == VT_BSTR
)
7769 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7771 IXMLDOMNode_Release(node
);
7774 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testUUID']/Value/uuidData"), &node
));
7775 ok(node
!= NULL
, "expected node\n");
7776 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7777 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7778 if (V_VT(&v
) == VT_BSTR
)
7779 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7781 IXMLDOMNode_Release(node
);
7783 /* now load the schema */
7784 V_VT(&v
) = VT_DISPATCH
;
7785 V_DISPATCH(&v
) = NULL
;
7786 ole_check(IXMLDOMDocument2_QueryInterface(schema
, &IID_IDispatch
, (void**)&V_DISPATCH(&v
)));
7787 ok(V_DISPATCH(&v
) != NULL
, "failed to get IDispatch interface\n");
7788 ole_check(IXMLDOMSchemaCollection_add(cache
, _bstr_("urn:x-schema:datatype-test-xdr"), v
));
7791 /* associate the cache to the doc */
7792 V_VT(&v
) = VT_DISPATCH
;
7793 V_DISPATCH(&v
) = NULL
;
7794 ole_check(IXMLDOMSchemaCollection_QueryInterface(cache
, &IID_IDispatch
, (void**)&V_DISPATCH(&v
)));
7795 ok(V_DISPATCH(&v
) != NULL
, "failed to get IDispatch interface\n");
7796 ole_check(IXMLDOMDocument2_putref_schemas(doc
, v
));
7799 /* validate the doc */
7803 ole_check(IXMLDOMDocument2_validate(doc
, &err
));
7804 ok(err
!= NULL
, "domdoc_validate() should always set err\n");
7805 ole_expect(IXMLDOMParseError_get_errorCode(err
, &l
), S_FALSE
);
7806 ole_expect(IXMLDOMParseError_get_reason(err
, &bstr
), S_FALSE
);
7807 ok(l
== 0, "got %08x : %s\n", l
, wine_dbgstr_w(bstr
));
7808 IXMLDOMParseError_Release(err
);
7810 /* check the data types again */
7812 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testBase64']/Value/base64Data"), &node
));
7813 ok(node
!= NULL
, "expected node\n");
7814 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7815 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7816 if (V_VT(&v
) == VT_BSTR
)
7817 ok(lstrcmpW(V_BSTR(&v
), _bstr_("bin.base64")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7819 IXMLDOMNode_Release(node
);
7822 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testHex']/Value/hexData"), &node
));
7823 ok(node
!= NULL
, "expected node\n");
7824 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7825 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7826 if (V_VT(&v
) == VT_BSTR
)
7827 ok(lstrcmpW(V_BSTR(&v
), _bstr_("bin.hex")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7829 IXMLDOMNode_Release(node
);
7832 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testBool']/Value/boolData"), &node
));
7833 ok(node
!= NULL
, "expected node\n");
7834 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7835 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7836 if (V_VT(&v
) == VT_BSTR
)
7837 ok(lstrcmpW(V_BSTR(&v
), _bstr_("boolean")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7839 IXMLDOMNode_Release(node
);
7842 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testChar']/Value/charData"), &node
));
7843 ok(node
!= NULL
, "expected node\n");
7844 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7845 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7846 if (V_VT(&v
) == VT_BSTR
)
7847 ok(lstrcmpW(V_BSTR(&v
), _bstr_("char")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7849 IXMLDOMNode_Release(node
);
7852 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testDate']/Value/dateData"), &node
));
7853 ok(node
!= NULL
, "expected node\n");
7854 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7855 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7856 if (V_VT(&v
) == VT_BSTR
)
7857 ok(lstrcmpW(V_BSTR(&v
), _bstr_("date")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7859 IXMLDOMNode_Release(node
);
7862 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testDateTime']/Value/dateTimeData"), &node
));
7863 ok(node
!= NULL
, "expected node\n");
7864 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7865 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7866 if (V_VT(&v
) == VT_BSTR
)
7867 ok(lstrcmpW(V_BSTR(&v
), _bstr_("dateTime")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7869 IXMLDOMNode_Release(node
);
7872 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testDateTimeTz']/Value/dateTimeTzData"), &node
));
7873 ok(node
!= NULL
, "expected node\n");
7874 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7875 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7876 if (V_VT(&v
) == VT_BSTR
)
7877 ok(lstrcmpW(V_BSTR(&v
), _bstr_("dateTime.tz")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7879 IXMLDOMNode_Release(node
);
7882 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testFixed']/Value/fixedData"), &node
));
7883 ok(node
!= NULL
, "expected node\n");
7884 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7885 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7886 if (V_VT(&v
) == VT_BSTR
)
7887 ok(lstrcmpW(V_BSTR(&v
), _bstr_("fixed.14.4")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7889 IXMLDOMNode_Release(node
);
7892 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testFloat']/Value/floatData"), &node
));
7893 ok(node
!= NULL
, "expected node\n");
7894 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7895 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7896 if (V_VT(&v
) == VT_BSTR
)
7897 ok(lstrcmpW(V_BSTR(&v
), _bstr_("float")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7899 IXMLDOMNode_Release(node
);
7902 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testI1']/Value/i1Data"), &node
));
7903 ok(node
!= NULL
, "expected node\n");
7904 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7905 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7906 if (V_VT(&v
) == VT_BSTR
)
7907 ok(lstrcmpW(V_BSTR(&v
), _bstr_("i1")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7909 IXMLDOMNode_Release(node
);
7912 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testI2']/Value/i2Data"), &node
));
7913 ok(node
!= NULL
, "expected node\n");
7914 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7915 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7916 if (V_VT(&v
) == VT_BSTR
)
7917 ok(lstrcmpW(V_BSTR(&v
), _bstr_("i2")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7919 IXMLDOMNode_Release(node
);
7922 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testI4']/Value/i4Data"), &node
));
7923 ok(node
!= NULL
, "expected node\n");
7924 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7925 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7926 if (V_VT(&v
) == VT_BSTR
)
7927 ok(lstrcmpW(V_BSTR(&v
), _bstr_("i4")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7929 IXMLDOMNode_Release(node
);
7932 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testI8']/Value/i8Data"), &node
));
7933 ok(node
!= NULL
, "expected node\n");
7934 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7935 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7936 if (V_VT(&v
) == VT_BSTR
)
7937 ok(lstrcmpW(V_BSTR(&v
), _bstr_("i8")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7939 IXMLDOMNode_Release(node
);
7942 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testInt']/Value/intData"), &node
));
7943 ok(node
!= NULL
, "expected node\n");
7944 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7945 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7946 if (V_VT(&v
) == VT_BSTR
)
7947 ok(lstrcmpW(V_BSTR(&v
), _bstr_("int")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7949 IXMLDOMNode_Release(node
);
7951 /* nmtoken does not return a bstr */
7953 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testNmtoken']/Value/nmtokData"), &node
));
7954 ok(node
!= NULL
, "expected node\n");
7955 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7956 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7957 if (V_VT(&v
) == VT_BSTR
)
7958 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7960 IXMLDOMNode_Release(node
);
7962 /* nmtokens does not return a bstr */
7964 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testNmtokens']/Value/nmtoksData"), &node
));
7965 ok(node
!= NULL
, "expected node\n");
7966 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
7967 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
7968 if (V_VT(&v
) == VT_BSTR
)
7969 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7971 IXMLDOMNode_Release(node
);
7974 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testNumber']/Value/numData"), &node
));
7975 ok(node
!= NULL
, "expected node\n");
7976 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7977 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7978 if (V_VT(&v
) == VT_BSTR
)
7979 ok(lstrcmpW(V_BSTR(&v
), _bstr_("number")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7981 IXMLDOMNode_Release(node
);
7984 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testR4']/Value/r4Data"), &node
));
7985 ok(node
!= NULL
, "expected node\n");
7986 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7987 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7988 if (V_VT(&v
) == VT_BSTR
)
7989 ok(lstrcmpW(V_BSTR(&v
), _bstr_("r4")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
7991 IXMLDOMNode_Release(node
);
7994 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testR8']/Value/r8Data"), &node
));
7995 ok(node
!= NULL
, "expected node\n");
7996 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
7997 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
7998 if (V_VT(&v
) == VT_BSTR
)
7999 ok(lstrcmpW(V_BSTR(&v
), _bstr_("r8")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8001 IXMLDOMNode_Release(node
);
8003 /* dt:string is the default, does not return a bstr */
8005 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testString']/Value/stringData"), &node
));
8006 ok(node
!= NULL
, "expected node\n");
8007 ole_expect(IXMLDOMNode_get_dataType(node
, &v
), S_FALSE
);
8008 ok(V_VT(&v
) == VT_NULL
, "got variant type %i\n", V_VT(&v
));
8009 if (V_VT(&v
) == VT_BSTR
)
8010 ok(0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8012 IXMLDOMNode_Release(node
);
8015 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testTime']/Value/timeData"), &node
));
8016 ok(node
!= NULL
, "expected node\n");
8017 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
8018 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
8019 if (V_VT(&v
) == VT_BSTR
)
8020 ok(lstrcmpW(V_BSTR(&v
), _bstr_("time")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8022 IXMLDOMNode_Release(node
);
8025 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testTimeTz']/Value/timeTzData"), &node
));
8026 ok(node
!= NULL
, "expected node\n");
8027 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
8028 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
8029 if (V_VT(&v
) == VT_BSTR
)
8030 ok(lstrcmpW(V_BSTR(&v
), _bstr_("time.tz")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8032 IXMLDOMNode_Release(node
);
8035 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testU1']/Value/u1Data"), &node
));
8036 ok(node
!= NULL
, "expected node\n");
8037 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
8038 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
8039 if (V_VT(&v
) == VT_BSTR
)
8040 ok(lstrcmpW(V_BSTR(&v
), _bstr_("ui1")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8042 IXMLDOMNode_Release(node
);
8045 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testU2']/Value/u2Data"), &node
));
8046 ok(node
!= NULL
, "expected node\n");
8047 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
8048 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
8049 if (V_VT(&v
) == VT_BSTR
)
8050 ok(lstrcmpW(V_BSTR(&v
), _bstr_("ui2")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8052 IXMLDOMNode_Release(node
);
8055 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testU4']/Value/u4Data"), &node
));
8056 ok(node
!= NULL
, "expected node\n");
8057 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
8058 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
8059 if (V_VT(&v
) == VT_BSTR
)
8060 ok(lstrcmpW(V_BSTR(&v
), _bstr_("ui4")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8062 IXMLDOMNode_Release(node
);
8065 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testU8']/Value/u8Data"), &node
));
8066 ok(node
!= NULL
, "expected node\n");
8067 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
8068 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
8069 if (V_VT(&v
) == VT_BSTR
)
8070 ok(lstrcmpW(V_BSTR(&v
), _bstr_("ui8")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8072 IXMLDOMNode_Release(node
);
8075 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testURI']/Value/uriData"), &node
));
8076 ok(node
!= NULL
, "expected node\n");
8077 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
8078 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
8079 if (V_VT(&v
) == VT_BSTR
)
8080 ok(lstrcmpW(V_BSTR(&v
), _bstr_("uri")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8082 IXMLDOMNode_Release(node
);
8085 ole_check(IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("//Property[Name!text()='testUUID']/Value/uuidData"), &node
));
8086 ok(node
!= NULL
, "expected node\n");
8087 todo_wine
ole_check(IXMLDOMNode_get_dataType(node
, &v
));
8088 todo_wine
ok(V_VT(&v
) == VT_BSTR
, "got variant type %i\n", V_VT(&v
));
8089 if (V_VT(&v
) == VT_BSTR
)
8090 ok(lstrcmpW(V_BSTR(&v
), _bstr_("uuid")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8092 IXMLDOMNode_Release(node
);
8094 ok(IXMLDOMDocument2_Release(schema
) == 0, "schema not released\n");
8095 ok(IXMLDOMDocument2_Release(doc
) == 0, "doc not released\n");
8096 ok(IXMLDOMSchemaCollection_Release(cache
) == 0, "cache not released\n");
8101 static void test_put_dataType(void)
8103 IXMLDOMCDATASection
*cdata
;
8104 IXMLDOMDocument
*doc
;
8109 doc
= create_document(&IID_IXMLDOMDocument
);
8112 str
= SysAllocString( szComplete4
);
8113 hr
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
8114 ok( hr
== S_OK
, "loadXML failed\n");
8115 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
8116 SysFreeString( str
);
8118 hr
= IXMLDOMDocument_createCDATASection(doc
, _bstr_("test"), &cdata
);
8119 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8120 hr
= IXMLDOMCDATASection_put_dataType(cdata
, _bstr_("number"));
8121 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
8122 hr
= IXMLDOMCDATASection_put_dataType(cdata
, _bstr_("string"));
8123 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
8124 IXMLDOMCDATASection_Release(cdata
);
8126 IXMLDOMDocument_Release(doc
);
8130 static void test_createNode(void)
8132 IXMLDOMDocument
*doc
;
8133 IXMLDOMElement
*elem
;
8139 doc
= create_document(&IID_IXMLDOMDocument
);
8142 /* NODE_ELEMENT nodes */
8143 /* 1. specified namespace */
8145 V_I4(&v
) = NODE_ELEMENT
;
8147 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("ns1:test"), _bstr_("http://winehq.org"), &node
);
8148 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8150 hr
= IXMLDOMNode_get_prefix(node
, &prefix
);
8151 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8152 ok(lstrcmpW(prefix
, _bstr_("ns1")) == 0, "wrong prefix\n");
8153 SysFreeString(prefix
);
8154 IXMLDOMNode_Release(node
);
8156 /* 2. default namespace */
8157 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("test"), _bstr_("http://winehq.org/default"), &node
);
8158 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8159 prefix
= (void*)0xdeadbeef;
8160 hr
= IXMLDOMNode_get_prefix(node
, &prefix
);
8161 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
8162 ok(prefix
== 0, "expected empty prefix, got %p\n", prefix
);
8164 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)&elem
);
8165 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8167 V_VT(&var
) = VT_BSTR
;
8168 hr
= IXMLDOMElement_getAttribute(elem
, _bstr_("xmlns"), &var
);
8169 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
8170 ok( V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
8173 hr
= IXMLDOMElement_get_namespaceURI(elem
, &str
);
8174 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8175 ok( lstrcmpW(str
, _bstr_("http://winehq.org/default")) == 0, "expected default namespace\n");
8178 IXMLDOMElement_Release(elem
);
8179 IXMLDOMNode_Release(node
);
8181 IXMLDOMDocument_Release(doc
);
8185 static void test_get_prefix(void)
8187 IXMLDOMDocumentFragment
*fragment
;
8188 IXMLDOMCDATASection
*cdata
;
8189 IXMLDOMElement
*element
;
8190 IXMLDOMComment
*comment
;
8191 IXMLDOMDocument
*doc
;
8195 doc
= create_document(&IID_IXMLDOMDocument
);
8198 /* nodes that can't support prefix */
8200 str
= (void*)0xdeadbeef;
8201 hr
= IXMLDOMDocument_get_prefix(doc
, &str
);
8202 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
8203 ok( str
== 0, "got %p\n", str
);
8205 hr
= IXMLDOMDocument_get_prefix(doc
, NULL
);
8206 ok( hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8209 hr
= IXMLDOMDocument_createCDATASection(doc
, NULL
, &cdata
);
8210 ok(hr
== S_OK
, "got %08x\n", hr
);
8212 str
= (void*)0xdeadbeef;
8213 hr
= IXMLDOMCDATASection_get_prefix(cdata
, &str
);
8214 ok(hr
== S_FALSE
, "got %08x\n", hr
);
8215 ok( str
== 0, "got %p\n", str
);
8217 hr
= IXMLDOMCDATASection_get_prefix(cdata
, NULL
);
8218 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
8219 IXMLDOMCDATASection_Release(cdata
);
8222 hr
= IXMLDOMDocument_createComment(doc
, NULL
, &comment
);
8223 ok(hr
== S_OK
, "got %08x\n", hr
);
8225 str
= (void*)0xdeadbeef;
8226 hr
= IXMLDOMComment_get_prefix(comment
, &str
);
8227 ok(hr
== S_FALSE
, "got %08x\n", hr
);
8228 ok( str
== 0, "got %p\n", str
);
8230 hr
= IXMLDOMComment_get_prefix(comment
, NULL
);
8231 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
8232 IXMLDOMComment_Release(comment
);
8235 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &fragment
);
8236 ok(hr
== S_OK
, "got %08x\n", hr
);
8238 str
= (void*)0xdeadbeef;
8239 hr
= IXMLDOMDocumentFragment_get_prefix(fragment
, &str
);
8240 ok(hr
== S_FALSE
, "got %08x\n", hr
);
8241 ok( str
== 0, "got %p\n", str
);
8243 hr
= IXMLDOMDocumentFragment_get_prefix(fragment
, NULL
);
8244 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
8245 IXMLDOMDocumentFragment_Release(fragment
);
8248 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &element
);
8249 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8251 hr
= IXMLDOMElement_get_prefix(element
, NULL
);
8252 ok( hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8254 str
= (void*)0xdeadbeef;
8255 hr
= IXMLDOMElement_get_prefix(element
, &str
);
8256 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
8257 ok( str
== 0, "got %p\n", str
);
8259 IXMLDOMElement_Release(element
);
8262 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("a:elem"), &element
);
8263 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8265 str
= (void*)0xdeadbeef;
8266 hr
= IXMLDOMElement_get_prefix(element
, &str
);
8267 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8268 ok( lstrcmpW(str
, _bstr_("a")) == 0, "expected prefix \"a\"\n");
8271 str
= (void*)0xdeadbeef;
8272 hr
= IXMLDOMElement_get_namespaceURI(element
, &str
);
8273 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
8274 ok( str
== 0, "got %p\n", str
);
8276 IXMLDOMElement_Release(element
);
8278 IXMLDOMDocument_Release(doc
);
8282 static void test_selectSingleNode(void)
8284 IXMLDOMDocument
*doc
;
8285 IXMLDOMNodeList
*list
;
8292 doc
= create_document(&IID_IXMLDOMDocument
);
8295 hr
= IXMLDOMDocument_selectSingleNode(doc
, NULL
, NULL
);
8296 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8298 hr
= IXMLDOMDocument_selectNodes(doc
, NULL
, NULL
);
8299 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8301 str
= SysAllocString( szComplete4
);
8302 hr
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
8303 ok( hr
== S_OK
, "loadXML failed\n");
8304 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
8305 SysFreeString( str
);
8307 hr
= IXMLDOMDocument_selectSingleNode(doc
, NULL
, NULL
);
8308 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8310 hr
= IXMLDOMDocument_selectNodes(doc
, NULL
, NULL
);
8311 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8313 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("lc"), NULL
);
8314 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8316 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("lc"), NULL
);
8317 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8319 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("lc"), &node
);
8320 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8321 IXMLDOMNode_Release(node
);
8323 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("lc"), &list
);
8324 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8325 IXMLDOMNodeList_Release(list
);
8327 list
= (void*)0xdeadbeef;
8328 hr
= IXMLDOMDocument_selectNodes(doc
, NULL
, &list
);
8329 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8330 ok(list
== (void*)0xdeadbeef, "got %p\n", list
);
8332 node
= (void*)0xdeadbeef;
8333 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("nonexistent"), &node
);
8334 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
8335 ok(node
== 0, "got %p\n", node
);
8337 list
= (void*)0xdeadbeef;
8338 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("nonexistent"), &list
);
8339 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8341 hr
= IXMLDOMNodeList_get_length(list
, &len
);
8342 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8343 ok(len
== 0, "got %d\n", len
);
8344 IXMLDOMNodeList_Release(list
);
8346 IXMLDOMDocument_Release(doc
);
8350 static void test_events(void)
8352 IConnectionPointContainer
*conn
;
8353 IConnectionPoint
*point
;
8354 IXMLDOMDocument
*doc
;
8357 doc
= create_document(&IID_IXMLDOMDocument
);
8360 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IConnectionPointContainer
, (void**)&conn
);
8361 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8363 hr
= IConnectionPointContainer_FindConnectionPoint(conn
, &IID_IDispatch
, &point
);
8364 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8365 IConnectionPoint_Release(point
);
8366 hr
= IConnectionPointContainer_FindConnectionPoint(conn
, &IID_IPropertyNotifySink
, &point
);
8367 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8368 IConnectionPoint_Release(point
);
8369 hr
= IConnectionPointContainer_FindConnectionPoint(conn
, &DIID_XMLDOMDocumentEvents
, &point
);
8370 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8371 IConnectionPoint_Release(point
);
8373 IConnectionPointContainer_Release(conn
);
8375 IXMLDOMDocument_Release(doc
);
8378 static void test_createProcessingInstruction(void)
8380 static const WCHAR bodyW
[] = {'t','e','s','t',0};
8381 IXMLDOMProcessingInstruction
*pi
;
8382 IXMLDOMDocument
*doc
;
8386 doc
= create_document(&IID_IXMLDOMDocument
);
8389 /* test for BSTR handling, pass broken BSTR */
8390 memcpy(&buff
[2], bodyW
, sizeof(bodyW
));
8391 /* just a big length */
8392 *(DWORD
*)buff
= 0xf0f0;
8393 hr
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("test"), &buff
[2], &pi
);
8394 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8396 IXMLDOMProcessingInstruction_Release(pi
);
8397 IXMLDOMDocument_Release(doc
);
8400 static void test_put_nodeTypedValue(void)
8402 IXMLDOMDocument
*doc
;
8403 IXMLDOMElement
*elem
;
8407 doc
= create_document(&IID_IXMLDOMDocument
);
8410 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Element"), &elem
);
8411 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8413 V_VT(&type
) = VT_EMPTY
;
8414 hr
= IXMLDOMElement_get_dataType(elem
, &type
);
8415 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
8416 ok(V_VT(&type
) == VT_NULL
, "got %d, expected VT_NULL\n", V_VT(&type
));
8418 /* set typed value for untyped node */
8419 V_VT(&type
) = VT_I1
;
8421 hr
= IXMLDOMElement_put_nodeTypedValue(elem
, type
);
8422 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8424 V_VT(&type
) = VT_EMPTY
;
8425 hr
= IXMLDOMElement_get_dataType(elem
, &type
);
8426 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
8427 ok(V_VT(&type
) == VT_NULL
, "got %d, expected VT_NULL\n", V_VT(&type
));
8429 /* no type info stored */
8430 V_VT(&type
) = VT_EMPTY
;
8431 hr
= IXMLDOMElement_get_nodeTypedValue(elem
, &type
);
8432 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8433 ok(V_VT(&type
) == VT_BSTR
, "got %d, expected VT_BSTR\n", V_VT(&type
));
8434 ok(memcmp(V_BSTR(&type
), _bstr_("1"), 2*sizeof(WCHAR
)) == 0,
8435 "got %s, expected \"1\"\n", wine_dbgstr_w(V_BSTR(&type
)));
8436 VariantClear(&type
);
8438 IXMLDOMDocument_Release(doc
);
8442 static void test_get_xml(void)
8444 static const char xmlA
[] = "<?xml version=\"1.0\" encoding=\"UTF-16\"?>\r\n<a>test</a>\r\n";
8445 IXMLDOMProcessingInstruction
*pi
;
8447 IXMLDOMDocument
*doc
;
8453 doc
= create_document(&IID_IXMLDOMDocument
);
8457 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_("<a>test</a>"), &b
);
8458 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8459 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
8461 hr
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"),
8462 _bstr_("version=\"1.0\" encoding=\"UTF-16\""), &pi
);
8463 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8465 hr
= IXMLDOMDocument_get_firstChild(doc
, &first
);
8466 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8468 V_UNKNOWN(&v
) = (IUnknown
*)first
;
8469 V_VT(&v
) = VT_UNKNOWN
;
8471 hr
= IXMLDOMDocument_insertBefore(doc
, (IXMLDOMNode
*)pi
, v
, NULL
);
8472 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8474 IXMLDOMProcessingInstruction_Release(pi
);
8475 IXMLDOMNode_Release(first
);
8477 hr
= IXMLDOMDocument_get_xml(doc
, &xml
);
8478 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8480 ok(memcmp(xml
, _bstr_(xmlA
), sizeof(xmlA
)*sizeof(WCHAR
)) == 0,
8481 "got %s, expected %s\n", wine_dbgstr_w(xml
), xmlA
);
8484 IXMLDOMDocument_Release(doc
);
8489 IXMLDOMDocument
*doc
;
8492 hr
= CoInitialize( NULL
);
8493 ok( hr
== S_OK
, "failed to init com\n");
8499 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (void**)&doc
);
8502 win_skip("IXMLDOMDocument is not available (0x%08x)\n", hr
);
8506 IXMLDOMDocument_Release(doc
);
8509 test_persiststreaminit();
8513 test_getElementsByTagName();
8515 test_get_childNodes();
8516 test_get_firstChild();
8517 test_get_lastChild();
8519 test_replaceChild();
8520 test_removeNamedItem();
8521 test_IXMLDOMDocument2();
8527 test_nodeTypeTests();
8528 test_DocumentSaveToDocument();
8529 test_DocumentSaveToFile();
8530 test_testTransforms();
8532 test_FormattingXML();
8533 test_nodeTypedValue();
8534 test_TransformWithLoadingLocalFile();
8535 test_put_nodeValue();
8536 test_document_IObjectSafety();
8538 test_getQualifiedItem();
8539 test_removeQualifiedItem();
8540 test_get_ownerDocument();
8541 test_setAttributeNode();
8542 test_get_dataType();
8543 test_put_dataType();
8546 test_default_properties();
8547 test_selectSingleNode();
8549 test_createProcessingInstruction();
8550 test_put_nodeTypedValue();