4 * Copyright 2010, 2012-2013 Nikolay Sivov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/test.h"
34 DEFINE_GUID(IID_IXmlReaderInput
, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda);
36 static HRESULT (WINAPI
*pCreateXmlReader
)(REFIID riid
, void **ppvObject
, IMalloc
*pMalloc
);
37 static HRESULT (WINAPI
*pCreateXmlReaderInputWithEncodingName
)(IUnknown
*stream
,
42 IXmlReaderInput
**ppInput
);
43 static const char *debugstr_guid(REFIID riid
)
47 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
48 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
49 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
50 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
55 static WCHAR
*a2w(const char *str
)
57 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
58 WCHAR
*ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
59 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
63 static void free_str(WCHAR
*str
)
65 HeapFree(GetProcessHeap(), 0, str
);
68 static const char xmldecl_full
[] = "\xef\xbb\xbf<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
70 static IStream
*create_stream_on_data(const char *data
, int size
)
72 IStream
*stream
= NULL
;
77 hglobal
= GlobalAlloc(GHND
, size
);
78 ptr
= GlobalLock(hglobal
);
80 memcpy(ptr
, data
, size
);
82 hr
= CreateStreamOnHGlobal(hglobal
, TRUE
, &stream
);
83 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
84 ok(stream
!= NULL
, "Expected non-NULL stream\n");
86 GlobalUnlock(hglobal
);
91 static void ok_pos_(IXmlReader
*reader
, int line
, int pos
, int line_broken
,
92 int pos_broken
, int todo
, int _line_
)
98 hr
= IXmlReader_GetLineNumber(reader
, &l
);
99 ok_(__FILE__
, _line_
)(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
100 hr
= IXmlReader_GetLinePosition(reader
, &p
);
101 ok_(__FILE__
, _line_
)(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
103 if (line_broken
== -1 && pos_broken
== -1)
106 broken_state
= broken((line_broken
== -1 ? line
: line_broken
) == l
&&
107 (pos_broken
== -1 ? pos
: pos_broken
) == p
);
111 ok_(__FILE__
, _line_
)((l
== line
&& pos
== p
) || broken_state
,
112 "Expected (%d,%d), got (%d,%d)\n", line
, pos
, l
, p
);
115 ok_(__FILE__
, _line_
)((l
== line
&& pos
== p
) || broken_state
,
116 "Expected (%d,%d), got (%d,%d)\n", line
, pos
, l
, p
);
119 #define ok_pos(reader, l, p, l_brk, p_brk, todo) ok_pos_(reader, l, p, l_brk, p_brk, todo, __LINE__)
121 typedef struct input_iids_t
{
126 static const IID
*setinput_full
[] = {
127 &IID_IXmlReaderInput
,
129 &IID_ISequentialStream
,
133 /* this applies to early xmllite versions */
134 static const IID
*setinput_full_old
[] = {
135 &IID_IXmlReaderInput
,
136 &IID_ISequentialStream
,
141 /* after ::SetInput(IXmlReaderInput*) */
142 static const IID
*setinput_readerinput
[] = {
144 &IID_ISequentialStream
,
148 static const IID
*empty_seq
[] = {
152 static input_iids_t input_iids
;
154 static void ok_iids_(const input_iids_t
*iids
, const IID
**expected
, const IID
**exp_broken
, int todo
, int line
)
158 while (expected
[i
++]) size
++;
162 ok_(__FILE__
, line
)(iids
->count
== size
, "Sequence size mismatch (%d), got (%d)\n", size
, iids
->count
);
165 ok_(__FILE__
, line
)(iids
->count
== size
, "Sequence size mismatch (%d), got (%d)\n", size
, iids
->count
);
167 if (iids
->count
!= size
) return;
169 for (i
= 0; i
< size
; i
++) {
170 ok_(__FILE__
, line
)(IsEqualGUID(&iids
->iids
[i
], expected
[i
]) ||
171 (exp_broken
? broken(IsEqualGUID(&iids
->iids
[i
], exp_broken
[i
])) : FALSE
),
172 "Wrong IID(%d), got (%s)\n", i
, debugstr_guid(&iids
->iids
[i
]));
175 #define ok_iids(got, exp, brk, todo) ok_iids_(got, exp, brk, todo, __LINE__)
177 static const char *state_to_str(XmlReadState state
)
179 static const char* state_names
[] = {
180 "XmlReadState_Initial",
181 "XmlReadState_Interactive",
182 "XmlReadState_Error",
183 "XmlReadState_EndOfFile",
184 "XmlReadState_Closed"
187 static const char unknown
[] = "unknown";
191 case XmlReadState_Initial
:
192 case XmlReadState_Interactive
:
193 case XmlReadState_Error
:
194 case XmlReadState_EndOfFile
:
195 case XmlReadState_Closed
:
196 return state_names
[state
];
202 static const char *type_to_str(XmlNodeType type
)
204 static const char* type_names
[] = {
206 "XmlNodeType_Element",
207 "XmlNodeType_Attribute",
211 "XmlNodeType_ProcessingInstruction",
212 "XmlNodeType_Comment",
214 "XmlNodeType_DocumentType",
216 "XmlNodeType_Whitespace",
218 "XmlNodeType_EndElement",
220 "XmlNodeType_XmlDeclaration"
223 static const char unknown
[] = "unknown";
227 case XmlNodeType_None
:
228 case XmlNodeType_Element
:
229 case XmlNodeType_Attribute
:
230 case XmlNodeType_Text
:
231 case XmlNodeType_CDATA
:
232 case XmlNodeType_ProcessingInstruction
:
233 case XmlNodeType_Comment
:
234 case XmlNodeType_DocumentType
:
235 case XmlNodeType_Whitespace
:
236 case XmlNodeType_EndElement
:
237 case XmlNodeType_XmlDeclaration
:
238 return type_names
[type
];
244 static void test_read_state_(IXmlReader
*reader
, XmlReadState expected
,
245 XmlReadState exp_broken
, int todo
, int line
)
251 state
= -1; /* invalid value */
252 hr
= IXmlReader_GetProperty(reader
, XmlReaderProperty_ReadState
, (LONG_PTR
*)&state
);
253 ok_(__FILE__
, line
)(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
255 if (exp_broken
== -1)
258 broken_state
= broken(exp_broken
== state
);
263 ok_(__FILE__
, line
)(state
== expected
|| broken_state
, "Expected (%s), got (%s)\n",
264 state_to_str(expected
), state_to_str(state
));
267 ok_(__FILE__
, line
)(state
== expected
|| broken_state
, "Expected (%s), got (%s)\n",
268 state_to_str(expected
), state_to_str(state
));
271 #define test_read_state(reader, exp, brk, todo) test_read_state_(reader, exp, brk, todo, __LINE__)
273 typedef struct _testinput
275 IUnknown IUnknown_iface
;
279 static inline testinput
*impl_from_IUnknown(IUnknown
*iface
)
281 return CONTAINING_RECORD(iface
, testinput
, IUnknown_iface
);
284 static HRESULT WINAPI
testinput_QueryInterface(IUnknown
*iface
, REFIID riid
, void** ppvObj
)
286 if (IsEqualGUID( riid
, &IID_IUnknown
))
289 IUnknown_AddRef(iface
);
293 input_iids
.iids
[input_iids
.count
++] = *riid
;
297 return E_NOINTERFACE
;
300 static ULONG WINAPI
testinput_AddRef(IUnknown
*iface
)
302 testinput
*This
= impl_from_IUnknown(iface
);
303 return InterlockedIncrement(&This
->ref
);
306 static ULONG WINAPI
testinput_Release(IUnknown
*iface
)
308 testinput
*This
= impl_from_IUnknown(iface
);
311 ref
= InterlockedDecrement(&This
->ref
);
314 HeapFree(GetProcessHeap(), 0, This
);
320 static const struct IUnknownVtbl testinput_vtbl
=
322 testinput_QueryInterface
,
327 static HRESULT
testinput_createinstance(void **ppObj
)
331 input
= HeapAlloc(GetProcessHeap(), 0, sizeof (*input
));
332 if(!input
) return E_OUTOFMEMORY
;
334 input
->IUnknown_iface
.lpVtbl
= &testinput_vtbl
;
337 *ppObj
= &input
->IUnknown_iface
;
342 static HRESULT WINAPI
teststream_QueryInterface(ISequentialStream
*iface
, REFIID riid
, void **obj
)
344 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_ISequentialStream
))
351 return E_NOINTERFACE
;
354 static ULONG WINAPI
teststream_AddRef(ISequentialStream
*iface
)
359 static ULONG WINAPI
teststream_Release(ISequentialStream
*iface
)
364 static int stream_readcall
;
366 static HRESULT WINAPI
teststream_Read(ISequentialStream
*iface
, void *pv
, ULONG cb
, ULONG
*pread
)
368 static const char xml
[] = "<!-- comment -->";
370 if (stream_readcall
++)
376 *pread
= sizeof(xml
) / 2;
377 memcpy(pv
, xml
, *pread
);
381 static HRESULT WINAPI
teststream_Write(ISequentialStream
*iface
, const void *pv
, ULONG cb
, ULONG
*written
)
383 ok(0, "unexpected call\n");
387 static const ISequentialStreamVtbl teststreamvtbl
=
389 teststream_QueryInterface
,
396 static BOOL
init_pointers(void)
398 /* don't free module here, it's to be unloaded on exit */
399 HMODULE mod
= LoadLibraryA("xmllite.dll");
403 win_skip("xmllite library not available\n");
407 #define MAKEFUNC(f) if (!(p##f = (void*)GetProcAddress(mod, #f))) return FALSE;
408 MAKEFUNC(CreateXmlReader
);
409 MAKEFUNC(CreateXmlReaderInputWithEncodingName
);
415 static void test_reader_create(void)
421 XmlNodeType nodetype
;
426 pCreateXmlReader(&IID_IXmlReader
, NULL
, NULL
);
427 pCreateXmlReader(NULL
, (void**)&reader
, NULL
);
430 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
431 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
433 test_read_state(reader
, XmlReadState_Closed
, -1, FALSE
);
435 nodetype
= XmlNodeType_Element
;
436 hr
= IXmlReader_GetNodeType(reader
, &nodetype
);
437 ok(hr
== S_FALSE
, "got %08x\n", hr
);
438 ok(nodetype
== XmlNodeType_None
, "got %d\n", nodetype
);
441 hr
= IXmlReader_GetProperty(reader
, XmlReaderProperty_DtdProcessing
, (LONG_PTR
*)&dtd
);
442 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
443 ok(dtd
== DtdProcessing_Prohibit
, "got %d\n", dtd
);
446 hr
= IXmlReader_SetProperty(reader
, XmlReaderProperty_DtdProcessing
, dtd
);
447 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
449 hr
= IXmlReader_SetProperty(reader
, XmlReaderProperty_DtdProcessing
, -1);
450 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
452 /* Null input pointer, releases previous input */
453 hr
= IXmlReader_SetInput(reader
, NULL
);
454 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
456 test_read_state(reader
, XmlReadState_Initial
, XmlReadState_Closed
, FALSE
);
458 /* test input interface selection sequence */
459 hr
= testinput_createinstance((void**)&input
);
460 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
464 input_iids
.count
= 0;
465 hr
= IXmlReader_SetInput(reader
, input
);
466 ok(hr
== E_NOINTERFACE
, "Expected E_NOINTERFACE, got %08x\n", hr
);
467 ok_iids(&input_iids
, setinput_full
, setinput_full_old
, FALSE
);
468 IUnknown_Release(input
);
470 IXmlReader_Release(reader
);
473 static void test_readerinput(void)
475 IXmlReaderInput
*reader_input
;
476 IXmlReader
*reader
, *reader2
;
477 IUnknown
*obj
, *input
;
478 IStream
*stream
, *stream2
;
479 XmlNodeType nodetype
;
483 hr
= pCreateXmlReaderInputWithEncodingName(NULL
, NULL
, NULL
, FALSE
, NULL
, NULL
);
484 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
485 hr
= pCreateXmlReaderInputWithEncodingName(NULL
, NULL
, NULL
, FALSE
, NULL
, &reader_input
);
486 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
488 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
489 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
491 ref
= IStream_AddRef(stream
);
492 ok(ref
== 2, "Expected 2, got %d\n", ref
);
493 IStream_Release(stream
);
494 hr
= pCreateXmlReaderInputWithEncodingName((IUnknown
*)stream
, NULL
, NULL
, FALSE
, NULL
, &reader_input
);
495 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
497 hr
= IUnknown_QueryInterface(reader_input
, &IID_IStream
, (void**)&stream2
);
498 ok(hr
== E_NOINTERFACE
, "Expected S_OK, got %08x\n", hr
);
500 hr
= IUnknown_QueryInterface(reader_input
, &IID_ISequentialStream
, (void**)&stream2
);
501 ok(hr
== E_NOINTERFACE
, "Expected S_OK, got %08x\n", hr
);
503 /* IXmlReaderInput grabs a stream reference */
504 ref
= IStream_AddRef(stream
);
505 ok(ref
== 3, "Expected 3, got %d\n", ref
);
506 IStream_Release(stream
);
508 /* try ::SetInput() with valid IXmlReaderInput */
509 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
510 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
512 ref
= IUnknown_AddRef(reader_input
);
513 ok(ref
== 2, "Expected 2, got %d\n", ref
);
514 IUnknown_Release(reader_input
);
516 hr
= IXmlReader_SetInput(reader
, reader_input
);
517 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
519 test_read_state(reader
, XmlReadState_Initial
, -1, FALSE
);
521 nodetype
= XmlNodeType_Element
;
522 hr
= IXmlReader_GetNodeType(reader
, &nodetype
);
523 ok(hr
== S_OK
, "got %08x\n", hr
);
524 ok(nodetype
== XmlNodeType_None
, "got %d\n", nodetype
);
526 /* IXmlReader grabs a IXmlReaderInput reference */
527 ref
= IUnknown_AddRef(reader_input
);
528 ok(ref
== 3, "Expected 3, got %d\n", ref
);
529 IUnknown_Release(reader_input
);
531 ref
= IStream_AddRef(stream
);
532 ok(ref
== 4, "Expected 4, got %d\n", ref
);
533 IStream_Release(stream
);
535 /* reset input and check state */
536 hr
= IXmlReader_SetInput(reader
, NULL
);
537 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
539 test_read_state(reader
, XmlReadState_Initial
, XmlReadState_Closed
, FALSE
);
541 IXmlReader_Release(reader
);
543 ref
= IStream_AddRef(stream
);
544 ok(ref
== 3, "Expected 3, got %d\n", ref
);
545 IStream_Release(stream
);
547 ref
= IUnknown_AddRef(reader_input
);
548 ok(ref
== 2, "Expected 2, got %d\n", ref
);
549 IUnknown_Release(reader_input
);
551 /* IID_IXmlReaderInput */
552 /* it returns a kind of private undocumented vtable incompatible with IUnknown,
553 so it's not a COM interface actually.
554 Such query will be used only to check if input is really IXmlReaderInput */
555 obj
= (IUnknown
*)0xdeadbeef;
556 hr
= IUnknown_QueryInterface(reader_input
, &IID_IXmlReaderInput
, (void**)&obj
);
557 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
558 ref
= IUnknown_AddRef(reader_input
);
559 ok(ref
== 3, "Expected 3, got %d\n", ref
);
560 IUnknown_Release(reader_input
);
562 IUnknown_Release(reader_input
);
563 IUnknown_Release(reader_input
);
564 IStream_Release(stream
);
566 /* test input interface selection sequence */
568 hr
= testinput_createinstance((void**)&input
);
569 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
571 input_iids
.count
= 0;
572 ref
= IUnknown_AddRef(input
);
573 ok(ref
== 2, "Expected 2, got %d\n", ref
);
574 IUnknown_Release(input
);
575 hr
= pCreateXmlReaderInputWithEncodingName(input
, NULL
, NULL
, FALSE
, NULL
, &reader_input
);
576 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
577 ok_iids(&input_iids
, empty_seq
, NULL
, FALSE
);
578 /* IXmlReaderInput stores stream interface as IUnknown */
579 ref
= IUnknown_AddRef(input
);
580 ok(ref
== 3, "Expected 3, got %d\n", ref
);
581 IUnknown_Release(input
);
583 hr
= pCreateXmlReader(&IID_IXmlReader
, (LPVOID
*)&reader
, NULL
);
584 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
586 input_iids
.count
= 0;
587 ref
= IUnknown_AddRef(reader_input
);
588 ok(ref
== 2, "Expected 2, got %d\n", ref
);
589 IUnknown_Release(reader_input
);
590 ref
= IUnknown_AddRef(input
);
591 ok(ref
== 3, "Expected 3, got %d\n", ref
);
592 IUnknown_Release(input
);
593 hr
= IXmlReader_SetInput(reader
, reader_input
);
594 ok(hr
== E_NOINTERFACE
, "Expected E_NOINTERFACE, got %08x\n", hr
);
595 ok_iids(&input_iids
, setinput_readerinput
, NULL
, FALSE
);
597 test_read_state(reader
, XmlReadState_Closed
, -1, FALSE
);
599 ref
= IUnknown_AddRef(input
);
600 ok(ref
== 3, "Expected 3, got %d\n", ref
);
601 IUnknown_Release(input
);
603 ref
= IUnknown_AddRef(reader_input
);
604 ok(ref
== 3 || broken(ref
== 2) /* versions 1.0.x and 1.1.x - XP, Vista */,
605 "Expected 3, got %d\n", ref
);
606 IUnknown_Release(reader_input
);
607 /* repeat another time, no check or caching here */
608 input_iids
.count
= 0;
609 hr
= IXmlReader_SetInput(reader
, reader_input
);
610 ok(hr
== E_NOINTERFACE
, "Expected E_NOINTERFACE, got %08x\n", hr
);
611 ok_iids(&input_iids
, setinput_readerinput
, NULL
, FALSE
);
614 hr
= pCreateXmlReader(&IID_IXmlReader
, (LPVOID
*)&reader2
, NULL
);
615 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
617 /* resolving from IXmlReaderInput to IStream/ISequentialStream is done at
618 ::SetInput() level, each time it's called */
619 input_iids
.count
= 0;
620 hr
= IXmlReader_SetInput(reader2
, reader_input
);
621 ok(hr
== E_NOINTERFACE
, "Expected E_NOINTERFACE, got %08x\n", hr
);
622 ok_iids(&input_iids
, setinput_readerinput
, NULL
, FALSE
);
624 IXmlReader_Release(reader2
);
625 IXmlReader_Release(reader
);
627 IUnknown_Release(reader_input
);
628 IUnknown_Release(input
);
631 static void test_reader_state(void)
634 XmlNodeType nodetype
;
637 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
638 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
640 /* invalid arguments */
641 hr
= IXmlReader_GetProperty(reader
, XmlReaderProperty_ReadState
, NULL
);
642 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
644 /* attempt to read on closed reader */
645 test_read_state(reader
, XmlReadState_Closed
, -1, 0);
648 /* newer versions crash here, probably cause no input was set */
649 hr
= IXmlReader_Read(reader
, &nodetype
);
650 ok(hr
== S_FALSE
, "got %08x\n", hr
);
652 IXmlReader_Release(reader
);
655 static void test_read_xmldeclaration(void)
664 hr
= pCreateXmlReader(&IID_IXmlReader
, (LPVOID
*)&reader
, NULL
);
665 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
667 /* position methods with Null args */
668 hr
= IXmlReader_GetLineNumber(reader
, NULL
);
669 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
671 hr
= IXmlReader_GetLinePosition(reader
, NULL
);
672 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
674 stream
= create_stream_on_data(xmldecl_full
, sizeof(xmldecl_full
));
676 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
677 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
679 hr
= IXmlReader_GetAttributeCount(reader
, &count
);
680 ok(hr
== S_OK
, "got %08x\n", hr
);
681 ok(count
== 0, "got %d\n", count
);
683 /* try to move without attributes */
684 hr
= IXmlReader_MoveToElement(reader
);
685 ok(hr
== S_FALSE
, "got %08x\n", hr
);
687 hr
= IXmlReader_MoveToNextAttribute(reader
);
688 ok(hr
== S_FALSE
, "got %08x\n", hr
);
690 hr
= IXmlReader_MoveToFirstAttribute(reader
);
691 ok(hr
== S_FALSE
, "got %08x\n", hr
);
693 ok_pos(reader
, 0, 0, -1, -1, FALSE
);
696 hr
= IXmlReader_Read(reader
, &type
);
697 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
698 ok(type
== XmlNodeType_XmlDeclaration
,
699 "Expected XmlNodeType_XmlDeclaration, got %s\n", type_to_str(type
));
700 /* new version 1.2.x and 1.3.x properly update position for <?xml ?> */
701 ok_pos(reader
, 1, 3, -1, 55, TRUE
);
702 test_read_state(reader
, XmlReadState_Interactive
, -1, 0);
704 hr
= IXmlReader_GetValue(reader
, &val
, NULL
);
705 ok(hr
== S_OK
, "got %08x\n", hr
);
706 ok(*val
== 0, "got %s\n", wine_dbgstr_w(val
));
708 /* check attributes */
709 hr
= IXmlReader_MoveToNextAttribute(reader
);
710 ok(hr
== S_OK
, "got %08x\n", hr
);
712 type
= XmlNodeType_None
;
713 hr
= IXmlReader_GetNodeType(reader
, &type
);
714 ok(hr
== S_OK
, "got %08x\n", hr
);
715 ok(type
== XmlNodeType_Attribute
, "got %d\n", type
);
717 ok_pos(reader
, 1, 7, -1, 55, TRUE
);
719 /* try to move from last attribute */
720 hr
= IXmlReader_MoveToNextAttribute(reader
);
721 ok(hr
== S_OK
, "got %08x\n", hr
);
722 hr
= IXmlReader_MoveToNextAttribute(reader
);
723 ok(hr
== S_OK
, "got %08x\n", hr
);
724 hr
= IXmlReader_MoveToNextAttribute(reader
);
725 ok(hr
== S_FALSE
, "got %08x\n", hr
);
727 type
= XmlNodeType_None
;
728 hr
= IXmlReader_GetNodeType(reader
, &type
);
729 ok(hr
== S_OK
, "got %08x\n", hr
);
730 ok(type
== XmlNodeType_Attribute
, "got %d\n", type
);
732 hr
= IXmlReader_MoveToFirstAttribute(reader
);
733 ok(hr
== S_OK
, "got %08x\n", hr
);
734 ok_pos(reader
, 1, 7, -1, 55, TRUE
);
736 hr
= IXmlReader_GetAttributeCount(reader
, NULL
);
737 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
739 hr
= IXmlReader_GetAttributeCount(reader
, &count
);
740 ok(hr
== S_OK
, "got %08x\n", hr
);
741 ok(count
== 3, "Expected 3, got %d\n", count
);
743 hr
= IXmlReader_GetDepth(reader
, &count
);
744 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
746 ok(count
== 1, "Expected 1, got %d\n", count
);
748 hr
= IXmlReader_MoveToElement(reader
);
749 ok(hr
== S_OK
, "got %08x\n", hr
);
751 type
= XmlNodeType_None
;
752 hr
= IXmlReader_GetNodeType(reader
, &type
);
753 ok(hr
== S_OK
, "got %08x\n", hr
);
754 ok(type
== XmlNodeType_XmlDeclaration
, "got %d\n", type
);
756 type
= XmlNodeType_XmlDeclaration
;
757 hr
= IXmlReader_Read(reader
, &type
);
758 /* newer versions return syntax error here cause document is incomplete,
759 it makes more sense than invalid char error */
761 ok(hr
== WC_E_SYNTAX
|| broken(hr
== WC_E_XMLCHARACTER
), "got 0x%08x\n", hr
);
762 ok(type
== XmlNodeType_None
, "got %d\n", type
);
764 IStream_Release(stream
);
765 IXmlReader_Release(reader
);
773 HRESULT hr_broken
; /* this is set to older version results */
776 static struct test_entry comment_tests
[] = {
777 { "<!-- comment -->", "", " comment ", S_OK
},
778 { "<!-- - comment-->", "", " - comment", S_OK
},
779 { "<!-- -- comment-->", NULL
, NULL
, WC_E_COMMENT
, WC_E_GREATERTHAN
},
780 { "<!-- -- comment--->", NULL
, NULL
, WC_E_COMMENT
, WC_E_GREATERTHAN
},
784 static void test_read_comment(void)
786 struct test_entry
*test
= comment_tests
;
790 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
791 ok(hr
== S_OK
, "S_OK, got %08x\n", hr
);
798 stream
= create_stream_on_data(test
->xml
, strlen(test
->xml
)+1);
799 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
800 ok(hr
== S_OK
, "got %08x\n", hr
);
802 type
= XmlNodeType_None
;
803 hr
= IXmlReader_Read(reader
, &type
);
805 ok(hr
== test
->hr
|| broken(hr
== test
->hr_broken
), "got %08x for %s\n", hr
, test
->xml
);
807 ok(hr
== test
->hr
, "got %08x for %s\n", hr
, test
->xml
);
814 ok(type
== XmlNodeType_Comment
, "got %d for %s\n", type
, test
->xml
);
818 hr
= IXmlReader_GetLocalName(reader
, &str
, &len
);
819 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
820 ok(len
== strlen(test
->name
), "got %u\n", len
);
821 str_exp
= a2w(test
->name
);
822 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
827 hr
= IXmlReader_GetQualifiedName(reader
, &str
, &len
);
828 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
829 ok(len
== strlen(test
->name
), "got %u\n", len
);
830 str_exp
= a2w(test
->name
);
831 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
837 hr
= IXmlReader_GetValue(reader
, &str
, &len
);
838 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
839 ok(len
== strlen(test
->value
), "got %u\n", len
);
840 str_exp
= a2w(test
->value
);
841 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
845 IStream_Release(stream
);
849 IXmlReader_Release(reader
);
852 static struct test_entry pi_tests
[] = {
853 { "<?pi?>", "pi", "", S_OK
},
854 { "<?pi ?>", "pi", "", S_OK
},
855 { "<?pi ?>", "pi", "", S_OK
},
856 { "<?pi pi data?>", "pi", "pi data", S_OK
},
857 { "<?pi pi data ?>", "pi", "pi data ", S_OK
},
858 { "<?pi:pi?>", NULL
, NULL
, NC_E_NAMECOLON
, WC_E_NAMECHARACTER
},
859 { "<?:pi ?>", NULL
, NULL
, WC_E_PI
, WC_E_NAMECHARACTER
},
860 { "<?-pi ?>", NULL
, NULL
, WC_E_PI
, WC_E_NAMECHARACTER
},
861 { "<?xml-stylesheet ?>", "xml-stylesheet", "", S_OK
},
865 static void test_read_pi(void)
867 struct test_entry
*test
= pi_tests
;
871 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
872 ok(hr
== S_OK
, "S_OK, got %08x\n", hr
);
879 stream
= create_stream_on_data(test
->xml
, strlen(test
->xml
)+1);
880 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
881 ok(hr
== S_OK
, "got %08x\n", hr
);
883 type
= XmlNodeType_None
;
884 hr
= IXmlReader_Read(reader
, &type
);
886 ok(hr
== test
->hr
|| broken(hr
== test
->hr_broken
), "got %08x for %s\n", hr
, test
->xml
);
888 ok(hr
== test
->hr
, "got %08x for %s\n", hr
, test
->xml
);
895 ok(type
== XmlNodeType_ProcessingInstruction
, "got %d for %s\n", type
, test
->xml
);
899 hr
= IXmlReader_GetLocalName(reader
, &str
, &len
);
900 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
901 ok(len
== strlen(test
->name
), "got %u\n", len
);
902 str_exp
= a2w(test
->name
);
903 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
908 hr
= IXmlReader_GetQualifiedName(reader
, &str
, &len
);
909 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
910 ok(len
== strlen(test
->name
), "got %u\n", len
);
911 str_exp
= a2w(test
->name
);
912 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
916 len
= !strlen(test
->value
);
918 hr
= IXmlReader_GetValue(reader
, &str
, &len
);
919 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
920 ok(len
== strlen(test
->value
), "got %u\n", len
);
921 str_exp
= a2w(test
->value
);
922 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
926 IStream_Release(stream
);
930 IXmlReader_Release(reader
);
935 XmlNodeType types
[20];
938 static const char misc_test_xml
[] =
952 static struct nodes_test misc_test
= {
957 XmlNodeType_ProcessingInstruction
,
959 XmlNodeType_Whitespace
,
964 XmlNodeType_ProcessingInstruction
,
965 XmlNodeType_EndElement
,
970 static void test_read_full(void)
972 struct nodes_test
*test
= &misc_test
;
979 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
980 ok(hr
== S_OK
, "S_OK, got %08x\n", hr
);
982 stream
= create_stream_on_data(test
->xml
, strlen(test
->xml
)+1);
983 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
984 ok(hr
== S_OK
, "got %08x\n", hr
);
987 type
= XmlNodeType_None
;
988 hr
= IXmlReader_Read(reader
, &type
);
991 ok(test
->types
[i
] != XmlNodeType_None
, "%d: unexpected end of test data\n", i
);
992 if (test
->types
[i
] == XmlNodeType_None
) break;
993 ok(type
== test
->types
[i
], "%d: got wrong type %d, expected %d\n", i
, type
, test
->types
[i
]);
994 hr
= IXmlReader_Read(reader
, &type
);
997 ok(test
->types
[i
] == XmlNodeType_None
, "incomplete sequence, got %d\n", test
->types
[i
]);
999 IStream_Release(stream
);
1000 IXmlReader_Release(reader
);
1003 static const char test_dtd
[] =
1004 "<!DOCTYPE testdtd SYSTEM \"externalid uri\" >"
1007 static void test_read_dtd(void)
1009 static const WCHAR sysvalW
[] = {'e','x','t','e','r','n','a','l','i','d',' ','u','r','i',0};
1010 static const WCHAR dtdnameW
[] = {'t','e','s','t','d','t','d',0};
1011 static const WCHAR sysW
[] = {'S','Y','S','T','E','M',0};
1019 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
1020 ok(hr
== S_OK
, "S_OK, got %08x\n", hr
);
1022 hr
= IXmlReader_SetProperty(reader
, XmlReaderProperty_DtdProcessing
, DtdProcessing_Parse
);
1023 ok(hr
== S_OK
, "got 0x%8x\n", hr
);
1025 stream
= create_stream_on_data(test_dtd
, sizeof(test_dtd
));
1026 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
1027 ok(hr
== S_OK
, "got %08x\n", hr
);
1029 type
= XmlNodeType_None
;
1030 hr
= IXmlReader_Read(reader
, &type
);
1031 ok(hr
== S_OK
, "got 0x%8x\n", hr
);
1032 ok(type
== XmlNodeType_DocumentType
, "got type %d\n", type
);
1035 hr
= IXmlReader_GetAttributeCount(reader
, &count
);
1036 ok(hr
== S_OK
, "got %08x\n", hr
);
1037 ok(count
== 1, "got %d\n", count
);
1039 hr
= IXmlReader_MoveToFirstAttribute(reader
);
1040 ok(hr
== S_OK
, "got %08x\n", hr
);
1042 type
= XmlNodeType_None
;
1043 hr
= IXmlReader_GetNodeType(reader
, &type
);
1044 ok(hr
== S_OK
, "got %08x\n", hr
);
1045 ok(type
== XmlNodeType_Attribute
, "got %d\n", type
);
1049 hr
= IXmlReader_GetLocalName(reader
, &str
, &len
);
1050 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1052 ok(len
== lstrlenW(sysW
), "got %u\n", len
);
1053 ok(!lstrcmpW(str
, sysW
), "got %s\n", wine_dbgstr_w(str
));
1057 hr
= IXmlReader_GetValue(reader
, &str
, &len
);
1058 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1060 ok(len
== lstrlenW(sysvalW
), "got %u\n", len
);
1061 ok(!lstrcmpW(str
, sysvalW
), "got %s\n", wine_dbgstr_w(str
));
1063 hr
= IXmlReader_MoveToElement(reader
);
1064 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1068 hr
= IXmlReader_GetLocalName(reader
, &str
, &len
);
1069 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1070 ok(len
== lstrlenW(dtdnameW
), "got %u\n", len
);
1071 ok(!lstrcmpW(str
, dtdnameW
), "got %s\n", wine_dbgstr_w(str
));
1075 hr
= IXmlReader_GetQualifiedName(reader
, &str
, &len
);
1076 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1077 ok(len
== lstrlenW(dtdnameW
), "got %u\n", len
);
1078 ok(!lstrcmpW(str
, dtdnameW
), "got %s\n", wine_dbgstr_w(str
));
1080 type
= XmlNodeType_None
;
1081 hr
= IXmlReader_Read(reader
, &type
);
1082 ok(hr
== S_OK
, "got 0x%8x\n", hr
);
1083 ok(type
== XmlNodeType_Comment
, "got type %d\n", type
);
1085 IStream_Release(stream
);
1086 IXmlReader_Release(reader
);
1089 static struct test_entry element_tests
[] = {
1090 { "<a/>", "a", "", S_OK
},
1091 { "<a />", "a", "", S_OK
},
1092 { "<a:b/>", "a:b", "", NC_E_UNDECLAREDPREFIX
},
1093 { "<:a/>", NULL
, NULL
, NC_E_QNAMECHARACTER
},
1094 { "< a/>", NULL
, NULL
, NC_E_QNAMECHARACTER
},
1095 { "<a>", "a", "", S_OK
},
1096 { "<a >", "a", "", S_OK
},
1097 { "<a \r \t\n>", "a", "", S_OK
},
1098 { "</a>", NULL
, NULL
, NC_E_QNAMECHARACTER
},
1102 static void test_read_element(void)
1104 struct test_entry
*test
= element_tests
;
1105 static const char stag
[] = "<a><b></b></a>";
1106 static const char mismatch
[] = "<a></b>";
1113 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
1114 ok(hr
== S_OK
, "S_OK, got %08x\n", hr
);
1118 stream
= create_stream_on_data(test
->xml
, strlen(test
->xml
)+1);
1119 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
1120 ok(hr
== S_OK
, "got %08x\n", hr
);
1122 type
= XmlNodeType_None
;
1123 hr
= IXmlReader_Read(reader
, &type
);
1124 if (test
->hr_broken
)
1125 ok(hr
== test
->hr
|| broken(hr
== test
->hr_broken
), "got %08x for %s\n", hr
, test
->xml
);
1127 ok(hr
== test
->hr
, "got %08x for %s\n", hr
, test
->xml
);
1134 ok(type
== XmlNodeType_Element
, "got %d for %s\n", type
, test
->xml
);
1138 hr
= IXmlReader_GetQualifiedName(reader
, &str
, &len
);
1139 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1140 ok(len
== strlen(test
->name
), "got %u\n", len
);
1141 str_exp
= a2w(test
->name
);
1142 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
1148 hr
= IXmlReader_GetValue(reader
, &str
, &len
);
1149 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1150 ok(len
== 0, "got %u\n", len
);
1151 ok(*str
== 0, "got %s\n", wine_dbgstr_w(str
));
1154 IStream_Release(stream
);
1158 /* test reader depth increment */
1159 stream
= create_stream_on_data(stag
, sizeof(stag
));
1160 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
1161 ok(hr
== S_OK
, "got %08x\n", hr
);
1164 hr
= IXmlReader_GetDepth(reader
, &depth
);
1165 ok(hr
== S_OK
, "got %08x\n", hr
);
1166 ok(depth
== 0, "got %d\n", depth
);
1168 hr
= IXmlReader_Read(reader
, &type
);
1169 ok(hr
== S_OK
, "got %08x\n", hr
);
1172 hr
= IXmlReader_GetDepth(reader
, &depth
);
1173 ok(hr
== S_OK
, "got %08x\n", hr
);
1174 ok(depth
== 0, "got %d\n", depth
);
1176 hr
= IXmlReader_Read(reader
, &type
);
1177 ok(hr
== S_OK
, "got %08x\n", hr
);
1180 hr
= IXmlReader_GetDepth(reader
, &depth
);
1181 ok(hr
== S_OK
, "got %08x\n", hr
);
1182 ok(depth
== 1, "got %d\n", depth
);
1184 /* read end tag for inner element */
1185 type
= XmlNodeType_None
;
1186 hr
= IXmlReader_Read(reader
, &type
);
1187 ok(hr
== S_OK
, "got %08x\n", hr
);
1188 ok(type
== XmlNodeType_EndElement
, "got %d\n", type
);
1191 hr
= IXmlReader_GetDepth(reader
, &depth
);
1192 ok(hr
== S_OK
, "got %08x\n", hr
);
1194 ok(depth
== 2, "got %d\n", depth
);
1196 /* read end tag for container element */
1197 type
= XmlNodeType_None
;
1198 hr
= IXmlReader_Read(reader
, &type
);
1199 ok(hr
== S_OK
, "got %08x\n", hr
);
1200 ok(type
== XmlNodeType_EndElement
, "got %d\n", type
);
1203 hr
= IXmlReader_GetDepth(reader
, &depth
);
1204 ok(hr
== S_OK
, "got %08x\n", hr
);
1205 ok(depth
== 1, "got %d\n", depth
);
1207 IStream_Release(stream
);
1209 /* start/end tag mismatch */
1210 stream
= create_stream_on_data(mismatch
, sizeof(mismatch
));
1211 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
1212 ok(hr
== S_OK
, "got %08x\n", hr
);
1214 type
= XmlNodeType_None
;
1215 hr
= IXmlReader_Read(reader
, &type
);
1216 ok(hr
== S_OK
, "got %08x\n", hr
);
1217 ok(type
== XmlNodeType_Element
, "got %d\n", type
);
1219 type
= XmlNodeType_Element
;
1220 hr
= IXmlReader_Read(reader
, &type
);
1221 ok(hr
== WC_E_ELEMENTMATCH
, "got %08x\n", hr
);
1223 ok(type
== XmlNodeType_None
, "got %d\n", type
);
1225 IStream_Release(stream
);
1227 IXmlReader_Release(reader
);
1230 static ISequentialStream teststream
= { &teststreamvtbl
};
1232 static void test_read_pending(void)
1240 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
1241 ok(hr
== S_OK
, "S_OK, got 0x%08x\n", hr
);
1243 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)&teststream
);
1244 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1246 /* first read call returns incomplete node, second attempt fails with E_PENDING */
1247 stream_readcall
= 0;
1248 type
= XmlNodeType_Element
;
1249 hr
= IXmlReader_Read(reader
, &type
);
1250 ok(hr
== S_OK
|| broken(hr
== E_PENDING
), "got 0x%08x\n", hr
);
1251 /* newer versions are happy when it's enough data to detect node type,
1252 older versions keep reading until it fails to read more */
1253 ok(stream_readcall
== 1 || broken(stream_readcall
> 1), "got %d\n", stream_readcall
);
1254 ok(type
== XmlNodeType_Comment
|| broken(type
== XmlNodeType_None
), "got %d\n", type
);
1256 /* newer versions' GetValue() makes an attempt to read more */
1257 c
= stream_readcall
;
1258 value
= (void*)0xdeadbeef;
1259 hr
= IXmlReader_GetValue(reader
, &value
, NULL
);
1260 ok(hr
== E_PENDING
, "got 0x%08x\n", hr
);
1261 ok(value
== NULL
|| broken(value
== (void*)0xdeadbeef) /* Win8 sets it to NULL */, "got %p\n", value
);
1262 ok(c
< stream_readcall
|| broken(c
== stream_readcall
), "got %d, expected %d\n", stream_readcall
, c
+1);
1264 IXmlReader_Release(reader
);
1267 static void test_readvaluechunk(void)
1269 static const char testA
[] = "<!-- comment1 -->";
1278 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
1279 ok(hr
== S_OK
, "S_OK, got %08x\n", hr
);
1281 stream
= create_stream_on_data(testA
, sizeof(testA
));
1282 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
1283 ok(hr
== S_OK
, "got %08x\n", hr
);
1285 hr
= IXmlReader_Read(reader
, &type
);
1286 ok(hr
== S_OK
, "got %08x\n", hr
);
1290 hr
= IXmlReader_ReadValueChunk(reader
, &b
, 1, &c
);
1292 ok(hr
== S_OK
, "got %08x\n", hr
);
1293 ok(c
== 1, "got %u\n", c
);
1294 ok(b
== ' ', "got %x\n", b
);
1296 /* portion read as chunk is skipped from resulting node value */
1298 hr
= IXmlReader_GetValue(reader
, &value
, NULL
);
1299 ok(hr
== S_OK
, "got %08x\n", hr
);
1301 ok(value
[0] == 'c', "got %s\n", wine_dbgstr_w(value
));
1303 /* once value is returned/allocated it's not possible to read by chunk */
1306 hr
= IXmlReader_ReadValueChunk(reader
, &b
, 1, &c
);
1308 ok(hr
== S_FALSE
, "got %08x\n", hr
);
1309 ok(c
== 0, "got %u\n", c
);
1310 ok(b
== 0, "got %x\n", b
);
1313 hr
= IXmlReader_GetValue(reader
, &value
, NULL
);
1314 ok(hr
== S_OK
, "got %08x\n", hr
);
1316 ok(value
[0] == 'c', "got %s\n", wine_dbgstr_w(value
));
1318 IXmlReader_Release(reader
);
1321 static struct test_entry cdata_tests
[] = {
1322 { "<a><![CDATA[ ]]data ]]></a>", "", " ]]data ", S_OK
},
1323 { "<a><![CDATA[<![CDATA[ data ]]]]></a>", "", "<![CDATA[ data ]]", S_OK
},
1327 static void test_read_cdata(void)
1329 struct test_entry
*test
= cdata_tests
;
1333 hr
= pCreateXmlReader(&IID_IXmlReader
, (void**)&reader
, NULL
);
1334 ok(hr
== S_OK
, "S_OK, got %08x\n", hr
);
1341 stream
= create_stream_on_data(test
->xml
, strlen(test
->xml
)+1);
1342 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
1343 ok(hr
== S_OK
, "got %08x\n", hr
);
1345 type
= XmlNodeType_None
;
1346 hr
= IXmlReader_Read(reader
, &type
);
1348 /* read one more to get to CDATA */
1349 if (type
== XmlNodeType_Element
)
1351 type
= XmlNodeType_None
;
1352 hr
= IXmlReader_Read(reader
, &type
);
1355 if (test
->hr_broken
)
1356 ok(hr
== test
->hr
|| broken(hr
== test
->hr_broken
), "got %08x for %s\n", hr
, test
->xml
);
1358 ok(hr
== test
->hr
, "got %08x for %s\n", hr
, test
->xml
);
1365 ok(type
== XmlNodeType_CDATA
, "got %d for %s\n", type
, test
->xml
);
1369 hr
= IXmlReader_GetLocalName(reader
, &str
, &len
);
1370 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1371 ok(len
== strlen(test
->name
), "got %u\n", len
);
1372 str_exp
= a2w(test
->name
);
1373 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
1378 hr
= IXmlReader_GetQualifiedName(reader
, &str
, &len
);
1379 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1380 ok(len
== strlen(test
->name
), "got %u\n", len
);
1381 str_exp
= a2w(test
->name
);
1382 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
1388 hr
= IXmlReader_GetValue(reader
, &str
, &len
);
1389 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1390 ok(len
== strlen(test
->value
), "got %u\n", len
);
1391 str_exp
= a2w(test
->value
);
1392 ok(!lstrcmpW(str
, str_exp
), "got %s\n", wine_dbgstr_w(str
));
1396 IStream_Release(stream
);
1400 IXmlReader_Release(reader
);
1407 r
= CoInitialize( NULL
);
1408 ok( r
== S_OK
, "failed to init com\n");
1410 if (!init_pointers())
1416 test_reader_create();
1418 test_reader_state();
1420 test_read_comment();
1423 test_read_element();
1425 test_read_pending();
1426 test_readvaluechunk();
1427 test_read_xmldeclaration();