msxml3/test: Added ISAXXMLReader test.
[wine/multimedia.git] / dlls / msxml3 / tests / saxreader.c
blob64ad62506cd99c85d986289313b572a263ea1d1b
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 struct _contenthandler
34 const struct ISAXContentHandlerVtbl *lpContentHandlerVtbl;
35 } contenthandler;
37 static inline contenthandler *impl_from_ISAXContentHandler(ISAXContentHandler *iface)
39 return (contenthandler *)((char*)iface - FIELD_OFFSET(contenthandler, lpContentHandlerVtbl));
42 static HRESULT WINAPI contentHandler_QueryInterface(
43 ISAXContentHandler* iface,
44 REFIID riid,
45 void **ppvObject)
47 *ppvObject = NULL;
49 if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISAXContentHandler))
51 *ppvObject = iface;
53 else
55 return E_NOINTERFACE;
58 return S_OK;
61 static ULONG WINAPI contentHandler_AddRef(
62 ISAXContentHandler* iface)
64 return 2;
67 static ULONG WINAPI contentHandler_Release(
68 ISAXContentHandler* iface)
70 return 1;
73 static HRESULT WINAPI contentHandler_putDocumentLocator(
74 ISAXContentHandler* iface,
75 ISAXLocator *pLocator)
77 return S_OK;
80 static HRESULT WINAPI contentHandler_startDocument(
81 ISAXContentHandler* iface)
83 return S_OK;
86 static HRESULT WINAPI contentHandler_endDocument(
87 ISAXContentHandler* iface)
89 return S_OK;
92 static HRESULT WINAPI contentHandler_startPrefixMapping(
93 ISAXContentHandler* iface,
94 const WCHAR *pPrefix,
95 int nPrefix,
96 const WCHAR *pUri,
97 int nUri)
99 return S_OK;
102 static HRESULT WINAPI contentHandler_endPrefixMapping(
103 ISAXContentHandler* iface,
104 const WCHAR *pPrefix,
105 int nPrefix)
107 return S_OK;
110 static HRESULT WINAPI contentHandler_startElement(
111 ISAXContentHandler* iface,
112 const WCHAR *pNamespaceUri,
113 int nNamespaceUri,
114 const WCHAR *pLocalName,
115 int nLocalName,
116 const WCHAR *pQName,
117 int nQName,
118 ISAXAttributes *pAttr)
120 return S_OK;
123 static HRESULT WINAPI contentHandler_endElement(
124 ISAXContentHandler* iface,
125 const WCHAR *pNamespaceUri,
126 int nNamespaceUri,
127 const WCHAR *pLocalName,
128 int nLocalName,
129 const WCHAR *pQName,
130 int nQName)
132 return S_OK;
135 static HRESULT WINAPI contentHandler_characters(
136 ISAXContentHandler* iface,
137 const WCHAR *pChars,
138 int nChars)
140 return S_OK;
143 static HRESULT WINAPI contentHandler_ignorableWhitespace(
144 ISAXContentHandler* iface,
145 const WCHAR *pChars,
146 int nChars)
148 return S_OK;
151 static HRESULT WINAPI contentHandler_processingInstruction(
152 ISAXContentHandler* iface,
153 const WCHAR *pTarget,
154 int nTarget,
155 const WCHAR *pData,
156 int nData)
158 return S_OK;
161 static HRESULT WINAPI contentHandler_skippedEntity(
162 ISAXContentHandler* iface,
163 const WCHAR *pName,
164 int nName)
166 return S_OK;
170 static const ISAXContentHandlerVtbl contentHandlerVtbl =
172 contentHandler_QueryInterface,
173 contentHandler_AddRef,
174 contentHandler_Release,
175 contentHandler_putDocumentLocator,
176 contentHandler_startDocument,
177 contentHandler_endDocument,
178 contentHandler_startPrefixMapping,
179 contentHandler_endPrefixMapping,
180 contentHandler_startElement,
181 contentHandler_endElement,
182 contentHandler_characters,
183 contentHandler_ignorableWhitespace,
184 contentHandler_processingInstruction,
185 contentHandler_skippedEntity
188 static ISAXContentHandler contentHandler = { &contentHandlerVtbl };
191 static void test_saxreader(void)
193 HRESULT hr;
194 ISAXXMLReader *reader = NULL;
196 hr = CoCreateInstance(&CLSID_SAXXMLReader, NULL, CLSCTX_INPROC_SERVER,
197 &IID_ISAXXMLReader, (LPVOID*)&reader);
199 if(FAILED(hr))
201 skip("Failed to create SAXXMLReader instance\n");
202 return;
205 hr = ISAXXMLReader_putContentHandler(reader, &contentHandler);
206 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
208 ISAXXMLReader_Release(reader);
211 START_TEST(saxreader)
213 HRESULT hr;
215 hr = CoInitialize(NULL);
216 ok(hr == S_OK, "failed to init com\n");
218 test_saxreader();
220 CoUninitialize();