2 * XMLLite IXmlWriter tests
4 * Copyright 2011 (C) Alistair Leslie-Hughes
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
29 #include "wine/test.h"
32 DEFINE_GUID(IID_IXmlWriterOutput
, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33, 0x24, 0x51, 0xbc, 0x1a);
34 static HRESULT (WINAPI
*pCreateXmlWriter
)(REFIID riid
, void **ppvObject
, IMalloc
*pMalloc
);
35 static HRESULT (WINAPI
*pCreateXmlWriterOutputWithEncodingName
)(IUnknown
*stream
,
37 LPCWSTR encoding_name
,
38 IXmlWriterOutput
**output
);
40 static HRESULT WINAPI
testoutput_QueryInterface(IUnknown
*iface
, REFIID riid
, void **obj
)
42 if (IsEqualGUID(riid
, &IID_IUnknown
)) {
47 ok(0, "unknown riid=%s\n", wine_dbgstr_guid(riid
));
52 static ULONG WINAPI
testoutput_AddRef(IUnknown
*iface
)
57 static ULONG WINAPI
testoutput_Release(IUnknown
*iface
)
62 static const IUnknownVtbl testoutputvtbl
= {
63 testoutput_QueryInterface
,
68 static IUnknown testoutput
= { &testoutputvtbl
};
70 static HRESULT WINAPI
teststream_QueryInterface(ISequentialStream
*iface
, REFIID riid
, void **obj
)
72 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_ISequentialStream
))
82 static ULONG WINAPI
teststream_AddRef(ISequentialStream
*iface
)
87 static ULONG WINAPI
teststream_Release(ISequentialStream
*iface
)
92 static HRESULT WINAPI
teststream_Read(ISequentialStream
*iface
, void *pv
, ULONG cb
, ULONG
*pread
)
94 ok(0, "unexpected call\n");
98 static ULONG g_write_len
;
99 static HRESULT WINAPI
teststream_Write(ISequentialStream
*iface
, const void *pv
, ULONG cb
, ULONG
*written
)
106 static const ISequentialStreamVtbl teststreamvtbl
=
108 teststream_QueryInterface
,
115 static ISequentialStream teststream
= { &teststreamvtbl
};
117 static void test_writer_create(void)
126 pCreateXmlWriter(&IID_IXmlWriter
, NULL
, NULL
);
127 pCreateXmlWriter(NULL
, (void**)&writer
, NULL
);
130 hr
= pCreateXmlWriter(&IID_IXmlWriter
, (void**)&writer
, NULL
);
131 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
133 /* check default properties values */
135 hr
= IXmlWriter_GetProperty(writer
, XmlWriterProperty_ByteOrderMark
, &value
);
136 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
137 ok(value
== TRUE
, "got %ld\n", value
);
140 hr
= IXmlWriter_GetProperty(writer
, XmlWriterProperty_Indent
, &value
);
141 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
142 ok(value
== FALSE
, "got %ld\n", value
);
145 hr
= IXmlWriter_GetProperty(writer
, XmlWriterProperty_OmitXmlDeclaration
, &value
);
146 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
147 ok(value
== FALSE
, "got %ld\n", value
);
149 value
= XmlConformanceLevel_Auto
;
150 hr
= IXmlWriter_GetProperty(writer
, XmlWriterProperty_ConformanceLevel
, &value
);
151 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
152 ok(value
== XmlConformanceLevel_Document
, "got %ld\n", value
);
154 IXmlWriter_Release(writer
);
157 static BOOL
init_pointers(void)
159 /* don't free module here, it's to be unloaded on exit */
160 HMODULE mod
= LoadLibraryA("xmllite.dll");
164 win_skip("xmllite library not available\n");
168 #define MAKEFUNC(f) if (!(p##f = (void*)GetProcAddress(mod, #f))) return FALSE;
169 MAKEFUNC(CreateXmlWriter
);
170 MAKEFUNC(CreateXmlWriterOutputWithEncodingName
);
176 static void test_writeroutput(void)
178 static const WCHAR utf16W
[] = {'u','t','f','-','1','6',0};
179 IXmlWriterOutput
*output
;
184 hr
= pCreateXmlWriterOutputWithEncodingName(&testoutput
, NULL
, NULL
, &output
);
185 ok(hr
== S_OK
, "got %08x\n", hr
);
186 IUnknown_Release(output
);
188 hr
= pCreateXmlWriterOutputWithEncodingName(&testoutput
, NULL
, utf16W
, &output
);
189 ok(hr
== S_OK
, "got %08x\n", hr
);
191 hr
= IUnknown_QueryInterface(output
, &IID_IXmlWriterOutput
, (void**)&unk
);
192 ok(hr
== S_OK
, "got %08x\n", hr
);
193 ok(unk
!= NULL
, "got %p\n", unk
);
194 /* releasing 'unk' crashes on native */
195 IUnknown_Release(output
);
198 static void test_writestartdocument(void)
200 static const char fullprolog
[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
201 static const char prologversion
[] = "<?xml version=\"1.0\"?>";
202 static const WCHAR versionW
[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0};
203 static const WCHAR xmlW
[] = {'x','m','l',0};
210 hr
= pCreateXmlWriter(&IID_IXmlWriter
, (void**)&writer
, NULL
);
211 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
214 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
215 ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
217 hr
= IXmlWriter_WriteProcessingInstruction(writer
, xmlW
, versionW
);
218 ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
220 hr
= IXmlWriter_Flush(writer
);
221 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
223 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
224 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
226 hr
= IXmlWriter_SetOutput(writer
, (IUnknown
*)stream
);
227 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
229 /* nothing written yet */
230 hr
= IXmlWriter_Flush(writer
);
231 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
233 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
234 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
236 hr
= IXmlWriter_Flush(writer
);
237 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
239 hr
= GetHGlobalFromStream(stream
, &hglobal
);
240 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
242 ptr
= GlobalLock(hglobal
);
243 ok(!strncmp(ptr
, fullprolog
, strlen(fullprolog
)), "got %s, expected %s\n", ptr
, fullprolog
);
244 GlobalUnlock(hglobal
);
247 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
248 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
249 IStream_Release(stream
);
251 /* now add PI manually, and try to start a document */
252 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
253 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
255 hr
= IXmlWriter_SetOutput(writer
, (IUnknown
*)stream
);
256 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
258 hr
= IXmlWriter_WriteProcessingInstruction(writer
, xmlW
, versionW
);
259 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
261 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
262 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
264 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
265 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
267 /* another attempt to add 'xml' PI */
268 hr
= IXmlWriter_WriteProcessingInstruction(writer
, xmlW
, versionW
);
269 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
271 hr
= IXmlWriter_Flush(writer
);
272 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
274 hr
= GetHGlobalFromStream(stream
, &hglobal
);
275 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
277 ptr
= GlobalLock(hglobal
);
278 ok(!strncmp(ptr
, prologversion
, strlen(prologversion
)), "got %s\n", ptr
);
279 GlobalUnlock(hglobal
);
281 IStream_Release(stream
);
282 IXmlWriter_Release(writer
);
285 static void test_flush(void)
290 hr
= pCreateXmlWriter(&IID_IXmlWriter
, (void**)&writer
, NULL
);
291 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
293 hr
= IXmlWriter_SetOutput(writer
, (IUnknown
*)&teststream
);
294 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
296 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
297 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
300 hr
= IXmlWriter_Flush(writer
);
301 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
302 ok(g_write_len
> 0, "got %d\n", g_write_len
);
305 hr
= IXmlWriter_Flush(writer
);
306 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
307 ok(g_write_len
== 0, "got %d\n", g_write_len
);
309 /* Release() flushes too */
311 IXmlWriter_Release(writer
);
312 ok(g_write_len
== 0, "got %d\n", g_write_len
);
315 static void test_omitxmldeclaration(void)
317 static const char prologversion
[] = "<?xml version=\"1.0\"?>";
318 static const WCHAR versionW
[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0};
319 static const WCHAR xmlW
[] = {'x','m','l',0};
326 hr
= pCreateXmlWriter(&IID_IXmlWriter
, (void**)&writer
, NULL
);
327 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
329 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
330 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
332 hr
= IXmlWriter_SetOutput(writer
, (IUnknown
*)stream
);
333 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
335 hr
= IXmlWriter_SetProperty(writer
, XmlWriterProperty_OmitXmlDeclaration
, TRUE
);
336 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
338 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
339 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
341 hr
= IXmlWriter_Flush(writer
);
342 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
344 hr
= GetHGlobalFromStream(stream
, &hglobal
);
345 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
347 ptr
= GlobalLock(hglobal
);
348 ok(!ptr
, "got %p\n", ptr
);
349 GlobalUnlock(hglobal
);
352 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
353 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
355 IStream_Release(stream
);
357 /* now add PI manually, and try to start a document */
358 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
359 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
361 hr
= IXmlWriter_SetOutput(writer
, (IUnknown
*)stream
);
362 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
364 hr
= IXmlWriter_WriteProcessingInstruction(writer
, xmlW
, versionW
);
365 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
367 hr
= IXmlWriter_Flush(writer
);
368 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
370 hr
= GetHGlobalFromStream(stream
, &hglobal
);
371 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
373 ptr
= GlobalLock(hglobal
);
374 ok(!strncmp(ptr
, prologversion
, strlen(prologversion
)), "got %s\n", ptr
);
375 GlobalUnlock(hglobal
);
377 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
378 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
380 hr
= IXmlWriter_Flush(writer
);
381 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
383 ptr
= GlobalLock(hglobal
);
384 ok(!strncmp(ptr
, prologversion
, strlen(prologversion
)), "got %s\n", ptr
);
385 GlobalUnlock(hglobal
);
387 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
388 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
390 hr
= IXmlWriter_Flush(writer
);
391 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
393 ptr
= GlobalLock(hglobal
);
394 ok(!strncmp(ptr
, prologversion
, strlen(prologversion
)), "got %s\n", ptr
);
395 GlobalUnlock(hglobal
);
397 /* another attempt to add 'xml' PI */
398 hr
= IXmlWriter_WriteProcessingInstruction(writer
, xmlW
, versionW
);
399 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
401 hr
= IXmlWriter_Flush(writer
);
402 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
404 IStream_Release(stream
);
405 IXmlWriter_Release(writer
);
408 static void test_bom(void)
410 static const WCHAR versionW
[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0};
411 static const WCHAR utf16W
[] = {'u','t','f','-','1','6',0};
412 static const WCHAR xmlW
[] = {'x','m','l',0};
413 static const WCHAR aW
[] = {'a',0};
414 IXmlWriterOutput
*output
;
421 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
422 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
424 hr
= pCreateXmlWriterOutputWithEncodingName((IUnknown
*)stream
, NULL
, utf16W
, &output
);
425 ok(hr
== S_OK
, "got %08x\n", hr
);
427 hr
= pCreateXmlWriter(&IID_IXmlWriter
, (void**)&writer
, NULL
);
428 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
430 hr
= IXmlWriter_SetProperty(writer
, XmlWriterProperty_OmitXmlDeclaration
, TRUE
);
431 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
433 hr
= IXmlWriter_SetOutput(writer
, output
);
434 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
436 /* BOM is on by default */
437 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
438 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
440 hr
= IXmlWriter_Flush(writer
);
441 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
443 hr
= GetHGlobalFromStream(stream
, &hglobal
);
444 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
446 ptr
= GlobalLock(hglobal
);
447 ok(ptr
[0] == 0xff && ptr
[1] == 0xfe, "got %x,%x\n", ptr
[0], ptr
[1]);
448 GlobalUnlock(hglobal
);
450 IStream_Release(stream
);
451 IUnknown_Release(output
);
454 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
455 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
457 hr
= pCreateXmlWriterOutputWithEncodingName((IUnknown
*)stream
, NULL
, utf16W
, &output
);
458 ok(hr
== S_OK
, "got %08x\n", hr
);
460 hr
= IXmlWriter_SetOutput(writer
, output
);
461 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
463 hr
= IXmlWriter_WriteProcessingInstruction(writer
, xmlW
, versionW
);
464 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
466 hr
= IXmlWriter_Flush(writer
);
467 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
469 hr
= GetHGlobalFromStream(stream
, &hglobal
);
470 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
472 ptr
= GlobalLock(hglobal
);
473 ok(ptr
[0] == 0xff && ptr
[1] == 0xfe, "got %x,%x\n", ptr
[0], ptr
[1]);
474 GlobalUnlock(hglobal
);
476 IUnknown_Release(output
);
477 IStream_Release(stream
);
479 /* start with element */
480 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
481 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
483 hr
= pCreateXmlWriterOutputWithEncodingName((IUnknown
*)stream
, NULL
, utf16W
, &output
);
484 ok(hr
== S_OK
, "got %08x\n", hr
);
486 hr
= IXmlWriter_SetOutput(writer
, output
);
487 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
489 hr
= IXmlWriter_WriteStartElement(writer
, NULL
, aW
, NULL
);
490 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
492 hr
= IXmlWriter_Flush(writer
);
493 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
495 hr
= GetHGlobalFromStream(stream
, &hglobal
);
496 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
498 ptr
= GlobalLock(hglobal
);
499 ok(ptr
[0] == 0xff && ptr
[1] == 0xfe, "got %x,%x\n", ptr
[0], ptr
[1]);
500 GlobalUnlock(hglobal
);
502 IUnknown_Release(output
);
503 IStream_Release(stream
);
505 /* WriteElementString */
506 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
507 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
509 hr
= pCreateXmlWriterOutputWithEncodingName((IUnknown
*)stream
, NULL
, utf16W
, &output
);
510 ok(hr
== S_OK
, "got %08x\n", hr
);
512 hr
= IXmlWriter_SetOutput(writer
, output
);
513 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
515 hr
= IXmlWriter_WriteElementString(writer
, NULL
, aW
, NULL
, NULL
);
516 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
518 hr
= IXmlWriter_Flush(writer
);
519 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
521 hr
= GetHGlobalFromStream(stream
, &hglobal
);
522 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
524 ptr
= GlobalLock(hglobal
);
525 ok(ptr
[0] == 0xff && ptr
[1] == 0xfe, "got %x,%x\n", ptr
[0], ptr
[1]);
526 GlobalUnlock(hglobal
);
528 IUnknown_Release(output
);
529 IStream_Release(stream
);
531 IXmlWriter_Release(writer
);
534 static void test_writestartelement(void)
536 static const WCHAR valueW
[] = {'v','a','l','u','e',0};
537 static const char *str
= "<a><b>value</b>";
538 static const WCHAR aW
[] = {'a',0};
539 static const WCHAR bW
[] = {'b',0};
546 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
547 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
549 hr
= pCreateXmlWriter(&IID_IXmlWriter
, (void**)&writer
, NULL
);
550 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
552 hr
= IXmlWriter_WriteStartElement(writer
, NULL
, aW
, NULL
);
553 ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
555 hr
= IXmlWriter_SetOutput(writer
, (IUnknown
*)stream
);
556 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
558 hr
= IXmlWriter_WriteStartElement(writer
, aW
, NULL
, NULL
);
559 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
561 hr
= IXmlWriter_WriteStartElement(writer
, NULL
, NULL
, NULL
);
562 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
564 hr
= IXmlWriter_WriteStartElement(writer
, NULL
, NULL
, aW
);
565 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
567 hr
= IXmlWriter_WriteStartElement(writer
, NULL
, aW
, NULL
);
568 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
570 hr
= GetHGlobalFromStream(stream
, &hglobal
);
571 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
573 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
574 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
576 hr
= IXmlWriter_Flush(writer
);
577 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
579 ptr
= GlobalLock(hglobal
);
580 ok(!strncmp(ptr
, "<a", 2), "got %s\n", ptr
);
581 GlobalUnlock(hglobal
);
583 hr
= IXmlWriter_WriteStartDocument(writer
, XmlStandalone_Yes
);
584 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
586 /* write another element without closing previous one */
587 hr
= IXmlWriter_WriteStartElement(writer
, NULL
, aW
, NULL
);
588 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
590 hr
= IXmlWriter_WriteStartElement(writer
, NULL
, NULL
, NULL
);
591 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
593 hr
= IXmlWriter_WriteProcessingInstruction(writer
, aW
, aW
);
594 ok(hr
== WR_E_INVALIDACTION
, "got 0x%08x\n", hr
);
596 IStream_Release(stream
);
597 IXmlWriter_Release(writer
);
599 /* WriteElementString */
600 hr
= pCreateXmlWriter(&IID_IXmlWriter
, (void**)&writer
, NULL
);
601 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
603 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
604 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
606 hr
= IXmlWriter_WriteElementString(writer
, NULL
, bW
, NULL
, valueW
);
607 ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
609 hr
= IXmlWriter_SetOutput(writer
, (IUnknown
*)stream
);
610 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
612 hr
= IXmlWriter_WriteStartElement(writer
, NULL
, aW
, NULL
);
613 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
615 hr
= IXmlWriter_WriteElementString(writer
, NULL
, bW
, NULL
, valueW
);
616 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
618 hr
= IXmlWriter_Flush(writer
);
619 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
621 hr
= GetHGlobalFromStream(stream
, &hglobal
);
622 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
624 ptr
= GlobalLock(hglobal
);
625 ok(!strncmp(ptr
, str
, strlen(str
)), "got %s\n", ptr
);
626 GlobalUnlock(hglobal
);
628 IStream_Release(stream
);
629 IXmlWriter_Release(writer
);
634 if (!init_pointers())
637 test_writer_create();
639 test_writestartdocument();
640 test_writestartelement();
642 test_omitxmldeclaration();