msxml3/test: Added ISAXXMLReader test.
This commit is contained in:
parent
a3549cd9d2
commit
cabbe8fa35
|
@ -7,6 +7,7 @@ IMPORTS = oleaut32 ole32 user32 kernel32
|
|||
|
||||
CTESTS = \
|
||||
domdoc.c \
|
||||
saxreader.c \
|
||||
schema.c \
|
||||
xmldoc.c \
|
||||
xmlelem.c
|
||||
|
|
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
* XML test
|
||||
*
|
||||
* Copyright 2008 Piotr Caban
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
#define CONST_VTABLE
|
||||
|
||||
#include <stdio.h>
|
||||
#include "windows.h"
|
||||
#include "ole2.h"
|
||||
#include "msxml2.h"
|
||||
#include "ocidl.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
typedef struct _contenthandler
|
||||
{
|
||||
const struct ISAXContentHandlerVtbl *lpContentHandlerVtbl;
|
||||
} contenthandler;
|
||||
|
||||
static inline contenthandler *impl_from_ISAXContentHandler(ISAXContentHandler *iface)
|
||||
{
|
||||
return (contenthandler *)((char*)iface - FIELD_OFFSET(contenthandler, lpContentHandlerVtbl));
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_QueryInterface(
|
||||
ISAXContentHandler* iface,
|
||||
REFIID riid,
|
||||
void **ppvObject)
|
||||
{
|
||||
*ppvObject = NULL;
|
||||
|
||||
if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISAXContentHandler))
|
||||
{
|
||||
*ppvObject = iface;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static ULONG WINAPI contentHandler_AddRef(
|
||||
ISAXContentHandler* iface)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
static ULONG WINAPI contentHandler_Release(
|
||||
ISAXContentHandler* iface)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_putDocumentLocator(
|
||||
ISAXContentHandler* iface,
|
||||
ISAXLocator *pLocator)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_startDocument(
|
||||
ISAXContentHandler* iface)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_endDocument(
|
||||
ISAXContentHandler* iface)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_startPrefixMapping(
|
||||
ISAXContentHandler* iface,
|
||||
const WCHAR *pPrefix,
|
||||
int nPrefix,
|
||||
const WCHAR *pUri,
|
||||
int nUri)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_endPrefixMapping(
|
||||
ISAXContentHandler* iface,
|
||||
const WCHAR *pPrefix,
|
||||
int nPrefix)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_startElement(
|
||||
ISAXContentHandler* iface,
|
||||
const WCHAR *pNamespaceUri,
|
||||
int nNamespaceUri,
|
||||
const WCHAR *pLocalName,
|
||||
int nLocalName,
|
||||
const WCHAR *pQName,
|
||||
int nQName,
|
||||
ISAXAttributes *pAttr)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_endElement(
|
||||
ISAXContentHandler* iface,
|
||||
const WCHAR *pNamespaceUri,
|
||||
int nNamespaceUri,
|
||||
const WCHAR *pLocalName,
|
||||
int nLocalName,
|
||||
const WCHAR *pQName,
|
||||
int nQName)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_characters(
|
||||
ISAXContentHandler* iface,
|
||||
const WCHAR *pChars,
|
||||
int nChars)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_ignorableWhitespace(
|
||||
ISAXContentHandler* iface,
|
||||
const WCHAR *pChars,
|
||||
int nChars)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_processingInstruction(
|
||||
ISAXContentHandler* iface,
|
||||
const WCHAR *pTarget,
|
||||
int nTarget,
|
||||
const WCHAR *pData,
|
||||
int nData)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI contentHandler_skippedEntity(
|
||||
ISAXContentHandler* iface,
|
||||
const WCHAR *pName,
|
||||
int nName)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static const ISAXContentHandlerVtbl contentHandlerVtbl =
|
||||
{
|
||||
contentHandler_QueryInterface,
|
||||
contentHandler_AddRef,
|
||||
contentHandler_Release,
|
||||
contentHandler_putDocumentLocator,
|
||||
contentHandler_startDocument,
|
||||
contentHandler_endDocument,
|
||||
contentHandler_startPrefixMapping,
|
||||
contentHandler_endPrefixMapping,
|
||||
contentHandler_startElement,
|
||||
contentHandler_endElement,
|
||||
contentHandler_characters,
|
||||
contentHandler_ignorableWhitespace,
|
||||
contentHandler_processingInstruction,
|
||||
contentHandler_skippedEntity
|
||||
};
|
||||
|
||||
static ISAXContentHandler contentHandler = { &contentHandlerVtbl };
|
||||
|
||||
|
||||
static void test_saxreader(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
ISAXXMLReader *reader = NULL;
|
||||
|
||||
hr = CoCreateInstance(&CLSID_SAXXMLReader, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_ISAXXMLReader, (LPVOID*)&reader);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
skip("Failed to create SAXXMLReader instance\n");
|
||||
return;
|
||||
}
|
||||
|
||||
hr = ISAXXMLReader_putContentHandler(reader, &contentHandler);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
||||
ISAXXMLReader_Release(reader);
|
||||
}
|
||||
|
||||
START_TEST(saxreader)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
hr = CoInitialize(NULL);
|
||||
ok(hr == S_OK, "failed to init com\n");
|
||||
|
||||
test_saxreader();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
Loading…
Reference in New Issue