winhelp: Constify the internal .hlp file parsing.
[wine.git] / dlls / msxml3 / tests / saxreader.c
blob20a3326417166c60e30e11ad7eece14e839582b6
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 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;
43 } contenthandler;
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,
52 REFIID riid,
53 void **ppvObject)
55 *ppvObject = NULL;
57 if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISAXContentHandler))
59 *ppvObject = iface;
61 else
63 return E_NOINTERFACE;
66 return S_OK;
69 static ULONG WINAPI contentHandler_AddRef(
70 ISAXContentHandler* iface)
72 return 2;
75 static ULONG WINAPI contentHandler_Release(
76 ISAXContentHandler* iface)
78 return 1;
81 static HRESULT WINAPI contentHandler_putDocumentLocator(
82 ISAXContentHandler* iface,
83 ISAXLocator *pLocator)
85 return S_OK;
88 static HRESULT WINAPI contentHandler_startDocument(
89 ISAXContentHandler* iface)
91 return S_OK;
94 static HRESULT WINAPI contentHandler_endDocument(
95 ISAXContentHandler* iface)
97 return S_OK;
100 static HRESULT WINAPI contentHandler_startPrefixMapping(
101 ISAXContentHandler* iface,
102 const WCHAR *pPrefix,
103 int nPrefix,
104 const WCHAR *pUri,
105 int nUri)
107 return S_OK;
110 static HRESULT WINAPI contentHandler_endPrefixMapping(
111 ISAXContentHandler* iface,
112 const WCHAR *pPrefix,
113 int nPrefix)
115 return S_OK;
118 static HRESULT WINAPI contentHandler_startElement(
119 ISAXContentHandler* iface,
120 const WCHAR *pNamespaceUri,
121 int nNamespaceUri,
122 const WCHAR *pLocalName,
123 int nLocalName,
124 const WCHAR *pQName,
125 int nQName,
126 ISAXAttributes *pAttr)
128 return S_OK;
131 static HRESULT WINAPI contentHandler_endElement(
132 ISAXContentHandler* iface,
133 const WCHAR *pNamespaceUri,
134 int nNamespaceUri,
135 const WCHAR *pLocalName,
136 int nLocalName,
137 const WCHAR *pQName,
138 int nQName)
140 return S_OK;
143 static HRESULT WINAPI contentHandler_characters(
144 ISAXContentHandler* iface,
145 const WCHAR *pChars,
146 int nChars)
148 return S_OK;
151 static HRESULT WINAPI contentHandler_ignorableWhitespace(
152 ISAXContentHandler* iface,
153 const WCHAR *pChars,
154 int nChars)
156 return S_OK;
159 static HRESULT WINAPI contentHandler_processingInstruction(
160 ISAXContentHandler* iface,
161 const WCHAR *pTarget,
162 int nTarget,
163 const WCHAR *pData,
164 int nData)
166 return S_OK;
169 static HRESULT WINAPI contentHandler_skippedEntity(
170 ISAXContentHandler* iface,
171 const WCHAR *pName,
172 int nName)
174 return S_OK;
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)
201 HRESULT hr;
202 ISAXXMLReader *reader = NULL;
203 VARIANT var;
204 ISAXContentHandler *lpContentHandler;
206 hr = CoCreateInstance(&CLSID_SAXXMLReader, NULL, CLSCTX_INPROC_SERVER,
207 &IID_ISAXXMLReader, (LPVOID*)&reader);
209 if(FAILED(hr))
211 skip("Failed to create SAXXMLReader instance\n");
212 return;
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);
236 todo_wine {
237 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
240 ISAXXMLReader_Release(reader);
243 START_TEST(saxreader)
245 HRESULT hr;
247 hr = CoInitialize(NULL);
248 ok(hr == S_OK, "failed to init com\n");
250 test_saxreader();
252 CoUninitialize();