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
30 #include "wine/test.h"
32 static const WCHAR szSimpleXML
[] = {
33 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\"','1','.','0','\"',' ','?','>','\n',
34 '<','B','a','n','k','A','c','c','o','u','n','t','>','\n',
35 ' ',' ',' ','<','N','u','m','b','e','r','>','1','2','3','4','<','/','N','u','m','b','e','r','>','\n',
36 ' ',' ',' ','<','N','a','m','e','>','C','a','p','t','a','i','n',' ','A','h','a','b','<','/','N','a','m','e','>','\n',
37 '<','/','B','a','n','k','A','c','c','o','u','n','t','>','\n','\0'
40 typedef struct _contenthandler
42 const struct ISAXContentHandlerVtbl
*lpContentHandlerVtbl
;
45 static inline contenthandler
*impl_from_ISAXContentHandler(ISAXContentHandler
*iface
)
47 return (contenthandler
*)((char*)iface
- FIELD_OFFSET(contenthandler
, lpContentHandlerVtbl
));
50 static HRESULT WINAPI
contentHandler_QueryInterface(
51 ISAXContentHandler
* iface
,
57 if(IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_ISAXContentHandler
))
69 static ULONG WINAPI
contentHandler_AddRef(
70 ISAXContentHandler
* iface
)
75 static ULONG WINAPI
contentHandler_Release(
76 ISAXContentHandler
* iface
)
81 static HRESULT WINAPI
contentHandler_putDocumentLocator(
82 ISAXContentHandler
* iface
,
83 ISAXLocator
*pLocator
)
88 static HRESULT WINAPI
contentHandler_startDocument(
89 ISAXContentHandler
* iface
)
94 static HRESULT WINAPI
contentHandler_endDocument(
95 ISAXContentHandler
* iface
)
100 static HRESULT WINAPI
contentHandler_startPrefixMapping(
101 ISAXContentHandler
* iface
,
102 const WCHAR
*pPrefix
,
110 static HRESULT WINAPI
contentHandler_endPrefixMapping(
111 ISAXContentHandler
* iface
,
112 const WCHAR
*pPrefix
,
118 static HRESULT WINAPI
contentHandler_startElement(
119 ISAXContentHandler
* iface
,
120 const WCHAR
*pNamespaceUri
,
122 const WCHAR
*pLocalName
,
126 ISAXAttributes
*pAttr
)
131 static HRESULT WINAPI
contentHandler_endElement(
132 ISAXContentHandler
* iface
,
133 const WCHAR
*pNamespaceUri
,
135 const WCHAR
*pLocalName
,
143 static HRESULT WINAPI
contentHandler_characters(
144 ISAXContentHandler
* iface
,
151 static HRESULT WINAPI
contentHandler_ignorableWhitespace(
152 ISAXContentHandler
* iface
,
159 static HRESULT WINAPI
contentHandler_processingInstruction(
160 ISAXContentHandler
* iface
,
161 const WCHAR
*pTarget
,
169 static HRESULT WINAPI
contentHandler_skippedEntity(
170 ISAXContentHandler
* iface
,
178 static const ISAXContentHandlerVtbl contentHandlerVtbl
=
180 contentHandler_QueryInterface
,
181 contentHandler_AddRef
,
182 contentHandler_Release
,
183 contentHandler_putDocumentLocator
,
184 contentHandler_startDocument
,
185 contentHandler_endDocument
,
186 contentHandler_startPrefixMapping
,
187 contentHandler_endPrefixMapping
,
188 contentHandler_startElement
,
189 contentHandler_endElement
,
190 contentHandler_characters
,
191 contentHandler_ignorableWhitespace
,
192 contentHandler_processingInstruction
,
193 contentHandler_skippedEntity
196 static ISAXContentHandler contentHandler
= { &contentHandlerVtbl
};
199 static void test_saxreader(void)
202 ISAXXMLReader
*reader
= NULL
;
204 ISAXContentHandler
*lpContentHandler
;
206 hr
= CoCreateInstance(&CLSID_SAXXMLReader
, NULL
, CLSCTX_INPROC_SERVER
,
207 &IID_ISAXXMLReader
, (LPVOID
*)&reader
);
211 skip("Failed to create SAXXMLReader instance\n");
215 hr
= ISAXXMLReader_getContentHandler(reader
, NULL
);
216 ok(hr
== E_POINTER
, "Expected E_POINTER, got %08x\n", hr
);
218 hr
= ISAXXMLReader_getContentHandler(reader
, &lpContentHandler
);
219 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
220 ok(lpContentHandler
== NULL
, "Expected %p, got %p\n", NULL
, lpContentHandler
);
222 hr
= ISAXXMLReader_putContentHandler(reader
, NULL
);
223 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
225 hr
= ISAXXMLReader_putContentHandler(reader
, &contentHandler
);
226 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
228 hr
= ISAXXMLReader_getContentHandler(reader
, &lpContentHandler
);
229 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
230 ok(lpContentHandler
== &contentHandler
, "Expected %p, got %p\n", &contentHandler
, lpContentHandler
);
232 V_VT(&var
) = VT_BSTR
;
233 V_BSTR(&var
) = SysAllocString(szSimpleXML
);
235 hr
= ISAXXMLReader_parse(reader
, var
);
237 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
240 ISAXXMLReader_Release(reader
);
243 START_TEST(saxreader
)
247 hr
= CoInitialize(NULL
);
248 ok(hr
== S_OK
, "failed to init com\n");