4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2007-2008 Alistair Leslie-Hughes
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "msxml2did.h"
34 #include "wine/test.h"
36 static const WCHAR szEmpty[] = { 0 };
37 static const WCHAR szIncomplete[] = {
38 '<','?','x','m','l',' ',
39 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
41 static const WCHAR szComplete1[] = {
42 '<','?','x','m','l',' ',
43 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
44 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
46 static const WCHAR szComplete2[] = {
47 '<','?','x','m','l',' ',
48 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
49 '<','o','>','<','/','o','>','\n',0
51 static const WCHAR szComplete3[] = {
52 '<','?','x','m','l',' ',
53 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
54 '<','a','>','<','/','a','>','\n',0
56 static const WCHAR szComplete4[] = {
57 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
58 '<','l','c',' ','d','l','=','\'','s','t','r','1','\'','>','\n',
59 '<','b','s',' ','v','r','=','\'','s','t','r','2','\'',' ','s','z','=','\'','1','2','3','4','\'','>',
60 'f','n','1','.','t','x','t','\n',
61 '<','/','b','s','>','\n',
62 '<','p','r',' ','i','d','=','\'','s','t','r','3','\'',' ','v','r','=','\'','1','.','2','.','3','\'',' ',
63 'p','n','=','\'','w','i','n','e',' ','2','0','0','5','0','8','0','4','\'','>','\n',
64 'f','n','2','.','t','x','t','\n',
65 '<','/','p','r','>','\n',
66 '<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
70 '<','/','b','a','>','\n',
71 '<','/','f','o','>','\n',
72 '<','/','l','c','>','\n',0
74 static const WCHAR szComplete5[] = {
75 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
76 'x','m','l','n','s',':','C','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y','"',
77 ' ','x','m','l','n','s',':','S','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y',':','s','e','a','r','c','h','"','>',
78 '<','S',':','s','c','o','p','e','>',
79 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
80 '<','/','S',':','s','c','o','p','e','>',
81 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
82 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
83 'c','o','m','p','u','t','e','r',
84 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
85 '<','/','S',':','s','e','a','r','c','h','>',0
88 static const CHAR szExampleXML[] =
89 "<?xml version='1.0' encoding='utf-8'?>\n"
90 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
95 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
96 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
97 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
105 " <c type=\"old\">C2 field</c>\n"
108 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
117 " <foo:c>C4 field</foo:c>\n"
121 static const CHAR szTransformXML[] =
122 "<?xml version=\"1.0\"?>\n"
127 static const CHAR szTransformSSXML[] =
128 "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n"
129 " <xsl:output method=\"html\"/>\n"
130 " <xsl:template match=\"/\">\n"
131 " <xsl:apply-templates select=\"greeting\"/>\n"
133 " <xsl:template match=\"greeting\">\n"
137 " <xsl:value-of select=\".\"/>\n"
144 static const CHAR szTransformOutput[] =
147 "</h1></body></html>";
149 static const CHAR szTypeValueXML[] =
150 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
151 "<root xmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n"
152 " <string>Wine</string>\n"
153 " <string2 dt:dt=\"string\">String</string2>\n"
154 " <number dt:dt=\"number\">12.44</number>\n"
155 " <number2 dt:dt=\"NUMbEr\">-3.71e3</number2>\n"
156 " <int dt:dt=\"int\">-13</int>\n"
157 " <fixed dt:dt=\"fixed.14.4\">7322.9371</fixed>\n"
158 " <bool dt:dt=\"boolean\">1</bool>\n"
159 " <datetime dt:dt=\"datetime\">2009-11-18T03:21:33.12</datetime>\n"
160 " <datetimetz dt:dt=\"datetime.tz\">2003-07-11T11:13:57+03:00</datetimetz>\n"
161 " <date dt:dt=\"date\">3721-11-01</date>\n"
162 " <time dt:dt=\"time\">13:57:12.31321</time>\n"
163 " <timetz dt:dt=\"time.tz\">23:21:01.13+03:21</timetz>\n"
164 " <i1 dt:dt=\"i1\">-13</i1>\n"
165 " <i2 dt:dt=\"i2\">31915</i2>\n"
166 " <i4 dt:dt=\"i4\">-312232</i4>\n"
167 " <ui1 dt:dt=\"ui1\">123</ui1>\n"
168 " <ui2 dt:dt=\"ui2\">48282</ui2>\n"
169 " <ui4 dt:dt=\"ui4\">949281</ui4>\n"
170 " <r4 dt:dt=\"r4\">213124.0</r4>\n"
171 " <r8 dt:dt=\"r8\">0.412</r8>\n"
172 " <float dt:dt=\"float\">41221.421</float>\n"
173 " <uuid dt:dt=\"uuid\">333C7BC4-460F-11D0-BC04-0080C7055a83</uuid>\n"
174 " <binhex dt:dt=\"bin.hex\">fffca012003c</binhex>\n"
175 " <binbase64 dt:dt=\"bin.base64\">YmFzZTY0IHRlc3Q=</binbase64>\n"
178 static const CHAR szBasicTransformSSXMLPart1[] =
179 "<?xml version=\"1.0\"?>"
180 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >"
181 "<xsl:output method=\"html\"/>\n"
182 "<xsl:template match=\"/\">"
183 "<HTML><BODY><TABLE>"
184 " <xsl:apply-templates select='document(\"";
186 static const CHAR szBasicTransformSSXMLPart2[] =
188 " <xsl:sort select=\"cost\"/><xsl:sort select=\"name\"/>"
189 " </xsl:apply-templates>"
190 "</TABLE></BODY></HTML>"
192 "<xsl:template match=\"bottle\">"
193 " <TR><xsl:apply-templates select=\"name\" /><xsl:apply-templates select=\"cost\" /></TR>"
195 "<xsl:template match=\"name\">"
196 " <TD><xsl:apply-templates /></TD>"
198 "<xsl:template match=\"cost\">"
199 " <TD><xsl:apply-templates /></TD>"
203 static const CHAR szBasicTransformXML[] =
204 "<?xml version=\"1.0\"?><bottle><wine><name>Wine</name><cost>$25.00</cost></wine></bottle>";
206 static const CHAR szBasicTransformOutput[] =
207 "<HTML><BODY><TABLE><TD>Wine</TD><TD>$25.00</TD></TABLE></BODY></HTML>";
209 static const WCHAR szNonExistentFile[] = {
210 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
212 static const WCHAR szNonExistentAttribute[] = {
213 'n','o','n','E','x','i','s','i','t','i','n','g','A','t','t','r','i','b','u','t','e',0
215 static const WCHAR szDocument[] = {
216 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
219 static const WCHAR szOpen[] = { 'o','p','e','n',0 };
220 static WCHAR szdl[] = { 'd','l',0 };
221 static const WCHAR szvr[] = { 'v','r',0 };
222 static const WCHAR szlc[] = { 'l','c',0 };
223 static WCHAR szbs[] = { 'b','s',0 };
224 static const WCHAR szstr1[] = { 's','t','r','1',0 };
225 static const WCHAR szstr2[] = { 's','t','r','2',0 };
226 static const WCHAR szstar[] = { '*',0 };
227 static const WCHAR szfn1_txt[] = {'f','n','1','.','t','x','t',0};
229 static WCHAR szComment[] = {'A',' ','C','o','m','m','e','n','t',0 };
230 static WCHAR szCommentXML[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
231 static WCHAR szCommentNodeText[] = {'#','c','o','m','m','e','n','t',0 };
233 static WCHAR szElement[] = {'E','l','e','T','e','s','t', 0 };
234 static WCHAR szElementXML[] = {'<','E','l','e','T','e','s','t','/','>',0 };
235 static WCHAR szElementXML2[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
236 static WCHAR szElementXML3[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
237 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
238 static WCHAR szElementXML4[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
239 '&','a','m','p',';','x',' ',0x2103,'<','/','E','l','e','T','e','s','t','>',0 };
241 static WCHAR szAttribute[] = {'A','t','t','r',0 };
242 static WCHAR szAttributeXML[] = {'A','t','t','r','=','"','"',0 };
244 static WCHAR szCData[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
245 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
246 static WCHAR szCDataXML[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
247 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
249 static WCHAR szCDataNodeText[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
250 static WCHAR szDocFragmentText[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
252 static WCHAR szEntityRef[] = {'e','n','t','i','t','y','r','e','f',0 };
253 static WCHAR szEntityRefXML[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
254 static WCHAR szStrangeChars[] = {'&','x',' ',0x2103, 0};
256 #define expect_bstr_eq_and_free(bstr, expect) { \
257 BSTR bstrExp = alloc_str_from_narrow(expect); \
258 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
259 SysFreeString(bstr); \
260 SysFreeString(bstrExp); \
263 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
265 #define ole_check(expr) { \
267 ok(r == S_OK, #expr " returned %x\n", r); \
270 #define ole_expect(expr, expect) { \
272 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
275 #define double_eq(x, y) ok((x)-(y)<=1e-14*(x) && (x)-(y)>=-1e-14*(x), "expected %.16g, got %.16g\n", x, y)
277 static BSTR alloc_str_from_narrow(const char *str)
279 int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
280 BSTR ret = SysAllocStringLen(NULL, len - 1); /* NUL character added automatically */
281 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
285 BSTR alloced_bstrs[256];
286 int alloced_bstrs_count = 0;
288 static BSTR _bstr_(const char *str)
290 assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
291 alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
292 return alloced_bstrs[alloced_bstrs_count++];
295 static void free_bstrs(void)
298 for (i = 0; i < alloced_bstrs_count; i++)
299 SysFreeString(alloced_bstrs[i]);
300 alloced_bstrs_count = 0;
303 static VARIANT _variantbstr_(const char *str)
307 V_BSTR(&v) = _bstr_(str);
311 static BOOL compareIgnoreReturns(BSTR sLeft, BSTR sRight)
315 while (*sLeft == '\r' || *sLeft == '\n') sLeft++;
316 while (*sRight == '\r' || *sRight == '\n') sRight++;
317 if (*sLeft != *sRight) return FALSE;
318 if (!*sLeft) return TRUE;
324 static BOOL compareIgnoreReturnsWhitespace(BSTR sLeft, BSTR sRight)
326 /* MSXML3 inserts whitespace where as libxml doesn't. */
329 while (*sLeft == '\r' || *sLeft == '\n' || *sLeft == ' ') sLeft++;
330 while (*sRight == '\r' || *sRight == '\n' || *sRight == ' ') sRight++;
331 if (*sLeft != *sRight) return FALSE;
332 if (!*sLeft) return TRUE;
338 static void get_str_for_type(DOMNodeType type, char *buf)
352 wsprintfA(buf, "[%d]", type);
356 #define test_disp(u) _test_disp(__LINE__,u)
357 static void _test_disp(unsigned line, IUnknown *unk)
359 DISPID dispid = DISPID_XMLDOM_NODELIST_RESET;
367 hres = IUnknown_QueryInterface(unk, &IID_IDispatchEx, (void**)&dispex);
368 ok_(__FILE__,line) (hres == S_OK, "Could not get IDispatch: %08x\n", hres);
373 hres = IDispatchEx_GetTypeInfoCount(dispex, &ticnt);
374 ok_(__FILE__,line) (hres == S_OK, "GetTypeInfoCount failed: %08x\n", hres);
375 ok_(__FILE__,line) (ticnt == 1, "ticnt=%u\n", ticnt);
377 sName = SysAllocString( szstar );
378 hres = IDispatchEx_DeleteMemberByName(dispex, sName, fdexNameCaseSensitive);
379 ok(hres == E_NOTIMPL, "expected E_NOTIMPL got %08x\n", hres);
380 SysFreeString( sName );
382 hres = IDispatchEx_DeleteMemberByDispID(dispex, dispid);
383 ok(hres == E_NOTIMPL, "expected E_NOTIMPL got %08x\n", hres);
385 hres = IDispatchEx_GetMemberProperties(dispex, dispid, grfdexPropCanAll, &dwProps);
386 ok(hres == E_NOTIMPL, "expected E_NOTIMPL got %08x\n", hres);
387 ok(dwProps == 0, "expected 0 got %d\n", dwProps);
389 hres = IDispatchEx_GetMemberName(dispex, dispid, &sName);
390 ok(hres == E_NOTIMPL, "expected E_NOTIMPL got %08x\n", hres);
392 SysFreeString(sName);
394 hres = IDispatchEx_GetNextDispID(dispex, fdexEnumDefault, DISPID_XMLDOM_NODELIST_RESET, &dispid);
395 ok(hres == E_NOTIMPL, "expected E_NOTIMPL got %08x\n", hres);
397 hres = IDispatchEx_GetNameSpaceParent(dispex, &pUnk);
398 ok(hres == E_NOTIMPL, "expected E_NOTIMPL got %08x\n", hres);
399 if(hres == S_OK && pUnk)
400 IUnknown_Release(pUnk);
402 IDispatchEx_Release(dispex);
405 static int get_node_position(IXMLDOMNode *node)
410 IXMLDOMNode_AddRef(node);
413 IXMLDOMNode *new_node;
416 r = IXMLDOMNode_get_previousSibling(node, &new_node);
417 ok(SUCCEEDED(r), "get_previousSibling failed\n");
418 IXMLDOMNode_Release(node);
424 static void node_to_string(IXMLDOMNode *node, char *buf)
431 lstrcpyA(buf, "(null)");
435 IXMLDOMNode_AddRef(node);
438 IXMLDOMNode *new_node;
440 ole_check(IXMLDOMNode_get_nodeType(node, &type));
441 get_str_for_type(type, buf);
444 if (type == NODE_ATTRIBUTE)
447 ole_check(IXMLDOMNode_get_nodeName(node, &bstr));
449 wsprintfA(buf, "%ws", bstr);
454 r = IXMLDOMNode_selectSingleNode(node, _bstr_(".."), &new_node);
458 int pos = get_node_position(node);
459 DOMNodeType parent_type = NODE_INVALID;
460 r = IXMLDOMNode_get_parentNode(node, &new_node);
462 /* currently wine doesn't create a node for the <?xml ... ?>. To be able to test query
463 * results we "fix" it */
465 ole_check(IXMLDOMNode_get_nodeType(new_node, &parent_type));
466 if ((parent_type == NODE_DOCUMENT) && type != NODE_PROCESSING_INSTRUCTION && pos==1)
468 todo_wine ok(FALSE, "The first child of the document node in MSXML is the <?xml ... ?> processing instruction\n");
471 wsprintf(buf, "%d", pos);
475 ok(SUCCEEDED(r), "get_parentNode failed (%08x)\n", r);
476 IXMLDOMNode_Release(node);
485 static char *list_to_string(IXMLDOMNodeList *list)
487 static char buf[4096];
494 lstrcpyA(buf, "(null)");
497 ole_check(IXMLDOMNodeList_get_length(list, &len));
498 for (i = 0; i < len; i++)
503 ole_check(IXMLDOMNodeList_nextNode(list, &node));
504 node_to_string(node, pos);
506 IXMLDOMNode_Release(node);
512 #define expect_node(node, expstr) { char str[4096]; node_to_string(node, str); ok(strcmp(str, expstr)==0, "Invalid node: %s, expected %s\n", str, expstr); }
513 #define expect_list_and_release(list, expstr) { char *str = list_to_string(list); ok(strcmp(str, expstr)==0, "Invalid node list: %s, expected %s\n", str, expstr); if (list) IXMLDOMNodeList_Release(list); }
515 static void test_domdoc( void )
518 IXMLDOMDocument *doc = NULL;
519 IXMLDOMParseError *error;
520 IXMLDOMElement *element = NULL;
522 IXMLDOMText *nodetext = NULL;
523 IXMLDOMComment *node_comment = NULL;
524 IXMLDOMAttribute *node_attr = NULL;
525 IXMLDOMNode *nodeChild = NULL;
526 IXMLDOMProcessingInstruction *nodePI = NULL;
527 ISupportErrorInfo *support_error = NULL;
534 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
535 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
539 test_disp((IUnknown*)doc);
541 /* try some stupid things */
542 r = IXMLDOMDocument_loadXML( doc, NULL, NULL );
543 ok( r == S_FALSE, "loadXML failed\n");
546 r = IXMLDOMDocument_loadXML( doc, NULL, &b );
547 ok( r == S_FALSE, "loadXML failed\n");
548 ok( b == VARIANT_FALSE, "failed to load XML string\n");
550 /* try to load a document from a nonexistent file */
552 str = SysAllocString( szNonExistentFile );
554 V_VT(&var) = VT_BSTR;
557 r = IXMLDOMDocument_load( doc, var, &b);
558 ok( r == S_FALSE, "load (from file) failed\n");
559 ok( b == VARIANT_FALSE, "failed to load XML file\n");
560 SysFreeString( str );
562 /* try load an empty document */
564 str = SysAllocString( szEmpty );
565 r = IXMLDOMDocument_loadXML( doc, str, &b );
566 ok( r == S_FALSE, "loadXML failed\n");
567 ok( b == VARIANT_FALSE, "failed to load XML string\n");
568 SysFreeString( str );
570 r = IXMLDOMDocument_get_async( doc, &b );
571 ok( r == S_OK, "get_async failed (%08x)\n", r);
572 ok( b == VARIANT_TRUE, "Wrong default value\n");
574 /* check that there's no document element */
576 r = IXMLDOMDocument_get_documentElement( doc, &element );
577 ok( r == S_FALSE, "should be no document element\n");
579 /* try finding a node */
581 str = SysAllocString( szstr1 );
582 r = IXMLDOMDocument_selectSingleNode( doc, str, &node );
583 ok( r == S_FALSE, "ret %08x\n", r );
584 SysFreeString( str );
587 str = SysAllocString( szIncomplete );
588 r = IXMLDOMDocument_loadXML( doc, str, &b );
589 ok( r == S_FALSE, "loadXML failed\n");
590 ok( b == VARIANT_FALSE, "failed to load XML string\n");
591 SysFreeString( str );
593 /* check that there's no document element */
594 element = (IXMLDOMElement*)1;
595 r = IXMLDOMDocument_get_documentElement( doc, &element );
596 ok( r == S_FALSE, "should be no document element\n");
597 ok( element == NULL, "Element should be NULL\n");
599 /* try to load something valid */
601 str = SysAllocString( szComplete1 );
602 r = IXMLDOMDocument_loadXML( doc, str, &b );
603 ok( r == S_OK, "loadXML failed\n");
604 ok( b == VARIANT_TRUE, "failed to load XML string\n");
605 SysFreeString( str );
607 /* check if nodename is correct */
608 r = IXMLDOMDocument_get_nodeName( doc, NULL );
609 ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
611 /* content doesn't matter here */
613 r = IXMLDOMDocument_get_nodeName( doc, &str );
614 ok ( r == S_OK, "get_nodeName wrong code\n");
615 ok ( str != NULL, "str is null\n");
616 ok( !lstrcmpW( str, szDocument ), "incorrect nodeName\n");
617 SysFreeString( str );
620 r = IXMLDOMDocument_put_text( doc, _bstr_("Should Fail") );
621 ok( r == E_FAIL, "ret %08x\n", r );
623 /* check that there's a document element */
625 r = IXMLDOMDocument_get_documentElement( doc, &element );
626 ok( r == S_OK, "should be a document element\n");
629 IObjectIdentity *ident;
632 test_disp((IUnknown*)element);
634 r = IXMLDOMElement_QueryInterface( element, &IID_IObjectIdentity, (LPVOID*)&ident );
635 ok( r == E_NOINTERFACE, "ret %08x\n", r);
637 /* check if the tag is correct */
638 r = IXMLDOMElement_get_tagName( element, &tag );
639 ok( r == S_OK, "couldn't get tag name\n");
640 ok( tag != NULL, "tag was null\n");
641 ok( !lstrcmpW( tag, szOpen ), "incorrect tag name\n");
642 SysFreeString( tag );
644 /* figure out what happens if we try to reload the document */
645 str = SysAllocString( szComplete2 );
646 r = IXMLDOMDocument_loadXML( doc, str, &b );
647 ok( r == S_OK, "loadXML failed\n");
648 ok( b == VARIANT_TRUE, "failed to load XML string\n");
649 SysFreeString( str );
651 /* check if the tag is still correct */
653 r = IXMLDOMElement_get_tagName( element, &tag );
654 ok( r == S_OK, "couldn't get tag name\n");
655 ok( tag != NULL, "tag was null\n");
656 ok( !lstrcmpW( tag, szOpen ), "incorrect tag name\n");
657 SysFreeString( tag );
659 IXMLDOMElement_Release( element );
663 /* as soon as we call loadXML again, the document element will disappear */
665 r = IXMLDOMDocument_loadXML( doc, NULL, NULL );
666 ok( r == S_FALSE, "loadXML failed\n");
667 ok( b == 2, "variant modified\n");
668 r = IXMLDOMDocument_get_documentElement( doc, &element );
669 ok( r == S_FALSE, "should be no document element\n");
671 /* try to load something else simple and valid */
673 str = SysAllocString( szComplete3 );
674 r = IXMLDOMDocument_loadXML( doc, str, &b );
675 ok( r == S_OK, "loadXML failed\n");
676 ok( b == VARIANT_TRUE, "failed to load XML string\n");
677 SysFreeString( str );
679 /* try something a little more complicated */
681 str = SysAllocString( szComplete4 );
682 r = IXMLDOMDocument_loadXML( doc, str, &b );
683 ok( r == S_OK, "loadXML failed\n");
684 ok( b == VARIANT_TRUE, "failed to load XML string\n");
685 SysFreeString( str );
687 r = IXMLDOMDocument_get_parseError( doc, &error );
688 ok( r == S_OK, "returns %08x\n", r );
690 r = IXMLDOMParseError_get_errorCode( error, &code );
691 ok( r == S_FALSE, "returns %08x\n", r );
692 ok( code == 0, "code %d\n", code );
693 IXMLDOMParseError_Release( error );
695 /* test createTextNode */
696 str = SysAllocString( szOpen );
697 r = IXMLDOMDocument_createTextNode(doc, str, NULL);
698 ok( r == E_INVALIDARG, "returns %08x\n", r );
699 r = IXMLDOMDocument_createTextNode(doc, str, &nodetext);
700 ok( r == S_OK, "returns %08x\n", r );
701 SysFreeString( str );
704 IXMLDOMNamedNodeMap *pAttribs;
706 r = IXMLDOMText_QueryInterface(nodetext, &IID_IXMLDOMElement, (LPVOID*)&element);
707 ok(r == E_NOINTERFACE, "ret %08x\n", r );
709 /* Text Last Child Checks */
710 r = IXMLDOMText_get_lastChild(nodetext, NULL);
711 ok(r == E_INVALIDARG, "ret %08x\n", r );
713 nodeChild = (IXMLDOMNode*)0x1;
714 r = IXMLDOMText_get_lastChild(nodetext, &nodeChild);
715 ok(r == S_FALSE, "ret %08x\n", r );
716 ok(nodeChild == NULL, "nodeChild not NULL\n");
718 /* test get_attributes */
719 r = IXMLDOMText_get_attributes( nodetext, NULL );
720 ok( r == E_INVALIDARG, "get_attributes returned wrong code\n");
722 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
723 r = IXMLDOMText_get_attributes( nodetext, &pAttribs);
724 ok(r == S_FALSE, "ret %08x\n", r );
725 ok( pAttribs == NULL, "pAttribs not NULL\n");
727 /* test get_dataType */
728 r = IXMLDOMText_get_dataType(nodetext, &var);
729 ok(r == S_FALSE, "ret %08x\n", r );
730 ok( V_VT(&var) == VT_NULL, "incorrect dataType type\n");
733 /* test length property */
734 r = IXMLDOMText_get_length(nodetext, NULL);
735 ok(r == E_INVALIDARG, "ret %08x\n", r );
737 r = IXMLDOMText_get_length(nodetext, &nLength);
738 ok(r == S_OK, "ret %08x\n", r );
739 ok(nLength == 4, "expected 4 got %d\n", nLength);
741 /* test nodeTypeString */
742 r = IXMLDOMText_get_nodeTypeString(nodetext, &str);
743 ok(r == S_OK, "ret %08x\n", r );
744 ok( !lstrcmpW( str, _bstr_("text") ), "incorrect nodeTypeString string\n");
748 r = IXMLDOMText_put_data(nodetext, _bstr_("This &is a ; test <>\\"));
749 ok(r == S_OK, "ret %08x\n", r );
752 r = IXMLDOMText_get_data(nodetext, &str);
753 ok(r == S_OK, "ret %08x\n", r );
754 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
757 /* Confirm XML text is good */
758 r = IXMLDOMText_get_xml(nodetext, &str);
759 ok(r == S_OK, "ret %08x\n", r );
760 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
763 /* Confirm we get the put_data Text back */
764 r = IXMLDOMText_get_text(nodetext, &str);
765 ok(r == S_OK, "ret %08x\n", r );
766 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
769 /* test substringData */
770 r = IXMLDOMText_substringData(nodetext, 0, 4, NULL);
771 ok(r == E_INVALIDARG, "ret %08x\n", r );
773 /* test substringData - Invalid offset */
774 str = (BSTR)&szElement;
775 r = IXMLDOMText_substringData(nodetext, -1, 4, &str);
776 ok(r == E_INVALIDARG, "ret %08x\n", r );
777 ok( str == NULL, "incorrect string\n");
779 /* test substringData - Invalid offset */
780 str = (BSTR)&szElement;
781 r = IXMLDOMText_substringData(nodetext, 30, 0, &str);
782 ok(r == S_FALSE, "ret %08x\n", r );
783 ok( str == NULL, "incorrect string\n");
785 /* test substringData - Invalid size */
786 str = (BSTR)&szElement;
787 r = IXMLDOMText_substringData(nodetext, 0, -1, &str);
788 ok(r == E_INVALIDARG, "ret %08x\n", r );
789 ok( str == NULL, "incorrect string\n");
791 /* test substringData - Invalid size */
792 str = (BSTR)&szElement;
793 r = IXMLDOMText_substringData(nodetext, 2, 0, &str);
794 ok(r == S_FALSE, "ret %08x\n", r );
795 ok( str == NULL, "incorrect string\n");
797 /* test substringData - Start of string */
798 r = IXMLDOMText_substringData(nodetext, 0, 4, &str);
799 ok(r == S_OK, "ret %08x\n", r );
800 ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
803 /* test substringData - Middle of string */
804 r = IXMLDOMText_substringData(nodetext, 13, 4, &str);
805 ok(r == S_OK, "ret %08x\n", r );
806 ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
809 /* test substringData - End of string */
810 r = IXMLDOMText_substringData(nodetext, 20, 4, &str);
811 ok(r == S_OK, "ret %08x\n", r );
812 ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
815 /* test appendData */
816 r = IXMLDOMText_appendData(nodetext, NULL);
817 ok(r == S_OK, "ret %08x\n", r );
819 r = IXMLDOMText_appendData(nodetext, _bstr_(""));
820 ok(r == S_OK, "ret %08x\n", r );
822 r = IXMLDOMText_appendData(nodetext, _bstr_("Append"));
823 ok(r == S_OK, "ret %08x\n", r );
825 r = IXMLDOMText_get_text(nodetext, &str);
826 ok(r == S_OK, "ret %08x\n", r );
827 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
830 /* test insertData */
831 str = SysAllocStringLen(NULL, 0);
832 r = IXMLDOMText_insertData(nodetext, -1, str);
833 ok(r == S_OK, "ret %08x\n", r );
835 r = IXMLDOMText_insertData(nodetext, -1, NULL);
836 ok(r == S_OK, "ret %08x\n", r );
838 r = IXMLDOMText_insertData(nodetext, 1000, str);
839 ok(r == S_OK, "ret %08x\n", r );
841 r = IXMLDOMText_insertData(nodetext, 1000, NULL);
842 ok(r == S_OK, "ret %08x\n", r );
844 r = IXMLDOMText_insertData(nodetext, 0, NULL);
845 ok(r == S_OK, "ret %08x\n", r );
847 r = IXMLDOMText_insertData(nodetext, 0, str);
848 ok(r == S_OK, "ret %08x\n", r );
851 r = IXMLDOMText_insertData(nodetext, -1, _bstr_("Inserting"));
852 ok(r == E_INVALIDARG, "ret %08x\n", r );
854 r = IXMLDOMText_insertData(nodetext, 1000, _bstr_("Inserting"));
855 ok(r == E_INVALIDARG, "ret %08x\n", r );
857 r = IXMLDOMText_insertData(nodetext, 0, _bstr_("Begin "));
858 ok(r == S_OK, "ret %08x\n", r );
860 r = IXMLDOMText_insertData(nodetext, 17, _bstr_("Middle"));
861 ok(r == S_OK, "ret %08x\n", r );
863 r = IXMLDOMText_insertData(nodetext, 39, _bstr_(" End"));
864 ok(r == S_OK, "ret %08x\n", r );
866 r = IXMLDOMText_get_text(nodetext, &str);
867 ok(r == S_OK, "ret %08x\n", r );
868 ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
872 /* invalid arguments */
873 r = IXMLDOMText_deleteData(nodetext, -1, 1);
874 ok(r == E_INVALIDARG, "ret %08x\n", r );
876 r = IXMLDOMText_deleteData(nodetext, 0, 0);
877 ok(r == S_OK, "ret %08x\n", r );
879 r = IXMLDOMText_deleteData(nodetext, 0, -1);
880 ok(r == E_INVALIDARG, "ret %08x\n", r );
882 r = IXMLDOMText_get_length(nodetext, &nLength);
883 ok(r == S_OK, "ret %08x\n", r );
884 ok(nLength == 43, "expected 43 got %d\n", nLength);
886 r = IXMLDOMText_deleteData(nodetext, nLength, 1);
887 ok(r == S_OK, "ret %08x\n", r );
889 r = IXMLDOMText_deleteData(nodetext, nLength+1, 1);
890 ok(r == E_INVALIDARG, "ret %08x\n", r );
892 /* delete from start */
893 r = IXMLDOMText_deleteData(nodetext, 0, 5);
894 ok(r == S_OK, "ret %08x\n", r );
896 r = IXMLDOMText_get_length(nodetext, &nLength);
897 ok(r == S_OK, "ret %08x\n", r );
898 ok(nLength == 38, "expected 38 got %d\n", nLength);
900 r = IXMLDOMText_get_text(nodetext, &str);
901 ok(r == S_OK, "ret %08x\n", r );
902 /* whitespace preserving needs to be handled here */
903 todo_wine ok( !lstrcmpW( str, _bstr_("This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
906 /* delete from end */
907 r = IXMLDOMText_deleteData(nodetext, 35, 3);
908 ok(r == S_OK, "ret %08x\n", r );
910 r = IXMLDOMText_get_length(nodetext, &nLength);
911 ok(r == S_OK, "ret %08x\n", r );
912 ok(nLength == 35, "expected 35 got %d\n", nLength);
914 r = IXMLDOMText_get_text(nodetext, &str);
915 ok(r == S_OK, "ret %08x\n", r );
916 todo_wine ok( !lstrcmpW( str, _bstr_("This &is a Middle; test <>\\Append") ), "incorrect get_text string\n");
919 /* delete from inside */
920 r = IXMLDOMText_deleteData(nodetext, 1, 33);
921 ok(r == S_OK, "ret %08x\n", r );
923 r = IXMLDOMText_get_length(nodetext, &nLength);
924 ok(r == S_OK, "ret %08x\n", r );
925 ok(nLength == 2, "expected 2 got %d\n", nLength);
927 r = IXMLDOMText_get_text(nodetext, &str);
928 ok(r == S_OK, "ret %08x\n", r );
929 todo_wine ok( !lstrcmpW( str, _bstr_("") ), "incorrect get_text string\n");
932 /* delete whole data ... */
933 r = IXMLDOMText_get_length(nodetext, &nLength);
934 ok(r == S_OK, "ret %08x\n", r );
936 r = IXMLDOMText_deleteData(nodetext, 0, nLength);
937 ok(r == S_OK, "ret %08x\n", r );
938 /* ... and try again with empty string */
939 r = IXMLDOMText_deleteData(nodetext, 0, nLength);
940 ok(r == S_OK, "ret %08x\n", r );
943 V_VT(&var) = VT_BSTR;
944 V_BSTR(&var) = SysAllocString(szstr1);
945 r = IXMLDOMText_put_nodeValue(nodetext, var);
946 ok(r == S_OK, "ret %08x\n", r );
949 r = IXMLDOMText_get_text(nodetext, &str);
950 ok(r == S_OK, "ret %08x\n", r );
951 ok( !lstrcmpW( str, szstr1 ), "incorrect get_text string\n");
957 r = IXMLDOMText_put_nodeValue(nodetext, var);
958 ok(r == S_OK, "ret %08x\n", r );
961 r = IXMLDOMText_get_text(nodetext, &str);
962 ok(r == S_OK, "ret %08x\n", r );
963 ok( !lstrcmpW( str, _bstr_("99") ), "incorrect get_text string\n");
966 IXMLDOMText_Release( nodetext );
969 /* test Create Comment */
970 r = IXMLDOMDocument_createComment(doc, NULL, NULL);
971 ok( r == E_INVALIDARG, "returns %08x\n", r );
972 r = IXMLDOMDocument_createComment(doc, szComment, &node_comment);
973 ok( r == S_OK, "returns %08x\n", r );
976 /* Last Child Checks */
977 r = IXMLDOMComment_get_lastChild(node_comment, NULL);
978 ok(r == E_INVALIDARG, "ret %08x\n", r );
980 nodeChild = (IXMLDOMNode*)0x1;
981 r = IXMLDOMComment_get_lastChild(node_comment, &nodeChild);
982 ok(r == S_FALSE, "ret %08x\n", r );
983 ok(nodeChild == NULL, "pLastChild not NULL\n");
985 IXMLDOMComment_Release( node_comment );
988 /* test Create Attribute */
989 r = IXMLDOMDocument_createAttribute(doc, NULL, NULL);
990 ok( r == E_INVALIDARG, "returns %08x\n", r );
991 r = IXMLDOMDocument_createAttribute(doc, szAttribute, &node_attr);
992 ok( r == S_OK, "returns %08x\n", r );
993 IXMLDOMText_Release( node_attr);
995 /* test Processing Instruction */
996 str = SysAllocStringLen(NULL, 0);
997 r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, NULL);
998 ok( r == E_INVALIDARG, "returns %08x\n", r );
999 r = IXMLDOMDocument_createProcessingInstruction(doc, NULL, str, &nodePI);
1000 ok( r == E_FAIL, "returns %08x\n", r );
1001 r = IXMLDOMDocument_createProcessingInstruction(doc, str, str, &nodePI);
1002 ok( r == E_FAIL, "returns %08x\n", r );
1005 r = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI);
1006 ok( r == S_OK, "returns %08x\n", r );
1009 /* Last Child Checks */
1010 r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, NULL);
1011 ok(r == E_INVALIDARG, "ret %08x\n", r );
1013 nodeChild = (IXMLDOMNode*)0x1;
1014 r = IXMLDOMProcessingInstruction_get_lastChild(nodePI, &nodeChild);
1015 ok(r == S_FALSE, "ret %08x\n", r );
1016 ok(nodeChild == NULL, "nodeChild not NULL\n");
1018 r = IXMLDOMProcessingInstruction_get_dataType(nodePI, &var);
1019 ok(r == S_FALSE, "ret %08x\n", r );
1020 ok( V_VT(&var) == VT_NULL, "incorrect dataType type\n");
1024 r = IXMLDOMProcessingInstruction_get_nodeName(nodePI, &str);
1025 ok(r == S_OK, "ret %08x\n", r );
1026 ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n");
1030 r = IXMLDOMProcessingInstruction_get_target(nodePI, &str);
1031 ok(r == S_OK, "ret %08x\n", r );
1032 ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect target string\n");
1035 /* test nodeTypeString */
1036 r = IXMLDOMProcessingInstruction_get_nodeTypeString(nodePI, &str);
1037 ok(r == S_OK, "ret %08x\n", r );
1038 ok( !lstrcmpW( str, _bstr_("processinginstruction") ), "incorrect nodeTypeString string\n");
1041 /* test get_nodeValue */
1042 r = IXMLDOMProcessingInstruction_get_nodeValue(nodePI, &var);
1043 ok(r == S_OK, "ret %08x\n", r );
1044 ok( !lstrcmpW( V_BSTR(&var), _bstr_("version=\"1.0\"") ), "incorrect data string\n");
1048 r = IXMLDOMProcessingInstruction_get_data(nodePI, &str);
1049 ok(r == S_OK, "ret %08x\n", r );
1050 ok( !lstrcmpW( str, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
1054 r = IXMLDOMProcessingInstruction_put_data(nodePI, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
1055 ok(r == E_FAIL, "ret %08x\n", r );
1058 V_VT(&var) = VT_BSTR;
1059 V_BSTR(&var) = SysAllocString(szOpen); /* Doesn't matter what the string is, cannot set an xml node. */
1060 r = IXMLDOMProcessingInstruction_put_nodeValue(nodePI, var);
1061 ok(r == E_FAIL, "ret %08x\n", r );
1064 /* test get nodeName */
1065 r = IXMLDOMProcessingInstruction_get_nodeName(nodePI, &str);
1066 ok( !lstrcmpW( str, _bstr_("xml") ), "incorrect nodeName string\n");
1067 ok(r == S_OK, "ret %08x\n", r );
1070 IXMLDOMProcessingInstruction_Release(nodePI);
1073 r = IXMLDOMDocument_QueryInterface( doc, &IID_ISupportErrorInfo, (LPVOID*)&support_error );
1074 ok( r == S_OK, "ret %08x\n", r );
1077 r = ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error, &IID_IXMLDOMDocument );
1078 todo_wine ok( r == S_OK, "ret %08x\n", r );
1079 ISupportErrorInfo_Release( support_error );
1082 r = IXMLDOMDocument_Release( doc );
1083 ok( r == 0, "document ref count incorrect\n");
1088 static void test_domnode( void )
1091 IXMLDOMDocument *doc = NULL, *owner = NULL;
1092 IXMLDOMElement *element = NULL;
1093 IXMLDOMNamedNodeMap *map = NULL;
1094 IXMLDOMNode *node = NULL, *next = NULL;
1095 IXMLDOMNodeList *list = NULL;
1096 IXMLDOMAttribute *attr = NULL;
1097 DOMNodeType type = NODE_INVALID;
1103 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1104 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1108 ok( FALSE, "no document\n");
1113 str = SysAllocString( szComplete4 );
1114 r = IXMLDOMDocument_loadXML( doc, str, &b );
1115 ok( r == S_OK, "loadXML failed\n");
1116 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1117 SysFreeString( str );
1120 r = IXMLDOMNode_hasChildNodes( doc, &b );
1121 ok( r == S_OK, "hasChildNoes bad return\n");
1122 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
1124 r = IXMLDOMDocument_get_documentElement( doc, &element );
1125 ok( r == S_OK, "should be a document element\n");
1126 ok( element != NULL, "should be an element\n");
1129 ok( V_VT(&var) == VT_EMPTY, "variant init failed\n");
1131 r = IXMLDOMNode_get_nodeValue( doc, NULL );
1132 ok(r == E_INVALIDARG, "get_nodeValue ret %08x\n", r );
1134 r = IXMLDOMNode_get_nodeValue( doc, &var );
1135 ok( r == S_FALSE, "nextNode returned wrong code\n");
1136 ok( V_VT(&var) == VT_NULL, "variant wasn't empty\n");
1137 ok( V_BSTR(&var) == NULL, "variant value wasn't null\n");
1142 r = IXMLDOMNode_get_ownerDocument( element, &owner );
1143 ok( r == S_OK, "get_ownerDocument return code\n");
1144 ok( owner != doc, "get_ownerDocument return\n");
1145 IXMLDOMDocument_Release(owner);
1147 type = NODE_INVALID;
1148 r = IXMLDOMNode_get_nodeType( element, &type);
1149 ok( r == S_OK, "getNamedItem returned wrong code\n");
1150 ok( type == NODE_ELEMENT, "node not an element\n");
1153 r = IXMLDOMNode_get_baseName( element, &str );
1154 ok( r == S_OK, "get_baseName returned wrong code\n");
1155 ok( lstrcmpW(str,szlc) == 0, "basename was wrong\n");
1158 /* check if nodename is correct */
1159 r = IXMLDOMElement_get_nodeName( element, NULL );
1160 ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
1162 /* content doesn't matter here */
1164 r = IXMLDOMElement_get_nodeName( element, &str );
1165 ok ( r == S_OK, "get_nodeName wrong code\n");
1166 ok ( str != NULL, "str is null\n");
1167 ok( !lstrcmpW( str, szlc ), "incorrect nodeName\n");
1168 SysFreeString( str );
1170 str = SysAllocString( szNonExistentFile );
1172 V_I4(&var) = 0x1234;
1173 r = IXMLDOMElement_getAttribute( element, str, &var );
1174 ok( r == E_FAIL, "getAttribute ret %08x\n", r );
1175 ok( V_VT(&var) == VT_NULL || V_VT(&var) == VT_EMPTY, "vt = %x\n", V_VT(&var));
1178 r = IXMLDOMElement_getAttributeNode( element, str, NULL);
1179 ok( r == E_FAIL, "getAttributeNode ret %08x\n", r );
1181 attr = (IXMLDOMAttribute*)0xdeadbeef;
1182 r = IXMLDOMElement_getAttributeNode( element, str, &attr);
1183 ok( r == E_FAIL, "getAttributeNode ret %08x\n", r );
1184 ok( attr == NULL, "getAttributeNode ret %p, expected NULL\n", attr );
1185 SysFreeString( str );
1187 attr = (IXMLDOMAttribute*)0xdeadbeef;
1188 str = SysAllocString( szNonExistentAttribute );
1189 r = IXMLDOMElement_getAttributeNode( element, str, &attr);
1190 ok( r == S_FALSE, "getAttributeNode ret %08x\n", r );
1191 ok( attr == NULL, "getAttributeNode ret %p, expected NULL\n", attr );
1192 SysFreeString( str );
1194 str = SysAllocString( szdl );
1196 V_I4(&var) = 0x1234;
1197 r = IXMLDOMElement_getAttribute( element, str, &var );
1198 ok( r == S_OK, "getAttribute ret %08x\n", r );
1199 ok( V_VT(&var) == VT_BSTR, "vt = %x\n", V_VT(&var));
1200 ok( !lstrcmpW(V_BSTR(&var), szstr1), "wrong attr value\n");
1201 VariantClear( &var );
1203 r = IXMLDOMElement_getAttribute( element, NULL, &var );
1204 ok( r == E_INVALIDARG, "getAttribute ret %08x\n", r );
1206 r = IXMLDOMElement_getAttribute( element, str, NULL );
1207 ok( r == E_INVALIDARG, "getAttribute ret %08x\n", r );
1210 r = IXMLDOMElement_getAttributeNode( element, str, &attr);
1211 ok( r == S_OK, "GetAttributeNode ret %08x\n", r );
1212 ok( attr != NULL, "getAttributeNode returned NULL\n" );
1214 IXMLDOMAttribute_Release(attr);
1216 SysFreeString( str );
1218 r = IXMLDOMElement_get_attributes( element, &map );
1219 ok( r == S_OK, "get_attributes returned wrong code\n");
1220 ok( map != NULL, "should be attributes\n");
1223 r = IXMLDOMNode_hasChildNodes( element, &b );
1224 ok( r == S_OK, "hasChildNoes bad return\n");
1225 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
1228 ok( FALSE, "no element\n");
1232 ISupportErrorInfo *support_error;
1233 r = IXMLDOMNamedNodeMap_QueryInterface( map, &IID_ISupportErrorInfo, (LPVOID*)&support_error );
1234 ok( r == S_OK, "ret %08x\n", r );
1236 r = ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error, &IID_IXMLDOMNamedNodeMap );
1239 ok( r == S_OK, "ret %08x\n", r );
1241 ISupportErrorInfo_Release( support_error );
1243 str = SysAllocString( szdl );
1244 r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
1245 ok( r == S_OK, "getNamedItem returned wrong code\n");
1246 ok( node != NULL, "should be attributes\n");
1247 IXMLDOMNode_Release(node);
1248 SysFreeString( str );
1250 str = SysAllocString( szdl );
1251 r = IXMLDOMNamedNodeMap_getNamedItem( map, str, NULL );
1252 ok( r == E_INVALIDARG, "getNamedItem should return E_INVALIDARG\n");
1253 SysFreeString( str );
1255 /* something that isn't in szComplete4 */
1256 str = SysAllocString( szOpen );
1257 node = (IXMLDOMNode *) 1;
1258 r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
1259 ok( r == S_FALSE, "getNamedItem found a node that wasn't there\n");
1260 ok( node == NULL, "getNamedItem should have returned NULL\n");
1261 SysFreeString( str );
1263 /* test indexed access of attributes */
1264 r = IXMLDOMNamedNodeMap_get_length( map, NULL );
1265 ok ( r == E_INVALIDARG, "get_length should return E_INVALIDARG\n");
1267 r = IXMLDOMNamedNodeMap_get_length( map, &count );
1268 ok ( r == S_OK, "get_length wrong code\n");
1269 ok ( count == 1, "get_length != 1\n");
1272 r = IXMLDOMNamedNodeMap_get_item( map, -1, &node);
1273 ok ( r == S_FALSE, "get_item (-1) wrong code\n");
1274 ok ( node == NULL, "there is no node\n");
1277 r = IXMLDOMNamedNodeMap_get_item( map, 1, &node);
1278 ok ( r == S_FALSE, "get_item (1) wrong code\n");
1279 ok ( node == NULL, "there is no attribute\n");
1282 r = IXMLDOMNamedNodeMap_get_item( map, 0, &node);
1283 ok ( r == S_OK, "get_item (0) wrong code\n");
1284 ok ( node != NULL, "should be attribute\n");
1286 r = IXMLDOMNode_get_nodeName( node, NULL );
1287 ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code\n");
1289 /* content doesn't matter here */
1291 r = IXMLDOMNode_get_nodeName( node, &str );
1292 ok ( r == S_OK, "get_nodeName wrong code\n");
1293 ok ( str != NULL, "str is null\n");
1294 ok( !lstrcmpW( str, szdl ), "incorrect node name\n");
1295 SysFreeString( str );
1297 /* test sequential access of attributes */
1299 r = IXMLDOMNamedNodeMap_nextNode( map, &node );
1300 ok ( r == S_OK, "nextNode (first time) wrong code\n");
1301 ok ( node != NULL, "nextNode, should be attribute\n");
1303 r = IXMLDOMNamedNodeMap_nextNode( map, &node );
1304 ok ( r != S_OK, "nextNode (second time) wrong code\n");
1305 ok ( node == NULL, "nextNode, there is no attribute\n");
1307 r = IXMLDOMNamedNodeMap_reset( map );
1308 ok ( r == S_OK, "reset should return S_OK\n");
1310 r = IXMLDOMNamedNodeMap_nextNode( map, &node );
1311 ok ( r == S_OK, "nextNode (third time) wrong code\n");
1312 ok ( node != NULL, "nextNode, should be attribute\n");
1315 ok( FALSE, "no map\n");
1319 type = NODE_INVALID;
1320 r = IXMLDOMNode_get_nodeType( node, &type);
1321 ok( r == S_OK, "getNamedItem returned wrong code\n");
1322 ok( type == NODE_ATTRIBUTE, "node not an attribute\n");
1325 r = IXMLDOMNode_get_baseName( node, NULL );
1326 ok( r == E_INVALIDARG, "get_baseName returned wrong code\n");
1329 r = IXMLDOMNode_get_baseName( node, &str );
1330 ok( r == S_OK, "get_baseName returned wrong code\n");
1331 ok( lstrcmpW(str,szdl) == 0, "basename was wrong\n");
1332 SysFreeString( str );
1334 r = IXMLDOMNode_get_nodeValue( node, &var );
1335 ok( r == S_OK, "returns %08x\n", r );
1336 ok( V_VT(&var) == VT_BSTR, "vt %x\n", V_VT(&var));
1337 ok( !lstrcmpW(V_BSTR(&var), szstr1), "nodeValue incorrect\n");
1340 r = IXMLDOMNode_get_childNodes( node, NULL );
1341 ok( r == E_INVALIDARG, "get_childNodes returned wrong code\n");
1343 r = IXMLDOMNode_get_childNodes( node, &list );
1344 ok( r == S_OK, "get_childNodes returned wrong code\n");
1348 r = IXMLDOMNodeList_nextNode( list, &next );
1349 ok( r == S_OK, "nextNode returned wrong code\n");
1352 ok( FALSE, "no childlist\n");
1357 r = IXMLDOMNode_hasChildNodes( next, &b );
1358 ok( r == S_FALSE, "hasChildNoes bad return\n");
1359 ok( b == VARIANT_FALSE, "hasChildNoes wrong result\n");
1361 type = NODE_INVALID;
1362 r = IXMLDOMNode_get_nodeType( next, &type);
1363 ok( r == S_OK, "getNamedItem returned wrong code\n");
1364 ok( type == NODE_TEXT, "node not text\n");
1367 r = IXMLDOMNode_get_baseName( next, &str );
1368 ok( r == S_FALSE, "get_baseName returned wrong code\n");
1369 ok( str == NULL, "basename was wrong\n");
1373 ok( FALSE, "no next\n");
1376 IXMLDOMNode_Release( next );
1379 IXMLDOMNodeList_Release( list );
1382 IXMLDOMNode_Release( node );
1385 ok( FALSE, "no node\n");
1389 IXMLDOMNamedNodeMap_Release( map );
1391 /* now traverse the tree from the root element */
1394 r = IXMLDOMNode_get_childNodes( element, &list );
1395 ok( r == S_OK, "get_childNodes returned wrong code\n");
1397 /* using get_item for child list doesn't advance the position */
1398 ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
1399 expect_node(node, "E2.E2.D1");
1400 IXMLDOMNode_Release(node);
1401 ole_check(IXMLDOMNodeList_nextNode(list, &node));
1402 expect_node(node, "E1.E2.D1");
1403 IXMLDOMNode_Release(node);
1404 ole_check(IXMLDOMNodeList_reset(list));
1406 IXMLDOMNodeList_AddRef(list);
1407 expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
1408 ole_check(IXMLDOMNodeList_reset(list));
1410 node = (void*)0xdeadbeef;
1411 r = IXMLDOMNode_selectSingleNode( element, szdl, &node );
1412 ok( r == S_FALSE, "ret %08x\n", r );
1413 ok( node == NULL, "node %p\n", node );
1414 r = IXMLDOMNode_selectSingleNode( element, szbs, &node );
1415 ok( r == S_OK, "ret %08x\n", r );
1416 r = IXMLDOMNode_Release( node );
1417 ok( r == 0, "ret %08x\n", r );
1420 ok( FALSE, "no element\n");
1424 r = IXMLDOMNodeList_QueryInterface(list, &IID_IDispatch, NULL);
1425 ok( r == E_INVALIDARG || r == E_POINTER, "ret %08x\n", r );
1427 r = IXMLDOMNodeList_get_item(list, 0, NULL);
1428 ok(r == E_INVALIDARG, "Exected E_INVALIDARG got %08x\n", r);
1430 r = IXMLDOMNodeList_get_length(list, NULL);
1431 ok(r == E_INVALIDARG, "Exected E_INVALIDARG got %08x\n", r);
1433 r = IXMLDOMNodeList_get_length( list, &count );
1434 ok( r == S_OK, "get_length returns %08x\n", r );
1435 ok( count == 4, "get_length got %d\n", count );
1437 r = IXMLDOMNodeList_nextNode(list, NULL);
1438 ok(r == E_INVALIDARG, "Exected E_INVALIDARG got %08x\n", r);
1440 r = IXMLDOMNodeList_nextNode( list, &node );
1441 ok( r == S_OK, "nextNode returned wrong code\n");
1444 ok( FALSE, "no list\n");
1448 type = NODE_INVALID;
1449 r = IXMLDOMNode_get_nodeType( node, &type);
1450 ok( r == S_OK, "getNamedItem returned wrong code\n");
1451 ok( type == NODE_ELEMENT, "node not text\n");
1454 ok( V_VT(&var) == VT_EMPTY, "variant init failed\n");
1455 r = IXMLDOMNode_get_nodeValue( node, &var );
1456 ok( r == S_FALSE, "nextNode returned wrong code\n");
1457 ok( V_VT(&var) == VT_NULL, "variant wasn't empty\n");
1458 ok( V_BSTR(&var) == NULL, "variant value wasn't null\n");
1460 r = IXMLDOMNode_hasChildNodes( node, NULL );
1461 ok( r == E_INVALIDARG, "hasChildNoes bad return\n");
1464 r = IXMLDOMNode_hasChildNodes( node, &b );
1465 ok( r == S_OK, "hasChildNoes bad return\n");
1466 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
1469 r = IXMLDOMNode_get_baseName( node, &str );
1470 ok( r == S_OK, "get_baseName returned wrong code\n");
1471 ok( lstrcmpW(str,szbs) == 0, "basename was wrong\n");
1475 ok( FALSE, "no node\n");
1478 IXMLDOMNode_Release( node );
1480 IXMLDOMNodeList_Release( list );
1482 IXMLDOMElement_Release( element );
1485 str = SysAllocString( szComplete5 );
1486 r = IXMLDOMDocument_loadXML( doc, str, &b );
1487 ok( r == S_OK, "loadXML failed\n");
1488 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1489 SysFreeString( str );
1492 r = IXMLDOMNode_hasChildNodes( doc, &b );
1493 ok( r == S_OK, "hasChildNoes bad return\n");
1494 ok( b == VARIANT_TRUE, "hasChildNoes wrong result\n");
1496 r = IXMLDOMDocument_get_documentElement( doc, &element );
1497 ok( r == S_OK, "should be a document element\n");
1498 ok( element != NULL, "should be an element\n");
1502 static const WCHAR szSSearch[] = {'S',':','s','e','a','r','c','h',0};
1505 /* check if the tag is correct */
1506 r = IXMLDOMElement_get_tagName( element, &tag );
1507 ok( r == S_OK, "couldn't get tag name\n");
1508 ok( tag != NULL, "tag was null\n");
1509 ok( !lstrcmpW( tag, szSSearch ), "incorrect tag name\n");
1510 SysFreeString( tag );
1514 IXMLDOMElement_Release( element );
1515 ok(IXMLDOMDocument_Release( doc ) == 0, "document is not destroyed\n");
1518 static void test_refs(void)
1523 IXMLDOMDocument *doc = NULL;
1524 IXMLDOMElement *element = NULL;
1525 IXMLDOMNode *node = NULL, *node2;
1526 IXMLDOMNodeList *node_list = NULL;
1528 IUnknown *unk, *unk2;
1530 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1531 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1534 ref = IXMLDOMDocument_Release(doc);
1535 ok( ref == 0, "ref %d\n", ref);
1537 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1538 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1542 str = SysAllocString( szComplete4 );
1543 r = IXMLDOMDocument_loadXML( doc, str, &b );
1544 ok( r == S_OK, "loadXML failed\n");
1545 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1546 SysFreeString( str );
1548 ref = IXMLDOMDocument_AddRef( doc );
1549 ok( ref == 2, "ref %d\n", ref );
1550 ref = IXMLDOMDocument_AddRef( doc );
1551 ok( ref == 3, "ref %d\n", ref );
1552 IXMLDOMDocument_Release( doc );
1553 IXMLDOMDocument_Release( doc );
1555 r = IXMLDOMDocument_get_documentElement( doc, &element );
1556 ok( r == S_OK, "should be a document element\n");
1557 ok( element != NULL, "should be an element\n");
1559 ref = IXMLDOMDocument_AddRef( doc );
1560 ok( ref == 2, "ref %d\n", ref );
1561 IXMLDOMDocument_Release( doc );
1563 r = IXMLDOMElement_get_childNodes( element, &node_list );
1564 ok( r == S_OK, "rets %08x\n", r);
1566 ref = IXMLDOMNodeList_AddRef( node_list );
1567 ok( ref == 2, "ref %d\n", ref );
1568 IXMLDOMNodeList_Release( node_list );
1570 IXMLDOMNodeList_get_item( node_list, 0, &node );
1571 ok( r == S_OK, "rets %08x\n", r);
1573 IXMLDOMNodeList_get_item( node_list, 0, &node2 );
1574 ok( r == S_OK, "rets %08x\n", r);
1576 ref = IXMLDOMNode_AddRef( node );
1577 ok( ref == 2, "ref %d\n", ref );
1578 IXMLDOMNode_Release( node );
1580 ref = IXMLDOMNode_Release( node );
1581 ok( ref == 0, "ref %d\n", ref );
1582 ref = IXMLDOMNode_Release( node2 );
1583 ok( ref == 0, "ref %d\n", ref );
1585 ref = IXMLDOMNodeList_Release( node_list );
1586 ok( ref == 0, "ref %d\n", ref );
1588 ok( node != node2, "node %p node2 %p\n", node, node2 );
1590 ref = IXMLDOMDocument_Release( doc );
1591 ok( ref == 0, "ref %d\n", ref );
1593 ref = IXMLDOMElement_AddRef( element );
1595 ok( ref == 3, "ref %d\n", ref );
1597 IXMLDOMElement_Release( element );
1599 /* IUnknown must be unique however we obtain it */
1600 r = IXMLDOMElement_QueryInterface( element, &IID_IUnknown, (LPVOID*)&unk );
1601 ok( r == S_OK, "rets %08x\n", r );
1602 r = IXMLDOMElement_QueryInterface( element, &IID_IXMLDOMNode, (LPVOID*)&node );
1603 ok( r == S_OK, "rets %08x\n", r );
1604 r = IXMLDOMNode_QueryInterface( node, &IID_IUnknown, (LPVOID*)&unk2 );
1605 ok( r == S_OK, "rets %08x\n", r );
1606 ok( unk == unk2, "unk %p unk2 %p\n", unk, unk2 );
1608 IUnknown_Release( unk2 );
1609 IUnknown_Release( unk );
1610 IXMLDOMNode_Release( node );
1612 IXMLDOMElement_Release( element );
1616 static void test_create(void)
1618 static const WCHAR szOne[] = {'1',0};
1619 static const WCHAR szOneGarbage[] = {'1','G','a','r','b','a','g','e',0};
1623 IXMLDOMDocument *doc;
1624 IXMLDOMElement *element;
1625 IXMLDOMNode *root, *node, *child;
1626 IXMLDOMNamedNodeMap *attr_map;
1631 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1632 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1637 V_I1(&var) = NODE_ELEMENT;
1638 str = SysAllocString( szlc );
1639 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1640 ok( r == S_OK, "returns %08x\n", r );
1641 if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
1644 V_R4(&var) = NODE_ELEMENT;
1645 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1646 ok( r == S_OK, "returns %08x\n", r );
1647 if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
1649 V_VT(&var) = VT_BSTR;
1650 V_BSTR(&var) = SysAllocString( szOne );
1651 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1652 ok( r == S_OK, "returns %08x\n", r );
1653 if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
1656 V_VT(&var) = VT_BSTR;
1657 V_BSTR(&var) = SysAllocString( szOneGarbage );
1658 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1659 ok( r == E_INVALIDARG, "returns %08x\n", r );
1660 if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
1664 V_I4(&var) = NODE_ELEMENT;
1665 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1666 ok( r == S_OK, "returns %08x\n", r );
1667 r = IXMLDOMDocument_appendChild( doc, node, &root );
1668 ok( r == S_OK, "returns %08x\n", r );
1669 ok( node == root, "%p %p\n", node, root );
1671 ref = IXMLDOMNode_AddRef( node );
1672 ok(ref == 3, "ref %d\n", ref);
1673 IXMLDOMNode_Release( node );
1675 ref = IXMLDOMNode_Release( node );
1676 ok(ref == 1, "ref %d\n", ref);
1677 SysFreeString( str );
1680 V_I4(&var) = NODE_ELEMENT;
1681 str = SysAllocString( szbs );
1682 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1683 ok( r == S_OK, "returns %08x\n", r );
1684 SysFreeString( str );
1686 ref = IXMLDOMNode_AddRef( node );
1687 ok(ref == 2, "ref = %d\n", ref);
1688 IXMLDOMNode_Release( node );
1690 r = IXMLDOMNode_QueryInterface( node, &IID_IUnknown, (LPVOID*)&unk );
1691 ok( r == S_OK, "returns %08x\n", r );
1693 ref = IXMLDOMNode_AddRef( unk );
1694 ok(ref == 3, "ref = %d\n", ref);
1695 IXMLDOMNode_Release( unk );
1697 V_VT(&var) = VT_EMPTY;
1698 r = IXMLDOMNode_insertBefore( root, (IXMLDOMNode*)unk, var, &child );
1699 ok( r == S_OK, "returns %08x\n", r );
1700 ok( unk == (IUnknown*)child, "%p %p\n", unk, child );
1701 IXMLDOMNode_Release( child );
1702 IUnknown_Release( unk );
1705 V_VT(&var) = VT_NULL;
1706 V_DISPATCH(&var) = (IDispatch*)node;
1707 r = IXMLDOMNode_insertBefore( root, node, var, &child );
1708 ok( r == S_OK, "returns %08x\n", r );
1709 ok( node == child, "%p %p\n", node, child );
1710 IXMLDOMNode_Release( child );
1713 V_VT(&var) = VT_NULL;
1714 V_DISPATCH(&var) = (IDispatch*)node;
1715 r = IXMLDOMNode_insertBefore( root, node, var, NULL );
1716 ok( r == S_OK, "returns %08x\n", r );
1717 IXMLDOMNode_Release( node );
1719 r = IXMLDOMNode_QueryInterface( root, &IID_IXMLDOMElement, (LPVOID*)&element );
1720 ok( r == S_OK, "returns %08x\n", r );
1722 r = IXMLDOMElement_get_attributes( element, &attr_map );
1723 ok( r == S_OK, "returns %08x\n", r );
1724 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1725 ok( r == S_OK, "returns %08x\n", r );
1726 ok( num == 0, "num %d\n", num );
1727 IXMLDOMNamedNodeMap_Release( attr_map );
1729 V_VT(&var) = VT_BSTR;
1730 V_BSTR(&var) = SysAllocString( szstr1 );
1731 name = SysAllocString( szdl );
1732 r = IXMLDOMElement_setAttribute( element, name, var );
1733 ok( r == S_OK, "returns %08x\n", r );
1734 r = IXMLDOMElement_get_attributes( element, &attr_map );
1735 ok( r == S_OK, "returns %08x\n", r );
1736 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1737 ok( r == S_OK, "returns %08x\n", r );
1738 ok( num == 1, "num %d\n", num );
1739 IXMLDOMNamedNodeMap_Release( attr_map );
1742 V_VT(&var) = VT_BSTR;
1743 V_BSTR(&var) = SysAllocString( szstr2 );
1744 r = IXMLDOMElement_setAttribute( element, name, var );
1745 ok( r == S_OK, "returns %08x\n", r );
1746 r = IXMLDOMElement_get_attributes( element, &attr_map );
1747 ok( r == S_OK, "returns %08x\n", r );
1748 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1749 ok( r == S_OK, "returns %08x\n", r );
1750 ok( num == 1, "num %d\n", num );
1751 IXMLDOMNamedNodeMap_Release( attr_map );
1753 r = IXMLDOMElement_getAttribute( element, name, &var );
1754 ok( r == S_OK, "returns %08x\n", r );
1755 ok( !lstrcmpW(V_BSTR(&var), szstr2), "wrong attr value\n");
1757 SysFreeString(name);
1759 V_VT(&var) = VT_BSTR;
1760 V_BSTR(&var) = SysAllocString( szstr1 );
1761 name = SysAllocString( szlc );
1762 r = IXMLDOMElement_setAttribute( element, name, var );
1763 ok( r == S_OK, "returns %08x\n", r );
1764 r = IXMLDOMElement_get_attributes( element, &attr_map );
1765 ok( r == S_OK, "returns %08x\n", r );
1766 r = IXMLDOMNamedNodeMap_get_length( attr_map, &num );
1767 ok( r == S_OK, "returns %08x\n", r );
1768 ok( num == 2, "num %d\n", num );
1769 IXMLDOMNamedNodeMap_Release( attr_map );
1771 SysFreeString(name);
1775 name = SysAllocString( szbs );
1776 r = IXMLDOMElement_setAttribute( element, name, var );
1777 ok( r == S_OK, "returns %08x\n", r );
1779 r = IXMLDOMElement_getAttribute( element, name, &var );
1780 ok( r == S_OK, "returns %08x\n", r );
1781 ok( V_VT(&var) == VT_BSTR, "variant type %x\n", V_VT(&var));
1783 SysFreeString(name);
1785 /* Create an Attribute */
1787 V_I4(&var) = NODE_ATTRIBUTE;
1788 str = SysAllocString( szAttribute );
1789 r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
1790 ok( r == S_OK, "returns %08x\n", r );
1791 ok( node != NULL, "node was null\n");
1796 r = IXMLDOMNode_get_nodeTypeString(node, &str);
1797 ok( r == S_OK, "returns %08x\n", r );
1798 ok( !lstrcmpW( str, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
1800 IXMLDOMNode_Release( node );
1803 IXMLDOMElement_Release( element );
1804 IXMLDOMNode_Release( root );
1805 IXMLDOMDocument_Release( doc );
1808 static void test_getElementsByTagName(void)
1813 IXMLDOMDocument *doc;
1814 IXMLDOMNodeList *node_list;
1817 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1818 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1822 str = SysAllocString( szComplete4 );
1823 r = IXMLDOMDocument_loadXML( doc, str, &b );
1824 ok( r == S_OK, "loadXML failed\n");
1825 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1826 SysFreeString( str );
1828 str = SysAllocString( szstar );
1829 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1830 ok( r == S_OK, "ret %08x\n", r );
1831 r = IXMLDOMNodeList_get_length( node_list, &len );
1832 ok( r == S_OK, "ret %08x\n", r );
1833 ok( len == 6, "len %d\n", len );
1835 test_disp((IUnknown*)node_list);
1837 IXMLDOMNodeList_Release( node_list );
1838 SysFreeString( str );
1840 str = SysAllocString( szbs );
1841 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1842 ok( r == S_OK, "ret %08x\n", r );
1843 r = IXMLDOMNodeList_get_length( node_list, &len );
1844 ok( r == S_OK, "ret %08x\n", r );
1845 ok( len == 1, "len %d\n", len );
1846 IXMLDOMNodeList_Release( node_list );
1847 SysFreeString( str );
1849 str = SysAllocString( szdl );
1850 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1851 ok( r == S_OK, "ret %08x\n", r );
1852 r = IXMLDOMNodeList_get_length( node_list, &len );
1853 ok( r == S_OK, "ret %08x\n", r );
1854 ok( len == 0, "len %d\n", len );
1855 IXMLDOMNodeList_Release( node_list );
1856 SysFreeString( str );
1858 str = SysAllocString( szstr1 );
1859 r = IXMLDOMDocument_getElementsByTagName(doc, str, &node_list);
1860 ok( r == S_OK, "ret %08x\n", r );
1861 r = IXMLDOMNodeList_get_length( node_list, &len );
1862 ok( r == S_OK, "ret %08x\n", r );
1863 ok( len == 0, "len %d\n", len );
1864 IXMLDOMNodeList_Release( node_list );
1865 SysFreeString( str );
1867 IXMLDOMDocument_Release( doc );
1870 static void test_get_text(void)
1875 IXMLDOMDocument *doc;
1876 IXMLDOMNode *node, *node2, *node3;
1877 IXMLDOMNode *nodeRoot;
1878 IXMLDOMNodeList *node_list;
1879 IXMLDOMNamedNodeMap *node_map;
1882 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1883 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1887 str = SysAllocString( szComplete4 );
1888 r = IXMLDOMDocument_loadXML( doc, str, &b );
1889 ok( r == S_OK, "loadXML failed\n");
1890 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1891 SysFreeString( str );
1893 str = SysAllocString( szbs );
1894 r = IXMLDOMDocument_getElementsByTagName( doc, str, &node_list );
1895 ok( r == S_OK, "ret %08x\n", r );
1898 /* Test to get all child node text. */
1899 r = IXMLDOMDocument_QueryInterface(doc, &IID_IXMLDOMNode, (LPVOID*)&nodeRoot);
1900 ok( r == S_OK, "ret %08x\n", r );
1903 r = IXMLDOMNode_get_text( nodeRoot, &str );
1904 ok( r == S_OK, "ret %08x\n", r );
1905 ok( compareIgnoreReturnsWhitespace(str, _bstr_("fn1.txt\n\n fn2.txt \n\nf1\n")), "wrong get_text\n");
1908 IXMLDOMNode_Release(nodeRoot);
1912 /* this test crashes on win9x */
1913 r = IXMLDOMNodeList_QueryInterface(node_list, &IID_IDispatch, NULL);
1914 ok( r == E_INVALIDARG, "ret %08x\n", r );
1917 r = IXMLDOMNodeList_get_length( node_list, NULL );
1918 ok( r == E_INVALIDARG, "ret %08x\n", r );
1920 r = IXMLDOMNodeList_get_length( node_list, &len );
1921 ok( r == S_OK, "ret %08x\n", r );
1922 ok( len == 1, "expect 1 got %d\n", len );
1924 r = IXMLDOMNodeList_get_item( node_list, 0, NULL );
1925 ok( r == E_INVALIDARG, "ret %08x\n", r );
1927 r = IXMLDOMNodeList_nextNode( node_list, NULL );
1928 ok( r == E_INVALIDARG, "ret %08x\n", r );
1930 r = IXMLDOMNodeList_get_item( node_list, 0, &node );
1931 ok( r == S_OK, "ret %08x\n", r );
1932 IXMLDOMNodeList_Release( node_list );
1934 /* Invalid output parameter*/
1935 r = IXMLDOMNode_get_text( node, NULL );
1936 ok( r == E_INVALIDARG, "ret %08x\n", r );
1938 r = IXMLDOMNode_get_text( node, &str );
1939 ok( r == S_OK, "ret %08x\n", r );
1940 ok( !memcmp(str, szfn1_txt, lstrlenW(szfn1_txt) ), "wrong string\n" );
1943 r = IXMLDOMNode_get_attributes( node, &node_map );
1944 ok( r == S_OK, "ret %08x\n", r );
1946 str = SysAllocString( szvr );
1947 r = IXMLDOMNamedNodeMap_getNamedItem( node_map, str, &node2 );
1948 ok( r == S_OK, "ret %08x\n", r );
1951 r = IXMLDOMNode_get_text( node2, &str );
1952 ok( r == S_OK, "ret %08x\n", r );
1953 ok( !memcmp(str, szstr2, sizeof(szstr2)), "wrong string\n" );
1956 r = IXMLDOMNode_get_firstChild( node2, &node3 );
1957 ok( r == S_OK, "ret %08x\n", r );
1959 r = IXMLDOMNode_get_text( node3, &str );
1960 ok( r == S_OK, "ret %08x\n", r );
1961 ok( !memcmp(str, szstr2, sizeof(szstr2)), "wrong string\n" );
1965 IXMLDOMNode_Release( node3 );
1966 IXMLDOMNode_Release( node2 );
1967 IXMLDOMNamedNodeMap_Release( node_map );
1968 IXMLDOMNode_Release( node );
1969 IXMLDOMDocument_Release( doc );
1972 static void test_get_childNodes(void)
1977 IXMLDOMDocument *doc;
1978 IXMLDOMElement *element;
1979 IXMLDOMNode *node, *node2;
1980 IXMLDOMNodeList *node_list, *node_list2;
1983 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
1984 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
1988 str = SysAllocString( szComplete4 );
1989 r = IXMLDOMDocument_loadXML( doc, str, &b );
1990 ok( r == S_OK, "loadXML failed\n");
1991 ok( b == VARIANT_TRUE, "failed to load XML string\n");
1992 SysFreeString( str );
1994 r = IXMLDOMDocument_get_documentElement( doc, &element );
1995 ok( r == S_OK, "ret %08x\n", r);
1997 r = IXMLDOMElement_get_childNodes( element, &node_list );
1998 ok( r == S_OK, "ret %08x\n", r);
2000 r = IXMLDOMNodeList_get_length( node_list, &len );
2001 ok( r == S_OK, "ret %08x\n", r);
2002 ok( len == 4, "len %d\n", len);
2004 r = IXMLDOMNodeList_get_item( node_list, 2, &node );
2005 ok( r == S_OK, "ret %08x\n", r);
2007 r = IXMLDOMNode_get_childNodes( node, &node_list2 );
2008 ok( r == S_OK, "ret %08x\n", r);
2010 r = IXMLDOMNodeList_get_length( node_list2, &len );
2011 ok( r == S_OK, "ret %08x\n", r);
2012 ok( len == 0, "len %d\n", len);
2014 r = IXMLDOMNodeList_get_item( node_list2, 0, &node2);
2015 ok( r == S_FALSE, "ret %08x\n", r);
2017 IXMLDOMNodeList_Release( node_list2 );
2018 IXMLDOMNode_Release( node );
2019 IXMLDOMNodeList_Release( node_list );
2020 IXMLDOMElement_Release( element );
2021 IXMLDOMDocument_Release( doc );
2024 static void test_removeChild(void)
2029 IXMLDOMDocument *doc;
2030 IXMLDOMElement *element, *lc_element;
2031 IXMLDOMNode *fo_node, *ba_node, *removed_node, *temp_node, *lc_node;
2032 IXMLDOMNodeList *root_list, *fo_list;
2034 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
2035 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
2039 str = SysAllocString( szComplete4 );
2040 r = IXMLDOMDocument_loadXML( doc, str, &b );
2041 ok( r == S_OK, "loadXML failed\n");
2042 ok( b == VARIANT_TRUE, "failed to load XML string\n");
2043 SysFreeString( str );
2045 r = IXMLDOMDocument_get_documentElement( doc, &element );
2046 ok( r == S_OK, "ret %08x\n", r);
2048 r = IXMLDOMElement_get_childNodes( element, &root_list );
2049 ok( r == S_OK, "ret %08x\n", r);
2051 r = IXMLDOMNodeList_get_item( root_list, 3, &fo_node );
2052 ok( r == S_OK, "ret %08x\n", r);
2054 r = IXMLDOMNode_get_childNodes( fo_node, &fo_list );
2055 ok( r == S_OK, "ret %08x\n", r);
2057 r = IXMLDOMNodeList_get_item( fo_list, 0, &ba_node );
2058 ok( r == S_OK, "ret %08x\n", r);
2060 /* invalid parameter: NULL ptr */
2061 removed_node = (void*)0xdeadbeef;
2062 r = IXMLDOMElement_removeChild( element, NULL, &removed_node );
2063 ok( r == E_INVALIDARG, "ret %08x\n", r );
2064 ok( removed_node == (void*)0xdeadbeef, "%p\n", removed_node );
2066 /* ba_node is a descendant of element, but not a direct child. */
2067 removed_node = (void*)0xdeadbeef;
2068 r = IXMLDOMElement_removeChild( element, ba_node, &removed_node );
2069 ok( r == E_INVALIDARG, "ret %08x\n", r );
2070 ok( removed_node == NULL, "%p\n", removed_node );
2072 r = IXMLDOMElement_removeChild( element, fo_node, &removed_node );
2073 ok( r == S_OK, "ret %08x\n", r);
2074 ok( fo_node == removed_node, "node %p node2 %p\n", fo_node, removed_node );
2076 /* try removing already removed child */
2077 temp_node = (void*)0xdeadbeef;
2078 r = IXMLDOMElement_removeChild( element, fo_node, &temp_node );
2079 ok( r == E_INVALIDARG, "ret %08x\n", r);
2080 ok( temp_node == NULL, "%p\n", temp_node );
2082 /* the removed node has no parent anymore */
2083 r = IXMLDOMNode_get_parentNode( removed_node, &temp_node );
2084 ok( r == S_FALSE, "ret %08x\n", r);
2085 ok( temp_node == NULL, "%p\n", temp_node );
2087 IXMLDOMNode_Release( removed_node );
2088 IXMLDOMNode_Release( ba_node );
2089 IXMLDOMNodeList_Release( fo_list );
2091 r = IXMLDOMNodeList_get_item( root_list, 0, &lc_node );
2092 ok( r == S_OK, "ret %08x\n", r);
2094 r = IXMLDOMElement_QueryInterface( lc_node, &IID_IXMLDOMElement, (LPVOID*)&lc_element );
2095 ok( r == S_OK, "ret %08x\n", r);
2097 /* MS quirk: passing wrong interface pointer works, too */
2098 r = IXMLDOMElement_removeChild( element, (IXMLDOMNode*)lc_element, NULL );
2099 ok( r == S_OK, "ret %08x\n", r);
2101 r = IXMLDOMNode_get_parentNode( lc_node, &temp_node );
2102 ok( r == S_FALSE, "ret %08x\n", r);
2103 ok( temp_node == NULL, "%p\n", temp_node );
2105 IXMLDOMNode_Release( lc_node );
2106 IXMLDOMNodeList_Release( root_list );
2107 IXMLDOMElement_Release( element );
2108 IXMLDOMDocument_Release( doc );
2111 static void test_replaceChild(void)
2116 IXMLDOMDocument *doc;
2117 IXMLDOMElement *element, *ba_element;
2118 IXMLDOMNode *fo_node, *ba_node, *lc_node, *removed_node, *temp_node;
2119 IXMLDOMNodeList *root_list, *fo_list;
2120 IUnknown * unk1, *unk2;
2123 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
2124 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
2128 str = SysAllocString( szComplete4 );
2129 r = IXMLDOMDocument_loadXML( doc, str, &b );
2130 ok( r == S_OK, "loadXML failed\n");
2131 ok( b == VARIANT_TRUE, "failed to load XML string\n");
2132 SysFreeString( str );
2134 r = IXMLDOMDocument_get_documentElement( doc, &element );
2135 ok( r == S_OK, "ret %08x\n", r);
2137 r = IXMLDOMElement_get_childNodes( element, &root_list );
2138 ok( r == S_OK, "ret %08x\n", r);
2140 r = IXMLDOMNodeList_get_item( root_list, 0, &lc_node );
2141 ok( r == S_OK, "ret %08x\n", r);
2143 r = IXMLDOMNodeList_get_item( root_list, 3, &fo_node );
2144 ok( r == S_OK, "ret %08x\n", r);
2146 r = IXMLDOMNode_get_childNodes( fo_node, &fo_list );
2147 ok( r == S_OK, "ret %08x\n", r);
2149 r = IXMLDOMNodeList_get_item( fo_list, 0, &ba_node );
2150 ok( r == S_OK, "ret %08x\n", r);
2152 IXMLDOMNodeList_Release( fo_list );
2154 /* invalid parameter: NULL ptr for element to remove */
2155 removed_node = (void*)0xdeadbeef;
2156 r = IXMLDOMElement_replaceChild( element, ba_node, NULL, &removed_node );
2157 ok( r == E_INVALIDARG, "ret %08x\n", r );
2158 ok( removed_node == (void*)0xdeadbeef, "%p\n", removed_node );
2160 /* invalid parameter: NULL for replacement element. (Sic!) */
2161 removed_node = (void*)0xdeadbeef;
2162 r = IXMLDOMElement_replaceChild( element, NULL, fo_node, &removed_node );
2163 ok( r == E_INVALIDARG, "ret %08x\n", r );
2164 ok( removed_node == (void*)0xdeadbeef, "%p\n", removed_node );
2166 /* invalid parameter: OldNode is not a child */
2167 removed_node = (void*)0xdeadbeef;
2168 r = IXMLDOMElement_replaceChild( element, lc_node, ba_node, &removed_node );
2169 ok( r == E_INVALIDARG, "ret %08x\n", r );
2170 ok( removed_node == NULL, "%p\n", removed_node );
2172 /* invalid parameter: would create loop */
2173 removed_node = (void*)0xdeadbeef;
2174 r = IXMLDOMNode_replaceChild( fo_node, fo_node, ba_node, &removed_node );
2175 ok( r == E_FAIL, "ret %08x\n", r );
2176 ok( removed_node == NULL, "%p\n", removed_node );
2178 r = IXMLDOMElement_replaceChild( element, ba_node, fo_node, NULL );
2179 ok( r == S_OK, "ret %08x\n", r );
2181 r = IXMLDOMNodeList_get_item( root_list, 3, &temp_node );
2182 ok( r == S_OK, "ret %08x\n", r );
2184 /* ba_node and temp_node refer to the same node, yet they
2185 are different interface pointers */
2186 ok( ba_node != temp_node, "ba_node %p temp_node %p\n", ba_node, temp_node);
2187 r = IXMLDOMNode_QueryInterface( temp_node, &IID_IUnknown, (void**)&unk1);
2188 ok( r == S_OK, "ret %08x\n", r );
2189 r = IXMLDOMNode_QueryInterface( ba_node, &IID_IUnknown, (void**)&unk2);
2190 ok( r == S_OK, "ret %08x\n", r );
2191 todo_wine ok( unk1 == unk2, "unk1 %p unk2 %p\n", unk1, unk2);
2193 IUnknown_Release( unk1 );
2194 IUnknown_Release( unk2 );
2196 /* ba_node should have been removed from below fo_node */
2197 r = IXMLDOMNode_get_childNodes( fo_node, &fo_list );
2198 ok( r == S_OK, "ret %08x\n", r );
2200 /* MS quirk: replaceChild also accepts elements instead of nodes */
2201 r = IXMLDOMNode_QueryInterface( ba_node, &IID_IXMLDOMElement, (void**)&ba_element);
2202 ok( r == S_OK, "ret %08x\n", r );
2204 r = IXMLDOMElement_replaceChild( element, ba_node, (IXMLDOMNode*)ba_element, &removed_node );
2205 ok( r == S_OK, "ret %08x\n", r );
2207 r = IXMLDOMNodeList_get_length( fo_list, &len);
2208 ok( r == S_OK, "ret %08x\n", r );
2209 ok( len == 0, "len %d\n", len);
2211 IXMLDOMNodeList_Release( fo_list );
2213 IXMLDOMNode_Release(ba_node);
2214 IXMLDOMNode_Release(fo_node);
2215 IXMLDOMNode_Release(temp_node);
2216 IXMLDOMNodeList_Release( root_list );
2217 IXMLDOMElement_Release( element );
2218 IXMLDOMDocument_Release( doc );
2221 static void test_removeNamedItem(void)
2223 IXMLDOMDocument *doc;
2224 IXMLDOMElement *element;
2225 IXMLDOMNode *pr_node, *removed_node, *removed_node2;
2226 IXMLDOMNodeList *root_list;
2227 IXMLDOMNamedNodeMap * pr_attrs;
2233 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
2234 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
2238 str = SysAllocString( szComplete4 );
2239 r = IXMLDOMDocument_loadXML( doc, str, &b );
2240 ok( r == S_OK, "loadXML failed\n");
2241 ok( b == VARIANT_TRUE, "failed to load XML string\n");
2242 SysFreeString( str );
2244 r = IXMLDOMDocument_get_documentElement( doc, &element );
2245 ok( r == S_OK, "ret %08x\n", r);
2247 r = IXMLDOMElement_get_childNodes( element, &root_list );
2248 ok( r == S_OK, "ret %08x\n", r);
2250 r = IXMLDOMNodeList_get_item( root_list, 1, &pr_node );
2251 ok( r == S_OK, "ret %08x\n", r);
2253 r = IXMLDOMNode_get_attributes( pr_node, &pr_attrs );
2254 ok( r == S_OK, "ret %08x\n", r);
2256 r = IXMLDOMNamedNodeMap_get_length( pr_attrs, &len );
2257 ok( r == S_OK, "ret %08x\n", r);
2258 ok( len == 3, "length %d\n", len);
2260 removed_node = (void*)0xdeadbeef;
2261 r = IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs, NULL, &removed_node);
2262 ok ( r == E_INVALIDARG, "ret %08x\n", r);
2263 ok ( removed_node == (void*)0xdeadbeef, "removed_node == %p\n", removed_node);
2265 removed_node = (void*)0xdeadbeef;
2266 str = SysAllocString(szvr);
2267 r = IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs, str, &removed_node);
2268 ok ( r == S_OK, "ret %08x\n", r);
2270 removed_node2 = (void*)0xdeadbeef;
2271 r = IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs, str, &removed_node2);
2272 ok ( r == S_FALSE, "ret %08x\n", r);
2273 ok ( removed_node2 == NULL, "removed_node == %p\n", removed_node2 );
2275 r = IXMLDOMNamedNodeMap_get_length( pr_attrs, &len );
2276 ok( r == S_OK, "ret %08x\n", r);
2277 ok( len == 2, "length %d\n", len);
2279 r = IXMLDOMNamedNodeMap_setNamedItem( pr_attrs, removed_node, NULL);
2280 ok ( r == S_OK, "ret %08x\n", r);
2281 IXMLDOMNode_Release(removed_node);
2283 r = IXMLDOMNamedNodeMap_get_length( pr_attrs, &len );
2284 ok( r == S_OK, "ret %08x\n", r);
2285 ok( len == 3, "length %d\n", len);
2287 r = IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs, str, NULL);
2288 ok ( r == S_OK, "ret %08x\n", r);
2290 r = IXMLDOMNamedNodeMap_get_length( pr_attrs, &len );
2291 ok( r == S_OK, "ret %08x\n", r);
2292 ok( len == 2, "length %d\n", len);
2294 r = IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs, str, NULL);
2295 ok ( r == S_FALSE, "ret %08x\n", r);
2299 IXMLDOMNamedNodeMap_Release( pr_attrs );
2300 IXMLDOMNode_Release( pr_node );
2301 IXMLDOMNodeList_Release( root_list );
2302 IXMLDOMElement_Release( element );
2303 IXMLDOMDocument_Release( doc );
2306 static void test_XMLHTTP(void)
2308 static const WCHAR wszBody[] = {'m','o','d','e','=','T','e','s','t',0};
2309 static WCHAR wszPOST[] = {'P','O','S','T',0};
2310 static WCHAR wszUrl[] = {'h','t','t','p',':','/','/',
2311 'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
2312 'p','o','s','t','t','e','s','t','.','p','h','p',0};
2313 static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0};
2314 IXMLHttpRequest *pXMLHttpRequest;
2319 HRESULT hr = CoCreateInstance(&CLSID_XMLHTTPRequest, NULL,
2320 CLSCTX_INPROC_SERVER, &IID_IXMLHttpRequest,
2321 (void **)&pXMLHttpRequest);
2322 ok(hr == S_OK, "CoCreateInstance(CLSID_XMLHTTPRequest) should have succeeded instead of failing with 0x%08x\n", hr);
2326 VariantInit(&dummy);
2327 V_VT(&dummy) = VT_ERROR;
2328 V_ERROR(&dummy) = DISP_E_MEMBERNOTFOUND;
2329 VariantInit(&varfalse);
2330 V_VT(&varfalse) = VT_BOOL;
2331 V_BOOL(&varfalse) = VARIANT_FALSE;
2332 V_VT(&varbody) = VT_BSTR;
2333 V_BSTR(&varbody) = SysAllocString(wszBody);
2335 hr = IXMLHttpRequest_open(pXMLHttpRequest, wszPOST, wszUrl, varfalse, dummy, dummy);
2336 todo_wine ok(hr == S_OK, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr);
2338 hr = IXMLHttpRequest_send(pXMLHttpRequest, varbody);
2339 todo_wine ok(hr == S_OK, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr);
2340 VariantClear(&varbody);
2342 hr = IXMLHttpRequest_get_responseText(pXMLHttpRequest, &bstrResponse);
2343 todo_wine ok(hr == S_OK, "IXMLHttpRequest_get_responseText should have succeeded instead of failing with 0x%08x\n", hr);
2344 /* the server currently returns "FAILED" because the Content-Type header is
2345 * not what the server expects */
2348 ok(!memcmp(bstrResponse, wszExpectedResponse, sizeof(wszExpectedResponse)), "bstrResponse differs from what was expected\n");
2349 SysFreeString(bstrResponse);
2352 IXMLHttpRequest_Release(pXMLHttpRequest);
2355 static void test_IXMLDOMDocument2(void)
2360 IXMLDOMDocument *doc;
2361 IXMLDOMDocument2 *doc2;
2362 IDispatchEx *dispex;
2366 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
2367 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
2371 str = SysAllocString( szComplete4 );
2372 r = IXMLDOMDocument_loadXML( doc, str, &b );
2373 ok( r == S_OK, "loadXML failed\n");
2374 ok( b == VARIANT_TRUE, "failed to load XML string\n");
2375 SysFreeString( str );
2377 r = IXMLDOMDocument_QueryInterface( doc, &IID_IXMLDOMDocument2, (void**)&doc2 );
2378 ok( r == S_OK, "ret %08x\n", r );
2379 ok( doc == (IXMLDOMDocument*)doc2, "interfaces differ\n");
2381 r = IXMLDOMDocument_QueryInterface( doc, &IID_IDispatchEx, (void**)&dispex );
2382 ok( r == S_OK, "ret %08x\n", r );
2385 IDispatchEx_Release(dispex);
2388 /* we will check if the variant got cleared */
2389 ref = IXMLDOMDocument2_AddRef(doc2);
2390 expect_eq(ref, 3, int, "%d"); /* doc, doc2, AddRef*/
2391 V_VT(&var) = VT_UNKNOWN;
2392 V_UNKNOWN(&var) = (IUnknown *)doc2;
2395 ole_expect(IXMLDOMDocument2_getProperty(doc2, _bstr_("askldhfaklsdf"), &var), E_FAIL);
2396 expect_eq(V_VT(&var), VT_UNKNOWN, int, "%x");
2397 ole_expect(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), NULL), E_INVALIDARG);
2400 ole_check(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), &var));
2401 expect_eq(V_VT(&var), VT_BSTR, int, "%x");
2402 expect_bstr_eq_and_free(V_BSTR(&var), "XSLPattern");
2405 /* the variant didn't get cleared*/
2406 expect_eq(IXMLDOMDocument2_Release(doc2), 2, int, "%d");
2408 /* setProperty tests */
2409 ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("askldhfaklsdf"), var), E_FAIL);
2410 ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), var), E_FAIL);
2411 ole_expect(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL);
2412 ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
2413 ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
2414 ole_check(IXMLDOMDocument2_setProperty(doc2, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
2416 /* contrary to what MSDN claims you can switch back from XPath to XSLPattern */
2417 ole_check(IXMLDOMDocument2_getProperty(doc2, _bstr_("SelectionLanguage"), &var));
2418 expect_eq(V_VT(&var), VT_BSTR, int, "%x");
2419 expect_bstr_eq_and_free(V_BSTR(&var), "XSLPattern");
2421 IXMLDOMDocument2_Release( doc2 );
2422 IXMLDOMDocument_Release( doc );
2426 static void test_XPath(void)
2431 IXMLDOMDocument2 *doc;
2432 IXMLDOMNode *rootNode;
2433 IXMLDOMNode *elem1Node;
2435 IXMLDOMNodeList *list;
2437 r = CoCreateInstance( &CLSID_DOMDocument, NULL,
2438 CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
2442 ole_check(IXMLDOMDocument_loadXML(doc, _bstr_(szExampleXML), &b));
2443 ok(b == VARIANT_TRUE, "failed to load XML string\n");
2445 /* switch to XPath */
2446 ole_check(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
2448 /* some simple queries*/
2449 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root"), &list));
2450 ole_check(IXMLDOMNodeList_get_item(list, 0, &rootNode));
2451 ole_check(IXMLDOMNodeList_reset(list));
2452 expect_list_and_release(list, "E2.D1");
2453 if (rootNode == NULL)
2456 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root//c"), &list));
2457 expect_list_and_release(list, "E3.E1.E2.D1 E3.E2.E2.D1");
2459 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("//c[@type]"), &list));
2460 expect_list_and_release(list, "E3.E2.E2.D1");
2462 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("elem"), &list));
2463 /* using get_item for query results advances the position */
2464 ole_check(IXMLDOMNodeList_get_item(list, 1, &node));
2465 expect_node(node, "E2.E2.D1");
2466 IXMLDOMNode_Release(node);
2467 ole_check(IXMLDOMNodeList_nextNode(list, &node));
2468 expect_node(node, "E4.E2.D1");
2469 IXMLDOMNode_Release(node);
2470 ole_check(IXMLDOMNodeList_reset(list));
2471 expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
2473 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("."), &list));
2474 expect_list_and_release(list, "E2.D1");
2476 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("elem[3]/preceding-sibling::*"), &list));
2477 ole_check(IXMLDOMNodeList_get_item(list, 0, &elem1Node));
2478 ole_check(IXMLDOMNodeList_reset(list));
2479 expect_list_and_release(list, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
2481 /* select an attribute */
2482 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//@type"), &list));
2483 expect_list_and_release(list, "A'type'.E3.E2.E2.D1");
2485 /* would evaluate to a number */
2486 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("count(*)"), &list), E_FAIL);
2487 /* would evaluate to a boolean */
2488 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("position()>0"), &list), E_FAIL);
2489 /* would evaluate to a string */
2490 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_("name()"), &list), E_FAIL);
2493 ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_("c"), &list));
2494 expect_list_and_release(list, "");
2495 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("elem//c"), &list));
2496 expect_list_and_release(list, "");
2497 ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("//elem[4]"), &list));
2498 expect_list_and_release(list, "");
2500 /* foo undeclared in document node */
2501 ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
2502 /* undeclared in <root> node */
2503 ole_expect(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//foo:c"), &list), E_FAIL);
2504 /* undeclared in <elem> node */
2505 ole_expect(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//foo:c"), &list), E_FAIL);
2506 /* but this trick can be used */
2507 ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//*[name()='foo:c']"), &list));
2508 expect_list_and_release(list, "E3.E4.E2.D1");
2510 /* it has to be declared in SelectionNamespaces */
2511 todo_wine ole_check(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
2512 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
2514 /* now the namespace can be used */
2515 todo_wine ole_check(IXMLDOMDocument_selectNodes(doc, _bstr_("root//test:c"), &list));
2516 todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
2517 todo_wine ole_check(IXMLDOMNode_selectNodes(rootNode, _bstr_(".//test:c"), &list));
2518 todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
2519 todo_wine ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_("//test:c"), &list));
2520 todo_wine expect_list_and_release(list, "E3.E3.E2.D1 E3.E4.E2.D1");
2521 todo_wine ole_check(IXMLDOMNode_selectNodes(elem1Node, _bstr_(".//test:x"), &list));
2522 todo_wine expect_list_and_release(list, "E5.E1.E4.E1.E2.D1");
2524 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
2525 ole_expect(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
2526 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL);
2528 ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
2531 todo_wine ole_check(IXMLDOMDocument2_getProperty(doc, _bstr_("SelectionNamespaces"), &var));
2532 todo_wine expect_eq(V_VT(&var), VT_BSTR, int, "%x");
2533 if (V_VT(&var) == VT_BSTR)
2534 expect_bstr_eq_and_free(V_BSTR(&var), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
2536 /* extra attributes - same thing*/
2537 ole_expect(IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"),
2538 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL);
2539 ole_expect(IXMLDOMDocument_selectNodes(doc, _bstr_("root//foo:c"), &list), E_FAIL);
2541 IXMLDOMNode_Release(rootNode);
2542 IXMLDOMNode_Release(elem1Node);
2543 IXMLDOMDocument_Release(doc);
2547 static void test_cloneNode(void )
2549 IXMLDOMDocument *doc = NULL;
2551 IXMLDOMNodeList *pList;
2552 IXMLDOMNamedNodeMap *mapAttr;
2553 LONG nLength = 0, nLength1 = 0;
2554 LONG nAttrCnt = 0, nAttrCnt1 = 0;
2556 IXMLDOMNode *node_clone;
2557 IXMLDOMNode *node_first;
2560 static const WCHAR szSearch[] = { 'l', 'c', '/', 'p', 'r', 0 };
2562 r = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
2566 str = SysAllocString( szComplete4 );
2567 ole_check(IXMLDOMDocument_loadXML(doc, str, &b));
2568 ok(b == VARIANT_TRUE, "failed to load XML string\n");
2574 str = SysAllocString( szSearch);
2575 r = IXMLDOMNode_selectSingleNode(doc, str, &node);
2576 ok( r == S_OK, "ret %08x\n", r );
2577 ok( node != NULL, "node %p\n", node );
2582 IXMLDOMDocument_Release(doc);
2586 /* Check invalid parameter */
2587 r = IXMLDOMNode_cloneNode(node, VARIANT_TRUE, NULL);
2588 ok( r == E_INVALIDARG, "ret %08x\n", r );
2591 r = IXMLDOMNode_cloneNode(node, VARIANT_TRUE, &node_clone);
2592 ok( r == S_OK, "ret %08x\n", r );
2593 ok( node_clone != NULL, "node %p\n", node );
2597 IXMLDOMDocument_Release(doc);
2598 IXMLDOMNode_Release(node);
2602 r = IXMLDOMNode_get_firstChild(node_clone, &node_first);
2603 ok( r == S_OK, "ret %08x\n", r );
2606 IXMLDOMDocument *doc2;
2608 r = IXMLDOMNode_get_ownerDocument(node_clone, &doc2);
2609 ok( r == S_OK, "ret %08x\n", r );
2611 IXMLDOMDocument_Release(doc2);
2613 IXMLDOMNode_Release(node_first);
2616 r = IXMLDOMNode_get_childNodes(node, &pList);
2617 ok( r == S_OK, "ret %08x\n", r );
2620 IXMLDOMNodeList_get_length(pList, &nLength);
2621 IXMLDOMNodeList_Release(pList);
2624 r = IXMLDOMNode_get_attributes(node, &mapAttr);
2625 ok( r == S_OK, "ret %08x\n", r );
2628 IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt);
2629 IXMLDOMNamedNodeMap_Release(mapAttr);
2632 r = IXMLDOMNode_get_childNodes(node_clone, &pList);
2633 ok( r == S_OK, "ret %08x\n", r );
2636 IXMLDOMNodeList_get_length(pList, &nLength1);
2637 IXMLDOMNodeList_Release(pList);
2640 r = IXMLDOMNode_get_attributes(node_clone, &mapAttr);
2641 ok( r == S_OK, "ret %08x\n", r );
2644 IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt1);
2645 IXMLDOMNamedNodeMap_Release(mapAttr);
2648 ok(nLength == nLength1, "wrong Child count (%d, %d)\n", nLength, nLength1);
2649 ok(nAttrCnt == nAttrCnt1, "wrong Attribute count (%d, %d)\n", nAttrCnt, nAttrCnt1);
2650 IXMLDOMNode_Release(node_clone);
2653 r = IXMLDOMNode_cloneNode(node, VARIANT_FALSE, &node_clone);
2654 ok( r == S_OK, "ret %08x\n", r );
2655 ok( node_clone != NULL, "node %p\n", node );
2659 IXMLDOMDocument_Release(doc);
2660 IXMLDOMNode_Release(node);
2664 r = IXMLDOMNode_get_firstChild(node_clone, &node_first);
2665 ok( r == S_FALSE, "ret %08x\n", r );
2668 IXMLDOMDocument *doc2;
2670 r = IXMLDOMNode_get_ownerDocument(node_clone, &doc2);
2671 ok( r == S_OK, "ret %08x\n", r );
2673 IXMLDOMDocument_Release(doc2);
2675 IXMLDOMNode_Release(node_first);
2678 r = IXMLDOMNode_get_childNodes(node_clone, &pList);
2679 ok( r == S_OK, "ret %08x\n", r );
2682 IXMLDOMNodeList_get_length(pList, &nLength1);
2683 ok( nLength1 == 0, "Length should be 0 (%d)\n", nLength1);
2684 IXMLDOMNodeList_Release(pList);
2687 r = IXMLDOMNode_get_attributes(node_clone, &mapAttr);
2688 ok( r == S_OK, "ret %08x\n", r );
2691 IXMLDOMNamedNodeMap_get_length(mapAttr, &nAttrCnt1);
2692 ok( nAttrCnt1 == 3, "Attribute count should be 3 (%d)\n", nAttrCnt1);
2693 IXMLDOMNamedNodeMap_Release(mapAttr);
2696 ok(nLength != nLength1, "wrong Child count (%d, %d)\n", nLength, nLength1);
2697 ok(nAttrCnt == nAttrCnt1, "wrong Attribute count (%d, %d)\n", nAttrCnt, nAttrCnt1);
2698 IXMLDOMNode_Release(node_clone);
2701 IXMLDOMNode_Release(node);
2702 IXMLDOMDocument_Release(doc);
2705 static void test_xmlTypes(void)
2707 IXMLDOMDocument *doc = NULL;
2708 IXMLDOMElement *pRoot;
2710 IXMLDOMComment *pComment;
2711 IXMLDOMElement *pElement;
2712 IXMLDOMAttribute *pAttrubute;
2713 IXMLDOMNamedNodeMap *pAttribs;
2714 IXMLDOMCDATASection *pCDataSec;
2715 IXMLDOMImplementation *pIXMLDOMImplementation = NULL;
2716 IXMLDOMDocumentFragment *pDocFrag = NULL;
2717 IXMLDOMEntityReference *pEntityRef = NULL;
2719 IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1; /* Used for testing Siblings */
2723 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
2727 hr = IXMLDOMDocument_get_nextSibling(doc, NULL);
2728 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2730 hr = IXMLDOMDocument_get_nextSibling(doc, &pNextChild);
2731 ok(hr == S_FALSE, "ret %08x\n", hr );
2732 ok(pNextChild == NULL, "pDocChild not NULL\n");
2734 /* test previous Sibling */
2735 hr = IXMLDOMDocument_get_previousSibling(doc, NULL);
2736 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2738 pNextChild = (IXMLDOMNode *)0x1;
2739 hr = IXMLDOMDocument_get_previousSibling(doc, &pNextChild);
2740 ok(hr == S_FALSE, "ret %08x\n", hr );
2741 ok(pNextChild == NULL, "pNextChild not NULL\n");
2743 /* test get_attributes */
2744 hr = IXMLDOMDocument_get_attributes( doc, NULL );
2745 ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
2747 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2748 hr = IXMLDOMDocument_get_attributes( doc, &pAttribs);
2749 ok(hr == S_FALSE, "ret %08x\n", hr );
2750 ok( pAttribs == NULL, "pAttribs not NULL\n");
2752 /* test get_dataType */
2753 hr = IXMLDOMDocument_get_dataType(doc, &v);
2754 ok(hr == S_FALSE, "ret %08x\n", hr );
2755 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2758 /* test nodeTypeString */
2759 hr = IXMLDOMDocument_get_nodeTypeString(doc, &str);
2760 ok(hr == S_OK, "ret %08x\n", hr );
2761 ok( !lstrcmpW( str, _bstr_("document") ), "incorrect nodeTypeString string\n");
2764 /* test implementation */
2765 hr = IXMLDOMDocument_get_implementation(doc, NULL);
2766 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2768 hr = IXMLDOMDocument_get_implementation(doc, &pIXMLDOMImplementation);
2769 ok(hr == S_OK, "ret %08x\n", hr );
2772 VARIANT_BOOL hasFeature = VARIANT_TRUE;
2773 BSTR sEmpty = SysAllocStringLen(NULL, 0);
2775 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, NULL, sEmpty, &hasFeature);
2776 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2778 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, NULL);
2779 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2781 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
2782 ok(hr == S_OK, "ret %08x\n", hr );
2783 ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
2785 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, &hasFeature);
2786 ok(hr == S_OK, "ret %08x\n", hr );
2787 ok(hasFeature == VARIANT_FALSE, "hasFeature returned true\n");
2789 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), NULL, &hasFeature);
2790 ok(hr == S_OK, "ret %08x\n", hr );
2791 ok(hasFeature == VARIANT_TRUE, "hasFeature returned false\n");
2793 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
2794 ok(hr == S_OK, "ret %08x\n", hr );
2795 ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
2797 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), _bstr_("1.0"), &hasFeature);
2798 ok(hr == S_OK, "ret %08x\n", hr );
2799 ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
2801 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("XML"), _bstr_("1.0"), &hasFeature);
2802 ok(hr == S_OK, "ret %08x\n", hr );
2803 ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
2805 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature);
2806 ok(hr == S_OK, "ret %08x\n", hr );
2807 ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
2809 hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("SSS"), NULL, &hasFeature);
2810 ok(hr == S_OK, "ret %08x\n", hr );
2811 ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
2813 SysFreeString(sEmpty);
2814 IXMLDOMImplementation_Release(pIXMLDOMImplementation);
2819 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
2820 ok(hr == S_OK, "ret %08x\n", hr );
2823 hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
2824 ok(hr == S_OK, "ret %08x\n", hr );
2828 hr = IXMLDOMDocument_createComment(doc, szComment, &pComment);
2829 ok(hr == S_OK, "ret %08x\n", hr );
2832 /* test get_attributes */
2833 hr = IXMLDOMComment_get_attributes( pComment, NULL );
2834 ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
2836 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
2837 hr = IXMLDOMComment_get_attributes( pComment, &pAttribs);
2838 ok(hr == S_FALSE, "ret %08x\n", hr );
2839 ok( pAttribs == NULL, "pAttribs not NULL\n");
2841 /* test nodeTypeString */
2842 hr = IXMLDOMComment_get_nodeTypeString(pComment, &str);
2843 ok(hr == S_OK, "ret %08x\n", hr );
2844 ok( !lstrcmpW( str, _bstr_("comment") ), "incorrect nodeTypeString string\n");
2847 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pComment, NULL);
2848 ok(hr == S_OK, "ret %08x\n", hr );
2850 hr = IXMLDOMComment_get_nodeName(pComment, &str);
2851 ok(hr == S_OK, "ret %08x\n", hr );
2852 ok( !lstrcmpW( str, szCommentNodeText ), "incorrect comment node Name\n");
2855 hr = IXMLDOMComment_get_xml(pComment, &str);
2856 ok(hr == S_OK, "ret %08x\n", hr );
2857 ok( !lstrcmpW( str, szCommentXML ), "incorrect comment xml\n");
2860 hr = IXMLDOMComment_get_dataType(pComment, &v);
2861 ok(hr == S_FALSE, "ret %08x\n", hr );
2862 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
2865 /* put data Tests */
2866 hr = IXMLDOMComment_put_data(pComment, _bstr_("This &is a ; test <>\\"));
2867 ok(hr == S_OK, "ret %08x\n", hr );
2869 /* get data Tests */
2870 hr = IXMLDOMComment_get_data(pComment, &str);
2871 ok(hr == S_OK, "ret %08x\n", hr );
2872 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
2875 /* get data Tests */
2876 hr = IXMLDOMComment_get_nodeValue(pComment, &v);
2877 ok(hr == S_OK, "ret %08x\n", hr );
2878 ok( V_VT(&v) == VT_BSTR, "incorrect dataType type\n");
2879 ok( !lstrcmpW( V_BSTR(&v), _bstr_("This &is a ; test <>\\") ), "incorrect get_nodeValue string\n");
2882 /* Confirm XML text is good */
2883 hr = IXMLDOMComment_get_xml(pComment, &str);
2884 ok(hr == S_OK, "ret %08x\n", hr );
2885 ok( !lstrcmpW( str, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
2888 /* Confirm we get the put_data Text back */
2889 hr = IXMLDOMComment_get_text(pComment, &str);
2890 ok(hr == S_OK, "ret %08x\n", hr );
2891 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
2894 /* test length property */
2895 hr = IXMLDOMComment_get_length(pComment, &len);
2896 ok(hr == S_OK, "ret %08x\n", hr );
2897 ok(len == 21, "expected 21 got %d\n", len);
2899 /* test substringData */
2900 hr = IXMLDOMComment_substringData(pComment, 0, 4, NULL);
2901 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2903 /* test substringData - Invalid offset */
2904 str = (BSTR)&szElement;
2905 hr = IXMLDOMComment_substringData(pComment, -1, 4, &str);
2906 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2907 ok( str == NULL, "incorrect string\n");
2909 /* test substringData - Invalid offset */
2910 str = (BSTR)&szElement;
2911 hr = IXMLDOMComment_substringData(pComment, 30, 0, &str);
2912 ok(hr == S_FALSE, "ret %08x\n", hr );
2913 ok( str == NULL, "incorrect string\n");
2915 /* test substringData - Invalid size */
2916 str = (BSTR)&szElement;
2917 hr = IXMLDOMComment_substringData(pComment, 0, -1, &str);
2918 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2919 ok( str == NULL, "incorrect string\n");
2921 /* test substringData - Invalid size */
2922 str = (BSTR)&szElement;
2923 hr = IXMLDOMComment_substringData(pComment, 2, 0, &str);
2924 ok(hr == S_FALSE, "ret %08x\n", hr );
2925 ok( str == NULL, "incorrect string\n");
2927 /* test substringData - Start of string */
2928 hr = IXMLDOMComment_substringData(pComment, 0, 4, &str);
2929 ok(hr == S_OK, "ret %08x\n", hr );
2930 ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
2933 /* test substringData - Middle of string */
2934 hr = IXMLDOMComment_substringData(pComment, 13, 4, &str);
2935 ok(hr == S_OK, "ret %08x\n", hr );
2936 ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
2939 /* test substringData - End of string */
2940 hr = IXMLDOMComment_substringData(pComment, 20, 4, &str);
2941 ok(hr == S_OK, "ret %08x\n", hr );
2942 ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
2945 /* test appendData */
2946 hr = IXMLDOMComment_appendData(pComment, NULL);
2947 ok(hr == S_OK, "ret %08x\n", hr );
2949 hr = IXMLDOMComment_appendData(pComment, _bstr_(""));
2950 ok(hr == S_OK, "ret %08x\n", hr );
2952 hr = IXMLDOMComment_appendData(pComment, _bstr_("Append"));
2953 ok(hr == S_OK, "ret %08x\n", hr );
2955 hr = IXMLDOMComment_get_text(pComment, &str);
2956 ok(hr == S_OK, "ret %08x\n", hr );
2957 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
2960 /* test insertData */
2961 str = SysAllocStringLen(NULL, 0);
2962 hr = IXMLDOMComment_insertData(pComment, -1, str);
2963 ok(hr == S_OK, "ret %08x\n", hr );
2965 hr = IXMLDOMComment_insertData(pComment, -1, NULL);
2966 ok(hr == S_OK, "ret %08x\n", hr );
2968 hr = IXMLDOMComment_insertData(pComment, 1000, str);
2969 ok(hr == S_OK, "ret %08x\n", hr );
2971 hr = IXMLDOMComment_insertData(pComment, 1000, NULL);
2972 ok(hr == S_OK, "ret %08x\n", hr );
2974 hr = IXMLDOMComment_insertData(pComment, 0, NULL);
2975 ok(hr == S_OK, "ret %08x\n", hr );
2977 hr = IXMLDOMComment_insertData(pComment, 0, str);
2978 ok(hr == S_OK, "ret %08x\n", hr );
2981 hr = IXMLDOMComment_insertData(pComment, -1, _bstr_("Inserting"));
2982 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2984 hr = IXMLDOMComment_insertData(pComment, 1000, _bstr_("Inserting"));
2985 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
2987 hr = IXMLDOMComment_insertData(pComment, 0, _bstr_("Begin "));
2988 ok(hr == S_OK, "ret %08x\n", hr );
2990 hr = IXMLDOMComment_insertData(pComment, 17, _bstr_("Middle"));
2991 ok(hr == S_OK, "ret %08x\n", hr );
2993 hr = IXMLDOMComment_insertData(pComment, 39, _bstr_(" End"));
2994 ok(hr == S_OK, "ret %08x\n", hr );
2996 hr = IXMLDOMComment_get_text(pComment, &str);
2997 ok(hr == S_OK, "ret %08x\n", hr );
2998 ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3002 /* invalid arguments */
3003 hr = IXMLDOMComment_deleteData(pComment, -1, 1);
3004 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3006 hr = IXMLDOMComment_deleteData(pComment, 0, 0);
3007 ok(hr == S_OK, "ret %08x\n", hr );
3009 hr = IXMLDOMComment_deleteData(pComment, 0, -1);
3010 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3012 hr = IXMLDOMComment_get_length(pComment, &len);
3013 ok(hr == S_OK, "ret %08x\n", hr );
3014 ok(len == 43, "expected 43 got %d\n", len);
3016 hr = IXMLDOMComment_deleteData(pComment, len, 1);
3017 ok(hr == S_OK, "ret %08x\n", hr );
3019 hr = IXMLDOMComment_deleteData(pComment, len+1, 1);
3020 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3022 /* delete from start */
3023 hr = IXMLDOMComment_deleteData(pComment, 0, 5);
3024 ok(hr == S_OK, "ret %08x\n", hr );
3026 hr = IXMLDOMComment_get_length(pComment, &len);
3027 ok(hr == S_OK, "ret %08x\n", hr );
3028 ok(len == 38, "expected 38 got %d\n", len);
3030 hr = IXMLDOMComment_get_text(pComment, &str);
3031 ok(hr == S_OK, "ret %08x\n", hr );
3032 ok( !lstrcmpW( str, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3035 /* delete from end */
3036 hr = IXMLDOMComment_deleteData(pComment, 35, 3);
3037 ok(hr == S_OK, "ret %08x\n", hr );
3039 hr = IXMLDOMComment_get_length(pComment, &len);
3040 ok(hr == S_OK, "ret %08x\n", hr );
3041 ok(len == 35, "expected 35 got %d\n", len);
3043 hr = IXMLDOMComment_get_text(pComment, &str);
3044 ok(hr == S_OK, "ret %08x\n", hr );
3045 ok( !lstrcmpW( str, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string\n");
3048 /* delete from inside */
3049 hr = IXMLDOMComment_deleteData(pComment, 1, 33);
3050 ok(hr == S_OK, "ret %08x\n", hr );
3052 hr = IXMLDOMComment_get_length(pComment, &len);
3053 ok(hr == S_OK, "ret %08x\n", hr );
3054 ok(len == 2, "expected 2 got %d\n", len);
3056 hr = IXMLDOMComment_get_text(pComment, &str);
3057 ok(hr == S_OK, "ret %08x\n", hr );
3058 ok( !lstrcmpW( str, _bstr_(" ") ), "incorrect get_text string\n");
3061 /* delete whole data ... */
3062 hr = IXMLDOMComment_get_length(pComment, &len);
3063 ok(hr == S_OK, "ret %08x\n", hr );
3065 hr = IXMLDOMComment_deleteData(pComment, 0, len);
3066 ok(hr == S_OK, "ret %08x\n", hr );
3067 /* ... and try again with empty string */
3068 hr = IXMLDOMComment_deleteData(pComment, 0, len);
3069 ok(hr == S_OK, "ret %08x\n", hr );
3071 IXMLDOMComment_Release(pComment);
3075 hr = IXMLDOMDocument_createElement(doc, szElement, &pElement);
3076 ok(hr == S_OK, "ret %08x\n", hr );
3079 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3080 ok(hr == S_OK, "ret %08x\n", hr );
3082 /* test nodeTypeString */
3083 hr = IXMLDOMDocument_get_nodeTypeString(pElement, &str);
3084 ok(hr == S_OK, "ret %08x\n", hr );
3085 ok( !lstrcmpW( str, _bstr_("element") ), "incorrect nodeTypeString string\n");
3088 hr = IXMLDOMElement_get_nodeName(pElement, &str);
3089 ok(hr == S_OK, "ret %08x\n", hr );
3090 ok( !lstrcmpW( str, szElement ), "incorrect element node Name\n");
3093 hr = IXMLDOMElement_get_xml(pElement, &str);
3094 ok(hr == S_OK, "ret %08x\n", hr );
3095 ok( !lstrcmpW( str, szElementXML ), "incorrect element xml\n");
3098 hr = IXMLDOMElement_get_dataType(pElement, &v);
3099 ok(hr == S_FALSE, "ret %08x\n", hr );
3100 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
3104 hr = IXMLDOMDocument_createAttribute(doc, szAttribute, &pAttrubute);
3105 ok(hr == S_OK, "ret %08x\n", hr );
3108 IXMLDOMNode *pNewChild = (IXMLDOMNode *)0x1;
3110 hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, NULL);
3111 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3113 pNextChild = (IXMLDOMNode *)0x1;
3114 hr = IXMLDOMAttribute_get_nextSibling(pAttrubute, &pNextChild);
3115 ok(hr == S_FALSE, "ret %08x\n", hr );
3116 ok(pNextChild == NULL, "pNextChild not NULL\n");
3118 /* test Previous Sibling*/
3119 hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, NULL);
3120 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3122 pNextChild = (IXMLDOMNode *)0x1;
3123 hr = IXMLDOMAttribute_get_previousSibling(pAttrubute, &pNextChild);
3124 ok(hr == S_FALSE, "ret %08x\n", hr );
3125 ok(pNextChild == NULL, "pNextChild not NULL\n");
3127 /* test get_attributes */
3128 hr = IXMLDOMAttribute_get_attributes( pAttrubute, NULL );
3129 ok( hr == E_INVALIDARG, "get_attributes returned wrong code\n");
3131 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
3132 hr = IXMLDOMAttribute_get_attributes( pAttrubute, &pAttribs);
3133 ok(hr == S_FALSE, "ret %08x\n", hr );
3134 ok( pAttribs == NULL, "pAttribs not NULL\n");
3136 hr = IXMLDOMElement_appendChild(pElement, (IXMLDOMNode*)pAttrubute, &pNewChild);
3137 ok(hr == E_FAIL, "ret %08x\n", hr );
3138 ok(pNewChild == NULL, "pNewChild not NULL\n");
3140 hr = IXMLDOMElement_get_attributes(pElement, &pAttribs);
3141 ok(hr == S_OK, "ret %08x\n", hr );
3144 hr = IXMLDOMNamedNodeMap_setNamedItem(pAttribs, (IXMLDOMNode*)pAttrubute, NULL );
3145 ok(hr == S_OK, "ret %08x\n", hr );
3147 IXMLDOMNamedNodeMap_Release(pAttribs);
3150 hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str);
3151 ok(hr == S_OK, "ret %08x\n", hr );
3152 ok( !lstrcmpW( str, szAttribute ), "incorrect attribute node Name\n");
3155 /* test nodeTypeString */
3156 hr = IXMLDOMAttribute_get_nodeTypeString(pAttrubute, &str);
3157 ok(hr == S_OK, "ret %08x\n", hr );
3158 ok( !lstrcmpW( str, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
3162 hr = IXMLDOMAttribute_get_nodeName(pAttrubute, &str);
3163 ok(hr == S_OK, "ret %08x\n", hr );
3164 ok( !lstrcmpW( str, szAttribute ), "incorrect nodeName string\n");
3167 /* test name property */
3168 hr = IXMLDOMAttribute_get_name(pAttrubute, &str);
3169 ok(hr == S_OK, "ret %08x\n", hr );
3170 ok( !lstrcmpW( str, szAttribute ), "incorrect name string\n");
3173 hr = IXMLDOMAttribute_get_xml(pAttrubute, &str);
3174 ok(hr == S_OK, "ret %08x\n", hr );
3175 ok( !lstrcmpW( str, szAttributeXML ), "incorrect attribute xml\n");
3178 hr = IXMLDOMAttribute_get_dataType(pAttrubute, &v);
3179 ok(hr == S_FALSE, "ret %08x\n", hr );
3180 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
3183 IXMLDOMAttribute_Release(pAttrubute);
3185 /* Check Element again with the Add Attribute*/
3186 hr = IXMLDOMElement_get_xml(pElement, &str);
3187 ok(hr == S_OK, "ret %08x\n", hr );
3188 ok( !lstrcmpW( str, szElementXML2 ), "incorrect element xml\n");
3192 hr = IXMLDOMElement_put_text(pElement, _bstr_("TestingNode"));
3193 ok(hr == S_OK, "ret %08x\n", hr );
3195 hr = IXMLDOMElement_get_xml(pElement, &str);
3196 ok(hr == S_OK, "ret %08x\n", hr );
3197 ok( !lstrcmpW( str, szElementXML3 ), "incorrect element xml\n");
3200 /* Test for reversible escaping */
3201 str = SysAllocString( szStrangeChars );
3202 hr = IXMLDOMElement_put_text(pElement, str);
3203 ok(hr == S_OK, "ret %08x\n", hr );
3204 SysFreeString( str );
3206 hr = IXMLDOMElement_get_xml(pElement, &str);
3207 ok(hr == S_OK, "ret %08x\n", hr );
3208 ok( !lstrcmpW( str, szElementXML4 ), "incorrect element xml\n");
3211 hr = IXMLDOMElement_get_text(pElement, &str);
3212 ok(hr == S_OK, "ret %08x\n", hr );
3213 ok( !lstrcmpW( str, szStrangeChars ), "incorrect element text\n");
3216 IXMLDOMElement_Release(pElement);
3220 hr = IXMLDOMDocument_createCDATASection(doc, szCData, NULL);
3221 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3223 hr = IXMLDOMDocument_createCDATASection(doc, szCData, &pCDataSec);
3224 ok(hr == S_OK, "ret %08x\n", hr );
3227 IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1;
3232 hr = IXMLDOMCDATASection_QueryInterface(pCDataSec, &IID_IXMLDOMElement, (LPVOID*)&pElement);
3233 ok(hr == E_NOINTERFACE, "ret %08x\n", hr);
3235 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pCDataSec, NULL);
3236 ok(hr == S_OK, "ret %08x\n", hr );
3238 /* get Attribute Tests */
3239 hr = IXMLDOMCDATASection_get_attributes(pCDataSec, NULL);
3240 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3242 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
3243 hr = IXMLDOMCDATASection_get_attributes(pCDataSec, &pAttribs);
3244 ok(hr == S_FALSE, "ret %08x\n", hr );
3245 ok(pAttribs == NULL, "pAttribs != NULL\n");
3247 hr = IXMLDOMCDATASection_get_nodeName(pCDataSec, &str);
3248 ok(hr == S_OK, "ret %08x\n", hr );
3249 ok( !lstrcmpW( str, szCDataNodeText ), "incorrect cdata node Name\n");
3252 hr = IXMLDOMCDATASection_get_xml(pCDataSec, &str);
3253 ok(hr == S_OK, "ret %08x\n", hr );
3254 ok( !lstrcmpW( str, szCDataXML ), "incorrect cdata xml\n");
3257 /* test lastChild */
3258 pNextChild = (IXMLDOMNode*)0x1;
3259 hr = IXMLDOMCDATASection_get_lastChild(pCDataSec, &pNextChild);
3260 ok(hr == S_FALSE, "ret %08x\n", hr );
3261 ok(pNextChild == NULL, "pNextChild not NULL\n");
3263 /* test get_dataType */
3264 hr = IXMLDOMCDATASection_get_dataType(pCDataSec, NULL);
3265 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3267 hr = IXMLDOMCDATASection_get_dataType(pCDataSec, &v);
3268 ok(hr == S_FALSE, "ret %08x\n", hr );
3269 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
3272 /* test nodeTypeString */
3273 hr = IXMLDOMCDATASection_get_nodeTypeString(pCDataSec, &str);
3274 ok(hr == S_OK, "ret %08x\n", hr );
3275 ok( !lstrcmpW( str, _bstr_("cdatasection") ), "incorrect nodeTypeString string\n");
3278 /* put data Tests */
3279 hr = IXMLDOMCDATASection_put_data(pCDataSec, _bstr_("This &is a ; test <>\\"));
3280 ok(hr == S_OK, "ret %08x\n", hr );
3282 /* Confirm XML text is good */
3283 hr = IXMLDOMCDATASection_get_xml(pCDataSec, &str);
3284 ok(hr == S_OK, "ret %08x\n", hr );
3285 ok( !lstrcmpW( str, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
3288 /* Confirm we get the put_data Text back */
3289 hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
3290 ok(hr == S_OK, "ret %08x\n", hr );
3291 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3294 /* test length property */
3295 hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
3296 ok(hr == S_OK, "ret %08x\n", hr );
3297 ok(len == 21, "expected 21 got %d\n", len);
3299 /* test get nodeValue */
3300 hr = IXMLDOMCDATASection_get_nodeValue(pCDataSec, &var);
3301 ok(hr == S_OK, "ret %08x\n", hr );
3302 ok(V_VT(&var) == VT_BSTR, "got vt %04x\n", V_VT(&var));
3303 ok( !lstrcmpW( V_BSTR(&var), _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3307 hr = IXMLDOMCDATASection_get_data(pCDataSec, &str);
3308 ok(hr == S_OK, "ret %08x\n", hr );
3309 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3312 /* test substringData */
3313 hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, 4, NULL);
3314 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3316 /* test substringData - Invalid offset */
3317 str = (BSTR)&szElement;
3318 hr = IXMLDOMCDATASection_substringData(pCDataSec, -1, 4, &str);
3319 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3320 ok( str == NULL, "incorrect string\n");
3322 /* test substringData - Invalid offset */
3323 str = (BSTR)&szElement;
3324 hr = IXMLDOMCDATASection_substringData(pCDataSec, 30, 0, &str);
3325 ok(hr == S_FALSE, "ret %08x\n", hr );
3326 ok( str == NULL, "incorrect string\n");
3328 /* test substringData - Invalid size */
3329 str = (BSTR)&szElement;
3330 hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, -1, &str);
3331 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3332 ok( str == NULL, "incorrect string\n");
3334 /* test substringData - Invalid size */
3335 str = (BSTR)&szElement;
3336 hr = IXMLDOMCDATASection_substringData(pCDataSec, 2, 0, &str);
3337 ok(hr == S_FALSE, "ret %08x\n", hr );
3338 ok( str == NULL, "incorrect string\n");
3340 /* test substringData - Start of string */
3341 hr = IXMLDOMCDATASection_substringData(pCDataSec, 0, 4, &str);
3342 ok(hr == S_OK, "ret %08x\n", hr );
3343 ok( !lstrcmpW( str, _bstr_("This") ), "incorrect substringData string\n");
3346 /* test substringData - Middle of string */
3347 hr = IXMLDOMCDATASection_substringData(pCDataSec, 13, 4, &str);
3348 ok(hr == S_OK, "ret %08x\n", hr );
3349 ok( !lstrcmpW( str, _bstr_("test") ), "incorrect substringData string\n");
3352 /* test substringData - End of string */
3353 hr = IXMLDOMCDATASection_substringData(pCDataSec, 20, 4, &str);
3354 ok(hr == S_OK, "ret %08x\n", hr );
3355 ok( !lstrcmpW( str, _bstr_("\\") ), "incorrect substringData string\n");
3358 /* test appendData */
3359 hr = IXMLDOMCDATASection_appendData(pCDataSec, NULL);
3360 ok(hr == S_OK, "ret %08x\n", hr );
3362 hr = IXMLDOMCDATASection_appendData(pCDataSec, _bstr_(""));
3363 ok(hr == S_OK, "ret %08x\n", hr );
3365 hr = IXMLDOMCDATASection_appendData(pCDataSec, _bstr_("Append"));
3366 ok(hr == S_OK, "ret %08x\n", hr );
3368 hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
3369 ok(hr == S_OK, "ret %08x\n", hr );
3370 ok( !lstrcmpW( str, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
3373 /* test insertData */
3374 str = SysAllocStringLen(NULL, 0);
3375 hr = IXMLDOMCDATASection_insertData(pCDataSec, -1, str);
3376 ok(hr == S_OK, "ret %08x\n", hr );
3378 hr = IXMLDOMCDATASection_insertData(pCDataSec, -1, NULL);
3379 ok(hr == S_OK, "ret %08x\n", hr );
3381 hr = IXMLDOMCDATASection_insertData(pCDataSec, 1000, str);
3382 ok(hr == S_OK, "ret %08x\n", hr );
3384 hr = IXMLDOMCDATASection_insertData(pCDataSec, 1000, NULL);
3385 ok(hr == S_OK, "ret %08x\n", hr );
3387 hr = IXMLDOMCDATASection_insertData(pCDataSec, 0, NULL);
3388 ok(hr == S_OK, "ret %08x\n", hr );
3390 hr = IXMLDOMCDATASection_insertData(pCDataSec, 0, str);
3391 ok(hr == S_OK, "ret %08x\n", hr );
3394 hr = IXMLDOMCDATASection_insertData(pCDataSec, -1, _bstr_("Inserting"));
3395 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3397 hr = IXMLDOMCDATASection_insertData(pCDataSec, 1000, _bstr_("Inserting"));
3398 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3400 hr = IXMLDOMCDATASection_insertData(pCDataSec, 0, _bstr_("Begin "));
3401 ok(hr == S_OK, "ret %08x\n", hr );
3403 hr = IXMLDOMCDATASection_insertData(pCDataSec, 17, _bstr_("Middle"));
3404 ok(hr == S_OK, "ret %08x\n", hr );
3406 hr = IXMLDOMCDATASection_insertData(pCDataSec, 39, _bstr_(" End"));
3407 ok(hr == S_OK, "ret %08x\n", hr );
3409 hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
3410 ok(hr == S_OK, "ret %08x\n", hr );
3411 ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3415 /* invalid arguments */
3416 hr = IXMLDOMCDATASection_deleteData(pCDataSec, -1, 1);
3417 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3419 hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, 0);
3420 ok(hr == S_OK, "ret %08x\n", hr );
3422 hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, -1);
3423 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3425 hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
3426 ok(hr == S_OK, "ret %08x\n", hr );
3427 ok(len == 43, "expected 43 got %d\n", len);
3429 hr = IXMLDOMCDATASection_deleteData(pCDataSec, len, 1);
3430 ok(hr == S_OK, "ret %08x\n", hr );
3432 hr = IXMLDOMCDATASection_deleteData(pCDataSec, len+1, 1);
3433 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3435 /* delete from start */
3436 hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, 5);
3437 ok(hr == S_OK, "ret %08x\n", hr );
3439 hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
3440 ok(hr == S_OK, "ret %08x\n", hr );
3441 ok(len == 38, "expected 38 got %d\n", len);
3443 hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
3444 ok(hr == S_OK, "ret %08x\n", hr );
3445 ok( !lstrcmpW( str, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3448 /* delete from end */
3449 hr = IXMLDOMCDATASection_deleteData(pCDataSec, 35, 3);
3450 ok(hr == S_OK, "ret %08x\n", hr );
3452 hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
3453 ok(hr == S_OK, "ret %08x\n", hr );
3454 ok(len == 35, "expected 35 got %d\n", len);
3456 hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
3457 ok(hr == S_OK, "ret %08x\n", hr );
3458 ok( !lstrcmpW( str, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string\n");
3461 /* delete from inside */
3462 hr = IXMLDOMCDATASection_deleteData(pCDataSec, 1, 33);
3463 ok(hr == S_OK, "ret %08x\n", hr );
3465 hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
3466 ok(hr == S_OK, "ret %08x\n", hr );
3467 ok(len == 2, "expected 2 got %d\n", len);
3469 hr = IXMLDOMCDATASection_get_text(pCDataSec, &str);
3470 ok(hr == S_OK, "ret %08x\n", hr );
3471 ok( !lstrcmpW( str, _bstr_(" ") ), "incorrect get_text string\n");
3474 /* delete whole data ... */
3475 hr = IXMLDOMCDATASection_get_length(pCDataSec, &len);
3476 ok(hr == S_OK, "ret %08x\n", hr );
3478 hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, len);
3479 ok(hr == S_OK, "ret %08x\n", hr );
3481 /* ... and try again with empty string */
3482 hr = IXMLDOMCDATASection_deleteData(pCDataSec, 0, len);
3483 ok(hr == S_OK, "ret %08x\n", hr );
3485 IXMLDOMCDATASection_Release(pCDataSec);
3488 /* Document Fragments */
3489 hr = IXMLDOMDocument_createDocumentFragment(doc, NULL);
3490 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3492 hr = IXMLDOMDocument_createDocumentFragment(doc, &pDocFrag);
3493 ok(hr == S_OK, "ret %08x\n", hr );
3496 IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1;
3498 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pDocFrag, NULL);
3499 ok(hr == S_OK, "ret %08x\n", hr );
3501 /* get Attribute Tests */
3502 hr = IXMLDOMDocumentFragment_get_attributes(pDocFrag, NULL);
3503 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3505 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
3506 hr = IXMLDOMDocumentFragment_get_attributes(pDocFrag, &pAttribs);
3507 ok(hr == S_FALSE, "ret %08x\n", hr );
3508 ok(pAttribs == NULL, "pAttribs != NULL\n");
3510 hr = IXMLDOMDocumentFragment_get_nodeName(pDocFrag, &str);
3511 ok(hr == S_OK, "ret %08x\n", hr );
3512 ok( !lstrcmpW( str, szDocFragmentText ), "incorrect docfragment node Name\n");
3515 /* test next Sibling*/
3516 hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, NULL);
3517 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3519 pNextChild = (IXMLDOMNode *)0x1;
3520 hr = IXMLDOMDocumentFragment_get_nextSibling(pDocFrag, &pNextChild);
3521 ok(hr == S_FALSE, "ret %08x\n", hr );
3522 ok(pNextChild == NULL, "pNextChild not NULL\n");
3524 /* test Previous Sibling*/
3525 hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, NULL);
3526 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3528 pNextChild = (IXMLDOMNode *)0x1;
3529 hr = IXMLDOMDocumentFragment_get_previousSibling(pDocFrag, &pNextChild);
3530 ok(hr == S_FALSE, "ret %08x\n", hr );
3531 ok(pNextChild == NULL, "pNextChild not NULL\n");
3533 /* test get_dataType */
3534 hr = IXMLDOMDocumentFragment_get_dataType(pDocFrag, NULL);
3535 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3537 hr = IXMLDOMDocumentFragment_get_dataType(pDocFrag, &v);
3538 ok(hr == S_FALSE, "ret %08x\n", hr );
3539 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
3542 /* test nodeTypeString */
3543 hr = IXMLDOMDocumentFragment_get_nodeTypeString(pDocFrag, &str);
3544 ok(hr == S_OK, "ret %08x\n", hr );
3545 ok( !lstrcmpW( str, _bstr_("documentfragment") ), "incorrect nodeTypeString string\n");
3548 IXMLDOMDocumentFragment_Release(pDocFrag);
3551 /* Entity References */
3552 hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, NULL);
3553 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3555 hr = IXMLDOMDocument_createEntityReference(doc, szEntityRef, &pEntityRef);
3556 ok(hr == S_OK, "ret %08x\n", hr );
3559 hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pEntityRef, NULL);
3560 ok(hr == S_OK, "ret %08x\n", hr );
3562 /* get Attribute Tests */
3563 hr = IXMLDOMEntityReference_get_attributes(pEntityRef, NULL);
3564 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3566 pAttribs = (IXMLDOMNamedNodeMap*)0x1;
3567 hr = IXMLDOMEntityReference_get_attributes(pEntityRef, &pAttribs);
3568 ok(hr == S_FALSE, "ret %08x\n", hr );
3569 ok(pAttribs == NULL, "pAttribs != NULL\n");
3572 hr = IXMLDOMEntityReference_get_dataType(pEntityRef, &v);
3573 ok(hr == S_FALSE, "ret %08x\n", hr );
3574 ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
3577 /* test nodeTypeString */
3578 hr = IXMLDOMEntityReference_get_nodeTypeString(pEntityRef, &str);
3579 ok(hr == S_OK, "ret %08x\n", hr );
3580 ok( !lstrcmpW( str, _bstr_("entityreference") ), "incorrect nodeTypeString string\n");
3584 hr = IXMLDOMEntityReference_get_xml(pEntityRef, &str);
3585 ok(hr == S_OK, "ret %08x\n", hr );
3586 ok( !lstrcmpW( str, szEntityRefXML ), "incorrect xml string\n");
3589 IXMLDOMEntityReference_Release(pEntityRef);
3592 IXMLDOMElement_Release( pRoot );
3596 IXMLDOMDocument_Release(doc);
3601 static void test_nodeTypeTests( void )
3603 IXMLDOMDocument *doc = NULL;
3604 IXMLDOMElement *pRoot;
3605 IXMLDOMElement *pElement;
3608 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
3612 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
3613 ok(hr == S_OK, "ret %08x\n", hr );
3616 hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
3617 ok(hr == S_OK, "ret %08x\n", hr );
3620 hr = IXMLDOMElement_put_dataType(pRoot, NULL);
3621 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
3624 hr = IXMLDOMElement_put_dataType(pRoot, _bstr_("abcdefg") );
3625 ok(hr == E_FAIL, "ret %08x\n", hr );
3628 * The name passed into put_dataType is case-insensitive. So many of the names
3629 * have been changed to reflect this.
3632 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Boolean"), &pElement);
3633 ok(hr == S_OK, "ret %08x\n", hr );
3636 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3638 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Boolean") );
3639 ok(hr == S_OK, "ret %08x\n", hr );
3641 IXMLDOMElement_Release(pElement);
3645 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_String"), &pElement);
3646 ok(hr == S_OK, "ret %08x\n", hr );
3649 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3651 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("String") );
3652 ok(hr == S_OK, "ret %08x\n", hr );
3654 IXMLDOMElement_Release(pElement);
3658 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Number"), &pElement);
3659 ok(hr == S_OK, "ret %08x\n", hr );
3662 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3664 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("number") );
3665 ok(hr == S_OK, "ret %08x\n", hr );
3667 IXMLDOMElement_Release(pElement);
3671 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Int"), &pElement);
3672 ok(hr == S_OK, "ret %08x\n", hr );
3675 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3677 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("InT") );
3678 ok(hr == S_OK, "ret %08x\n", hr );
3680 IXMLDOMElement_Release(pElement);
3684 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Fixed"), &pElement);
3685 ok(hr == S_OK, "ret %08x\n", hr );
3688 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3690 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("fixed.14.4") );
3691 ok(hr == S_OK, "ret %08x\n", hr );
3693 IXMLDOMElement_Release(pElement);
3697 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_DateTime"), &pElement);
3698 ok(hr == S_OK, "ret %08x\n", hr );
3701 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3703 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime") );
3704 ok(hr == S_OK, "ret %08x\n", hr );
3706 IXMLDOMElement_Release(pElement);
3710 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_DateTime_tz"), &pElement);
3711 ok(hr == S_OK, "ret %08x\n", hr );
3714 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3716 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime.tz") );
3717 ok(hr == S_OK, "ret %08x\n", hr );
3719 IXMLDOMElement_Release(pElement);
3723 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Date"), &pElement);
3724 ok(hr == S_OK, "ret %08x\n", hr );
3727 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3729 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Date") );
3730 ok(hr == S_OK, "ret %08x\n", hr );
3732 IXMLDOMElement_Release(pElement);
3736 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Time"), &pElement);
3737 ok(hr == S_OK, "ret %08x\n", hr );
3740 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3742 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Time") );
3743 ok(hr == S_OK, "ret %08x\n", hr );
3745 IXMLDOMElement_Release(pElement);
3749 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Time_TZ"), &pElement);
3750 ok(hr == S_OK, "ret %08x\n", hr );
3753 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3755 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("Time.tz") );
3756 ok(hr == S_OK, "ret %08x\n", hr );
3758 IXMLDOMElement_Release(pElement);
3762 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I1"), &pElement);
3763 ok(hr == S_OK, "ret %08x\n", hr );
3766 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3768 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I1") );
3769 ok(hr == S_OK, "ret %08x\n", hr );
3771 IXMLDOMElement_Release(pElement);
3775 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I2"), &pElement);
3776 ok(hr == S_OK, "ret %08x\n", hr );
3779 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3781 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I2") );
3782 ok(hr == S_OK, "ret %08x\n", hr );
3784 IXMLDOMElement_Release(pElement);
3788 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_I4"), &pElement);
3789 ok(hr == S_OK, "ret %08x\n", hr );
3792 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3794 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("I4") );
3795 ok(hr == S_OK, "ret %08x\n", hr );
3797 IXMLDOMElement_Release(pElement);
3801 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI1"), &pElement);
3802 ok(hr == S_OK, "ret %08x\n", hr );
3805 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3807 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI1") );
3808 ok(hr == S_OK, "ret %08x\n", hr );
3810 IXMLDOMElement_Release(pElement);
3814 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI2"), &pElement);
3815 ok(hr == S_OK, "ret %08x\n", hr );
3818 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3820 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI2") );
3821 ok(hr == S_OK, "ret %08x\n", hr );
3823 IXMLDOMElement_Release(pElement);
3827 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_UI4"), &pElement);
3828 ok(hr == S_OK, "ret %08x\n", hr );
3831 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3833 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UI4") );
3834 ok(hr == S_OK, "ret %08x\n", hr );
3836 IXMLDOMElement_Release(pElement);
3840 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_r4"), &pElement);
3841 ok(hr == S_OK, "ret %08x\n", hr );
3844 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3846 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("r4") );
3847 ok(hr == S_OK, "ret %08x\n", hr );
3849 IXMLDOMElement_Release(pElement);
3853 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_r8"), &pElement);
3854 ok(hr == S_OK, "ret %08x\n", hr );
3857 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3859 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("r8") );
3860 ok(hr == S_OK, "ret %08x\n", hr );
3862 IXMLDOMElement_Release(pElement);
3866 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_float"), &pElement);
3867 ok(hr == S_OK, "ret %08x\n", hr );
3870 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3872 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("float") );
3873 ok(hr == S_OK, "ret %08x\n", hr );
3875 IXMLDOMElement_Release(pElement);
3879 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_uuid"), &pElement);
3880 ok(hr == S_OK, "ret %08x\n", hr );
3883 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3885 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("UuId") );
3886 ok(hr == S_OK, "ret %08x\n", hr );
3888 IXMLDOMElement_Release(pElement);
3892 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_bin_hex"), &pElement);
3893 ok(hr == S_OK, "ret %08x\n", hr );
3896 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3898 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("bin.hex") );
3899 ok(hr == S_OK, "ret %08x\n", hr );
3901 IXMLDOMElement_Release(pElement);
3905 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_bin_base64"), &pElement);
3906 ok(hr == S_OK, "ret %08x\n", hr );
3909 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3911 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("bin.base64") );
3912 ok(hr == S_OK, "ret %08x\n", hr );
3914 IXMLDOMElement_Release(pElement);
3917 /* Check changing types */
3918 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing_Change"), &pElement);
3919 ok(hr == S_OK, "ret %08x\n", hr );
3922 IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pElement, NULL);
3924 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("DateTime.tz") );
3925 ok(hr == S_OK, "ret %08x\n", hr );
3927 hr = IXMLDOMElement_put_dataType(pElement, _bstr_("string") );
3928 ok(hr == S_OK, "ret %08x\n", hr );
3930 IXMLDOMElement_Release(pElement);
3933 IXMLDOMElement_Release(pRoot);
3937 IXMLDOMDocument_Release(doc);
3942 static void test_DocumentSaveToDocument(void)
3944 IXMLDOMDocument *doc = NULL;
3945 IXMLDOMDocument *doc2 = NULL;
3946 IXMLDOMElement *pRoot;
3950 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
3954 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc2 );
3957 IXMLDOMDocument_Release(doc);
3961 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
3962 ok(hr == S_OK, "ret %08x\n", hr );
3965 hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
3966 ok(hr == S_OK, "ret %08x\n", hr );
3973 V_VT(&vDoc) = VT_UNKNOWN;
3974 V_UNKNOWN(&vDoc) = (IUnknown*)doc2;
3976 hr = IXMLDOMDocument_save(doc, vDoc);
3977 ok(hr == S_OK, "ret %08x\n", hr );
3979 hr = IXMLDOMDocument_get_xml(doc, &sOrig);
3980 ok(hr == S_OK, "ret %08x\n", hr );
3982 hr = IXMLDOMDocument_get_xml(doc2, &sNew);
3983 ok(hr == S_OK, "ret %08x\n", hr );
3985 ok( !lstrcmpW( sOrig, sNew ), "New document is not the same as origial\n");
3987 SysFreeString(sOrig);
3988 SysFreeString(sNew);
3992 IXMLDOMDocument_Release(doc2);
3993 IXMLDOMDocument_Release(doc);
3996 static void test_DocumentSaveToFile(void)
3998 IXMLDOMDocument *doc = NULL;
3999 IXMLDOMElement *pRoot;
4005 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
4009 hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
4010 ok(hr == S_OK, "ret %08x\n", hr );
4013 hr = IXMLDOMDocument_appendChild(doc, (IXMLDOMNode*)pRoot, NULL);
4014 ok(hr == S_OK, "ret %08x\n", hr );
4019 V_VT(&vFile) = VT_BSTR;
4020 V_BSTR(&vFile) = _bstr_("test.xml");
4022 hr = IXMLDOMDocument_save(doc, vFile);
4023 ok(hr == S_OK, "ret %08x\n", hr );
4027 IXMLDOMElement_Release(pRoot);
4028 IXMLDOMDocument_Release(doc);
4030 file = CreateFile("test.xml", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
4031 ok(file != INVALID_HANDLE_VALUE, "Could not open file: %u\n", GetLastError());
4032 if(file == INVALID_HANDLE_VALUE)
4035 ReadFile(file, buffer, sizeof(buffer), &read, NULL);
4036 ok(read != 0, "could not read file\n");
4037 ok(buffer[0] != '<' || buffer[1] != '?', "File contains processing instruction\n");
4040 DeleteFile("test.xml");
4043 static void test_testTransforms(void)
4045 IXMLDOMDocument *doc = NULL;
4046 IXMLDOMDocument *docSS = NULL;
4052 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
4056 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&docSS );
4059 IXMLDOMDocument_Release(doc);
4063 hr = IXMLDOMDocument_loadXML(doc, _bstr_(szTransformXML), &bSucc);
4064 ok(hr == S_OK, "ret %08x\n", hr );
4066 hr = IXMLDOMDocument_loadXML(docSS, _bstr_(szTransformSSXML), &bSucc);
4067 ok(hr == S_OK, "ret %08x\n", hr );
4069 hr = IXMLDOMDocument_QueryInterface(docSS, &IID_IXMLDOMNode, (LPVOID*)&pNode );
4070 ok(hr == S_OK, "ret %08x\n", hr );
4075 hr = IXMLDOMDocument_transformNode(doc, pNode, &bOut);
4076 ok(hr == S_OK, "ret %08x\n", hr );
4077 ok( compareIgnoreReturns( bOut, _bstr_(szTransformOutput)), "Stylesheet output not correct\n");
4078 SysFreeString(bOut);
4080 IXMLDOMNode_Release(pNode);
4083 IXMLDOMDocument_Release(docSS);
4084 IXMLDOMDocument_Release(doc);
4089 static void test_Namespaces(void)
4091 IXMLDOMDocument2 *doc = NULL;
4093 IXMLDOMNode *pNode2 = NULL;
4097 static const CHAR szNamespacesXML[] =
4098 "<?xml version=\"1.0\"?>\n"
4099 "<root xmlns:WEB='http://www.winehq.org'>\n"
4100 "<WEB:Site version=\"1.0\" />\n"
4103 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
4107 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szNamespacesXML), &bSucc);
4108 ok(hr == S_OK, "ret %08x\n", hr );
4109 ok(bSucc == VARIANT_TRUE, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4111 hr = IXMLDOMDocument_selectSingleNode(doc, _bstr_("root"), &pNode );
4112 ok(hr == S_OK, "ret %08x\n", hr );
4115 hr = IXMLDOMNode_get_firstChild( pNode, &pNode2 );
4116 ok( hr == S_OK, "ret %08x\n", hr );
4117 ok( pNode2 != NULL, "pNode2 == NULL\n");
4119 /* Test get_prefix */
4120 hr = IXMLDOMNode_get_prefix(pNode2, NULL);
4121 ok( hr == E_INVALIDARG, "ret %08x\n", hr );
4122 /* NOTE: Need to test that arg2 gets cleared on Error. */
4124 hr = IXMLDOMNode_get_prefix(pNode2, &str);
4125 ok( hr == S_OK, "ret %08x\n", hr );
4126 ok( !lstrcmpW( str, _bstr_("WEB")), "incorrect prefix string\n");
4129 /* Test get_namespaceURI */
4130 hr = IXMLDOMNode_get_namespaceURI(pNode2, NULL);
4131 ok( hr == E_INVALIDARG, "ret %08x\n", hr );
4132 /* NOTE: Need to test that arg2 gets cleared on Error. */
4134 hr = IXMLDOMNode_get_namespaceURI(pNode2, &str);
4135 ok( hr == S_OK, "ret %08x\n", hr );
4136 ok( !lstrcmpW( str, _bstr_("http://www.winehq.org")), "incorrect namespaceURI string\n");
4139 IXMLDOMNode_Release(pNode2);
4140 IXMLDOMNode_Release(pNode);
4143 IXMLDOMDocument2_Release(doc);
4148 static void test_FormattingXML(void)
4150 IXMLDOMDocument2 *doc = NULL;
4151 IXMLDOMElement *pElement;
4155 static const CHAR szLinefeedXML[] = "<?xml version=\"1.0\"?>\n<Root>\n\t<Sub val=\"A\" />\n</Root>";
4156 static const CHAR szLinefeedRootXML[] = "<Root>\r\n\t<Sub val=\"A\"/>\r\n</Root>";
4158 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
4162 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szLinefeedXML), &bSucc);
4163 ok(hr == S_OK, "ret %08x\n", hr );
4164 ok(bSucc == VARIANT_TRUE, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4166 if(bSucc == VARIANT_TRUE)
4168 hr = IXMLDOMDocument2_get_documentElement(doc, &pElement);
4169 ok(hr == S_OK, "ret %08x\n", hr );
4172 hr = IXMLDOMElement_get_xml(pElement, &str);
4173 ok(hr == S_OK, "ret %08x\n", hr );
4174 ok( !lstrcmpW( str, _bstr_(szLinefeedRootXML) ), "incorrect element xml\n");
4177 IXMLDOMElement_Release(pElement);
4181 IXMLDOMDocument2_Release(doc);
4186 static void test_NodeTypeValue(void)
4188 IXMLDOMDocument2 *doc = NULL;
4194 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
4198 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szTypeValueXML), &bSucc);
4199 ok(hr == S_OK, "ret %08x\n", hr );
4200 ok(bSucc == VARIANT_TRUE, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4201 if(bSucc == VARIANT_TRUE)
4203 hr = IXMLDOMDocument2_get_nodeValue(doc, NULL);
4204 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
4208 hr = IXMLDOMDocument2_get_nodeValue(doc, &v);
4209 ok(hr == S_FALSE, "ret %08x\n", hr );
4210 ok(V_VT(&v) == VT_NULL, "expect VT_NULL got %d\n", V_VT(&v));
4212 hr = IXMLDOMDocument2_get_nodeTypedValue(doc, NULL);
4213 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
4215 hr = IXMLDOMDocument2_get_nodeTypedValue(doc, &v);
4216 ok(hr == S_FALSE, "ret %08x\n", hr );
4218 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/string"), &pNode);
4219 ok(hr == S_OK, "ret %08x\n", hr );
4224 hr = IXMLDOMNode_get_nodeValue(pNode, &v);
4225 ok(hr == S_FALSE, "ret %08x\n", hr );
4226 ok(V_VT(&v) == VT_NULL, "expect VT_NULL got %d\n", V_VT(&v));
4228 hr = IXMLDOMNode_get_nodeTypedValue(pNode, NULL);
4229 ok(hr == E_INVALIDARG, "ret %08x\n", hr );
4231 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4232 ok(hr == S_OK, "ret %08x\n", hr );
4233 ok(V_VT(&v) == VT_BSTR, "incorrect type\n");
4234 ok(!lstrcmpW( V_BSTR(&v), _bstr_("Wine") ), "incorrect value\n");
4237 IXMLDOMNode_Release(pNode);
4240 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/string2"), &pNode);
4241 ok(hr == S_OK, "ret %08x\n", hr );
4244 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4245 ok(hr == S_OK, "ret %08x\n", hr );
4246 ok(V_VT(&v) == VT_BSTR, "incorrect type\n");
4247 ok(!lstrcmpW( V_BSTR(&v), _bstr_("String") ), "incorrect value\n");
4250 IXMLDOMNode_Release(pNode);
4253 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/number"), &pNode);
4254 ok(hr == S_OK, "ret %08x\n", hr );
4257 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4258 ok(hr == S_OK, "ret %08x\n", hr );
4259 ok(V_VT(&v) == VT_BSTR, "incorrect type\n");
4260 ok(!lstrcmpW( V_BSTR(&v), _bstr_("12.44") ), "incorrect value\n");
4263 IXMLDOMNode_Release(pNode);
4266 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/number2"), &pNode);
4267 ok(hr == S_OK, "ret %08x\n", hr );
4270 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4271 ok(hr == S_OK, "ret %08x\n", hr );
4272 ok(V_VT(&v) == VT_BSTR, "incorrect type\n");
4273 ok(!lstrcmpW( V_BSTR(&v), _bstr_("-3.71e3") ), "incorrect value\n");
4276 IXMLDOMNode_Release(pNode);
4279 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/int"), &pNode);
4280 ok(hr == S_OK, "ret %08x\n", hr );
4283 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4284 ok(hr == S_OK, "ret %08x\n", hr );
4285 ok(V_VT(&v) == VT_I4, "incorrect type\n");
4286 ok(V_I4(&v) == -13, "incorrect value\n");
4289 IXMLDOMNode_Release(pNode);
4292 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/fixed"), &pNode);
4293 ok(hr == S_OK, "ret %08x\n", hr );
4296 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4297 ok(hr == S_OK, "ret %08x\n", hr );
4298 ok(V_VT(&v) == VT_CY, "incorrect type\n");
4301 IXMLDOMNode_Release(pNode);
4304 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/bool"), &pNode);
4305 ok(hr == S_OK, "ret %08x\n", hr );
4308 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4309 ok(hr == S_OK, "ret %08x\n", hr );
4310 ok(V_VT(&v) == VT_BOOL, "incorrect type\n");
4311 ok(V_BOOL(&v) == VARIANT_TRUE, "incorrect value\n");
4314 IXMLDOMNode_Release(pNode);
4317 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/datetime"), &pNode);
4318 ok(hr == S_OK, "ret %08x\n", hr );
4321 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4322 ok(hr == S_OK, "ret %08x\n", hr );
4323 ok(V_VT(&v) == VT_DATE, "incorrect type\n");
4324 double_eq(40135.13996527778, V_DATE(&v));
4327 IXMLDOMNode_Release(pNode);
4330 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/datetimetz"), &pNode);
4331 ok(hr == S_OK, "ret %08x\n", hr );
4334 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4335 ok(hr == S_OK, "ret %08x\n", hr );
4336 ok(V_VT(&v) == VT_DATE, "incorrect type\n");
4337 double_eq(37813.59302083334, V_DATE(&v));
4340 IXMLDOMNode_Release(pNode);
4343 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/date"), &pNode);
4344 ok(hr == S_OK, "ret %08x\n", hr );
4347 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4348 ok(hr == S_OK, "ret %08x\n", hr );
4349 ok(V_VT(&v) == VT_DATE, "incorrect type\n");
4350 double_eq(665413.0, V_DATE(&v));
4353 IXMLDOMNode_Release(pNode);
4356 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/time"), &pNode);
4357 ok(hr == S_OK, "ret %08x\n", hr );
4360 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4361 ok(hr == S_OK, "ret %08x\n", hr );
4362 ok(V_VT(&v) == VT_DATE, "incorrect type\n");
4363 double_eq(0.5813888888888888, V_DATE(&v));
4366 IXMLDOMNode_Release(pNode);
4369 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/timetz"), &pNode);
4370 ok(hr == S_OK, "ret %08x\n", hr );
4373 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4374 ok(hr == S_OK, "ret %08x\n", hr );
4375 ok(V_VT(&v) == VT_DATE, "incorrect type\n");
4376 double_eq(1.112511574074074, V_DATE(&v));
4379 IXMLDOMNode_Release(pNode);
4382 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/i1"), &pNode);
4383 ok(hr == S_OK, "ret %08x\n", hr );
4386 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4387 ok(hr == S_OK, "ret %08x\n", hr );
4388 ok(V_VT(&v) == VT_I1, "incorrect type\n");
4389 ok(V_I1(&v) == -13, "incorrect value\n");
4392 IXMLDOMNode_Release(pNode);
4395 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/i2"), &pNode);
4396 ok(hr == S_OK, "ret %08x\n", hr );
4399 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4400 ok(hr == S_OK, "ret %08x\n", hr );
4401 ok(V_VT(&v) == VT_I2, "incorrect type\n");
4402 ok(V_I2(&v) == 31915, "incorrect value\n");
4405 IXMLDOMNode_Release(pNode);
4408 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/i4"), &pNode);
4409 ok(hr == S_OK, "ret %08x\n", hr );
4412 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4413 ok(hr == S_OK, "ret %08x\n", hr );
4414 ok(V_VT(&v) == VT_I4, "incorrect type\n");
4415 ok(V_I4(&v) == -312232, "incorrect value\n");
4418 IXMLDOMNode_Release(pNode);
4421 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/ui1"), &pNode);
4422 ok(hr == S_OK, "ret %08x\n", hr );
4425 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4426 ok(hr == S_OK, "ret %08x\n", hr );
4427 ok(V_VT(&v) == VT_UI1, "incorrect type\n");
4428 ok(V_UI1(&v) == 123, "incorrect value\n");
4431 IXMLDOMNode_Release(pNode);
4434 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/ui2"), &pNode);
4435 ok(hr == S_OK, "ret %08x\n", hr );
4438 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4439 ok(hr == S_OK, "ret %08x\n", hr );
4440 ok(V_VT(&v) == VT_UI2, "incorrect type\n");
4441 ok(V_UI2(&v) == 48282, "incorrect value\n");
4444 IXMLDOMNode_Release(pNode);
4447 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/ui4"), &pNode);
4448 ok(hr == S_OK, "ret %08x\n", hr );
4451 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4452 ok(hr == S_OK, "ret %08x\n", hr );
4453 ok(V_VT(&v) == VT_UI4, "incorrect type\n");
4454 ok(V_UI4(&v) == 949281, "incorrect value\n");
4457 IXMLDOMNode_Release(pNode);
4460 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/r4"), &pNode);
4461 ok(hr == S_OK, "ret %08x\n", hr );
4464 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4465 ok(hr == S_OK, "ret %08x\n", hr );
4466 ok(V_VT(&v) == VT_R4, "incorrect type\n");
4467 double_eq(213124.0, V_R4(&v));
4470 IXMLDOMNode_Release(pNode);
4473 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/r8"), &pNode);
4474 ok(hr == S_OK, "ret %08x\n", hr );
4477 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4478 ok(hr == S_OK, "ret %08x\n", hr );
4479 ok(V_VT(&v) == VT_R8, "incorrect type\n");
4480 double_eq(0.412, V_R8(&v));
4483 IXMLDOMNode_Release(pNode);
4486 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/float"), &pNode);
4487 ok(hr == S_OK, "ret %08x\n", hr );
4490 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4491 ok(hr == S_OK, "ret %08x\n", hr );
4492 ok(V_VT(&v) == VT_R8, "incorrect type\n");
4493 double_eq(41221.421, V_R8(&v));
4496 IXMLDOMNode_Release(pNode);
4499 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/uuid"), &pNode);
4500 ok(hr == S_OK, "ret %08x\n", hr );
4503 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4504 ok(hr == S_OK, "ret %08x\n", hr );
4505 ok(V_VT(&v) == VT_BSTR, "incorrect type\n");
4506 ok(!lstrcmpW(V_BSTR(&v), _bstr_("333C7BC4-460F-11D0-BC04-0080C7055a83")), "incorrect value\n");
4509 IXMLDOMNode_Release(pNode);
4512 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/binhex"), &pNode);
4513 ok(hr == S_OK, "ret %08x\n", hr );
4516 BYTE bytes[] = {0xff,0xfc,0xa0,0x12,0x00,0x3c};
4518 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4519 ok(hr == S_OK, "ret %08x\n", hr );
4520 ok(V_VT(&v) == (VT_ARRAY|VT_UI1), "incorrect type\n");
4521 ok(V_ARRAY(&v)->rgsabound[0].cElements == 6, "incorrect array size\n");
4522 if(V_ARRAY(&v)->rgsabound[0].cElements == 6)
4523 ok(!memcmp(bytes, V_ARRAY(&v)->pvData, sizeof(bytes)), "incorrect value\n");
4526 IXMLDOMNode_Release(pNode);
4529 hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/binbase64"), &pNode);
4530 ok(hr == S_OK, "ret %08x\n", hr );
4533 BYTE bytes[] = {0x62,0x61,0x73,0x65,0x36,0x34,0x20,0x74,0x65,0x73,0x74};
4535 hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
4536 ok(hr == S_OK, "ret %08x\n", hr );
4537 ok(V_VT(&v) == (VT_ARRAY|VT_UI1), "incorrect type\n");
4538 ok(V_ARRAY(&v)->rgsabound[0].cElements == 11, "incorrect array size\n");
4539 if(V_ARRAY(&v)->rgsabound[0].cElements == 11)
4540 ok(!memcmp(bytes, V_ARRAY(&v)->pvData, sizeof(bytes)), "incorrect value\n");
4543 IXMLDOMNode_Release(pNode);
4547 IXMLDOMDocument2_Release(doc);
4552 static void test_TransformWithLoadingLocalFile(void)
4554 IXMLDOMDocument2 *doc = NULL;
4555 IXMLDOMDocument2 *xsl = NULL;
4561 char lpPathBuffer[MAX_PATH];
4564 /* Create a Temp File. */
4565 GetTempPathA(MAX_PATH, lpPathBuffer);
4566 strcat(lpPathBuffer, "customers.xml" );
4568 file = CreateFile(lpPathBuffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
4569 ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
4570 if(file == INVALID_HANDLE_VALUE)
4573 WriteFile(file, szBasicTransformXML, strlen(szBasicTransformXML), &dwWritten, NULL);
4576 /* Correct path to not include a escape character. */
4577 for(i=0; i < strlen(lpPathBuffer); i++)
4579 if(lpPathBuffer[i] == '\\')
4580 lpPathBuffer[i] = '/';
4583 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&doc );
4587 hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (LPVOID*)&xsl );
4590 IXMLDOMDocument2_Release(doc);
4594 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(szTypeValueXML), &bSucc);
4595 ok(hr == S_OK, "ret %08x\n", hr );
4596 ok(bSucc == VARIANT_TRUE, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4597 if(bSucc == VARIANT_TRUE)
4600 BSTR sPart1 = _bstr_(szBasicTransformSSXMLPart1);
4601 BSTR sPart2 = _bstr_(szBasicTransformSSXMLPart2);
4602 BSTR sFileName = _bstr_(lpPathBuffer);
4603 int nLegnth = lstrlenW(sPart1) + lstrlenW(sPart2) + lstrlenW(sFileName) + 1;
4605 sXSL = SysAllocStringLen(NULL, nLegnth);
4606 lstrcpyW(sXSL, sPart1);
4607 lstrcatW(sXSL, sFileName);
4608 lstrcatW(sXSL, sPart2);
4610 hr = IXMLDOMDocument2_loadXML(xsl, sXSL, &bSucc);
4611 ok(hr == S_OK, "ret %08x\n", hr );
4612 ok(bSucc == VARIANT_TRUE, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4613 if(bSucc == VARIANT_TRUE)
4617 hr = IXMLDOMDocument_QueryInterface(xsl, &IID_IXMLDOMNode, (LPVOID*)&pNode );
4618 ok(hr == S_OK, "ret %08x\n", hr );
4621 /* This will load the temp file via the XSL */
4622 hr = IXMLDOMDocument2_transformNode(doc, pNode, &sResult);
4623 ok(hr == S_OK, "ret %08x\n", hr );
4626 ok( compareIgnoreReturns( sResult, _bstr_(szBasicTransformOutput)), "Stylesheet output not correct\n");
4627 SysFreeString(sResult);
4630 IXMLDOMNode_Release(pNode);
4634 SysFreeString(sXSL);
4637 IXMLDOMDocument2_Release(doc);
4638 IXMLDOMDocument2_Release(xsl);
4640 DeleteFile(lpPathBuffer);
4648 r = CoInitialize( NULL );
4649 ok( r == S_OK, "failed to init com\n");
4655 test_getElementsByTagName();
4657 test_get_childNodes();
4659 test_replaceChild();
4660 test_removeNamedItem();
4662 test_IXMLDOMDocument2();
4666 test_nodeTypeTests();
4667 test_DocumentSaveToDocument();
4668 test_DocumentSaveToFile();
4669 test_testTransforms();
4671 test_FormattingXML();
4672 test_NodeTypeValue();
4673 test_TransformWithLoadingLocalFile();