Release 1.3.7.
[wine/gsoc-2012-control.git] / dlls / msxml3 / tests / saxreader.c
blob6480f0708fcc0872bc7f24a2e9ca22e0d25af6ec
1 /*
2 * XML test
4 * Copyright 2008 Piotr Caban
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
21 #define COBJMACROS
22 #define CONST_VTABLE
24 #include <stdio.h>
25 #include "windows.h"
26 #include "ole2.h"
27 #include "msxml2.h"
28 #include "ocidl.h"
30 #include "wine/test.h"
32 typedef enum _CH {
33 CH_ENDTEST,
34 CH_PUTDOCUMENTLOCATOR,
35 CH_STARTDOCUMENT,
36 CH_ENDDOCUMENT,
37 CH_STARTPREFIXMAPPING,
38 CH_ENDPREFIXMAPPING,
39 CH_STARTELEMENT,
40 CH_ENDELEMENT,
41 CH_CHARACTERS,
42 CH_IGNORABLEWHITESPACE,
43 CH_PROCESSINGINSTRUCTION,
44 CH_SKIPPEDENTITY
45 } CH;
47 static const WCHAR szSimpleXML[] = {
48 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\"','1','.','0','\"',' ','?','>','\n',
49 '<','B','a','n','k','A','c','c','o','u','n','t','>','\n',
50 ' ',' ',' ','<','N','u','m','b','e','r','>','1','2','3','4','<','/','N','u','m','b','e','r','>','\n',
51 ' ',' ',' ','<','N','a','m','e','>','C','a','p','t','a','i','n',' ','A','h','a','b','<','/','N','a','m','e','>','\n',
52 '<','/','B','a','n','k','A','c','c','o','u','n','t','>','\n','\0'
55 static const WCHAR szCarriageRetTest[] = {
56 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','"','1','.','0','"','?','>','\r','\n',
57 '<','B','a','n','k','A','c','c','o','u','n','t','>','\r','\n',
58 '\t','<','N','u','m','b','e','r','>','1','2','3','4','<','/','N','u','m','b','e','r','>','\r','\n',
59 '\t','<','N','a','m','e','>','C','a','p','t','a','i','n',' ','A','h','a','b','<','/','N','a','m','e','>','\r','\n',
60 '<','/','B','a','n','k','A','c','c','o','u','n','t','>','\0'
63 static const CHAR szTestXML[] =
64 "<?xml version=\"1.0\" ?>\n"
65 "<BankAccount>\n"
66 " <Number>1234</Number>\n"
67 " <Name>Captain Ahab</Name>\n"
68 "</BankAccount>\n";
70 typedef struct _contenthandlercheck {
71 CH id;
72 int line;
73 int column;
74 const char *arg1;
75 const char *arg2;
76 const char *arg3;
77 } content_handler_test;
79 static content_handler_test contentHandlerTest1[] = {
80 { CH_PUTDOCUMENTLOCATOR, 0, 0 },
81 { CH_STARTDOCUMENT, 0, 0 },
82 { CH_STARTELEMENT, 2, 14, "", "BankAccount", "BankAccount" },
83 { CH_CHARACTERS, 2, 14, "\n " },
84 { CH_STARTELEMENT, 3, 12, "", "Number", "Number" },
85 { CH_CHARACTERS, 3, 12, "1234" },
86 { CH_ENDELEMENT, 3, 18, "", "Number", "Number" },
87 { CH_CHARACTERS, 3, 25, "\n " },
88 { CH_STARTELEMENT, 4, 10, "", "Name", "Name" },
89 { CH_CHARACTERS, 4, 10, "Captain Ahab" },
90 { CH_ENDELEMENT, 4, 24, "", "Name", "Name" },
91 { CH_CHARACTERS, 4, 29, "\n" },
92 { CH_ENDELEMENT, 5, 3, "", "BankAccount", "BankAccount" },
93 { CH_ENDDOCUMENT, 0, 0 },
94 { CH_ENDTEST }
97 static content_handler_test contentHandlerTest2[] = {
98 { CH_PUTDOCUMENTLOCATOR, 0, 0 },
99 { CH_STARTDOCUMENT, 0, 0 },
100 { CH_STARTELEMENT, 2, 14, "", "BankAccount", "BankAccount" },
101 { CH_CHARACTERS, 2, 14, "\n" },
102 { CH_CHARACTERS, 2, 16, "\t" },
103 { CH_STARTELEMENT, 3, 10, "", "Number", "Number" },
104 { CH_CHARACTERS, 3, 10, "1234" },
105 { CH_ENDELEMENT, 3, 16, "", "Number", "Number" },
106 { CH_CHARACTERS, 3, 23, "\n" },
107 { CH_CHARACTERS, 3, 25, "\t" },
108 { CH_STARTELEMENT, 4, 8, "", "Name", "Name" },
109 { CH_CHARACTERS, 4, 8, "Captain Ahab" },
110 { CH_ENDELEMENT, 4, 22, "", "Name", "Name" },
111 { CH_CHARACTERS, 4, 27, "\n" },
112 { CH_ENDELEMENT, 5, 3, "", "BankAccount", "BankAccount" },
113 { CH_ENDDOCUMENT, 0, 0 },
114 { CH_ENDTEST }
117 static content_handler_test *expectCall;
118 static ISAXLocator *locator;
120 static void test_saxstr(unsigned line, const WCHAR *szStr, int nStr, const char *szTest)
122 WCHAR buf[1024];
123 int len;
125 if(!szTest) {
126 ok_(__FILE__,line) (szStr == NULL, "szStr != NULL\n");
127 ok_(__FILE__,line) (nStr == 0, "nStr = %d, expected 0\n", nStr);
128 return;
131 len = strlen(szTest);
132 ok_(__FILE__,line) (len == nStr, "nStr = %d, expected %d (%s)\n", nStr, len, szTest);
133 if(len != nStr)
134 return;
136 MultiByteToWideChar(CP_ACP, 0, szTest, -1, buf, sizeof(buf)/sizeof(WCHAR));
137 ok_(__FILE__,line) (!memcmp(szStr, buf, len*sizeof(WCHAR)), "unexpected szStr %s, expected %s\n",
138 wine_dbgstr_wn(szStr, nStr), szTest);
141 static BOOL test_expect_call(CH id)
143 ok(expectCall->id == id, "unexpected call %d, expected %d\n", id, expectCall->id);
144 return expectCall->id == id;
147 static void test_locator(unsigned line, int loc_line, int loc_column)
149 int rcolumn, rline;
150 ISAXLocator_getLineNumber(locator, &rline);
151 ISAXLocator_getColumnNumber(locator, &rcolumn);
153 ok_(__FILE__,line) (rline == loc_line,
154 "unexpected line %d, expected %d\n", rline, loc_line);
155 ok_(__FILE__,line) (rcolumn == loc_column,
156 "unexpected column %d, expected %d\n", rcolumn, loc_column);
159 static HRESULT WINAPI contentHandler_QueryInterface(
160 ISAXContentHandler* iface,
161 REFIID riid,
162 void **ppvObject)
164 *ppvObject = NULL;
166 if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISAXContentHandler))
168 *ppvObject = iface;
170 else
172 return E_NOINTERFACE;
175 return S_OK;
178 static ULONG WINAPI contentHandler_AddRef(
179 ISAXContentHandler* iface)
181 return 2;
184 static ULONG WINAPI contentHandler_Release(
185 ISAXContentHandler* iface)
187 return 1;
190 static HRESULT WINAPI contentHandler_putDocumentLocator(
191 ISAXContentHandler* iface,
192 ISAXLocator *pLocator)
194 if(!test_expect_call(CH_PUTDOCUMENTLOCATOR))
195 return E_FAIL;
197 locator = pLocator;
198 test_locator(__LINE__, expectCall->line, expectCall->column);
200 expectCall++;
201 return S_OK;
204 static HRESULT WINAPI contentHandler_startDocument(
205 ISAXContentHandler* iface)
207 if(!test_expect_call(CH_STARTDOCUMENT))
208 return E_FAIL;
210 test_locator(__LINE__, expectCall->line, expectCall->column);
212 expectCall++;
213 return S_OK;
216 static HRESULT WINAPI contentHandler_endDocument(
217 ISAXContentHandler* iface)
219 if(!test_expect_call(CH_ENDDOCUMENT))
220 return E_FAIL;
222 test_locator(__LINE__, expectCall->line, expectCall->column);
224 expectCall++;
225 return S_OK;
228 static HRESULT WINAPI contentHandler_startPrefixMapping(
229 ISAXContentHandler* iface,
230 const WCHAR *pPrefix,
231 int nPrefix,
232 const WCHAR *pUri,
233 int nUri)
235 if(!test_expect_call(CH_ENDDOCUMENT))
236 return E_FAIL;
238 test_saxstr(__LINE__, pPrefix, nPrefix, expectCall->arg1);
239 test_saxstr(__LINE__, pUri, nUri, expectCall->arg2);
240 test_locator(__LINE__, expectCall->line, expectCall->column);
242 expectCall++;
243 return S_OK;
246 static HRESULT WINAPI contentHandler_endPrefixMapping(
247 ISAXContentHandler* iface,
248 const WCHAR *pPrefix,
249 int nPrefix)
251 if(!test_expect_call(CH_ENDPREFIXMAPPING))
252 return E_FAIL;
254 test_saxstr(__LINE__, pPrefix, nPrefix, expectCall->arg1);
255 test_locator(__LINE__, expectCall->line, expectCall->column);
257 expectCall++;
258 return S_OK;
261 static HRESULT WINAPI contentHandler_startElement(
262 ISAXContentHandler* iface,
263 const WCHAR *pNamespaceUri,
264 int nNamespaceUri,
265 const WCHAR *pLocalName,
266 int nLocalName,
267 const WCHAR *pQName,
268 int nQName,
269 ISAXAttributes *pAttr)
271 if(!test_expect_call(CH_STARTELEMENT))
272 return E_FAIL;
274 test_saxstr(__LINE__, pNamespaceUri, nNamespaceUri, expectCall->arg1);
275 test_saxstr(__LINE__, pLocalName, nLocalName, expectCall->arg2);
276 test_saxstr(__LINE__, pQName, nQName, expectCall->arg3);
277 test_locator(__LINE__, expectCall->line, expectCall->column);
279 expectCall++;
280 return S_OK;
283 static HRESULT WINAPI contentHandler_endElement(
284 ISAXContentHandler* iface,
285 const WCHAR *pNamespaceUri,
286 int nNamespaceUri,
287 const WCHAR *pLocalName,
288 int nLocalName,
289 const WCHAR *pQName,
290 int nQName)
292 if(!test_expect_call(CH_ENDELEMENT))
293 return E_FAIL;
295 test_saxstr(__LINE__, pNamespaceUri, nNamespaceUri, expectCall->arg1);
296 test_saxstr(__LINE__, pLocalName, nLocalName, expectCall->arg2);
297 test_saxstr(__LINE__, pQName, nQName, expectCall->arg3);
298 test_locator(__LINE__, expectCall->line, expectCall->column);
300 expectCall++;
301 return S_OK;
304 static HRESULT WINAPI contentHandler_characters(
305 ISAXContentHandler* iface,
306 const WCHAR *pChars,
307 int nChars)
309 if(!test_expect_call(CH_CHARACTERS))
310 return E_FAIL;
312 test_saxstr(__LINE__, pChars, nChars, expectCall->arg1);
313 test_locator(__LINE__, expectCall->line, expectCall->column);
315 expectCall++;
316 return S_OK;
319 static HRESULT WINAPI contentHandler_ignorableWhitespace(
320 ISAXContentHandler* iface,
321 const WCHAR *pChars,
322 int nChars)
324 if(!test_expect_call(CH_IGNORABLEWHITESPACE))
325 return E_FAIL;
327 test_saxstr(__LINE__, pChars, nChars, expectCall->arg1);
328 test_locator(__LINE__, expectCall->line, expectCall->column);
330 expectCall++;
331 return S_OK;
334 static HRESULT WINAPI contentHandler_processingInstruction(
335 ISAXContentHandler* iface,
336 const WCHAR *pTarget,
337 int nTarget,
338 const WCHAR *pData,
339 int nData)
341 if(!test_expect_call(CH_PROCESSINGINSTRUCTION))
342 return E_FAIL;
344 test_saxstr(__LINE__, pTarget, nTarget, expectCall->arg1);
345 test_saxstr(__LINE__, pData, nData, expectCall->arg2);
346 test_locator(__LINE__, expectCall->line, expectCall->column);
348 expectCall++;
349 return S_OK;
352 static HRESULT WINAPI contentHandler_skippedEntity(
353 ISAXContentHandler* iface,
354 const WCHAR *pName,
355 int nName)
357 if(!test_expect_call(CH_SKIPPEDENTITY))
358 return E_FAIL;
360 test_saxstr(__LINE__, pName, nName, expectCall->arg1);
361 test_locator(__LINE__, expectCall->line, expectCall->column);
363 expectCall++;
364 return S_OK;
368 static const ISAXContentHandlerVtbl contentHandlerVtbl =
370 contentHandler_QueryInterface,
371 contentHandler_AddRef,
372 contentHandler_Release,
373 contentHandler_putDocumentLocator,
374 contentHandler_startDocument,
375 contentHandler_endDocument,
376 contentHandler_startPrefixMapping,
377 contentHandler_endPrefixMapping,
378 contentHandler_startElement,
379 contentHandler_endElement,
380 contentHandler_characters,
381 contentHandler_ignorableWhitespace,
382 contentHandler_processingInstruction,
383 contentHandler_skippedEntity
386 static ISAXContentHandler contentHandler = { &contentHandlerVtbl };
388 static HRESULT WINAPI isaxerrorHandler_QueryInterface(
389 ISAXErrorHandler* iface,
390 REFIID riid,
391 void **ppvObject)
393 *ppvObject = NULL;
395 if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISAXErrorHandler))
397 *ppvObject = iface;
399 else
401 return E_NOINTERFACE;
404 return S_OK;
407 static ULONG WINAPI isaxerrorHandler_AddRef(
408 ISAXErrorHandler* iface)
410 return 2;
413 static ULONG WINAPI isaxerrorHandler_Release(
414 ISAXErrorHandler* iface)
416 return 1;
419 static HRESULT WINAPI isaxerrorHandler_error(
420 ISAXErrorHandler* iface,
421 ISAXLocator *pLocator,
422 const WCHAR *pErrorMessage,
423 HRESULT hrErrorCode)
425 return S_OK;
428 static HRESULT WINAPI isaxerrorHandler_fatalError(
429 ISAXErrorHandler* iface,
430 ISAXLocator *pLocator,
431 const WCHAR *pErrorMessage,
432 HRESULT hrErrorCode)
434 return S_OK;
437 static HRESULT WINAPI isaxerrorHanddler_ignorableWarning(
438 ISAXErrorHandler* iface,
439 ISAXLocator *pLocator,
440 const WCHAR *pErrorMessage,
441 HRESULT hrErrorCode)
443 return S_OK;
446 static const ISAXErrorHandlerVtbl errorHandlerVtbl =
448 isaxerrorHandler_QueryInterface,
449 isaxerrorHandler_AddRef,
450 isaxerrorHandler_Release,
451 isaxerrorHandler_error,
452 isaxerrorHandler_fatalError,
453 isaxerrorHanddler_ignorableWarning
456 static ISAXErrorHandler errorHandler = { &errorHandlerVtbl };
458 static void test_saxreader(void)
460 HRESULT hr;
461 ISAXXMLReader *reader = NULL;
462 VARIANT var;
463 ISAXContentHandler *lpContentHandler;
464 ISAXErrorHandler *lpErrorHandler;
465 SAFEARRAY *pSA;
466 SAFEARRAYBOUND SADim[1];
467 char *pSAData = NULL;
468 IStream *iStream;
469 ULARGE_INTEGER liSize;
470 LARGE_INTEGER liPos;
471 ULONG bytesWritten;
472 HANDLE file;
473 static const CHAR testXmlA[] = "test.xml";
474 static const WCHAR testXmlW[] = {'t','e','s','t','.','x','m','l',0};
475 IXMLDOMDocument *domDocument;
476 BSTR bstrData;
477 VARIANT_BOOL vBool;
479 hr = CoCreateInstance(&CLSID_SAXXMLReader, NULL, CLSCTX_INPROC_SERVER,
480 &IID_ISAXXMLReader, (LPVOID*)&reader);
481 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
483 hr = ISAXXMLReader_getContentHandler(reader, NULL);
484 ok(hr == E_POINTER, "Expected E_POINTER, got %08x\n", hr);
486 hr = ISAXXMLReader_getErrorHandler(reader, NULL);
487 ok(hr == E_POINTER, "Expected E_POINTER, got %08x\n", hr);
489 hr = ISAXXMLReader_getContentHandler(reader, &lpContentHandler);
490 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
491 ok(lpContentHandler == NULL, "Expected %p, got %p\n", NULL, lpContentHandler);
493 hr = ISAXXMLReader_getErrorHandler(reader, &lpErrorHandler);
494 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
495 ok(lpErrorHandler == NULL, "Expected %p, got %p\n", NULL, lpErrorHandler);
497 hr = ISAXXMLReader_putContentHandler(reader, NULL);
498 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
500 hr = ISAXXMLReader_putContentHandler(reader, &contentHandler);
501 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
503 hr = ISAXXMLReader_putErrorHandler(reader, &errorHandler);
504 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
506 hr = ISAXXMLReader_getContentHandler(reader, &lpContentHandler);
507 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
508 ok(lpContentHandler == &contentHandler, "Expected %p, got %p\n", &contentHandler, lpContentHandler);
510 V_VT(&var) = VT_BSTR;
511 V_BSTR(&var) = SysAllocString(szSimpleXML);
513 expectCall = contentHandlerTest1;
514 hr = ISAXXMLReader_parse(reader, var);
515 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
516 test_expect_call(CH_ENDTEST);
518 VariantClear(&var);
520 SADim[0].lLbound= 0;
521 SADim[0].cElements= sizeof(szTestXML)-1;
522 pSA = SafeArrayCreate(VT_UI1, 1, SADim);
523 SafeArrayAccessData(pSA, (void**)&pSAData);
524 memcpy(pSAData, szTestXML, sizeof(szTestXML)-1);
525 SafeArrayUnaccessData(pSA);
526 V_VT(&var) = VT_ARRAY|VT_UI1;
527 V_ARRAY(&var) = pSA;
529 expectCall = contentHandlerTest1;
530 hr = ISAXXMLReader_parse(reader, var);
531 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
532 test_expect_call(CH_ENDTEST);
534 SafeArrayDestroy(pSA);
536 CreateStreamOnHGlobal(NULL, TRUE, &iStream);
537 liSize.QuadPart = strlen(szTestXML);
538 IStream_SetSize(iStream, liSize);
539 IStream_Write(iStream, szTestXML, strlen(szTestXML), &bytesWritten);
540 liPos.QuadPart = 0;
541 IStream_Seek(iStream, liPos, STREAM_SEEK_SET, NULL);
542 V_VT(&var) = VT_UNKNOWN|VT_DISPATCH;
543 V_UNKNOWN(&var) = (IUnknown*)iStream;
545 expectCall = contentHandlerTest1;
546 hr = ISAXXMLReader_parse(reader, var);
547 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
548 test_expect_call(CH_ENDTEST);
550 IStream_Release(iStream);
552 V_VT(&var) = VT_BSTR;
553 V_BSTR(&var) = SysAllocString(szCarriageRetTest);
555 expectCall = contentHandlerTest2;
556 hr = ISAXXMLReader_parse(reader, var);
557 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
558 test_expect_call(CH_ENDTEST);
560 VariantClear(&var);
562 file = CreateFileA(testXmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
563 ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
564 WriteFile(file, szTestXML, sizeof(szTestXML)-1, &bytesWritten, NULL);
565 CloseHandle(file);
567 expectCall = contentHandlerTest1;
568 hr = ISAXXMLReader_parseURL(reader, testXmlW);
569 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
570 test_expect_call(CH_ENDTEST);
572 DeleteFileA(testXmlA);
574 hr = CoCreateInstance(&CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
575 &IID_IXMLDOMDocument, (LPVOID*)&domDocument);
576 if(FAILED(hr))
578 skip("Failed to create DOMDocument instance\n");
579 return;
581 bstrData = SysAllocString(szSimpleXML);
582 hr = IXMLDOMDocument_loadXML(domDocument, bstrData, &vBool);
583 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
584 V_VT(&var) = VT_UNKNOWN;
585 V_UNKNOWN(&var) = (IUnknown*)domDocument;
587 expectCall = contentHandlerTest2;
588 hr = ISAXXMLReader_parse(reader, var);
589 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
590 test_expect_call(CH_ENDTEST);
591 IXMLDOMDocument_Release(domDocument);
593 ISAXXMLReader_Release(reader);
594 SysFreeString(bstrData);
597 /* UTF-8 data with UTF-8 BOM and UTF-16 in prolog */
598 static const CHAR UTF8BOMTest[] =
599 "\xEF\xBB\xBF<?xml version = \"1.0\" encoding = \"UTF-16\"?>\n"
600 "<a></a>\n";
602 struct enc_test_entry_t {
603 const GUID *guid;
604 const char *clsid;
605 const char *data;
606 HRESULT hr;
607 int todo;
610 static const struct enc_test_entry_t encoding_test_data[] = {
611 { &CLSID_SAXXMLReader, "CLSID_SAXXMLReader", UTF8BOMTest, 0xc00ce56f, 1 },
612 { &CLSID_SAXXMLReader30, "CLSID_SAXXMLReader30", UTF8BOMTest, 0xc00ce56f, 1 },
613 { &CLSID_SAXXMLReader40, "CLSID_SAXXMLReader40", UTF8BOMTest, S_OK, 0 },
614 { &CLSID_SAXXMLReader60, "CLSID_SAXXMLReader60", UTF8BOMTest, S_OK, 0 },
615 { 0 }
618 static void test_encoding(void)
620 const struct enc_test_entry_t *entry = encoding_test_data;
621 static const WCHAR testXmlW[] = {'t','e','s','t','.','x','m','l',0};
622 static const CHAR testXmlA[] = "test.xml";
623 ISAXXMLReader *reader;
624 DWORD written;
625 HANDLE file;
626 HRESULT hr;
628 while (entry->guid)
630 hr = CoCreateInstance(entry->guid, NULL, CLSCTX_INPROC_SERVER, &IID_ISAXXMLReader, (void**)&reader);
631 if (hr != S_OK)
633 win_skip("can't create %s instance\n", entry->clsid);
634 entry++;
635 continue;
638 file = CreateFileA(testXmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
639 ok(file != INVALID_HANDLE_VALUE, "Could not create file: %u\n", GetLastError());
640 WriteFile(file, UTF8BOMTest, sizeof(UTF8BOMTest)-1, &written, NULL);
641 CloseHandle(file);
643 hr = ISAXXMLReader_parseURL(reader, testXmlW);
644 if (entry->todo)
645 todo_wine ok(hr == entry->hr, "Expected 0x%08x, got 0x%08x. CLSID %s\n", entry->hr, hr, entry->clsid);
646 else
647 ok(hr == entry->hr, "Expected 0x%08x, got 0x%08x. CLSID %s\n", entry->hr, hr, entry->clsid);
649 DeleteFileA(testXmlA);
650 ISAXXMLReader_Release(reader);
652 entry++;
656 START_TEST(saxreader)
658 ISAXXMLReader *reader;
659 HRESULT hr;
661 hr = CoInitialize(NULL);
662 ok(hr == S_OK, "failed to init com\n");
664 hr = CoCreateInstance(&CLSID_SAXXMLReader, NULL, CLSCTX_INPROC_SERVER,
665 &IID_ISAXXMLReader, (void**)&reader);
667 if(FAILED(hr))
669 skip("Failed to create SAXXMLReader instance\n");
670 CoUninitialize();
671 return;
673 ISAXXMLReader_Release(reader);
675 test_saxreader();
676 test_encoding();
678 CoUninitialize();